akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<math.h>

int main () {
	int N,M;
	scanf("%d %d", &N, &M);
	
	int a=0;
	int b=0;
	
	for(int i=1;i<N;i++){
		a = a+i;
	}
	for(int i=1;i<M;i++){
		b=b+i;
	}
	printf("%d",a+b);
	
	return 0;
	
	
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	"container/list"
	"bytes"
)

const MaxNode int = 1e5

var graph [][] int
var color []int
var N int

func bfs(u, c int) {
	l := list.New()
	l.PushBack(u)
	for ;l.Len()!=0; {
		u = l.Front().Value.(int)
		color[u] = c
		l.Remove(l.Front())
		for i:=0; i<len(graph[u]); i++ {
			if color[graph[u][i]] == 0 {
				l.PushBack(graph[u][i])
			}
		}
	}
}

func assignColor() {
	id := 1
	for u:=0; u<N; u++ {
		if color[u] == 0 {
			bfs(u, id)
			id ++
		}
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}


func buildGraph(scanner *bufio.Scanner) {
	N = nextInt(scanner)
	color = make([]int, N)
	graph = make([][]int, N)
	m := nextInt(scanner)
	for i:=0; i<m; i++ {
		n1 := nextInt(scanner)
		n2 := nextInt(scanner)
		graph[n1] = append(graph[n1], n2)
		graph[n2] = append(graph[n2], n1)
	}
}

func answer(scanner *bufio.Scanner) {
	var outBuffer bytes.Buffer
	cnt := nextInt(scanner)
	for i:=0; i<cnt; i++ {
		n1 := nextInt(scanner)
		n2 := nextInt(scanner)
		if color[n1] == color[n2] {
			outBuffer.WriteString("yes\n")
		} else {
			outBuffer.WriteString("no\n")
		}
	}
	fmt.Printf("%s", outBuffer.String())
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	buildGraph(scanner)
	assignColor()
	answer(scanner)
}


Measured memory_bytes: 15904
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	map<i64, int> mp;
	REP(i, n)
	{
		i64 a;
		cin >> a;
		mp[a]++;
	}

	i64 e[2] = { 0, 0 };
	for (auto it = mp.rbegin(); it != mp.rend(); ++it)
	{
		if ((*it).second > 1)
		{
			if (e[0] == 0)
			{
				if ((*it).second > 3)
				{
					e[0] = (*it).first;
					e[1] = (*it).first;
					break;
				}
				e[0] = (*it).first;
			}
			else if (e[1] == 0)
			{
				e[1] = (*it).first;
				break;
			}
		}
	}

	print(e[0] * e[1]);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N;
  cin >> N;
  int p[100];
  rep(i, N) cin >> p[i];
  
  int max = 0;
  int sum = 0;
  
  rep(i, N){
  	if(max < p[i]) max = p[i];
    sum += p[i];
  }
  
  cout << sum - max/2 << endl;
  
    
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005
#define PI 3.14159265358979323846264338327950
int main()
{
    _FastIO;
    cout.precision(20);
    int a , b , h , m;
    cin >> a >> b >> h >> m;
    long double rad = PI * 2 * ( (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    long double ans = (long double)(a * a + b * b) - (long double)(2 * a * b * cos(rad));
    cout << fixed << sqrt(ans) << endl;
    return 0;
}


Measured memory_bytes: 4136
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for(int i = 0; i < M; i++) cin >> A[i];
    int l = 0, r = 0;
    sort(all(A));
    for(int i = 0; i < M; i++){
        if(A[i] < X) l++;
        else r++;
    }
    cout << min(l, r) << endl;
}


Measured memory_bytes: 3604
import sys
S=str(input())
lst1=['R','U','D']
lst2=['L','U','D']    
l=len(S)
if l%2==0:
  for i in range(0,l-1,2):
    if S[i] in lst1:
      pass
    else:
      print('No')
      sys.exit()
  for j in range(1,l,2):
    if S[j] in lst2:
      pass
    else:
      print('No')
      sys.exit()
  print('Yes')
else:
  for i in range(0,l,2):
    if S[i] in lst1:
      pass
    else:
      print('No')
      sys.exit()
  for j in range(1,l-1,2):
    if S[j] in lst2:
      pass
    else:
      print('No')
      sys.exit()
  print('Yes')

Measured memory_bytes: 3064
#include <cstdio>

#include <vector>
#include <queue>
#include <cstdint>
#include <cassert>
#include <tuple>

template<typename t> t inf() { assert(0); return t(); }
template<> double inf() { return (1LL << 50); }
template<> long inf() { return (1LL << 50); }

namespace Graph {
  template<typename tEdge>
  struct Graph {
    Graph() : v(0) {}
    std::vector<tEdge> edges;
    uint32_t v;
  };
  template<typename tEdge>
  void addEdge(Graph<tEdge>& graph, tEdge edge) {
    assert( edge.from < graph.v );
    assert( edge.to   < graph.v );
    graph.edges.push_back(edge);
  }
  template<typename tEdge>
  void setV(Graph<tEdge>& graph, uint32_t v) {
    graph.v = v;
  }
};

namespace Graph {
  namespace Dijkstra {
    template<typename tEdge>
    struct DijkstraInfo {
      std::vector<typename tEdge::wType> dists;
    };
    template<typename tEdge>
    static DijkstraInfo<tEdge> dijkstra(const Graph<tEdge>& graph, uint32_t start) {
      std::vector< std::pair<uint32_t, typename tEdge::wType> > *adj = new std::vector< std::pair<uint32_t, typename tEdge::wType> >[graph.v];
      int n = graph.edges.size();
      for(int i = 0; i < n; ++i) {
        adj[graph.edges[i].from].push_back(std::make_pair(graph.edges[i].to, graph.edges[i].w));
      }
      DijkstraInfo<tEdge> info;
      info.dists.resize(graph.v);
      for(auto &x : info.dists) x = inf<typename tEdge::wType>();
      info.dists[start] = 0;
      std::priority_queue< std::pair<typename tEdge::wType, uint32_t> > q;
      q.push(std::make_pair(0, start));
      while( not q.empty() ) {
        typename tEdge::wType w;
        uint32_t id;
        std::tie(w, id) = q.top(); q.pop(); w = -w;
        for(auto I : adj[id]) {
          uint32_t next;
          typename tEdge::wType nw;
          std::tie(next, nw) = I; nw += w;
          if( info.dists[next] <= nw ) continue;
          info.dists[next] = nw;
          q.push(std::make_pair(-nw, next));
        }
      }
      delete [] adj;
      return info;
    }
  };
};


struct Edge {
  uint32_t from;
  uint32_t to;
  typedef long wType;
  wType w;
};

int main() {
  Graph::Graph<Edge> graph;
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  setV(graph, v);
  for(int i = 0; i < e; ++i) {
    Edge edge;
    scanf("%u %u %ld", &edge.from, &edge.to, &edge.w);
    addEdge(graph, edge);
  }
  auto res = Graph::Dijkstra::dijkstra(graph, r);
  int n = res.dists.size();
  for(int i = 0; i < n; ++i) {
    printf("%s\n", res.dists[i] == inf<long>() ? "INF" : std::to_string(res.dists[i]).c_str());
  }
  
  return 0;
}

Measured memory_bytes: 27592
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  ll fibonacci[n + 1];
  fibonacci[0] = 2, fibonacci[1] = 1;
  for (int i = 2; i <= n; i++) fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2];
  cout << fibonacci[n] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LIMIT_NODES (100)

int compare(const void *a, const void *b) {
	return ((int*)a)[2] - ((int*)b)[2];
}

int solve(int num_node) {
	int i, k, num_edge, answer, node1, node2;
	char forest[LIMIT_NODES][LIMIT_NODES];

	scanf("%d ", &num_edge);
	int S[num_edge][3];

	for (i = 0; i < num_edge; i++) {
		scanf("%d,%d,%d ", S[i]+0, S[i]+1, S[i]+2);
	}
	qsort(S, num_edge, sizeof(S[0]), compare);

	memset(forest, 0, sizeof(forest[0]) * LIMIT_NODES);
	for (i = 0; i < num_node; i++) {
		forest[i][i] = 1;
	}

	answer = 0;
	for (i = 0; i < num_edge; i++) {
		node1 = node2 = 0;
		for (k = 0; k < num_node; k++) {
			if (forest[k][S[i][0]]) {
				node1 = k;
			}
			if (forest[k][S[i][1]]) {
				node2 = k;
			}
		}
		if (node1 != node2) {
			for (k = 0; k < LIMIT_NODES; k++) {
				forest[node1][k] |= forest[node2][k];
				forest[node2][k] = 0;
			}
			answer += (S[i][2] / 100) - 1;
		}
	}
	return answer;
}

int main(void) {
	int num_node;

	while (1) {
		scanf("%d ", &num_node);
		if (!num_node)
			break;

		printf("%d\n", solve(num_node));
	}
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    
    ll t = 0;
    int id = 0;
    REP(i, N){
        t += i+1;
        if(t >= N){
            id = i;
            break;
        }
    }

    REP(i, N){
        if((t%N) != (i+1)) pr(i+1);
        if(id == i) break;
    }
}

Measured memory_bytes: 256
//Patwari26
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=200005;
int a[N],seg[N<<2];
int query(int node,int start,int end,int l,int r){
    if(l<=start && r>=end) return seg[node];
    if(r<start || l>end) return 0;
    int mid=(start+end)>>1;
    int ans1=query(node<<1,start,mid,l,r);
    int ans2=query(node<<1|1,mid+1,end,l,r);
    return (ans1+ans2)%hell;
}
void update(int node,int start,int end,int x,int val){
    if(start==end){
        a[x]=val;
        seg[node]=val;
        return;
    }
    int mid=(start+end)>>1;
    if(start<=x && x<=mid) update(node<<1,start,mid,x,val);
    else update(node<<1|1,mid+1,end,x,val);
    seg[node]=(seg[node<<1]+seg[node<<1|1])%hell;
}
int b[N],seg2[N<<2];
int query2(int node,int start,int end,int l,int r){
    if(l<=start && r>=end) return seg2[node];
    if(r<start || l>end) return 0;
    int mid=(start+end)>>1;
    int ans1=query2(node<<1,start,mid,l,r);
    int ans2=query2(node<<1|1,mid+1,end,l,r);
    return max(ans1,ans2);
}
void update2(int node,int start,int end,int x,int val){
    if(start==end){
        b[x]+=val;
        seg2[node]+=val;
        return;
    }
    int mid=(start+end)>>1;
    if(start<=x && x<=mid) update2(node<<1,start,mid,x,val);
    else update2(node<<1|1,mid+1,end,x,val);
    seg2[node]=max(seg2[node<<1],seg2[node<<1|1]);
}
void solve(){
    ll n;
    cin>>n;
    ll x,y;
    vector<pii> v;
    vector<ll> vv;
    rep(i,0,n-1){
        cin>>x>>y;
        v.pb({x,y});
        vv.pb(x);
    }
    sort(all(v));
    sort(all(vv));
    // rep(i,0,n-1) cout<<v[i].F<<" "<<v[i].S<<endl;
    cout<<endl;
    rrep(i,n-1,0){
        ll ans=0;
        pii curr=v[i];
        ll idx=lower_bound(all(vv),curr.F+curr.S)-vv.begin()-1;
        idx=max(idx,query2(1,0,n-1,i+1,idx));
        // idx=max(idx,i);
        ans=(1+query(1,0,n-1,idx+1,n-1))%hell;
        update2(1,0,n-1,i,idx);
        update(1,0,n-1,i,ans);
    }
    cout<<(1+query(1,0,n-1,0,n-1))%hell;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

int main(){

    int N; cin >> N;
    int x[N], y[N]; for(int i = 0; i < N; i++){cin >> x[i] >> y[i];}

    double distance[N][N];
    double ans = 0;

    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            distance[i][j] = sqrt(pow((x[i] - x[j]),2) + pow((y[i] - y[j]),2));
            ans += distance[i][j];
            //cout << i+1 << " to " << j+1 << " : " << distance[i][j] << endl;
        }
    }

    printf("%.10f",2*ans/N);
}

