akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100010;
int n, m, Assigned[N];
int Visited[N], t=0;
vector<int> a[N];

bool visit(int u) {
    if (Visited[u]!=t)
        Visited[u]=t;
    else
        return false;

    for (int i=0; int v=a[u][i]; i++)
    if (!Assigned[v] || visit(Assigned[v])) {
        Assigned[v]=u;
        return true;
    }
    return false;
}

main() {
    scanf("%d", &n);
    int x, y;
    for(int i = 1; i <= n-1; ++i) {
        scanf("%d%d", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for (int i=1; i<=n; i++)
        a[i].push_back(0);

    int Count = 0;
    for (int i=1; i<=n; i++) {
        t++;
        Count += visit(i);
    }
    cout << (Count == n ? "Second": "First");
}


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

int main() {
  int n,k;
  int a=1;
  for(int i=0;i<n;i++){
    cin>>n>>k;
    if(a>k)
      a+=k;
    else
      a*=2;
    }
  cout<<a<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    //上からみて判断すればO(nlogn)
    ll n;
    ll sum= 0;
    cin >> n;
    vector<ll>A(n+1,0);
    vector<ll>B(n+1,0);
    REP(i,n){
        cin >> A[i+1];
    }
    REFOR(i,n,1){
        ll cnt= 0;
        ll p= 2;
        while (n>=i*p) {
            cnt+=B[i*p];
            p++;
        }
        //ここがポイント
        //上に置かれた球の和のNOR
        B[i]= (cnt&1)^A[i];
        sum+= B[i];
    }
    cout << sum << endl;
    int s= 0;
    FOR(i,1,n+1){
        if(B[i]){
            s++;
            cout << i << ((s==sum)?"":" ");
        }
    }
    if(sum) cout << endl;
}


Measured memory_bytes: 3968
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	      Scanner sc = new Scanner(System.in);
	      int a = sc.nextInt();
	      int b = sc.nextInt();
	      int c = sc.nextInt();
    	      int x = sc.nextInt();
    	      int l, m;
    	      int root = 0;
    	      for(int i=0; i<=a; i++) {
    	    	  l = 500 * i;
    	    	  if(l > x) {
    	    	  break;
    	    	  }
    	    	  for(int j=0; j<=b; j++) {
    	    		  m = l + 100*j;
    	    		  if(m > x) {
    	    			  break;
    	    		  }
    	    		  if((x-m) /50 <= c){
    	    			  root++;
    	    		  }
    	    	  }
    	      }
	      System.out.println(root);
	}
}

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

using namespace std;

struct Node {
	Node(int size = 0) : size(size), end(0), idx(0){}
	vector<Node> child;
	int size;
	int end;
	int idx;
};

void make(Node& cur, const vector<string>& vs, int s, int e, int idx){
	cur.size = e - s;
	cur.idx = idx;
	if(cur.size <= 1) return;
	if(vs[s].size() == idx){
		cur.end = 1;
		++s;
	} else {
		cur.end = 0;
	}
	if(cur.end == 0 && vs[s][idx] == vs[e-1][idx]){
		make(cur, vs, s, e, idx+1);
		return;
	}
	cur.child.assign(26, Node());
	for(int i=0;i<26;++i){
		if(s >= e || vs[s][idx] != 'a'+i) continue;
		int l = s, h = e;
		while(h-l > 1){
			int m = (l+h)/2;
			if(vs[m][idx] == 'a'+i) l = m;
			else h = m;
		}
		make(cur.child[i], vs, s, h, idx+1);
		s = h;
	}
}

int main(){
	int N;
	static string S[100000];
	while(cin >> N){
		for(int i=0;i<N;i++) cin >> S[i];
		vector<string> vs(N);
		for(int i=0;i<N;i++) vs[i] = S[i];
		sort(vs.begin(), vs.end());
		Node c;
		make(c, vs, 0, N, 0);
		int Q; cin >> Q;
		for(int i=0;i<Q;i++){
			int res = 1;
			int k; cin >> k;
			string order; cin >> order;
			const Node* cur = &c;
			const string& t = S[k-1];
			while(cur->size > 1){
				if(t.size() <= cur->idx) break;
				res += cur->end;
				for(int j=0;j<26;j++){
					const Node* ch = &cur->child[order[j]-'a'];
					if(order[j] == t[cur->idx]){
						cur = ch;
						break;
					} else {
						res += ch->size;
					}
				}
			}
			cout << res << endl;
		}
	}
}



