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

using namespace std;
#define PB push_back
#define LL long long
#define int LL
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int,int>
#define LD long double

template<class C> void mini(C& a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C& a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
const int INF = LLONG_MAX / 2;

int mul(int a, int b){
  return INF / b > a? a * b : INF;
}
vector<VI> graph;

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin>>n;
  graph.resize(n);
  vector<PII> edges(n - 1);
  REP(i, n - 1){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    edges[i] = {a,b};
    graph[a].PB(b);
    graph[b].PB(a);
  } 
  PII res = {INF, INF};
  REP(i, n){
    vector<bool> vis(n);
    vis[i] = true;
    VI q = {i};
    int tres = 1;
    int col = 0;
    while(q.size()){
      col++;
      VI nq;
      int maxDeg = 1;
      for(int a : q){
        if(a == i){
          maxi(maxDeg, (int)graph[a].size());
        } else{
          maxi(maxDeg, (int)graph[a].size() - 1);
        }
        for(int b: graph[a]){
          if(vis[b])
            continue;
          vis[b] = true;
          nq.PB(b);
        }
      }
      debug(maxDeg);
      tres = mul(tres, maxDeg);
      q = move(nq);
    }
    debug(i, col, tres);
    mini(res,{col, tres});
  }
  REP(i, n - 1){
    vector<bool> vis(n);
    int v1 = edges[i].st;
    int v2 = edges[i].nd;
    vis[v1] = vis[v2] =  true;
    VI q = {v1, v2};
    int tres = 2;
    int col = 0;
    while(q.size()){
      col++;
      VI nq;
      int maxDeg = 1;
      for(int a : q){
        maxi(maxDeg, (int)graph[a].size() - 1);
        for(int b: graph[a]){
          if(vis[b])
            continue;
          vis[b] = true;
          nq.PB(b);
        }
      }
      tres = mul(tres, maxDeg);
      q = move(nq);
    }
    debug(v1, v2, col, tres);
    mini(res,{col, tres});
  }
  cout<<res.st<<" "<<res.nd<<"\n";
}

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

int main(){
  string S;
  cin >>S;
  int len=S.length();
  if(len==1){
    cout<<1<<endl;
    return 0;
  }
  int cnt=len-1;
  for(int i=0;i<len-1;i++){
    if(S.at(i)==S.at(i+1)){
      i+=2;
      cnt--;
      }
  }
  cout<<cnt+1<<endl;
  return 0;
}

  
  
  
  

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

int main(void)
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<int>> friends(n);
	vector<vector<int>> block(n);
	int ans[n];

	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		friends[a].push_back(b);
		friends[b].push_back(a);
	}
	rep(i, k) 
	{
		int a, b; 
		cin >> a >> b;
		a--; b--;
		block[a].push_back(b);
		block[b].push_back(a);
	}

	int label[n];
	int l = 0;
	queue<int> que;

	rep(i, n) label[i] = -1;
	for(int i = 0; i < n; i++)
	{
		if (label[i] != -1) 
			continue;
		l++;
		que.push(i);
		while (!que.empty())
		{
			int now = que.front();
			que.pop();
			label[now] = l; 
			for(int i = 0; i < friends[now].size(); i++)
			{
				if (label[friends[now][i]] != -1) continue; 
				label[friends[now][i]] = l;
				que.push(friends[now][i]);
			}
		}
	}

	map<int, int> mp;
	rep(i, n) mp[label[i]]++;
	rep(i, n)
	{
		ans[i] = mp[label[i]] - friends[i].size() - 1;
	}
	rep(i, n)
	{
		rep(j, block[i].size())
		{
			if (label[i] == label[block[i][j]])
				ans[i]--;
		}
	}
	rep(i, n) printf("%d%c", ans[i], i==n-1?'\n':' ');
	return 0;
}


Measured memory_bytes: 13184
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        s:i64,
    }
    // x1y1 - x2y1 / 2
    let x1 = 1e9 as i64;

    let mut t = (s as f64).sqrt() as i64;

    if t * t == s {
        println!("{} {} {} {} {} {}", 0, 0, t, 0, 0, t);
        return;
    }
    t += 1;
    let e = t * t - s;
    println!("{} {} {} {} {} {}", 0, 0, t, e, 1, t);
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<=c && c<='9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

};

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

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

	UnionFind uf(n+1);
	for (int i=0; i<m; ++i) {
		int a, b;
		cin >> a >> b;
		uf.unite(a, b);
	}
	std::set<int> roots;
	for (int i=1; i<n+1; ++i) {
		roots.insert( uf.root(i) );
	}

	cout << roots.size()-1 << endl;

	return 0;
}

Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 400005;
 