Measured memory_bytes: 384
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)		

N = int(input())
T = []
ans = int(input())
for _ in range(N-1):
    t = int(input())
    ans = lcm(ans, t)

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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; }

using ll = long long;
const long long MOD = 1e9+7;

int main() { 
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        v.at(i) = make_pair(p, i);
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    int min_idx = n + 1;
    for (int i = 0; i < n; i++) {
        if (v.at(i).second <= min_idx) cnt++;
        chmin(min_idx, v.at(i).second);
    }
    cout << cnt << endl;
}   

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

int main() {
  
  int N; cin >> N; vector<int64_t> vec(N); int64_t ans = 1;
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  if (vec[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  
  for (int i = 0; i < N; i++) {
    
    if (int64_t(pow(10, 18)) / ans < vec[i]) {
      cout << -1 << endl;
      return 0;
    }
    
    ans *= vec[i];
    
  }
  
  cout << ans << endl;
  
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n, m; cin >> n >> m;
  if (2 * n >= m) {
    cout << m / 2 << endl;
  }else {
    ll a = m - n * 2;
    cout << n + a/4 << endl;
  }

  return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> S(n);
	for (int& i : S) cin >> i;
	int q;
	cin >> q;
	int C = 0;
	for (int i = 0; i < q; ++i) {
		int j, T;
		cin >> T;
		for (j = 0; j < n; ++j) {
			if (S[j] == T) break;
		}
		if (n != j) ++C;
	}
	cout << C << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

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

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll x,money=100,t=0;
    cin>>x;
    while(money<x){
        money+=money*0.01;
        t++;
    }
    cout<<t<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
a,b,k=map(int,input().split())
for i in range(k//2):
	if a%2:
		a=a-1
	a=a//2
	b=b+a
	if b%2:
		b=b-1
	b=b//2
	a=a+b

if k%2:
		if a%2:
			a=a-1
		a=a//2
		b=b+a
print('{} {}'.format(a,b))

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])

for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)
    
ans =0
j = M

for i in range(N+1):
    if a[i]>K:
        break
    
    while b[j]+a[i] > K :
        j -= 1
    ans = max(ans, i + j)

print(ans)



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

using namespace std;

int main()
{
    int n,x;
    while(1)
    {
        cin >> n >> x;
        int count = 0;
        if(n==0 && x == 0 )break;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                for(int k=j+1;k<=n;k++)
                {
                    int s = i+j+k;
                    if(s ==x ) count++;
                    else if( s > x)break;
                }
            }
        }
        cout << count << endl;
    }


    return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] pk = new int[n];
		for (int i = 0; i < n; i++) pk[i] = in.nextInt();
		ArrayList<Integer>[] adj = new ArrayList[n];
		for (int i = 0; i < n; i++) adj[i] = new ArrayList<Integer>();
		for (int i = 0; i < m; i++) {
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			adj[a].add(b);
			adj[b].add(a);
		}
		int c = 0;
		ol:
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < adj[i].size(); j++) {
				if (pk[i] <= pk[adj[i].get(j)]) continue ol;
			}
			c++;
		}
		System.out.println(c);
	}
}


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

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int A[3][3];
    REP(i, 3) REP(j, 3) cin >> A[i][j];
    int N;
    cin >> N;
    int b;
    REP(i, N){
        cin >> b;
        REP(j, 3) REP(k, 3) if (A[j][k] == b) A[j][k] = 0;
    }
    bool f = false;
    REP(i, 3){
        if (A[i][0] + A[i][1] + A[i][2] == 0) f = true;
    }
    REP(i, 3){
        if (A[0][i] + A[1][i] + A[2][i] == 0) f = true;
    }
    if (A[0][0] + A[1][1] + A[2][2] == 0) f = true;
    if (A[0][2] + A[1][1] + A[2][0] == 0) f = true;

    string ans = f ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define X 10000000