Measured memory_bytes: 42376
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    inverses = [1] * (n + 1)
    inverses[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        inverses[m - 1] = inv
    return factorials, inverses


def solve(n):
    MOD = 1000000007
    fac, inv = prepare(n, MOD)
    ans = 0
    cnt = 0
    for k in range((n + 1) // 2, n):
        tmp = fac[k - 1] * inv[n - 1 - k] * inv[2 * k - n]
        tmp %= MOD
        tmp *= fac[k]
        tmp %= MOD
        tmp *= fac[n - 1 - k]
        tmp %= MOD
        just = (tmp - cnt) % MOD
        ans += just * k
        ans %= MOD
        cnt = tmp
    return ans


n = int(input())
print(solve(n))


Measured memory_bytes: 82220
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int N, cnt[MAXN], arr[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for(int i =  0;i  < N; i++) cin >> arr[i];
	
	typedef pair<int, int> ii;
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	int harus = (N+1)/2;
	for (int i= 0; i < N; i += 2) {
		cnt[arr[i]]++;
		pq.push({harus-cnt[arr[i]], arr[i]});
	}
	pq.push({harus, -2});
	
	harus = N/2;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i < N; i += 2) {
		cnt[arr[i]]++;
		pq.push({harus-cnt[arr[i]], arr[i]});
	}
	pq.push({harus, -3});
	
	int prv = -1;
	int ans = 0;
	int cnt = 0;
	while (!pq.empty()) {
		while (pq.top().second == prv) pq.pop();
		ii now = pq.top(); pq.pop();
		ans += now.first;
		prv = now.second;
		cnt++;
		if (cnt == 2) goto selesai;
	}
	
	selesai:
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 2168
a, b, k = map(int, input().split())

ls = []

for i in range(k):
    if (a + i) in ls:
        break
    else:
        ls.append(a+i)
        
    if (b - i) in ls:
        break
    else:
        ls.append(b-i)

ls_ans = sorted(ls)

for j in range(len(ls_ans)):
    print(ls_ans[j])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 2000
int main(void){
  int i=0,j=0;
  char op,c;
  int stack[M],num,flag;
  for(i=0;i<M;i++){
    stack[i]='\0';
  }
  i=0;
  while(1){
    flag=-1;
    c=getchar();
    if(feof(stdin)!=0){
      break;
    }
    if('1'<=c && c<='9'){
      ungetc(c,stdin);
      flag=1;
      scanf("%d",&num);
    }else if(c!=' ' && c!='\n'){
      ungetc(c,stdin);
      flag=0;
      scanf("%c",&op);
    }
    if(flag==1){
      stack[j]=num;
    }
    if(flag==0){
      stack[j]=op;
    }
    if(stack[j]=='+' && flag==0){
      stack[j-2]=stack[j-2]+stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }else if(stack[j]=='-'&& flag==0){
      stack[j-2]=stack[j-2]-stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }else if(stack[j]=='*'&& flag==0){
      stack[j-2]=stack[j-2]*stack[j-1];
      stack[j]='\0';
      stack[j-1]='\0';
      j=j-2;
    }
    if(flag==0 || flag==1){
      j++;
    }
  }
  printf("%d\n",stack[0]);
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < 15; i++) {
        for(int j = 0; j < 25; j++) {
            if(i*7+j*4 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	string s;
	cin>>s;
	if (s[s.length()-1] == 's') 
		cout<<s<<"es"<<endl;
	else cout<<s<<"s"<<endl;


	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  REP(i, n) {
    if(i < a[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ret = 0;
  FOR(i, 1, n) {
    if(a[i] == a[i-1]+1) {

    } else {
      if(a[i] > a[i-1]+1) {
        cout << -1 << endl;
        return 0;
      }
      ret += a[i-1];
    }
  }
  ret += a[n-1];

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C; cin>>A>>B>>C;
    int K; cin>>K;
    int Max=max({A,B,C});
    int ans=A+B+C-Max+Max*pow(2,K);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << '\n';
    return 0;
}


Measured memory_bytes: 256
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

h,w,m = (int(x) for x in input().split())
rows = [[0,i] for i in xrange(h)]
cols = [[0,i] for i in xrange(w)]
bomb_dict = dict()
for i in xrange(m):
    hi,wi = (int(x)-1 for x in input().split())
    rows[hi][0] += 1
    cols[wi][0] += 1
    bomb_dict[(hi,wi)] = True

rows = sorted(rows, reverse=True)
cols = sorted(cols, reverse=True)
row_val = rows[0][0]
col_val = cols[0][0]
ans = None
for row in rows:
    if row[0] != row_val:
        break
    for col in cols:
        if col[0] != col_val:
            break
        getr = bomb_dict.get((row[1], col[1]), False)
        if not getr:
            ans = row_val + col_val
            break
    
    if ans:
        break

if ans is None:
    ans = row_val + col_val - 1
print(ans)


Measured memory_bytes: 195460
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main(){

    int x,y;
    cin>>x>>y;
    for(int i=0; i<=x; i++){
        if((i*4)+((x-i)*2)==y){
            cout<<"Yes";
            return 0;
        }
    }   cout<<"No";

    
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int time(int a,int b,int c,int d,int e,int m){
	int ret =  a+b+c+d+e;
	rep(i,m-1){
		ret += d+e;
	}
	return ret;
}
bool cmp(const pair<double,string>&a,const pair<double,string>&b){
	if( fabs(a.first-b.first) < 1e-8){
		return a.second < b.second;
	}
	return a.first > b.first;
}
int main(){
	int n;
	
	while(cin >> n , n){
		vector< pair<double,string> > data(n);
		rep(i,n){
			string l; int p,a,b,c,d,e,f,s,m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			data[i].first = (double)(f*s*m-p)/time(a,b,c,d,e,m);
			data[i].second = l;
		}
		sort(data.begin(),data.end(),cmp);
		rep(i,n){
			cout << data[i].second << endl;
		}
		cout << "#" << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		String S = sc.next();
		int cnt_a = 0;
		int cnt_b = 0;
		for(int i = 0; i < S.length(); i++) {
			String s = S.substring(i, i + 1);
			if(s.equals("a")) {
				if(cnt_a + cnt_b < A + B) {
					cnt_a++;
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else if(s.equals("b")) {
				if(cnt_a + cnt_b < A + B && cnt_b < B) {
					cnt_b++;
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		}
	}
}


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

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  ll res = n / (a+b)*a;
  // cout << res << endl;
  res += min(n % (a+b), a);
  cout << res << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

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

class CLower {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<ll> a(n);
        rep(i,n){
            in >> a[i];
        }
        vector<int> c(n,0);
        int ans=0;
        for(int i=n-2;i>=0;i--){
            if(a[i+1]<=a[i]){
                c[i]=c[i+1]+1;
            }else{
                c[i]=0;
            }
            ans=max(ans,c[i]);
        }
        out << ans << endl;
	}
};


int main() {
	CLower solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vvin f(n,vin(10));
    vvin p(n,vin(11));
    rep(i,n)rep(j,10)cin>>f[i][j];
    rep(i,n)rep(j,11)cin>>p[i][j];
    int res;
    ll sum;
    ll M=-INF;
    rep2(i,1,1<<10){
        bitset<12> tmp(i);
        sum=0;
        rep(j,n){
            res=0;
            rep(k,10){
                if(tmp.test(k)&&f[j][k])res++;
            }
            sum+=(ll)p[j][res];
        }
        M=max(M,sum);
    }
    cout<<M<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100010
#define INFTY 10000000
#define NIL -1

struct Node {
	int value;
	struct Node *next;
};
typedef struct Node node_t;


int N;
int M;
node_t *G[MAX];
int color[MAX];

node_t* addNode(node_t *node, int value)
{
	node_t *new = (node_t*)malloc(sizeof(node_t));
	new->value = value;
	new->next = node;
	return new;
}

void dfs(int r, int c)
{
	color[r] = c;
	node_t *n;
	for (n=G[r]; n!=NULL; n=n->next) {
		int v = n->value;
		if (color[v] == NIL) {
			color[v] = c;
			dfs(v, c);
		}
	}
}

void assignColor()
{
	int i, u;
	int id =1;
	for (i=0; i<N; i++) {
		color[i] = NIL;
	}
	for (u=0; u<N; u++) {
		if (color[u] == NIL) dfs(u, id++);
	}
}


int main()
{
	int i, n, u, v;	
	scanf("%d %d", &N, &M);	
	for (i = 0; i < M; i++) {
		scanf("%d %d", &n, &v);
		G[n] = addNode(G[n], v);
		G[v] = addNode(G[v], n);
	}
	
	assignColor();
	
	int Q;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++) {
		scanf("%d %d", &u, &v);
		if (color[u] == color[v]) {
			puts("yes");			
		}
		else {
			puts("no");
		}
	}

	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> bridges(m);
    rep(i, m) cin >> bridges[i].second >> bridges[i].first;
    sort(bridges.begin(), bridges.end());
    int ans = 0, prev_break = -1;
    for (auto p : bridges) {
        if (p.second <= prev_break && prev_break < p.first) continue;
        ans++;
        prev_break = p.first - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;

int main(){
	cin>>s;
	for(int i=0;i<s.size();i++) if(i%2==0) cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
double n, x, d, r;

int main()
{
    scanf("%lf%lf%lf", &n, &d, &x);
    d+=(n-0.5)*x;
    for(;n; d+=d/n--)
        r+=d;
    printf("%.10lf\n", r);
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ll N, ans{}, d{}, e{};
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  sort(begin(C), end(C));
  for (int i = 0; i != N; ++i) {
    while (d != N && A[d] < B[i]) ++d;
    while (e != N && B[i] >= C[e]) ++e;
    ans += d * (N-e);
  }
  cout << ans << endl;
}


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

int main() {

	string Sa, Sb, Sc;
	cin >> Sa >> Sb >> Sc;

	transform(Sa.begin(), Sa.end(), Sa.begin(), ::toupper);
	transform(Sb.begin(), Sb.end(), Sb.begin(), ::toupper);
	transform(Sc.begin(), Sc.end(), Sc.begin(), ::toupper);

	char turn = 'A';
	while (true) {
		if (turn == 'A') {
			if (Sa == "") break;
			turn = Sa.at(0);
			Sa = Sa.substr(1, Sa.size()-1);
		}
		else if (turn=='B')
		{
			if (Sb == "") break;
			turn = Sb.at(0);
			Sb = Sb.substr(1, Sb.size() - 1);
		}
		else if (turn=='C')
		{
			if (Sc == "") break;
			turn = Sc.at(0);
			Sc = Sc.substr(1, Sc.size() - 1);
		}
	}

	cout << turn << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e5+7;
int fa[maxn];
int Find(int x)
{
    return x==fa[x]?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
    x=Find(x),y=Find(y);
    fa[y]=x;
}
int main()
{
    for(int i=0;i<maxn;i++) fa[i]=i;
    int n,m;
    cin>>n>>m;
    vi p(n);
    for(int i=0;i<n;i++) cin>>p[i];
    int ans=0;
    for(int i=0,x,y;i<m;i++)
    {
        cin>>x>>y;
        x--,y--;
        Union(x,y);
    }
    for(int i=0;i<n;i++)
    {
        p[i]--;
        if(Find(p[i])==Find(i)) ans++;
    }
    print(ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int a;
		int b[]=new int[36];
		for(int i=0;i<10;i++) {
			b[i]=i+1;
		}
		b[10]=12;
		b[11]=14;
		b[12]=15;
		b[13]=16;
		b[14]=18;
		b[15]=20;
		b[16]=21;
		b[17]=24;
		b[18]=25;
		b[19]=27;
		b[20]=28;
		b[21]=30;
		b[22]=32;
		b[23]=35;
		b[24]=36;
		b[25]=40;
		b[26]=42;
		b[27]=45;
		b[28]=48;
		b[29]=49;
		b[30]=56;
		b[31]=63;
		b[32]=64;
		b[33]=72;
		b[34]=81;
		b[35]=54;
		while(sc.hasNextInt()) {
			a=sc.nextInt();
			for(int i=0;i<36;i++) {
				if(a==b[i]) {
					System.out.println("Yes");
					break;
				}
				if(i==35&&a!=b[35]) {
					System.out.println("No");
				}
			}
			
		}
	}

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
  
int main() {
  int N,M;
  cin >> N >> M;
  vp ab(M);
  rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    ab[i] = P(a,b);
  }
  int ans = 0;
  rep(i,M) {
    UnionFind t = UnionFind(N);
    rep(j,M) {
      if(j==i) continue;
      t.connect(ab[j].first,ab[j].second);
    }
    if(t.root(ab[i].first) != t.root(ab[i].second)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int M = sc.nextInt();

       String s = new String();
       char[][] a = new char[(int)N][N];
       for (int i=0 ; i<N; i++) {
           s = sc.next();
           a[i]=s.toCharArray();
       }
       char[][] b = new char[(int)M][M];
       for (int i=0 ; i<M; i++) {
           s = sc.next();
           b[i]=s.toCharArray();
       }
       boolean flg=false;
       for(int i=0;i<N-M+1;i++) {
    	   for(int j=0;j<N-M+1;j++) {
    		   flg=false;
    		   for(int k=0;k<M;k++) {
    			   for(int l=0;l<M;l++) {
    				   if(a[i+k][j+l]!=b[k][l]) {
    					   flg=true;
    					   break;
    				   }
    			   }
    			   if(flg==true)break;
    		   }
    		   if(flg==false)break;
    	   }
    	   if(flg==false)break;
       }
       
       String ans=new String("No");
       if(flg==false) {
    	  ans="Yes";
       }
       
       System.out.println(ans);
   }
      

}

Measured memory_bytes: 20692
#include <iostream>
#include <vector>

std::vector<int> bases = { 6, 9 };

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

  std::vector<int> dp(N + 1, 1 << 28);

  dp[0] = 0;

  for (int i = 0; i <= N; i++) {
    for (auto b : bases) {
      for (int y = 1; i + y <= N; y *= b) {
        dp[i + y] = std::min(dp[i + y], dp[i] + 1);
      }
    }
  }

  std::cout << dp[N] << std::endl;
}


Measured memory_bytes: 640
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let [| K; T |] = reada int
    let A = reada int

    let a = A |> Array.max
    let ans = (a - 1) - (K - a)
    List.max [ 0; ans ] |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 14044
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
// #include <immintrin.h>
// #include <emmintrin.h>

#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define vi vector<int>
#define vpii vector<pii>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define aal(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)res=res*a%_MOD;
  }
  return res;
}
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}



int p2[N],p5[N];
map<pii,int>has;
void Solve() {
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    double x;
    cin>>x;
    LL xx=llround(x*1e9),t=xx;
    while(t%2==0)t/=2,p2[i]++;
    t=xx;
    while(t%5==0)t/=5,p5[i]++;
    has[mp(p2[i],p5[i])]++;
  }
  LL ans=0;
  for(auto p:has){
    for(auto pp:has){
      if(p>pp)continue;
      if(min(p.fi.fi+pp.fi.fi,p.fi.se+pp.fi.se)>=18){
        if(p==pp)ans+=(LL)p.se*(p.se-1)/2;
        else ans+=(LL)p.se*pp.se;
      }
    }
  }
  cout<<ans<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}


Measured memory_bytes: 5244
from collections import Counter
import math

def div(n):
    prime = []
    tmp = int(math.sqrt(n)) + 1
    
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            prime.append(num)
    
    if n != 1:
        prime.append(n)
    return prime

n = int(input())
prime_div = Counter(div(n))
ans = 0

for p, ex in prime_div.items():
    k = 1
    while ex >= k:
        ex -= k
        ans += 1
        k += 1

print(ans)

Measured memory_bytes: 68084
#include <iostream>

using namespace std;

int main() {
    int a,b;
    string c;
    while (true)
    {
    cin>>a>>c>>b;
    if(c=="?") 
         break;
    if(c=="+")
    cout<<a+b<<endl;
    else if(c=="-")
    cout<<a-b<<endl;
    else if(c=="*")
    cout<<a*b<<endl;
    else   
    cout<<a/b<<endl;
    
    
    }
    
}


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

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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    cout << max(0ll, a-k) << " " << max(b - max(0ll, k-a), 0ll) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
        int n,r;
        cin >> n >> r; 
        while(n){
                int in[50][2];
                for(int i = 0; i < r; i++){
                        cin >> in[i][0] >> in[i][1];
                }  
                int m = n; 
                for(int i = r-1; i >= 0; i--){
                        int p = in[i][0];
                        int c = in[i][1];
                        if(n-(p-1)-c >= m) continue;
                        if(n-c < m){
                                m -= p-1;
                        }else{
                                m += c; 
                        }  
                }  
                cout << m << endl;
                cin >> n >> r; 
        }  
}

Measured memory_bytes: 0
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe

main :: IO ()
main = do
    -- 文字列の入力
    sa <- filter (`elem` ['a'..'c']) <$> getLine
    sb <- filter (`elem` ['a'..'c']) <$> getLine
    sc <- filter (`elem` ['a'..'c']) <$> getLine
    -- 出力
    putStrLn $ solve sa sb sc 'a'

solve :: String -> String -> String -> Char -> String
solve [] _ _ 'a' = "A"
solve _ [] _ 'b' = "B"
solve _ _ [] 'c' = "C"
solve (a:sa) sb sc 'a' = solve sa sb sc a
solve sa (b:sb) sc 'b' = solve sa sb sc b
solve sa sb (c:sc) 'c' = solve sa sb sc c


Measured memory_bytes: 508
s = input()
for i in range(2**3):
    l=[]
    for j in range(3):
        if (i>>j)&1:
            l.append("+")
        else:
            l.append("-")
    x = ""
    for k,lp in zip(s,l):
        x+=k
        x+=lp
    x+=s[-1]
    if eval(x)==7:
        print(x+"=7")
        break

Measured memory_bytes: 3064
n,m=map(int,input().split())
xyz = [list(map(int, input().split())) for i in range(n)]

t000=[xyz[i][0]+xyz[i][1]+xyz[i][2] for i in range(n)]
t001=[xyz[i][0]+xyz[i][1]-xyz[i][2] for i in range(n)]
t010=[xyz[i][0]-xyz[i][1]+xyz[i][2] for i in range(n)]
t011=[xyz[i][0]-xyz[i][1]-xyz[i][2] for i in range(n)]
t100=[-xyz[i][0]+xyz[i][1]+xyz[i][2] for i in range(n)]
t101=[-xyz[i][0]+xyz[i][1]-xyz[i][2] for i in range(n)]
t110=[-xyz[i][0]-xyz[i][1]+xyz[i][2] for i in range(n)]
t111=[-xyz[i][0]-xyz[i][1]-xyz[i][2] for i in range(n)]
t000.sort()
t001.sort()
t010.sort()
t011.sort()
t100.sort()
t101.sort()
t110.sort()
t111.sort()


ans=[sum(t000[-m:]),sum(t001[-m:]),sum(t010[-m:]),
     sum(t011[-m:]),sum(t100[-m:]),sum(t101[-m:]),
     sum(t110[-m:]),sum(t111[-m:])]

if m!=0:
    print(max(ans))
else:
    print(0)

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

using namespace std;


int main(){
    int N;
    cin >> N;

    vector<int> a(N); 
    int i=0, l;
    while(cin >> l){
        a[i] = l;
        i++;
        if ( i >= N){
            break;
        };
    };
    

    bool flag = true;
    for (int i=0;i<N;i++){
        if( a[i]%2 == 0 ){
            if( a[i]%3==0 || a[i]%5 ==0 ){
                continue;
            }else{
                 cout << "DENIED" << endl;
                 flag = false;
                 break;
            }
        }
    }    
    if(flag){
        cout << "APPROVED" << endl;            
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r , g , b;
    cin>>r>>g>>b;
    int c=r*100+g*10+b;
    if(c%4 == 0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    reverse(all(s));
    if(s == t) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ld n;
    cin>>n;
    cout<<fixed<<setprecision(10);
    ld h=n/3;
    cout<<h*h*h;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
//#include <algorithm>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	int n, k; cin >> n >> k;
	int r, s, p; cin >> r >> s >> p;
	string t; cin >> t;

	vector<vector<int>> dp(n, vector<int>(3, 0)); //dp[i][0=r], dp[i][1=s], dp[i][2=p]

	for (int i = 0; i <= n - 1; i++) {
		if (i < k) {
			if (t[i] == 'r') dp[i] = {0, 0, p};
			else if (t[i] == 's') dp[i] = {r, 0, 0};
			else dp[i] = {0, s, 0};
		}
		else {
			if (t[i] == 'r') {
				dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
				dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
				dp[i][2] = p + max(dp[i - k][0], dp[i - k][1]);
			}

			else if (t[i] == 's') {
				dp[i][0] = r + max(dp[i - k][1], dp[i - k][2]);
				dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
				dp[i][2] = max(dp[i - k][0], dp[i - k][1]);
			}

			else {
				dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
				dp[i][1] = s + max(dp[i - k][0], dp[i - k][2]);
				dp[i][2] = max(dp[i - k][0], dp[i - k][1]);
			}
		}
	}

	int ans = 0;
	for (int i = n - 1, cnt = 0; i >= 0 and cnt < k; i--, cnt++) ans += *max_element(dp[i].begin(), dp[i].end());
	cout << ans;

	return 0;
}

Measured memory_bytes: 8432
# abc094 C
n = gets.to_i
x = gets.split.map(&:to_i)

mmin = x.sort[n/2 - 1]
mmax = x.sort[n/2]

x.each do |xx|
  if xx <= mmin
    p mmax
  elsif xx >= mmax
    p mmin
  end
end


Measured memory_bytes: 32248
#include <iostream>
using namespace std;
int main(){

char b;
cin >> b;
  switch(b){
      case 'A':
      cout << "T" << endl;
      break;
      case 'T':
      cout << "A" << endl;
      break;
      case 'C':
      cout << "G" << endl;
      break;
      case 'G':
      cout << "C" << endl;
      break;
  }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;cin >> x;
	ll sum = 0;
	for(int i = 1; i <= 1000000; i++){
		sum += i;
		if(sum >= x){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
while True:
    H,W = (int(x) for x in input().split())

    if (W == 0 and H == 0):
        exit()

    elif ((W % 2) == 0) :
        if ((H % 2) ==0):
            for i in range(H // 2):
                print("#." * (W // 2))
                print(".#" * (W // 2))

        elif ((H % 2) ==1):
            for i in range(H // 2):
                print("#." * (W // 2))
                print(".#" * (W // 2))
            print("#." * (W // 2))

    elif ((W % 2) == 1) :
        if ((H % 2) ==0):
            for i in range(H // 2):
                print("#." * (W // 2) + "#")
                print(".#" * (W // 2) + ".")

        elif ((H % 2) ==1):
            for i in range(H // 2):
                print("#." * (W // 2)+ "#")
                print(".#" * (W // 2)+ ".")
            print("#." * (W // 2) + "#")

    print("")



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
ll tri(ll n){
    return n * n * n;
}
int main(){
    ll n, k;
    cin >> n >> k;
    if(k % 2){
        cout << tri(n / k) << "\n"; 
    }else{
        int a = n * 2 / k;
        cout << tri(a / 2) + tri(a - a / 2) << "\n"; 
    }
}

Measured memory_bytes: 3552
using System;

public class Program
{
    public static void Main()
    {
        String[] aryData = Console.ReadLine().Split(' ');

        double x1 = double.Parse(aryData[0]);
        double y1 = double.Parse(aryData[1]);
        double x2 = double.Parse(aryData[2]);
        double y2 = double.Parse(aryData[3]);

        double lengthX = x2 - x1;
        double lengthY = y2 - y1;

        double answer = Math.Sqrt(lengthX * lengthX + lengthY * lengthY);

        Console.WriteLine(answer);

    }
}

Measured memory_bytes: 9300
from math import *

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

left=[0]*(N+1)
for i in range(N):
  left[i+1]=gcd(left[i],A[i])

right=[0]*(N+1)
for i in range(N-1,-1,-1):
  right[i]=gcd(right[i+1],A[i])

ans=0
for i in range(N):
  ans=max(ans,gcd(left[i],right[i+1]))

print(ans)


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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define rep(i,n) for(int i=0;i<(n);i++)
int N;
vector<string> Key(3);

ll DFS(string S){
    ll C=stoll(S);
    if(C==0)S="";
    if(C>N)return 0;
    ll ret=0;
    if(S.find("3")!=-1&&S.find("5")!=-1&&S.find("7")!=-1){
        ret=1;
    }

    for(int i=0;i<3;i++){
        ret+=DFS(S+Key[i]);
    }

    return ret;
}

int main(){
    cin>>N;
    Key[0]="3";
    Key[1]="5";
    Key[2]="7";
    cout<<DFS("0")<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200005;
ll a[N],f[N],g[N];
ll ans;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
		f[i]=f[i-1]+a[i];
	for(int i=n;i;i--)
		g[i]=g[i+1]+a[i];
	ans=abs(f[1]-g[2]);
	for(int i=3;i<=n;i++)
		ans=min(abs(f[i-1]-g[i]),ans);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[2009][2009], e[2009][2009], f[2009][2009];
int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c; cin >> c;
			if (c == '1') {
				a[i][j] = 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == 1 && a[i][j + 1] == 1) { f[i][j] = 1; }
			if (a[i][j] == 1 && a[i + 1][j] == 1) { e[i][j] = 1; }
		}
	}
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { a[i][j] += a[i][j - 1]; } }
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { a[i][j] += a[i - 1][j]; } }
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { e[i][j] += e[i][j - 1]; } }
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { e[i][j] += e[i - 1][j]; } }
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { f[i][j] += f[i][j - 1]; } }
	for (int i = 1; i <= n + 1; i++) { for (int j = 1; j <= m + 1; j++) { f[i][j] += f[i - 1][j]; } }
	for (int i = 0; i < q; i++) {
		int px, py, qx, qy; scanf("%d%d%d%d", &px, &py, &qx, &qy);
		int F = a[px - 1][py - 1] + a[qx][qy] - a[px - 1][qy] - a[qx][py - 1];
		int E1 = e[px - 1][py - 1] + e[qx - 1][qy] - e[px - 1][qy] - e[qx - 1][py - 1];
		int E2 = f[px - 1][py - 1] + f[qx][qy - 1] - f[px - 1][qy - 1] - f[qx][py - 1];
		printf("%d\n", F - (E1 + E2));
	}
	return 0;
}

Measured memory_bytes: 49024
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int n;
	cin >> n;
	int d1[n], d2[n];
	for (int i = 0; i < n; ++i) {
		cin >> d1[i] >> d2[i];
	}

	int ans = 0;
	for (int i = 2; i < n; ++i) {
		if (d1[i] == d2[i] && d1[i - 1] == d2[i - 1] && d1[i - 2] == d2[i - 2]) { ans++; }
	}
	if (ans) { cout << "Yes"; }
	else { cout << "No"; }
	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){


int n;
int a[100003];
int b[100003];
long long int negasum=0;


cin >> n;

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

int d[100003] = {0,};
int point = 0;
int posi=0;

for(int i =0; i<n ; i++){
 if(b[i]>a[i]){
   negasum = negasum + b[i]-a[i];
  posi++;
 }else{
  d[point]=b[i]-a[i];
  point++;

 }
}

sort(d, d+100003);

for(int i =0; i<n ; i++){
d[i]=-d[i];
}


int use = -1;
int truth = 1;
int s = 0;
 if(negasum == 0){
    truth =2;
  }
for(int k =0; k<n ; k++){
 negasum = negasum - d[k];
  if(negasum > 0){

  }else if(s==0){
   use = k+1;
   s=1;
  }
}

if(use == -1){
truth =0;
}

if(truth == 0){
cout << -1;
}else if(truth == 1){
cout << posi+use;
}else{
cout << 0;
}


}

Measured memory_bytes: 1408