namespace sfxarray{
	int ord[MAXN], nord[MAXN], cnt[MAXN], aux[MAXN];
	void solve(int n, char *str, int *sfx, int *rev, int *lcp){
		int p = 1;
		memset(ord, 0, sizeof(ord));
		for(int i=0; i<n; i++){
			sfx[i] = i;
			ord[i] = str[i];
		}
		int pnt = 1;
		while(1){
			memset(cnt, 0, sizeof(cnt));
			for(int i=0; i<n; i++){
				cnt[ord[min(i+p, n)]]++;
			}
			for(int i=1; i<=n || i<=255; i++){
				cnt[i] += cnt[i-1];
			}
			for(int i=n-1; i>=0; i--){
				aux[--cnt[ord[min(i+p, n)]]] = i;
			}
			memset(cnt, 0, sizeof(cnt));
			for(int i=0; i<n; i++){
				cnt[ord[i]]++;
			}
			for(int i=1; i<=n || i<=255; i++){
				cnt[i] += cnt[i-1];
			}
			for(int i=n-1; i>=0; i--){
				sfx[--cnt[ord[aux[i]]]] = aux[i];
			}
			if(pnt == n) break;
			pnt = 1;
			nord[sfx[0]] = 1;
			for(int i=1; i<n; i++){
				if(ord[sfx[i-1]] != ord[sfx[i]] || ord[sfx[i-1] + p] != ord[sfx[i] + p]){
					pnt++;
				}
				nord[sfx[i]] = pnt;
			}
			memcpy(ord, nord, sizeof(int) * n);
			p *= 2;
		}
		for(int i=0; i<n; i++){
			rev[sfx[i]] = i;
		}
		int h = 0;
		for(int i=0; i<n; i++){
			if(rev[i]){
				int prv = sfx[rev[i] - 1];
				while(str[prv + h] == str[i + h]) h++;
				lcp[rev[i]] = h;
			}
			h = max(h-1, 0);
		}
	}
}
 
int n, k;
char str[MAXN];
int sfx[MAXN], rev[MAXN], lcp[MAXN];
int dp[MAXN];
priority_queue<pi, vector<pi>, greater<pi> > pq;
 
int trial(int v){
while(!pq.empty()) pq.pop();
	int l = (n + k - 1) / k;
	pq.push(pi(0, 0));
	for(int i=1; i<=n; i++){
		while(!pq.empty() && pq.top().second < i - l) pq.pop();
		if(!pq.empty() && pq.top().second == i - l && rev[i - l] > v) pq.pop();
		dp[i] = (pq.empty() ? 1e9 : pq.top().first) + 1;
		pq.push(pi(dp[i], i));
	}
	return dp[n];
}
 
int main(){
	scanf("%d %s",&k,str);
	k++;
	n = strlen(str);
	sfxarray::solve(n, str, sfx, rev, lcp);
	int s = 0, e = n-1;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m) <= k) e = m;
		else s = m+1;
	}
	for(int j=sfx[s]; j<sfx[s] + (n+k-1)/k; j++) printf("%c", str[j]);
}


Measured memory_bytes: 12920
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<pair<int,int>> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

vector<pair<int,int>> c;