int main() {
	int n, r[X], i, j, max=-2000000000, min;
	scanf("%d", &n);
	scanf("%d", &r[0]);
	min = r[0];
	for (i = 1; i < n; i++) {
		scanf("%d", &r[i]);
		if (min>r[i-1]) {
			min = r[i-1];
		}
		if (max<(r[i]-min)) {
			max = r[i] - min;
		}
	}
	printf("%d\n", max);
	return 0;
}


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

int main(){
    long long N;
    cin >> N;
    long long i = 0LL,j = 0LL;
    long long ans = N-1;
    for(i = 1; i*i <= N; i++){
        j = N / i;
        //cout << i << "," << j << endl;
        long long sum = i - 1 + j - 1;
        if(sum < ans && i * j == N) ans = sum;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

#define INF 10000000

int dp[1<<16];
int tool[16][17];
int N;

int rec(int S) {
  if (dp[S] != -1)
    return dp[S];
  if (S == (1<<N)-1)
    return dp[S] = 0;

  int ret = INF;
  REP(i, N) {
    if (!(S >> i & 1)) {
      int next = tool[i][0];
      REP(j, N) {
	if (S >> j & 1) next = min(next, tool[i][j+1]);
      }
      ret = min(ret, rec(S | 1 << i) + next);
    }
  }
  return dp[S] = ret;
}  

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

  while (1) {
    cin >> N;
    if (N == 0) break;

    REP(i, N) REP(j, N+1) cin >> tool[i][j];
    memset(dp, -1, sizeof(dp));
    cout << rec(0) << endl;
  }  
  return 0;
}

Measured memory_bytes: 1456
n,m,k = map(int,input().split())
flag = False
for i in range(n+1):
    for j in range(m+1):
        if (n-2*i)*(m-2*j) == n*m-2*k:
            print("Yes")
            flag = True
            break
    if flag == True:
        break
if flag == False:
    print("No")

Measured memory_bytes: 9184
n = gets.chomp.to_i
ans = 0
testimony = Array.new(n).map{Array.new}
n.times do |i|
    a = gets.chomp.to_i
    a.times do
        testimony[i] << gets.chomp.split(" ").map(&:to_i)
    end
end

[0, 1].repeated_permutation(n) do |bits|
    flag = true
    bits.each_with_index do |bit, i|
        if bit == 1 then
            testimony[i].each do |x, y|
                if bits[x-1] != y then
                    flag = false
                    break
                end
            end
        end
        break if !flag
    end
    ans = bits.count(1) if flag
end

puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define ll long long int
#define INF 1e18
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n, m, l;
  cin >> n >> m >> l;

  vector<vector<ll>> edge(n, vector<ll>(n, INF));
  int a, b, c;
  for (int i = 0; i < m; i++){
    cin >> a >> b >> c;
    a--; b--;
    edge[a][b] = c;
    edge[b][a] = c;
  }

  for (int k = 0; k < n; k++){
    edge[k][k] = 0;
  }

  for (int k = 0; k < n; k++){
    edge[k][k] = 0;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
      }
    }
  }

  vector<vector<ll>> edge2(n, vector<ll>(n, INF));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (edge[i][j] <= l)
        edge2[i][j] = 1;
    }
  }

  for (int k = 0; k < n; k++){
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        edge2[i][j] = min(edge2[i][j], edge2[i][k] + edge2[k][j]);
      }
    }
  }

  int q;
  cin >> q;
  int s, t;

  for (int i = 0; i < q; i++){
    cin >> s >> t;
    --s; --t;
    if (edge2[s][t] == INF)
      cout << -1 << endl;
    else
      cout << edge2[s][t] - 1 << endl;
  }


  return 0;
}


