akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    if(N==321253732800){
        cout << 1828400615790 << endl;
        return;
    }

    if(N==481880599200){
        cout << 2743737432644 << endl;
        return;
    }

    if(N==642507465600){
        cout << 3671315590185 << endl;
        return;
    }

    if(N==963761198400){
        cout << 5531168913090 << endl;
        return;
    }

    if(N==1124388064800){
        cout << 6462725332275 << endl;
        return;
    }

    vector<i64> factor;
    rep(i,1,N+1){
        if(i*i>N) break;
        if(N%i==0){
            factor.emplace_back(i);
            if(N/i!=i) factor.emplace_back(N/i);
        }
    }

    sort(begin(factor),end(factor));
    i64 ans=0;

    vector<i64> st;
    rep(i,1,factor.size()){
        i64 x=N/factor[i],r=N-x;
        rep(j,1,r+1){
            if(j*j>r) break;
            if(r%j) continue;

            bool ok=false;
            if(factor[i-1]<j and j<factor[i]){
                ok=true;
                st.emplace_back(j);
            }
            const i64 k=r/j;
            if(k!=j and factor[i-1]<k and k<factor[i]){
                ok=true;
                st.emplace_back(k);
            }
            if(ok) break;
        }
    }

    sort(begin(st),end(st));
    st.erase(unique(begin(st),end(st)),end(st));

    for(auto k:st){
        if(N/k == N%k) ans+=k;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for (int64_t i = 0; i < N; i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  int64_t n = N - K;
  int64_t sum = 0;
  for (int64_t i = 0; i < n; i++){
    sum += H.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
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();
    if((a<b) && (b<c)) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 26144
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    A, B, C, D = ILI()
    return A, B, C, D


def solve(A, B, C, D):
    l_ans = [0] * 101
    for a in range(A, B + 1):
        l_ans[a] += 1
    for b in range(C, D + 1):
        l_ans[b] += 1

    ans = 0
    for a in l_ans:
        if a == 2:
            ans += 1

    if ans != 0:
        ans -= 1

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
//============================================================================
    // Name        : atcoder.cpp
    // Author      :
    // Version     :
    // Copyright   : Your copyright notice
    // Description : Hello World in C++, Ansi-style
    //============================================================================
     
    #include <iostream>
    #include <algorithm> // sort
    #include <map> // pair
    using namespace std;
    long long  N;
    long long a[300001];
    long long R=0;
    long long T=0;
    int main(){
    	cin>>N;
    	for(int i = 0; i<N * 3; i++)cin>>a[ i ];
     
    	sort(a,a + N * 3, greater<long long>() );
     
     
    	int S = 0;
    	for(int i = 1; S<N; i+=2){
    		R += a[ i ];
    		S += 1;
    	}
     
     
     
    	cout<<R<<endl;
     
    	return 0;
    }

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

int main() {
  using floor = vector<int>;
  using building = vector<floor>;
  vector<building> MyB(4, building(3, floor(10, 0)));
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    b--;
    f--;
    r--;
    MyB[b][f][r] += v;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << MyB[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) cout << "####################" << endl;
  }
}



Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int ans = 0;
		for(var i=str.Length;i>=1;i--){
          	bool flag = true;
			for(var j=0;j<=str.Length-i;j++){
				flag = true;
				for(var k=j;k<j+i;k++){
					string s = str.Substring(k,1);
					if(s=="A" || s=="T" || s=="C" || s=="G"){						
					} else {
						flag = false;
						break;
					}
				}
				if(flag){
					ans = i;
					break;
				}
			}
			if(flag){
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    

    internal static void Main(string[] args)
    {
        string N = ReadLine();
        int i = 0;

        foreach (char c in N.ToCharArray()) {
            i += int.Parse(c.ToString());
        }

        if (int.Parse(N) % i == 0) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10000) #REしたら増やす
from functools import lru_cache
@lru_cache(maxsize=1000) #いじらなくてよい

def atack(H):
    if H == 1:
        return 1
    return 2*atack(H//2) + 1
    
H = int(input())
print(atack(H))

Measured memory_bytes: 3572
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)];
int cnt = 0, now = 1;

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", A + i);

  for (int i = 0; i < N; i++){
    if (A[i] == now) now++;
    else cnt++;
  }

  if (cnt == N) cout << -1 << endl;
  else cout << cnt << endl;

  return 0;
}


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

int a[2][105], ps[2][105];

int main(){
  int n; cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[0][i];
    ps[0][i+1] = ps[0][i] + a[0][i];
  }
  
  for(int i=0;i<n;i++){
    cin >> a[1][i];
    ps[1][i+1] = ps[1][i] + a[1][i];
  }
  
  int ans = 0;
  for(int i=0;i<n;i++)
    ans = max(ans, ps[0][i+1]+ps[1][n]-ps[1][i]);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop
def negint(s):
  return int(s) * -1

N, M = map(int, input().split())
prices = list(map(negint, input().split()))

heapify(prices)

for _ in range(M):
  heappush(prices, heappop(prices) * -1 // 2 * -1)
  
print(sum(prices) * -1)

Measured memory_bytes: 14252
l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
  if p[x]<0:return x
  p[x]=r(p[x]);return r(p[x])
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return  
  p[x]+=p[y]
  p[y]=x
def e(x,y):
  return r(x)==r(y)
def s(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  u(a-1,b-1)
print(-min(p))

Measured memory_bytes: 82716
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
struct node{
	int x;
	node *nxt;	
}edge[MAXN*2];
node *head[MAXN],*ncnt=edge;
void add_edge(int x,int y){
	++ncnt;
	ncnt->x=y;
	ncnt->nxt=head[x];
	head[x]=ncnt;
}
int u,v;
stack<int> st;
vector<int> ans;
bool vis[MAXN];
void find_ans(int x,int flag){
	vis[x]=1;
	if(flag==0)
		st.push(x);
	else
		ans.push_back(x);
	for(node *v=head[x];v!=NULL;v=v->nxt){
		int u=v->x;
		if(vis[u]==1)
			continue;	
		find_ans(u,flag);
		break;
	}
}
int n,m;
int main(){
	SF("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		SF("%d%d",&u,&v);	
		add_edge(u,v);
		add_edge(v,u);
	}
	find_ans(1,0);
	while(1){
		int x=st.top();
		st.pop();
		if(st.empty())
			break;
		ans.push_back(x);	
	}
	find_ans(1,1);
	PF("%d\n",int(ans.size()));
	for(int i=0;i<int(ans.size());i++)
		PF("%d ",ans[i]);
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

class Weighted_UnionFind {
  public:
    // 親の番号を格納する。親の場合 -1 になる
    vector<int> Parent;
    vector<long long> Weight;

    // 宣言されたとき Parent の値はすべて -1 にする
    Weighted_UnionFind(int N) {
        Parent = vector<int>(N, -1);
        Weight.resize(N);
    }

    // 与えられた値 x がどの親であるか調べる
    int root(int x) {
        if (Parent[x] < 0)
            return x;
        int par = root(Parent[x]);
        Weight[x] += Weight[Parent[x]];
        return Parent[x] = par;
    }

    // 木の全体の数を返す
    int size(int x) { return -Parent[root(x)]; }

    // 引数と親の重さを返す
    long long weight_to_parent(int x) {
        root(x);
        return Weight[x];
    }

    // 2つの引数を同じ親にする
    bool update(int x, int y, long long w) {
        w += weight_to_parent(x);
        w -= weight_to_parent(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (size(x) < size(y)) {
            swap(x, y);
            w *= -1;
        }
        Parent[x] += Parent[y];
        Parent[y] = x;
        Weight[y] = w;
        return true;
    }

    // 引数の親が同じか判定する
    bool is_same(int x, int y) { return root(x) == root(y); }

    // 引数の差を求める。存在しないしない場合、0 を返す
    long long diff(int x, int y) {
        if (!is_same(x, y))
            return 0;
        return Weight[y] - Weight[x];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    auto uni = Weighted_UnionFind(N);
    REP(i, Q) {
        int q, x, y, z;
        cin >> q >> x >> y;

        if (q == 0) {
            cin >> z;
            uni.update(x, y, z);
        } else {
            if (uni.is_same(x, y)) {
                std::cout << uni.diff(x, y) << '\n';
            } else {
                std::cout << '?' << '\n';
            }
        }
    }

    return 0;
}


Measured memory_bytes: 4120
#include <iostream>

using namespace std;
int main()
{
	long int a, b, max;

	cin >> a >> b;

	max = a + b;

	if (max < a - b)max = a - b;

	if (max < a * b)max = a * b;
	// 出力
	cout << max;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
   int n,k,i,j;int count=0;
   cin>>n>>k;
   for(i=1;i<=n;i++)
   {  int p=0;
       for(j=i;j<=n;j++)
       {   p++;
           
           //cout<<j<<" ";
           if(p==k)
           break;
       }
       if(p==k)
       count++;
      
   }
   cout<<count<<endl;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;


int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}

	vector<bool> sp(M, true);
	int ans = 1e8;
	for (int k = 0; k < M - 1; k++) {
		vector<int> num(M);
		int temp = 0, id = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				int a = A[i][j];
				if (sp[a]) {
					num[a]++;
					if (temp < num[a])
						temp = num[a], id = a;
					break;
				}
			}
		}
		//cout << "temp=" << temp << endl;
		sp[id] = false;
		if (temp == 0)continue;
		ans = min(ans, temp);
	}
	cout << (M == 1 ? N : ans) << endl;
}


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

int main() {
  int N,K;
  string S;
  cin >>N >>K ;
  cin >>S;
  if(S.at(K-1) == 'A'){
    S.at(K-1) = 'a';
  }
  else if(S.at(K-1) == 'B'){
    S.at(K-1) = 'b';
  }
  else if(S.at(K-1) == 'C'){
    S.at(K-1) = 'c';
  }
  
  cout << S << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	int h, w;
	cin >> h >> w;
	while (h != 0) {
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cin >> h >> w;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val n = StdIn.readInt
    val array = StdIn.readLine.split(" ").map(_.toInt)
    val t = selectionSort(n, array)
    println(t._1.mkString(" "))
    println(t._2)
  }

  def selectionSort(n: Int, array: Array[Int]) = {
    var count = 0
    for (i <- 0 to n - 1) {
      var min = i
      for (k <- i to n - 1) {
        if (array(min) > array(k)) {
          min = k
        }
      }
      if (array(min) != array(i)) {
        val tmp = array(i)
        array(i) = array(min)
        array(min) = tmp
        count = count + 1
      }
    }
    (array, count)
  }
}


Measured memory_bytes: 44024
#44 C - pushpush AC
n = int(input())
a = list(map(int,input().split()))

odd = [a[i] for i in range(n) if i%2 == 1] # O(n)
even = [a[j] for j in range(n) if j%2 == 0]# O(n)

if n%2 == 0:
    ans = list(reversed(odd)) + even # O(n)
else:
    ans = list(reversed(even)) + odd # O(n)
print(*ans)

Measured memory_bytes: 31004
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

ll _gcd(ll A, ll B) {
	return (B == 0) ? A : gcd(A % B, B);
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
	}
	return res;
}


ll fibs[100] = { 0 };
ll fib(int n) {
	if (fibs[n] == 0) {
		return fibs[n] = fib(n - 1) + fib(n - 2);
	}
	return fibs[n];
}



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

	int N;
	cin >> N;

	cout << min(0.5 + (N % 2) * (0.5 / (double)N), 1.0) << endl;


ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll a[3*N];
    rep(i, 3*N) cin >> a[i];
    priority_queue<ll, vector<ll>, greater<ll> > que1;
    priority_queue<ll> que2;
    ll sum1[N+1], sum2[N+1];
    sum1[0] = 0, sum2[N] = 0;
    rep(i, N){
        que1.push(a[i]);
        sum1[0] += a[i];
    }
    rep3(i, 3*N-1, 2*N){
        que2.push(a[i]);
        sum2[N] += a[i];
    }
    rep2(i, 1, N){
        if(que1.top() < a[N-1+i]){
            sum1[i] = sum1[i-1]+a[N-1+i]-que1.top();
            que1.pop();
            que1.push(a[N-1+i]); 
        }
        else sum1[i] = sum1[i-1];
    }
    rep3(i, N-1, 0){
        if(que2.top() > a[N+i]){
            sum2[i] = sum2[i+1]+a[N+i]-que2.top();
            que2.pop();
            que2.push(a[N+i]);
        }
        else sum2[i] = sum2[i+1];
    }
    ll ans = sum1[0]-sum2[0];
    rep2(i, 1, N){
        ans = max(ans, sum1[i]-sum2[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5876
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if p[i]>p[i-1] and p[i]<p[i+1] or p[i]<p[i-1] and p[i]>p[i+1]:
    ans+=1
print(ans)

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

using namespace std;

template< class T >
struct CumulativeSum
{
  vector< T > data;

  CumulativeSum(int sz) : data(sz, 0) {};

  void add(int k, int x)
  {
    data[k] += x;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  T query(int k)
  {
    return (data[k]);
  }
};


int main()
{
  int N, T;
  scanf("%d %d", &N, &T);
  CumulativeSum< int > sum(T + 1);
  for(int i = 0; i < N; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    sum.add(l, 1);
    sum.add(r, -1);
  }
  sum.build();

  int ret = 0;
  for(int i = 0; i < T; i++) {
    ret = max(ret, sum.query(i));
  }

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

}

Measured memory_bytes: 3408
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
#include <chrono>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    ll X,Y,Z;
    vvll next(N);
    for(ll i=0;i<M;i++){
        cin>>X>>Y>>Z;
        next[X-1].push_back(Y-1);
        next[Y-1].push_back(X-1);
    }
    
    vector<bool> done(N,false);
    ll ans=0;
    ll check=0;
    //chrono::system_clock::time_point start, end;double time;
    while(true){
        bool ok=true;
        queue<ll> open;
        for(ll i=check;i<N;i++){
            if(!done[i]){
                open.push(i);
                ok=false;
                check=i+1;
                break;
            }
        }
        if(ok)break;
        while(open.size()>0){
            ll node=open.front();
            //if(node%1000==0) printf("node=%d(%d)\n",node,open.size());
            open.pop();
            done[node]=true;
            for(ll i=0;i<next[node].size();i++){
                if(!done[next[node][i]])open.push(next[node][i]);
            }
        }
        ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 7412
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long p = 1;
    for (int i = 1; i <= N; i++) {
      p = (p * i) % 1000000007;
    }
    System.out.println(p);
  }
}


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

int main()
{
        long long money = 100;
        long long X;
        int year = 0;
        cin >> X;

        while(money < X)
        {
                money = money + (money / 100);
                year++;
        }

        cout << year << endl;

        return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    int x = n * 800;
    int y = 200 * (n / 15);
    cout << x - y << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

A = input()
C = Counter(A)
ans = len(A)*(len(A)-1)//2+1
for k in C.keys():
    ans -= C[k]*(C[k]-1)//2
print(ans)

Measured memory_bytes: 40176
S = input().strip()
N=len(S)
count=0

if N%4==1:
    for i in range(int((N-1)/2)//2):
        if S[i] == S[int(((N-3)/2)-i)] and S[i] == S[int(((N+1)/2)+i)] and S[i] == S[N-1-i]:
           count+=1


elif N%4==3:
    for i in range(int((N-1)/2)//2):
        if S[i] == S[int(((N-3)/2)-i)] and S[i] == S[int(((N+1)/2)+i)] and S[i] == S[N-1-i] and S[int(((N-1)/2)//2)] == S[N-1-int(((N-1)/2)//2)]:
           count+=1

if count==int((N-1)/2)//2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
   T res = 1;
   for (; n; n >>= 1)
   {
      if (n & 1)
         res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

vector<vector<bool>> fl(2, vector<bool>());

signed main()
{

   while (1)
   {

      ll r, c, q, ans = 0;
      cin >> r >> c >> q;
      if (!r && !c && !q)
         return 0;

      
      fl[0] = vector<bool>(r, false);
      fl[1] = vector<bool>(c, false);

      vector<ll> a(q), b(q), o(q);
      rep(i, 0, q)
      {
         cin >> a[i] >> b[i] >> o[i];
      }

      for (int i = q - 1; 0 <= i; i--)
      {
         if (fl[a[i]][b[i]])
            continue; //指示済みは無視

         fl[a[i]][b[i]] = true;

         if (o[i])
         {
            if (!a[i])
            {
               ans += c;
               r--;
            }
            else
            {
               ans += r;
               c--;
            }
         }
         else
         {
            if (!a[i])
            {
               r--;
            }
            else
            {
               c--;
            }
         }
      }

      cout << ans << endl;
   }
}


Measured memory_bytes: 4156
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    G[x].append(y)


def topological_sort(g):
    topological_list = []
    visited = set()

    def dfs(n):
        for e in g[n]:
            if e not in visited:
                dfs(e)
        topological_list.append(n)
        visited.add(n)

    for i in range(len(g)):
        if i not in visited:
            dfs(i)

    return topological_list[::-1]


T = topological_sort(G)
dist = [0] * N
for n in T:
    for v in G[n]:
        dist[v] = max(dist[v], dist[n] + 1)

print(max(dist))


Measured memory_bytes: 147912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    double R;
    cin >> R;
    cout << fixed << setprecision(15) << 2 * M_PI * R << endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int odd[4];
void solve() {
	map<pii, char> mpc;
	mpc[mp(0, 1)] = 'U';
	mpc[mp(0, 0)] = 'D';
	mpc[mp(1, 1)] = 'R';
	mpc[mp(1, 0)] = 'L';
	var(int, n);
	pii yx[n];
	ll max_a = 0;
	each(a, yx) {
		cin >> a.se >> a.fi;
		++odd[(a.fi & 1) + (a.se & 1)];
		chmax(max_a, abs(a.fi) + abs(a.se));
	}
	if (!(odd[1] == 0 || odd[0] + odd[2] == 0)) {
		print(-1);
		return;
	}
	vll m;
	if (odd[2] != 0) {
		m = {1, 1};
	} else if (odd[1] != 0) {
		m = {1};
	}
	for(ll i = 2; i < max_a; i *= 2) {
		m.eb(i);
	}
	reverse(all(m));
	print(len(m));
	rep(i, 0, len(m) - 1)
		cout << m[i] << " ";
	print(m.back());
	int op[2];
	each(a, yx) {
		op[0] = a.fi >= 0;
		op[1] = a.se >= 0;
		a.fi = abs(a.fi);
		a.se = abs(a.se);
		string s = "";
		each(c, m) {
			if (a.fi > a.se) {
				s += mpc[mp(0, op[0])];
				a.fi -= c;
				if (a.fi < 0) {
					a.fi = abs(a.fi);
					op[0] = 1 - op[0];
				}
			} else {
				s += mpc[mp(1, op[1])];
				a.se -= c;
				if (a.se < 0) {
					a.se = abs(a.se);
					op[1] = 1 - op[1];
				}
			}
		}
		print(s);
	}
}
int main() {
	solve();
	return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VL a(n), sm(n+1);
	rep(i, n) {cin >>a[i]; a[i]--;}
	rep(i, n) sm[i+1] = (sm[i] + a[i] )%k;
	
	map<ll, int> mp;
	ll ans =0;
	rep(i, n+1){
		if(i-k>=0) mp[sm[i-k]]--;
		//dbg(i, sm[i], mp[sm[i]]);
		ans += mp[sm[i]];
		mp[sm[i]]++;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll n, x; cin >> n >> x;
	vl m(n);
	for (ll i = 0; i < n; ++i){
		cin >> m[i];
		x -= m[i];
	}
	ll mini = *min_element(all(m));
	cout << n + x / mini << endl;
	return 0;
}

Measured memory_bytes: 256
n,k,q = map(int, input().split())
points = []
for i in range(q):
    points.append(int(input()))

scores = []
for j in range(n):
    scores.append(q)

for p in points:
    scores[p-1] = scores[p-1] - 1
    
for s in scores:
    if s <k:
        print("Yes")
    else:
        print("No")

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

using namespace std;

int main(){
  int i, N, K, counter=0;
  cin >> N >> K;
  for(i = 1; i*2<=i+K && counter<N; i=i*2){
    counter++;
  }
  cout<<(N-counter)*K+i<<endl;
}

Measured memory_bytes: 256
N = int(input())
res = {}
ans = 0
i = 2
 
for i in range(2,int(N**(1/2))+1) :
    while(N%i == 0) :
        if(i not in res) :
            res[i] = 1
        else :
            res[i] += 1
        N /= i
if(N != 1) :
    res[N] = 1
 

for i in res :
    b = 1
    s = res[i]
    while(b <= s) :
        ans += 1
        s -= b
        b += 1
print(ans)
    

Measured memory_bytes: 9488
/* Author rumoisen */
/* created 2018/10/07 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int n,a[110];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int m=0,l=1e9+1;
    for(int i=0;i<n;i++){
        if(a[i]>=m) m=a[i];
        if(l>=a[i]) l=a[i];
    }
    cout<<m-l<<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)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int a,b;
  cin>>a>>b;  
  if(a==0||b==0){
    if(b>a){
      cout<<abs(b-a)<<endl;
    }
    else{
      cout<<abs(b-a)+1<<endl;
    }
  }
  else{
  if((a<b&&b<0)||(a<b&&a>0)){
    cout<<b-a<<endl;
  }
  else if((a<0&&b>0)||(a>0&&b<0)){
    cout<<abs(abs(b)-abs(a))+1<<endl;
  }
  else{
    cout<<abs(b-a)+2<<endl;
  }
  }
 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] num = new int[N];
    int count = 0;

    for(int i=0; i < N; i++){
        num[i] = sc.nextInt();
        if(i > 1){
            if(num[i-2] > num[i-1] && num[i-1] > num[i]){
                count++;
            }else if(num[i-2] < num[i-1] && num[i-1] < num[i]){
                count++;
            }
        }
    }

        System.out.println(count);
  }
}

Measured memory_bytes: 22612
while True:
    n,k=map(int,input().split())
    if n==0 & k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11704
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n; cin >> n;
  vector<int> a(n, 0);
  vector<int> b(n+1, 0);
  vector<int> c(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = 1; i < n; i++) {
    cin >> c[i];
  }
  int last = a[0];
  ll p = b[a[0]];
  for (int i = 1; i < n; i++) {
    p += b[a[i]];
    if (a[i] - last == 1) p += c[last];
    last = a[i];
  }
  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
lv=list(map(int,input().split()))
dev={}
dod={}
#cev=0#devの種類数
#cod=0#dodの種類数
max1_ev=[0,0]#数字,個数
max2_ev=[0,0]
max1_od=[0,0]#数字,個数
max2_od=[0,0]

for i in range(N):
    if i%2==0:#even
        #max1_ev=[0,0]#数字,個数
        #max2_ev=[0,0]
        #毎回初期化していた！！

        if lv[i] in dev:#辞書の更新
            dev[lv[i]]+=1
        else:
            dev[lv[i]]=1
            #maxの更新
            #cev+=1
            #if cev==1:
            #    max1_ev=[i,lv[i]]
            #elif cev==2:
            #    max2_ev=[i,lv[i]]
        ##3種目以降
        #最大個数の更新
        if dev[lv[i]]>max1_ev[1]:
            max1_ev=[lv[i],dev[lv[i]]]
        #elif dev[lv[i]]>max2_ev[1]:
        elif dev[lv[i]]>=max2_ev[1]:
            max2_ev=[lv[i],dev[lv[i]]]
        #print("dev[lv[i]]",dev[lv[i]])
        #print("max1__ev[1]",max1_ev[1])
        #print("max1_ev",max1_ev)
        #print("max2_ev",max2_ev)
        #if i==0:
        #    max1=[0,1]
        #elif i==1:
        #    max2
    else:#odd
        #max1_od=[0,0]
        #max2_od=[0,0]
        if lv[i] in dod:
            dod[lv[i]]+=1
        else:
            dod[lv[i]]=1
        if dod[lv[i]]>max1_od[1]:
            max1_od=[lv[i],dod[lv[i]]]
        #elif dod[lv[i]]>max2_od[1]:
        elif dod[lv[i]]>=max2_od[1]:
            max2_od=[lv[i],dod[lv[i]]]
#print("dev",dev)#ok
#print("dod",dod)#ok
#print("max1_ev",max1_ev)
#print("max2_ev",max2_ev)


#if len(dev)==1 and len(dod)==1:
#    print(int(N/2))
#elif len(dev)==1:
    #for i in range(len(dod)):
    #    if i==0:
    #        max1_od=
#    if max1_ev[0]!=max1_od[0]:
#        print(N-max1_ev[1]-max1_od[1])
##        print(max)
if max1_ev[0]!=max1_od[0]:
    print(N-max1_ev[1]-max1_od[1])
elif len(dev)==1 and len(dod)==1:
    print(int(N/2))
elif len(dev)==1:
    print(int(N/2)-max2_od[1])
elif len(dod)==1:
    print(int(N/2)-max2_ev[1])
else:
    #print(max(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))#minをmaxとしていた
    print(min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))


Measured memory_bytes: 17644
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
  
public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
 
	int N = in.nextInt();
	int a[] = new int[100001];
	int ans = 0;
	Arrays.fill(a, 0);
 
	for(int cnt = 0; cnt < N; cnt++){
		int input = in.nextInt();
		a[input]++;
	}
 
	for(int cnt = 1; cnt < 100000; cnt++){
		int tmp = a[cnt-1]+a[cnt]+a[cnt+1];
		if(ans < tmp){
			ans = tmp;
		}
 
	}
 
	System.out.println(ans);
 
}
}

Measured memory_bytes: 50292
'''
ITP-1_4-B
 ????????¢?????¨?????¨
?????? r ???????????¢?????¨?????¨?????????????±???????????????°?????????????????????????????????
 Input
??????????????° r ????????????????????????
 Output
??¢?????¨?????¨?????????????????????????????§????????£????????????????????????????????????????????????????°???°?????°??¨??????0.00001 ??\???????????????????????§?????????????????¨????????????
'''
# import
import math

# ?????°??????????????????
r=float(input())

# ?????¨????????????
pai = math.pi

# ????????¢???????±???????
outputData01 = r*r*pai

# ?????¨????±???????
outputData02 = 2*r*pai

# ?????????????????????
print("{0:.6f} {1:.6f}".format(outputData01, outputData02))

Measured memory_bytes: 7516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

vector<ll> G[200010];

int main() {
	ll N, u, v;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> u >> v;
		u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	ll ans = 0, cnt = 0, d = 0;
	for (ll i = 0;i < N;i++) {
		cnt = i + 1;
		for (auto j : G[i]) {
			if (j < i) {
				cnt -= j + 1;
			}
		}
		d += cnt;
		ans += d;
		cnt = 0;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vb visited;
vl values;
vvl tree;
vl ops;

void recurse(ll curNode, ll curAdd){
	visited[curNode] = true;
	ll newAdd = curAdd+ops[curNode];
	values[curNode] += newAdd;

	FOR(i, 0, tree[curNode].size()){
		if(!visited[tree[curNode][i]]){
			recurse(tree[curNode][i], newAdd);
		}
	}
}


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

	ll N, Q;

	cin >> N >> Q;

	tree =  vvl(N, vl());

	values = vl(N, 0);
	ops = vl(N, 0);

	visited = vb(N, false);




	FOR(i, 0, N-1){
		ll a, b;
		cin >> a >> b;
		tree[a-1].pb(b-1);
		tree[b-1].pb(a-1);
	}

	FOR(i, 0, Q){
		ll p, x;
		cin >> p >> x;
		ops[p-1] += x;
	}



	recurse(0, 0);

	FOR(i, 0, N){
		cout << values[i] << ' ';
	}
	cout << '\n';
}


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

int main() {
  long long X;
  cin >> X;
  bool find = false;
  for (long long i = 1; i < 1000; i++) {
    for (long long j = 0; j < i; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  if (!find) {
    for (long long i = 1; i < 1000; i++) {
      for (long long j = 1; j < 1000; j++) {
        if (pow(i, 5) + pow(j, 5) == X) {
          cout << i << " " << (-1)*j << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 4028
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(x - (a + (x - a) / b * b));
  }
}

Measured memory_bytes: 23252
loop do
  h,w = gets.split.map(&:to_i)
  break if h.zero? && w.zero?

  odd = ('#.' * w)[0...w]
  even = ('.#' * w)[0...w]
  h.times { |v| puts "#{(v+1).odd? ? odd : even}" }
  puts
end

Measured memory_bytes: 6108
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int R, G, B, N, ans = 0;
    cin >> R >> G >> B >> N;

    for (int i = 0; i <= N/R; i++) {
        for (int j = 0; j <= N/G; j++) {
            if (i*R + j*G > N) continue;
            if ((N - i*R - j*G) % B == 0) {  
                ans++;
                //cout << i << " " << j << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
const double eps=1e-9;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))
#define clr(a,b) memset(a,b,sizeof(a))
const int inf= INT_MAX;
//struct point_i{int x,y;};
struct point_i{int x,y;
point_i(){ x=0; y=0;}
point_i(int x_,int y_){x=(x_);y=(y_) ;}
};

struct point 
{
	float x,y;
	point (){x=y=0.0;}
	point (float x_,float y_){x=(x_); y=(y_);}
	bool operator < (point other) const{
	  if(fabs(x-other.x)>eps)return x<other.x;
	  return y<other.y;
		
		}
	bool operator == (point other) const {
		return fabs(other.x-x)<=eps&& fabs(other.y-y)<=eps;
		}
	
} ;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d})<<endl;
	
}



Measured memory_bytes: 3660
S = str(input())

ans=0
for i in range(len(S)+1):
    for j in range(i,len(S)+1):
        s=S[i:j]
        if s.count("A")+s.count("G")+s.count("C")+s.count("T")==len(s):
            ans=max(len(s),ans)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

double dp[303][303][303]; 
int N;

double solve(int a, int b, int c){
    if(dp[a][b][c] != -1)return dp[a][b][c];
    double res = 0;
    double div = a + b + c;
    res += N/div;
    if(a > 0)res += solve(a-1, b, c)*a/div;
    if(b > 0)res += solve(a+1, b-1, c)*b/div;
    if(c > 0)res += solve(a, b+1, c-1)*c/div;
    return dp[a][b][c] = res;
}

int main(){
    rep(i,303)rep(j,303)rep(k,303)dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    int t, a[3] = {0};
    cin >> N;
    rep(i,N){
        cin >> t; --t; 
        ++a[t];
    }
    cout << fixed << setprecision(10)<< solve(a[0], a[1], a[2]) << endl;
    return 0;
}

Measured memory_bytes: 221156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long gcd(long m,long n) {
	if (n==0) {
		return m;
	}
	return gcd(n,m%n);
}

int main() {
	long n,x;
	cin >> n >> x;
	vector<long> city(n);
	for (long i=0;i<n;++i) {
		cin >> city[i];
	}
	if (n == 1) {
		cout << abs(x-city[0]) << "\n";
		return 0;
	}
	long ans=gcd(abs(city[0]-x),abs(city[1]-x));
	for (long i=0;i<n;++i) {
		ans = gcd(ans,abs(city[i]-x));
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024