int main(){
    int n,m;
    cin >> n>> m;
    rep(i,n){
        int a,b;
        cin >>a>>b;
        c.push_back(mp(a,b));
    }
    sort(c.begin(),c.end());
    //cerr<<"ch1"<<endl;
    int itr=0;
    int ans=0;
    rep2(i,m){
        while(itr<n&&c[itr].first<=i){//順番注意
            pair<int,int> d;
            d.first=c[itr].second;
            d.second=c[itr].first;
            pq.push(d);
            //cerr<<c[itr].first<<' '<<c[itr].second;
            itr++;
        }
        //cerr<<"ch2"<<endl;

        
        if(!pq.empty()){
            pair<int,int> q=pq.top();
            
            //cerr<<'q'<<q.first<<' '<<q.second<<endl;
            pq.pop();
            ans+=q.first;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2552
#include<stdio.h>
#include<stdlib.h>

#define N 101

int top,S[N];

int pop(){
  if(top==0){
    fprintf(stderr,"stack is empty\n");
    exit(2);
  }
  return S[top--];
}

void push(int a){
  if(top==100){
    fprintf(stderr,"stack over flow\n");
    exit(1);
  }
  S[++top]=a;
}

int main(){
  int num,a;
  char in[1000000];
  
  S[top]=NULL;
  
  while(scanf("%s",&in)!=-1){
    if(in[0]==42||in[0]==43||in[0]==45){
      switch(in[0]){
      case 42:
	push(pop()*pop());
	break;
      case 43:
	push(pop()+pop());
	break;
      case 45:
	a=pop();
	push(pop()-a);
	break;
      }
    }else{
      push(atoi(in));
    }
  }
  printf("%d\n",S[top]);
  return 0;
}



Measured memory_bytes: 2128
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String K = scan.next();
                
                for(int i=0; i<=2;i++){
                    char A = K.charAt(i);
                    System.out.print(A);
                }
                
               }
}

Measured memory_bytes: 35692
#
import sys
import math
#import numpy as np
import itertools
from collections import Counter
# いくつか入力
n,p = (int(i) for i in input().split())
# 空白区切りの数列をリストに代入
s = [int(i) for i in list(input())] 

answer = 0
#print(s)
q=0
x=[]
if p == 2 or p == 5:
    for i in range(n-1,-1,-1):
        if s[i]%p == 0:
            answer += i+1
else:
    d=1
    for i in range(n-1,-1,-1):
        q = (d*s[i]+q)%p
        x.append(q)
        d = (d * 10)%p
    #print(x)
    counter = Counter(x)
    #print(counter)

    for k in counter:
    #    print(k)
        if k==0:
            answer += counter[k] * (counter[k]+1) // 2
        else:
            answer += counter[k] * (counter[k]-1) // 2

print(answer)



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

const long inf = 2e18;
long n, k;
long a[200000];

template <class T>
long bin(long lo, long hi, T f, bool rev) {
  while (hi - lo > 1) {
    long mid = (lo + hi) / 2;
    if (f(mid) == rev) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return hi;
}

bool sub(long x) {
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    long v = a[i];
    auto cat = [v, x](long j) {
      return v * a[j] <= x;
    };
    
    if (v >= 0) {
      sum += bin(i, n, cat, true) - (i + 1);
    } else {
      sum += n - bin(i, n, cat, false);
    }
  }
  return sum >= k;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << bin(-inf, inf, sub, false) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    int H,  A;
    cin >> H >> A;
    int c = 0;
    while(H > 0) {
        H -= A;
        c++;
    }

    cout << c << endl;
}

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

int f[100005];
int main() {
	int n, W;
	scanf("%d%d", &n, &W);
	for (int i=1; i<=n*1000; i++) f[i]=1000000001;
	for (int i=1, w, v; i<=n; i++) {
		scanf("%d%d", &w, &v);
		for (int j=n*1000; j>=v; j--) f[j]=min(f[j], f[j-v]+w);
	}
	int ans=0;
	for (int i=0; i<=n*1000; i++) if (f[i]<=W) ans=i;
	printf("%d\n", ans); 
	return 0;
} 

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

  COMinit();

  ll H, W, A, B;
  
  cin >> H >> W >> A >> B;
  ll X = H - A-1;

  ll ans = 0;

  if((W - 1) == B){
    ans = COM(W-1+X, X);
  }
  else{
    for(ll i = 0; i < H; i++){

      //右にB進み、下にi個すすむ

      ll tmp_ans = 0;
      tmp_ans = COM(B + min(i, X), min(i, X));

      // 次に右に W-B-2、下にH-i-1個
      
      ans = (ans + (tmp_ans * COM(W-B-2+H-i-1, H-i-1)) % MOD) % MOD;

    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	int A, B,C;
	std::cin >> A >> B>>C;
	if (B - A == C - B)
	{
		std::cout << "YES";
	}
	else
		std::cout << "NO";


	return 0;
}
	

		
	

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int N,T;
	scanf("%d %d",&N,&T);
	/* N,Tで最初の時間とコストを入力*/
	int cost[N],time[N],i;
	for(i=0;i<N;i++){
	
		scanf("%d %d",&cost[i],&time[i]);
		//cost,timeのリストを入力
	}
	
	int k,mincost = cost[0],flag=0;
	for(k=0;k<N;k++){
	
		if(time[k] <= T){
		//timeがTより小さい場合、次の処理を実行する
			if(cost[k] <= mincost){
			//costがmincostより小さいならば、mincostが更新される
				mincost = cost[k];
				
			}
			
			flag++;
		}
		
	}
	
	if(flag == 0){
		
		printf("TLE");
		
	}else{
	
		printf("%d",mincost);
	
	}
	
	return 0;

}

Measured memory_bytes: 128
#ABC147_D
#N個の数字から2個選ぶの全組み合わせのXORを足してmodする問題

import numpy as np

N = int(input())
arr = np.array([int(i) for i in input().split()])
ans = 0
mod=10**9+7


for i  in range(60):
    c1=np.count_nonzero(arr&1)#arrの最下位bitの論理和。arrの最下位bitが1の数をカウント
    c0=N-c1#arrの最下位bitが0の数
    ans+=2**i*c1*c0#c1個の中から1つ選ぶ組み合わせとc0個の中から1つ選ぶ組み合わせの掛け算が、該当bitがXOR＝１となる組み合わせの数
    arr>>=1#最下位bitを変更
print(ans%mod)

Measured memory_bytes: 48856
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val S = LongArray(N + 1)
    for (i in 1 .. N) S[i] = S[i - 1] + A[i - 1]
    var ans = Long.MAX_VALUE
    var l = 1
    var r = 3
    for (i in 2 .. N - 2) {
        while (Math.abs(S[l] - (S[i] - S[l])) > Math.abs(S[l + 1] - (S[i] - S[l + 1]))) l++
        while (Math.abs(S[N] - S[r] - S[r] + S[i]) > Math.abs(S[N] - S[r + 1] - S[r + 1] + S[i])) r++
        val list = listOf(S[l], S[i] - S[l], S[r] - S[i], S[N] - S[r])
        val max = list.max()!!
        val min = list.min()!!
        ans = Math.min(ans, Math.abs(max - min))
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 89532
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// べき乗
ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  int N,cnt=0;
  ll D,x,y;
  cin >> N >> D;
  rep(i,N) {
    cin >> x >> y;
    if (x*x+y*y<=D*D) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int lhs ,x, y, z, f[10001] = {0};
    for (x = 1; x <= 100; x++){
        for (y = 1; y <= 100; y++){
            for (z = 1; z <= 100; z++){
                lhs = x*x + y*y + z*z + x*y + y*z + z*x;
                if (lhs <= 10000){
                    f[lhs]++;
                }
            }
        }
    }

    for (int i = 1; i <= N; i++){
        printf("%d\n", f[i]);
    }
    return 0;
}

Measured memory_bytes: 1768
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int calc(int h, int w, int K, int pat, const vector<vector<int>>& g)
{
    int hCount = (int)bitset<32>(pat).count();
    vector<int> bCount(hCount + 1, 0);
    int vCount = 0;
    bool isFirst = true;
    for(int i = 0; i < w; ++i)
    {
        int bi = 0;
        int wc = 0;
        bool needCut = false;
        for(int j = 0; j < h; ++j)
        {
            wc += g[j][i];
            if(j == h - 1 || (((pat >> j) & 1) == 1))
            {
                bCount[bi] += wc;
                if(bCount[bi] > K)
                {
                    needCut = true;
                    break;
                }
                wc = 0;
                bi++;
            }
        }
        if(needCut)
        {
            if(isFirst)
            {
                return -1;
            }
            bCount = vector<int>(hCount + 1, 0);
            vCount++;
            i--;
            isFirst = true;
        }
        isFirst = false;
    }

    return hCount + vCount;
}

int main(int, const char**)
{
    int h, w, K;
    cin >> h >> w >> K;
    vector<vector<int>> g(h, vector<int>(w, 0));
    rep(i, h)
    {
        string s;
        cin >> s;
        rep(j, w)
        {
            auto v = s[j] - '0';
            g[i][j] = v;
        }
    }

    int ans = numeric_limits<int>::max();
    for(int i = 0; i < (1 << (h - 1)); ++i)
    {
        auto a = calc(h, w, K, i, g);
        if(a >= 0)
        {
            ans = min(ans, a);
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define     mod             (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vector<int> , greater<int> >
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
#define     grid            vector<vector<int> >
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif




int32_t main()

{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    IOS;

    int n;

    cin >> n;

    grid day(n, vector<int>(3)), dp(n, vector<int>(3, 0));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
            cin >> day[i][j];
    }

    dp[0][0] = day[0][0];
    dp[0][1] = day[0][1];
    dp[0][2] = day[0][2];

    for (int i = 1; i < n; i++)
    {
        dp[i][0] = day[i][0] +  max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = day[i][1] +  max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = day[i][2] +  max(dp[i - 1][1], dp[i - 1][0]);
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;




}

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

int main(){
    int h,n;cin >>h>>n;
    vector<int> a(n);
    int cnt =0;
    for (int i = n - 1; i >= 0; i--)
    {
        /* code */
        int tmp;cin >>tmp;
        cnt += tmp;
    }
    if(h<=cnt)    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 640
//Programa en C++14 (compatible en c++11) para calcular el valor
//del 10Dq y B de un complejo d^6 octaedrico de campo alto segun 
//Tanabe-Sugano.
//El programa solo calcula el valor de 10Dq y B para 2 transiciones 
//observadas (caso observado en la sesion).
//Facultad de Ciencias e Ingenieria, Seccion Quimica PUCP, Junio 
//de 2018
//Autores del programa : Guillermo Guerrero y Alberto Flores
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC target("tune=native")
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define REP(i,x,y) for(ll (i)=(x);(i)<(y);(i)++)
#define RREP(i,x,y) for(ll (i)=(x);(i)>=(y);(i)--)
#define sqr(x) ((x)*(x))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define fst first
#define snd second
#define itm1 fst
#define itm2 snd.fst
#define itm3 snd.snd
#define oo 200000000000
//#define EPS 1e-9
#define MOD 1000000007
#define MAXN 92243249
#define cot 20
//#define N 300005
//#define min -9042414321442
#define INF 1065435634
#define N1 90
typedef long double ld;
typedef  long long ll;
//typedef short int ll;
//typedef ll ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef pair<ll,ii> tri;
typedef vector<ll> vi;
typedef vector<vi> vv;
#define N 100055   
#define M 31
//#define cap 1000000000
#define bas 10

inline ll ma(ll a, ll b){ return ((a-b>0)? a:b);}
inline ll mi(ll a, ll b){return ((a-b>0)? b:a);}
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

ll ans[N], dp1[N], dp2[N];
int main(){
  fastio;
  ll a,b; cin>>a>>b;
  ll x=abs(a-b);
  cout<<x*(x+1)/2-ma(a,b)<<endl;

  return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    bool flg = 1;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            if (s[i] == 'R') {
                flg = 0;
                break;
            }
        } else {
            if (s[i] == 'L') {
                flg = 0;
                break;
            }
        }
    }
    if (flg) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

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

const int max_n = 200111, inf = 1000111222;

vector<int> v[max_n];
int n;

int max_d = -1, res = 0;

void find_far(int cur, int pr, int d) {
    if (d > max_d) {
        max_d = d;
        res = cur;
    }
    for (int to : v[cur]) {
        if (to == pr) continue;
        find_far(to, cur, d + 1);
    }
}

int find_d(int from) {
    max_d = -1;
    find_far(from, -1, 0);
    int v1 = res;
    max_d = -1;
    find_far(v1, -1, 0);
    int v2 = res;
    return max_d;
}

int dp[max_n];

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i + 1 < n; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        v[a].PB(b);
        v[b].PB(a);
    }
    int d = find_d(0);
    dp[0] = 1;
    dp[1] = 0;
    for (int i = 2; i < max_n; ++i) {
        if (dp[i - 1] == 0 || dp[i - 2] == 0) {
            dp[i] = 1;
        } else {
            dp[i] = 0;
        }
    }
    if (dp[d] == 1) {
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}




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

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        while(n>0)
        {
            if(n%4==0||n%7==0)n=0;
            else n-=11;
        }
        if(n==0)puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<string> s(n);
    map<string,int> memo;
    
    for(int i = 0;i < n;i++){
          cin >> s[i];
          memo[s[i]] += 1;
    }
    int maxv = 0;
    for(auto x:memo){
          int v = x.second;
          if(maxv < v){
                maxv = v;
          }
    }
    
    for(auto it = memo.begin();it != memo.end();it++){
          if(it->second == maxv){
                cout << it->first << endl;
          }
    }
}


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

int main(){
    vector<int> A(5);
    for (int i=0;i<5;i++){
        cin >> A[i];
    }

    int ans = 0, m = 0;
    for(int i=0;i<5;i++){
        ans += A[i] + (10-A[i]%10)%10;
        m = max(m, (10-A[i]%10)%10);
    }
    cout << ans - m << endl;
}

Measured memory_bytes: 256
program fm
  implicit none
  integer::N
  integer::a,b,c
  character(2),allocatable,dimension(:)::S
  character,allocatable,dimension(:)::ans
  
  integer::i
  read*,N,a,b,c
  allocate(S(N+1))
  do i=1,N
    read*,S(i)
  end do
  S(N+1)="KK"
  allocate(ans(N))
  
  if(a+b+c==0)then
    print"(A)","No"
    stop
  endif
  if(a+b+c==1)then
    do i=1,N
      if(a+b==0.and.S(i)=="AB")then
        print"(A)","No"
        stop
      endif    
      if(a+c==0.and.S(i)=="AC")then
        print"(A)","No"
        stop
      endif
      if(b+c==0.and.S(i)=="BC")then
        print"(A)","No"
        stop
      endif
      if(S(i)=="AB")then
        if(a==0)then
          a=1;b=0
          ans(i)="A"
        else
          a=0;b=1
          ans(i)="B"
        endif
      endif
      if(S(i)=="AC")then
        if(a==0)then
          a=1;c=0
          ans(i)="A"
        else
          a=0;c=1
          ans(i)="C"
        endif
      endif
      if(S(i)=="BC")then
        if(b==0)then
          b=1;c=0
          ans(i)="B"
        else
          b=0;c=1
          ans(i)="C"
        endif
      endif
    end do
  else
    if(a+b==0.and.S(1)=="AB")then
      print"(A)","No"
      stop
    endif    
    if(a+c==0.and.S(1)=="AC")then
      print"(A)","No"
      stop
    endif
    if(b+c==0.and.S(1)=="BC")then
      print"(A)","No"
      stop
    endif
    do i=1,N
      if(S(i)=="AB")then
        if(a<b.or.(A+B+C==2.and.A*B==1.and.S(i+1)=="AC"))then
          a=a+1;b=b-1
          ans(i)="A"
        else
          a=a-1;b=b+1
          ans(i)="B"
        endif
      endif
      if(S(i)=="AC")then
        if(a<c.or.(A+B+C==2.and.A*C==1.and.S(i+1)=="AB"))then
          a=a+1;c=c-1
          ans(i)="A"
        else
          a=a-1;c=c+1
          ans(i)="C"
        endif
      endif
      if(S(i)=="BC")then
        if(b<c.or.(A+B+C==2.and.B*C==1.and.S(i+1)=="AB"))then
          b=b+1;c=c-1
          ans(i)="B"
        else
          b=b-1;c=c+1
          ans(i)="C"
        endif
      endif
    end do
  endif
  print"(a)","Yes"
  do i=1,N
    print"(A)",ans(i)
  end do
end program fm

Measured memory_bytes: 3236
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define set multiset
#define null NULL
#define ort (b+s)/2

using namespace std;

typedef long long Lint;
typedef long double db;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair<db,db> dd;
typedef pair<int,string> is;

const int maxn = 6000020;
const int K = 320;
const int MOd = 1e9 + 7;

Lint a, ar[maxn];

void solve() {
    string s;
    cin >> s;
    int a = s.size();
    int ans = a;
    for(int i=0;i+1<a;i++)
        if(s[i] != s[i+1])
            umin( ans, max( i+1, a-i-1 ) );
    printf("%d\n",ans);
}

int main(  ) {


	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}

Measured memory_bytes: 512
n = int(input())
ac = wa = tle = re = 0
for _ in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

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

using namespace std;

int main()
{
	long long N,SUM=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0)SUM += 0;
		else SUM += i + 1;
	}
	cout << SUM << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, sum=0, ans;
    cin >> n;
    vector<ll> a(n+2, 0);
    rep2(i, 1, n+1){
        cin >> a[i];
        sum += abs(a[i]-a[i-1]);
    }
    sum += abs(a[n+1]-a[n]);
    rep2(i, 1, n+1){
        ans = sum + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]));
        cout << ans << endl;
    }
}