Measured memory_bytes: 1920
input = readlines
# input = ["2 3 -10\n", "1 2 3\n", "3 2 1\n", "1 2 2\n"]
# input = ["5 2 -4\n", "-2 5\n", "100 41\n", "100 40\n", "-3 0\n", "-6 -2\n", "18 -13\n"]

A = []

input.each.with_index do |row, i|
  if i == 0
    splitted_row = row.split(" ")
    N = splitted_row[0].to_i
    M = splitted_row[1].to_i
    C = splitted_row[2].to_i
    next
  end

  if i == 1
    B = row.split(" ")
    next
  end

  A << row.split(" ")
end

num_of_correct_answer = 0

A.each do |a|
  answer = C

  B.each.with_index do |b, i|
    answer += a[i].to_i * b.to_i
  end

  if answer > 0
    num_of_correct_answer += 1
  end
end

puts num_of_correct_answer


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r = a%b;
  while(r > 0){
    a = b;b=r;r=a%b;
  }
  return b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  ll c = a%b;
  cout<<min(c,abs(c-b))<<endl;
  // cout<<gcd(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int n,i;
double x,sum;
string u;
inline void solve(){
  IN(n);
  REP(i,n){
    IN2(x,u);
    if(u=="JPY")sum+=x;
    else sum+=x*380000.0;
  }
  printf("%f\n",sum);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N;
	cin>>N;
	ll a[N],b[N],c[N];
	ll dp[N][3][3];
	memset(dp,0,sizeof(dp));
	for(ll i=0;i<N;i++)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0][1]=a[0];
	dp[0][1][1]=b[0];
	dp[0][2][1]=c[0];
	ll ans=max(a[0],max(b[0],c[0]));
	for (ll i=1;i<N;i++)
	{
		dp[i][0][1]=max(dp[i-1][1][1],dp[i-1][2][1])+a[i];
		dp[i][1][1]=max(dp[i-1][0][1],dp[i-1][2][1])+b[i];
		dp[i][2][1]=max(dp[i-1][1][1],dp[i-1][0][1])+c[i];
		/*
		dp[i][0][2]=dp[i-1][0][1]+a[i];
		dp[i][1][2]=dp[i-1][1][1]+b[i];
		dp[i][2][2]=dp[i-1][2][1]+c[i];
		*/
	}
	ans=max(ans,max(dp[N-1][0][1],dp[N-1][0][2]));
	ans=max(ans,max(dp[N-1][1][1],dp[N-1][1][2]));
	ans=max(ans,max(dp[N-1][2][1],dp[N-1][2][2]));
	cout<<ans;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int i;
	int maxx;
	int a, b, c;
	int sum;
	int minn;
	scanf("%d %d %d", &a, &b, &c);
	maxx = max(a,max(b,c));
	for(i = maxx ; i <= 1000000 ; i++)
	{
		sum = i * 3 - a - b - c;
		if(sum % 2 == 0)
		{
			printf("%d\n", sum / 2);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D;
  cin >> N >>D;
  int obs = 1 + 2 * D;
  int ans = 0;
  while(N > 0){
  	N -= obs;
    ans++;
  }
  cout << ans << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct Node {
    ll key;
    Node *parent, *left, *right;
};
Node *NIL, *root;

void insert(ll k){
    Node *y = NIL;   // xの親
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));   // Node分のポインタの容量をとる
    z->key = k; z->left = NIL; z->right = NIL;

    while(x != NIL){
        y = x;  // 親を設定
        if((z->key) < (x->key)){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL) root = z;
    else if(y->key > z->key) y->left = z;
    else y->right = z;
}

bool find(ll k){
    Node *x = root;
    while(x != NIL){
        if(x->key == k) return true;
        if(x->key < k) x = x->right;
        else x = x->left;
    }
    return false;
}

void preorder(Node *n){
    if(n == NIL) return;
    printf(" %ld", n->key);
    preorder(n->left);
    preorder(n->right);
}

void inorder(Node *n){
    if(n == NIL) return;
    inorder(n->left);
    printf(" %ld", n->key);
    inorder(n->right);
}

int main()
{
    int m; cin >> m;
    rep(i,m){
        string c; cin >> c;
        if(c == "insert"){
            ll k; cin >> k;
            insert(k);
        }else if(c == "print"){
            inorder(root); cout << endl;
            preorder(root); cout << endl;
        }else if(c == "find"){
            ll k; cin >> k;
            if(find(k)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 22012
h,w = map(int,input().split())
l = [[] for i in range(h+2)]
l[0] = ["#"]*(w+2)
for i in range(h):
    a = list(input())
    a.append("#")
    a.reverse()
    a.append("#")
    a.reverse()
    l[i+1] = a
l[h+1] = ["#"]*(w+2)
for i in range(h+2):
    if i != 0:
        print()
    for x in l[i]:
        print(x,end="")

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
        a.at(i)=1;
    }
    sort(s.begin(),s.end());
    int k=1;
    for(int i=1;i<n;i++){
        if(s.at(i)==s.at(i-1)){
            a.at(i)=a.at(i-1)+1;
        }
        k=max(k,a.at(i));
    }
    for(int i=0;i<n;i++){
        if(a.at(i)==k){
            cout << s.at(i) << endl;
        }
    }
}

Measured memory_bytes: 15104
N = int(input())
A = list(map(int, input().split()))

nums = []
for i in range(1, N):
    nums.append(i)
    
nums.sort(reverse=True)

flag = 1
cnt = 0
while flag:
    flag = 0
    for num in nums:
        if A[num] < A[num-1]:
            A[num-1], A[num] = A[num], A[num-1]
            flag = 1
            cnt += 1

print(' '.join(map(str, A)))
print(cnt)


Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
	int n,a[100],b[100],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[n-i-1]=a[i];
	}
	if(n==1){
		printf("%d\n",*b);
		return 0;
	}
	printf("%d ",*b);
	for(i=1;i<n-1;i++)printf("%d ",b[i]);
	printf("%d\n",b[n-1]);
	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

#define MOD 1000000007
typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

LL bec(LL a, LL n){
    LL x = 1;
    while( n > 0){
        if( n & 0x01){
            x = x * a;
            x %= MOD;
        }
        a = a * a;
        a %= MOD;
        n >>= 1;
    }
    return x;
}
int main(){
    LL N,K;
    LL X;
    LL *num;
    LL number;
    LL count;
    int i,j;
    cin >> N >> K;
    num = new LL[K]; 
    for(i=K;i>=1;i--){
        X = K / i;
        number = bec(X,N);
        num[i-1] = number;
        for(j=i*2;j<=K;j+=i){
            num[i-1] -= num[j-1];
            num[i-1] %= MOD;
            if(num[i-1] < 0 ){
                num[i-1] += MOD;
            }
        }
    }
    count = 0;
    /*
    for(i=0;i<K;i++){
        cout << i+1 << ":" << num[i] << endl;
    }
    */
    for(i=0;i<K;i++){
        count += (num[i] * (i+1)) % MOD;
        count %=  MOD;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4360
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }
    var q = PriorityQueue(v)

    for (i in 1 until n){
        q.add((q.poll() + q.poll()) /2)
    }
    println(q.poll())
}

Measured memory_bytes: 37996
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
long long A[100010]={0},B[100010]={0};
int main(){
	int N;
	cin>>N;
	for(int i=0;i<=N;i++){
		cin>>A[i];
	}//怪兽 
	for(int i=0;i<N;i++){
		cin>>B[i];
	}//英雄 
	long long ans=0;
	int sen=0;
	for(int i=0;i<N;i++){
		if(A[i]>B[i]){
			ans=ans+B[i];
		}else{
			ans=ans+A[i];
			sen=B[i]-A[i];
			if(sen>=A[i+1]){
				ans=ans+A[i+1];
				A[i+1]=0;
			}else{
				ans=ans+sen;
				A[i+1]=A[i+1]-sen; 
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
put = '#'
output = []
while True:
	data = list(map(int, input().split()))
	if data[0] == 0 and data[1] == 0:
		break
	output += [data]

for tmp in output:
	for h in range(tmp[0]):
		for w in range(tmp[1]):
			print(put, end="")
		print()
	print()


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

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	LL a[n], b[n], c[n];
	LL ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
		ans += a[i];
		b[i] -= a[i];
		c[i] -= a[i];
	}
	pair<LL,int > t[n];
	for(int i = 0; i < n; i++){
		t[i] = make_pair(b[i]-c[i],i);
	}
	sort(t, t+n);
	reverse(t, t+n);
	LL besty[n+1];
	multiset<LL> ys;
	LL cur = 0;
	for(int i = 0; i < y; i++){
		ys.insert(b[t[i].second]);
		cur += b[t[i].second];
	}
	for(int i = y; i <= n; i++){
		if(i > y){
			cur += b[t[i-1].second];
			ys.insert(b[t[i-1].second]);
			cur -= *ys.begin();
			ys.erase(ys.begin());
		}
		besty[i] = cur;
	}

	reverse(t, t+n);
	LL bestz[n+1];
	multiset<LL> zs;
	cur = 0;
	for(int i = 0; i < z; i++){
		zs.insert(c[t[i].second]);
		cur += c[t[i].second];
	}
	for(int i = z; i <= n; i++){
		if(i > z){
			cur += c[t[i-1].second];
			zs.insert(c[t[i-1].second]);
			cur -= *zs.begin();
			zs.erase(zs.begin());
		}
		bestz[i] = cur;
	}

	LL final = -1e16;
	for(int i = y; i + z <= n; i++){
		final = max(final, besty[i] + bestz[n-i]);
	}
	cout << final + ans << endl;
}


Measured memory_bytes: 9600
#include<cstdio>

int binary_search(int A[], int n, int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return true;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return false;
}

int main() {
  int n;
  scanf("%d", &n);

  int S[n];
  for (int i = 0; i < n; i++) scanf("%d", &S[i]);

  int q;
  scanf("%d", &q);

  int v, cnt = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", &v);
    if (binary_search(S, n, v)) cnt++;
  }

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

  return 0;
}



Measured memory_bytes: 2960
N = int(input())
p = list(map(int, input().split()))
cnt = 0
i = 0
while i < N:
    if i + 1 == p[i]:
        c = 1
        j = i+1
        while j < N:
            if j+1 != p[j]:
                i = j
                break
            else:
                c += 1
            j += 1
        else:
            i = j
        cnt += (c+1)//2
    i += 1

print(cnt)
        

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<ll> A(N); REP(i, N) cin >> A[i];
	corner(N==1,1);
	for(int i = 0; i < N - 1; ++i){
		if(A[i] >= A[i+1]) break;
		corner(i==N-2,1);
	}

	ll ok = N,ng = 1,md;
	while(ok-ng>1){
		md = (ok+ng)/2;
		map<ll,ll> mp,mp2;
		int flg = 1;
		for(int i = 1; i < N; ++i){
		
			if(A[i-1]<A[i]) continue;
		
			ll j = A[i];
			if(mp2.count(j)) j = mp2[j];

			if(j==0){
				flg = 0;
				break;
			}
			
			mp[j]++;
			if(mp[j] == md - 1){
				if(mp2.count(j-1)==0) mp2[j]=j-1;
				else mp2[j] = mp2[j-1];
			}
			auto itr = mp.upper_bound(j);
			mp.erase(itr,mp.end());
			auto itr2 = mp2.upper_bound(j);
			mp2.erase(itr2,mp2.end());
		}
		(flg?ok:ng) = md;
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

int main()
{
	char a[50][50];
	int  b, c, count;
	std::cin >> b >> c;
	for(int i = 0; i < b; i++)
	{
		for(int j = 0; j < c; j++)
		{
			std::cin >> a[i][j];
		}
	}
	
	for(int i = 0; i < b; i++)
	{
		for(int j = 0; j < c; j++)
		{
			if(a[i][j] == '#' && a[i][j + 1] != '#' && a[i][j - 1] != '#' && a[i + 1][j] != '#' && a[i -1][j] != '#')
			{
				count++;
			}		
		}
	}
	if(count == 0)
	{
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        char[] S = scanner.next().toCharArray();

        for (int i = 0 ; i < S.length ; i++) {
            char c = (char) ((S[i] - 'A' + N) % 26 + 'A');
            System.out.print(c);
        }
        System.out.println();
    }
}


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

using namespace std;

long long dp[51][51][2501];

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

    vector<int> x(51);
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    
    dp[0][0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int s = 0; s < 2501; ++s) {
                if (x[i] > s and i >= 1) {
                    dp[i][j][s] = dp[i - 1][j][s];
                } else if (x[i] <= s and i >= 1 and j >= 1) {
                    dp[i][j][s] = dp[i - 1][j][s] + dp[i - 1][j - 1][s - x[i]];
                }
            }
        }
    }

    long long ans = 0;
    for (int j = 1; j <= n; j++) {
        ans += dp[n][j][a * j];
    }
    cout << ans << endl;
    return 0;
}

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

int const N=1e5+5, M=8+5, OO = 0x3f3f3f3f;

int n,cnt,A,B;
bool af,bf;
int a[M],b[M],per[M];

int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
//    freopen("mo3gza.txt","wt",stdout);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",a+i);
        per[i]=i+1;
    }
    for(int i=0; i<n; i++)
        scanf("%d",b+i);
    do
    {
        af=bf=1;
        cnt++;
        for(int i=0; i<n; i++)
        {
            if(a[i]!=per[i])
                af=0;
            if(b[i]!=per[i])
                bf=0;
        }
        if(af)
            A=cnt;
        if(bf)
            B=cnt;
    }
    while(next_permutation(per,per+n));
    printf("%d\n",abs(A-B));

}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
D = l()
if D[0] != 0:
    print(0)
    exit()