Measured memory_bytes: 4012
import java.util.Scanner;

public class Main {
	
	static final int MAX_N = 1000;
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] basedata = sc.nextLine().split(" ");
        int N = Integer.parseInt(basedata[0]);
        int X = Integer.parseInt(basedata[1]);
        int minAmount = MAX_N;
        int totalAmount = 0;
        for (int i = 0; i < N; i++) {
        	int amount = sc.nextInt();
        	totalAmount += amount;
        	if (amount < minAmount) 
        		minAmount = amount;
        }
        int remainder = X - totalAmount;
        System.out.println((remainder/minAmount) + N);
    }
}

Measured memory_bytes: 21972
package main

import (
	"fmt"
	"sort"
)

func main() {

	fennecVSmonster()
}

//fennecVSmonster test
func fennecVSmonster() {

	var N, K int

	fmt.Scan(&N, &K)

	H := make([]int, N)

	for i := 0; i < N; i++ {

		fmt.Scan(&H[i])
	}

	sort.Sort(sort.IntSlice(H))

	hissatsu := N - K

	if hissatsu <= 0 {

		fmt.Println(0)
		return
	}

	temp := make([]int, hissatsu)

	for i := 0; i < hissatsu; i++ {

		temp[i] = H[i]

	}

	result := 0

	for j := 0; j < len(temp); j++ {

		result += temp[j]

	}

	fmt.Println(result)
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,A[N],B[N];
char s[N];

int main()
{
	cin>>n;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) 
		if (s[i]=='#') A[i]=A[i-1]+1; else A[i]=A[i-1];
	for (int i=n;i;i--)
		if (s[i]=='.') B[i]=B[i+1]+1; else B[i]=B[i+1];
		
	int ans=0x3f3f3f3f;
	for (int i=0;i<=n;i++) ans=min(ans,A[i]+B[i+1]);
	cout<<ans<<endl;		
	return 0;
}