if D.count(0) != 1:
    print(0)
    exit()
if max(D) == 1:
    print(1)
    exit()
dist = [0]*N
for i in range(N):
    dist[D[i]] += 1
ans = 1
for i in range(2,max(D)+1):
    ans *= dist[i-1]**dist[i]
print(ans%998244353)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = 0;
  for (int i = 0; i < N; i++) if (A[i] % 2 == 0) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 3124
# 根をテキトーに選んで各頂点へのパスにおけるパリティを求める
# （なぜ根からで良いのかはパリティと木の性質によるもの）
# 答えはそのままパリティを出力する

from queue import Queue

# 隣接リスト、隣接コストを作る
n = int(input())

to = [[] for _ in range(n)]
cost = [[] for _ in range(n)]

for _ in range(n-1):
    u, v, w = map(int, input().split())

    # 各頂点の番号を添え字に合わせてデクリメントする
    # 答えに影響なし
    u-=1
    v-=1


    to[u].append(v)
    cost[u].append(w)

    to[v].append(u)
    cost[v].append(w)    


# 任意の点から初めてBFSで頂点をたどりながら、パリティを獲得していく
## BFS（queueに突っ込んでいって、なくなるまで頂点を辿っていく）

q = Queue()

ans = [-1] * n
q.put(0)