Measured memory_bytes: 2048
//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define endl "\n"
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0);cout<< fixed<< setprecision(10);
#define DEBUG(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define DEBUG2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define DEBUG3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define DEBUG4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 2e5 + 9;

vector<vector<ll>> adj(N);
vector<bool> vis(N);

ll dfs(ll u, ll& ret)
{
    vis[u] = 1;
    for(ll v: adj[u]){
        if(vis[v]) continue;
        ret++; vis[v] = 1;
        dfs(v, ret);
    }
    return ret;
}

int main()
{
    fastio
    ll n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        ll u, v;
        cin>> u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    vector<ll> sizes;
    for(int i=1; i<=n; i++){
        if(vis[i]) continue;
        ll cnt = 1;
        dfs(i, cnt);
        sizes.push_back(cnt);
    }
    sort(all(sizes));
    cout<< sizes.back();
}



Measured memory_bytes: 23524
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#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 zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N;
    set<string> S;
    cin >> N;
    REP(i,N){
        string s;
        cin >> s;
        S.insert(s);
    }
    ll ans = S.size();
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define ll long long

struct Restaurant {
	string name;
	int score;
	int id;
};

bool cmp(Restaurant &a, Restaurant &b) {
	if(a.name == b.name) {
		return a.score > b.score;
	}
	return a.name < b.name;
}