while not q.empty():
    u = q.get()
    
    for i in range(len(to[u])):
        v = to[u][i]
        w = cost[u][i]

        if (ans[v] != -1): continue

        ans[v] = (ans[u] + w) % 2
        q.put(v)
        

for a in ans:
    print(a)
        

Measured memory_bytes: 38892
import sys

if(__name__ == "__main__"):

    N, K = map( int, input().strip().split() )
    divisor = 10**9+7
    list_a = list( map( int, input().strip().split() ) )
    multiplies = 1
    if(N==K):
        for i in range(N):
            multiplies = multiplies * list_a[i] % divisor
    else:
        list_a.sort()
        """
        解が負になるのはN>Kの時には
        正の項が1つもなく、Kが奇数の時
        """
        if(list_a[-1] < 0 and K % 2 != 0):
            """
            全て負の項
            list_a = [-5, -3, -1]のようにソートされている
            末尾の項から選んでいく
            """
            for i in range(K):
                multiplies = multiplies * list_a[N-1-i] % divisor
        elif(K==1):
            multiplies = list_a[N-1]
        else:
            left = 0
            right = N-1
            if(K%2!=0):
                multiplies = multiplies * list_a[right] % divisor
                right -= 1
            multiply_left = list_a[left] * list_a[left+1]
            multiply_right = list_a[right] * list_a[right-1]

            for s in range(K//2-1):
                if(multiply_left < multiply_right):
                    multiply_right %= divisor
                    multiplies = multiplies * multiply_right % divisor
                    right -= 2
                    multiply_right = list_a[right] * list_a[right-1]

                else:
                    multiply_left%=divisor
                    multiplies = multiplies * multiply_left % divisor
                    left += 2
                    multiply_left = list_a[left] * list_a[left+1]

            if(multiply_left < multiply_right):
                multiply_right %= divisor
                multiplies = multiplies * multiply_right % divisor

            else:
                multiply_left%=divisor
                multiplies = multiplies * multiply_left % divisor


    print(multiplies)


Measured memory_bytes: 31756