void solve() {

	int n;
	cin >> n;
	Restaurant arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i].name >> arr[i].score;
		arr[i].id = i + 1;
	}
	sort(arr, arr + n, cmp);

	for(int i = 0; i < n; i++) { 
		cout << arr[i].id << "\n";
	}	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long m = Long.parseLong(sc.next());
        long ans = 0;
        if(n * 2 > m) {
            ans = m / 2;
        }else {
            ans = n + ((m - 2*n)/4);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

vector<ll> polymul(vector<ll> f, vector<ll> g){
	int m=f.size(), n=g.size();
	vector<ll> h;
	for(int k=0; k<m+n-1; k++){
		h.push_back(0);
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			h[i+j]+=(f[i]*g[j]);
			h[i+j]%=MOD;
		}
	}
	return h;
}

int main()
{
	int n;
	cin>>n;
	ll p2[90001];
	p2[0]=1;
	for(int i=1; i<=n*n; i++){
		p2[i]=p2[i-1]*2%MOD;
	}
	int c[300][300];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin>>c[i][j];
		}
	}
	int r=0;
	for(int j=0; j<n; j++){
		int i0=-1;
		for(int i=0; i<n; i++){
			if(c[i][j]==1){
				i0=i;
				break;
			}
		}
		if(i0==-1) continue;
		for(int i=i0+1; i<n; i++){
			if(c[i][j]==0) continue;
			c[i][j]=0;
			for(int k=j+1; k<n; k++){
				if(c[i0][k]==1) c[i][k]=1-c[i][k];
			}
		}
		for(int k=j+1; k<n; k++){
			c[i0][k]=0;
		}
		r++;
	}
	ll ans=0;
	for(int s=r; s<=n; s++){
		if(s==0){
			ans+=p2[n*n];
			continue;
		}
		ll ans1=1;
		for(int i=0; i<s; i++){
			ans1*=(p2[n]+MOD-p2[i]);
			ans1%=MOD;
		}
		ll dp[301][301];
      for(int j=0; j<=n-s; j++){
        dp[0][j]=1;
      }
      for(int i=1; i<=s-r; i++){
        dp[i][0]=1;
      }
      for(int i=1; i<=s-r; i++){
        for(int j=1; j<=n-s; j++){
          dp[i][j]=(dp[i][j-1]*p2[i]%MOD+dp[i-1][j])%MOD;
        }
      }
		ans1*=dp[s-r][n-s];
		ans1%=MOD;
		ans1*=p2[n*(n-s)];
		ans1%=MOD;
		ans+=ans1;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

bool isAllVisit(const vector<bool>& visit) {
    for (auto&& v : visit) {
        if (!v)return false;
    }
    return true;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;

    ll ans = 1;
    map<int, int> m;
    for (int i = 1; i <= N; i++) {
        int n = i;
        int a = 2;
        while (i >= a * a) {
            if (n % a == 0) {
                m[a]++;
                m[a] %= MOD;
                n /= a;
            }
            else {
                a++;
            }
        }
        m[n]++;
    }

    for (auto&& s : m) {
        if (s.first == 1)continue;
        ans *= (s.second + 1);
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
	vector< vector<int>> A(3,vector<int>(3));
	int n;
	for(int i = 0; i< 3; i++){
		for(int j = 0; j<3 ; j++){
			cin >> A[i][j];
		}
	}
	cin >> n;
	int b;
	vector<vector<int>> check(3,vector<int>(3,0));
	for(int i=0; i<n ; i++ ){
		cin >> b;
		for(int row = 0; row< 3; row++){
			for(int col = 0; col<3; col ++){
				if(b == A[row][col]) check[row][col] = 1;
			}
		}
	}
	// for(int row = 0; row< 3; row++){
	// 	for(int col = 0; col<3; col ++){
	// 		cout << check[row][col] ;
	// 	}
	// }

	string ans = "No\n";
	//row check
	for(int row = 0;row<3;row++){
		int flag = 1;
		for(int col = 0;col<3;col++){
			if(check[row][col] == 0)flag = 0;
		}
		if(flag == 1){
			ans = "Yes\n";
			cout << ans ;
			//cout << "no1\n";
			return 0;
		}
	}

	for(int col = 0;col<3; col++){
		int flag = 1;
		for(int row = 0;row<3; row++){
			if(check[row][col] == 0)flag =0;
		}
		if(flag == 1){
			ans = "Yes\n";
			cout << ans;
			//cout << "no2\n";
			return 0;
		}
	}
	if((check[0][0]== 1 && check[1][1] == 1 && check[2][2] == 1) ||
		(check[2][0] == 1 && check[1][1]==1 && check[0][2]==1)){
			ans ="Yes\n";
			cout << ans ;
			//cout << "no3\n";
			return 0;
	}

	cout << ans ;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll k, x;
	cin >> k >> x;
	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3620
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 1
count = 0

a,b,c=map(int,input().split())
k=int(input())
bi=2**k
print(a+b+c+max(a,b,c)*(bi-1))

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

using namespace std;

int main(){

    string s;
    cin >> s;
    set<char> st;
    for(int i = 0; i < 4; i++)
        st.insert(s[i]);
    if( st.size() == 2 )
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
signed main(){
 
	lli n;
	cin>>n;
	vector<lli> a(n),b(n);

	REP(i,0,n)cin>>a[i];
	REP(i,0,n)cin>>b[i];

	lli sum=0;

	REP(i,0,n){
		if(a[i] >= b[i])sum += a[i]-b[i];
		else sum -= ((b[i]-a[i])/2);
	}

	if(sum>0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	return 0;
}

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

int main(){
  int n,d,x,a,i,sum=0;
  cin>>n>>d>>x;
  for(i=1;i<n+1;i++){
    cin>>a;
    for(int j=1;j<=d;j+=a){
      sum++;
    }
  }
    cout<<sum+x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
vector<int> to;
bool used[100100];
int main(){
	int n;
	cin>>n;
	to.push_back(-1);
	for(int i=0;i<n;i++){
		int d;
		cin>>d;
		to.push_back(d);
	}
	int now=1;
	for(int i=0;;i++){
		if(now==2){
			cout<<i<<endl;
			return 0;
		}
		if(used[now])break;
		used[now]++;
		now=to[now];
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 892