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

int main() {
	ll n, m,mem,sum=0;
	vector<ll> a;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> mem;
		sum = sum + mem;
		a.push_back(mem);
	}
	sort(a.begin(), a.end(),greater<ll>());
	if (a[m - 1] * 4 * m < sum) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
n = int(input())
A = [[]]*n

for i in range(n):
  an = int(input())
  for j in range(an):
    x, y = map(int, input().split())
    A[i] = A[i] + [[x-1 ,y]]

mx = 0
for i in range(2**n):
  B = [[0]*3 for _ in range(n)]
  uso = 0
  men_cnt = 0
  for j in range(n):
    if i>>j&1:
      men_cnt += 1
      B[j][2] = 1
      for k in range(len(A[j])):
        x, y = A[j][k]
        B[x][y] = 1
  for i in range(n):
    if (B[i][0] and B[i][1]) or (B[i][1] and B[i][2]==0) or (B[i][0] and B[i][2]):
      uso = 1
  if uso==0:
    if men_cnt>mx:
      mx = men_cnt
   
      
print(mx)
    

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

using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
    if(y >= 2*x && y <= 4*x && y%2==0 )
    {
        cout << "Yes";
    }else
    {
        cout << "No";
    }

    return 0;

}


Measured memory_bytes: 3640
function main(input) {
    const ALL = input.split('\n').map((n)=>parseInt(n, 10));

    var count = 0;

    for( a=0;a<=ALL[0];a++){
        for(var b=0;b<=ALL[1];b++){
            for(var c=0;c<=ALL[2];c++){
                var sum = (a*500)+(b*100)+(c*50);
                if(sum===ALL[3])count++;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
  int n;
  cin>>n;
  int a[110];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);

  cout<<a[n-1]-a[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int i;
  double sum;
  double A[N];
  for(i=0; i<N; i++)
    cin >> A[i];

  for(i=0; i<N; i++)
    sum += 1/A[i];

  cout << fixed;
  cout << setprecision(6) << 1/sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val N: Int = sc.nextInt()
  var d = mutableListOf<Int>()
  for (i in 1..N) {
    val di: Int = sc.nextInt()
    d.add(di)
  }
  var ans: Int = 0
  for (i in 0..N-2) {
    for (j in i+1..N-1) {
      ans += d[i]*d[j]
    }
  }
  println(ans)
  
}

Measured memory_bytes: 29604
#include <stdio.h>

long long int count(int dan, int cur){
  if(dan < cur){
    return 0;
  }else if(dan == cur){
    return 1;
  }else{
    return count(dan, cur+1) + count(dan, cur+2) + count(dan, cur+3);
  }
}

int main(int argc, char *argv[]){

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

    if(n == 0){
      break;
    }

    printf("%llu\n",count(n, 0) / (365 * 10) + 1);
    
  }

  
  
  return 0;    
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y,t;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		v1.push_back(r);
		
		for(;m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1]){++it;++it;}	//d¡r
			if(*it+n-x==v2.back()){++it;v2.pop_back();}	//d¡r
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it){
			m=*it;
			++it;
			x+=*it-m;
		}
	}
}

Measured memory_bytes: 960
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b, c, d, e, total;

int main(){

	cin >> a >> b >> c >> d >> e;

	if (a < 0) {
		total += abs(a) * c;
		a = 0;
	}
	if (a == 0)total += d;

	total += e * (b - a);

	cout << total << endl;


	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int h, w;
char a[1000][1000];
ll dp[1000][1000];

ll dfs(int x, int y) {
    if (dp[x][y] != -1) return dp[x][y];
    if (x == h - 1 && y == w - 1) return 1;
    ll res = 0;
    if (x + 1 < h && a[x + 1][y] == '.') {
        res += dfs(x + 1, y) % mod;
    }
    if (y + 1 < w && a[x][y + 1] == '.') {
        res += dfs(x, y + 1) % mod;
    }
    return dp[x][y] = res % mod;
}

int main()
{
    cin >> h >> w;
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
        dp[i][j] = -1;
    }

    ll ans = dfs(0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12520
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 16:15:34 2018
//
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	if A <= 8 && B <= 8 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    cin>>n>>m;
    int k[m];
    set<int> s[m];
    rep(i,m){
        cin>>k[i];
        rep(j,k[i]){
            int a;
            cin>>a;
            a--;
            s[i].insert(a);
        }
    }
    int p[m];
    rep(i,m) cin>>p[i];

    
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool ok=true;
        for(int i=0;i<m;i++){
            int sum=0;
            for(int j=0;j<n;j++){
                if(!s[i].count(j)) continue;
                if(bit & (1<<j)) sum++;
            }
            if(sum%2!=p[i]) ok=false;
        }
        if(ok) ans++;
    }

    cout<<ans<<endl;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    bool ch[26];
    rep(i,26) ch[i]=false;
    cin >> s;
    int len = s.length();
    for(int i=0; i<len; i++){
        int tmp = s[i]-'a';
        ch[tmp] = true;
    }
    for(int i=0; i<26; i++){
        if(!ch[i]){
            char ss = (char)(i+97);
            cout << ss << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  rep(i, 0, len(s)) { cout << "x"; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<ll>a(n);
	rep(i,n){
		cin>>a[i];
	}
	FOR(i,k,n){
		if(a[i]>a[i-k]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 4776
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
    int i,j,d;
    double ans=0;
    while(cin >> d){
        i=0;
        ans=0;
        while(i<600){
            ans+=i*i*d;
            i+=d;
        }
        printf("%.0lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
long dp[22222];
vector<pair<pair<int,int>,int> >A;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		A.push_back(make_pair(make_pair(a,b),c));
	}
	sort(A.begin(),A.end(),[](pair<pair<int,int>,int>a,pair<pair<int,int>,int>b)
	{
		return a.first.first+a.first.second<b.first.first+b.first.second;
	});
	for(pair<pair<int,int>,int>a:A)
	{
		for(int j=a.first.second;j>=0;j--)
			dp[j+a.first.first]=max(dp[j+a.first.first],dp[j]+a.second);
	}
	long ans=0;
	for(int i=0;i<22222;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	bool ans=true;
	for(int i=0;i<n;i++) cin >> s[i];
	for(int i=0;i<n-1;i++){
		if(s[i].back()!=s[i+1].front()) ans=false;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(s[i]==s[j]) ans=false;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

}


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

int main() {
	int n;
	cin>>n;
	map<string, int> m;
	m["AC"]; m["WA"];m["TLE"];m["RE"];
	for(int i=0;i<=n;i++){
	    string t;
	    getline(cin,t);
	    m[t]++;
	}
	cout<<"AC"<<" x "<<m["AC"]<<endl;
	cout<<"WA"<<" x "<<m["WA"]<<endl;
	cout<<"TLE"<<" x "<<m["TLE"]<<endl;
	cout<<"RE"<<" x "<<m["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

int mxN=1e5+5;
vector<int> adj[100005];
vector<bool> visited(mxN,false);
vector<int> level(mxN,0);
int ans=0;

void DFS(int i){
	visited[i]=true;

	for(auto it:adj[i]){
		if(!visited[it]){
			DFS(it);
		}
		level[i]=max(level[i],level[it]+1);
		ans=max(level[i],ans);
	}
}

void solve(){
	int n,m;
	cin>>n>>m;
	
	rep(i,0,m){
		int u,v;
		cin>>u>>v;
		adj[u].pb(v);
	}

	rep(i,1,n+1){
		if(!visited[i]){
			DFS(i);
		}
	}

	cout<<ans;
}
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 12004
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    ll n;
    cin >> n;
    // int a[N];
    // for (int i=1; i <= n; i++) { 
    //     cin >> a[i];
    // }

    ll cnt = 0;
    
    if (n&1) {
        
    }
    else {
        ll curr = 10;
        while (n/curr>0) {
            cnt+=ll((n/curr));
            curr *= 5;
        }
    }
    
    cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// http://drken1215.hatenablog.com/entry/2019/03/28/014100

int main() {
    int N;
    cin >> N;
    int cnt = 0;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        if(A[i] % 2 == 1) {
            cnt++;
        }
    }
    if(cnt % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int H, int W, int h, int w);

void solve(int H, int W, int h, int w) {
  int ans = H * W - H * w - h * W + h * w;
  printf("%d\n", ans);
}

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  solve(H, W, h, w);
  return 0;
}


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

const int MAX = 1400;

int minSquare(int tile[MAX][MAX], int x, int y) {
	if (tile[y][x] == 1) {
		tile[y][x] = 0;
		return 0;
	}
	return min(tile[y - 1][x - 1], min(tile[y - 1][x], tile[y][x - 1])) + 1;
}

int main() {
	int H, W;
	int tile[MAX][MAX];
	int ans = 0;


	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> tile[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		if (tile[i][0] == 1)tile[i][0] = 0;
		else {
			tile[i][0] = 1;
			ans = 1;
		}
	}
	for (int i = 1; i < W; i++) {
		if (tile[0][i] == 1)tile[0][i] = 0;
		else {
			tile[0][i] = 1;
			ans = 1;
		}
	}

	int x = 1;
	int y = 1;
	int n = min(H, W);
	for (int i = 1; i < n; i++) {
		for (int j = y; j < H; j++) {
			tile[j][x] = minSquare(tile, x, j);
			ans = max(tile[j][x], ans);
		}
		for (int j = x + 1; j < W; j++) {
			tile[y][j] = minSquare(tile, j, y);
			ans = max(tile[y][j], ans);
		}
		x++;
		y++;
	}

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

Measured memory_bytes: 10732
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve(){
	while (true) {
		int n, l;
		cin >> n >> l;
		if (n == 0) return;
		vector<pair<int, int>> going[200][200];
		REP(i, n) {
			string a;
			cin >> a;
			int b;
			cin >> b;
			int c = 1;
			if (a == "L") {
				c = -1;
			}
			going[0][b].push_back(mp(i + 1, c));
		}
		for (int q = 0;; ++q) {
			int ok = 0;
			for (int j = 1; j < l; ++j) {
				if (going[q][j].size() == 2) {
					swap(going[q][j][0].first, going[q][j][1].first);
				}
				REP(t, going[q][j].size()) {
					ok = 1;
					going[q + 1][j + going[q][j][t].second].push_back(going[q][j][t]);
				}
			}
			if (ok == 0) {
				cout << q << " ";
				if (going[q][0].size() != 0) {
					cout << going[q][0][0].first << endl;
				}
				else {
					cout << going[q][l][0].first << endl;
				}
				break;
			}
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
 
using namespace std;
 
int stam(int x[], int n, int p) {
    int sum = 0;
    for(int i = 0; i < n; i++)
        sum += (x[i] - p) * (x[i] - p);
    return sum;
}

int main()
{
  int n, p;
  cin >> n;
  int x[101];
  int sum = 0;
  for(int i = 0; i < n; i++) {
      cin >> x[i];
      sum += x[i];
  }

  int c1 = sum / n;
  int p1 = stam(x, n, c1);
  int p2 = stam(x, n, c1 + 1);
  p = min(p1, p2);

  cout << p << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
    for(int i=a;i<=b;i++) {
    	if(i%k==0) {
    		System.out.println("OK");
    		System.exit(0);
    	}
    }
    System.out.println("NG");
  }
}


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

const LL MOD = 1000000007LL;

LL modpow(LL x, LL n) {
  LL r = 1;
  while(n != 0) {
    if(n&1) r = r * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<LL> count(K+1);
  LL ret = 0;
  for(int i=K; i>=1; --i) {
    LL n = modpow(K / i, N);
    for(int j=i*2; j<=K; j+=i) {
      n = (n + MOD - count[j]) % MOD;
    }
    count[i] = n;
    ret = (ret + n * i) % MOD;
  }
  cout << ret << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
 
typedef long long ll;
 
int main(){
  int n,x,y;
  cin >> n >> x >> y;
  vector<int> ans(n);
  rep1(i,n){//i番目の頂点と
    for(int j=i+1;j<=n;j++){//j番目の頂点
      int path1 = j-i;
      
      //ショートカットを使う場合
      int path2 = abs(x-i);//xに着くまで
      path2 ++;//yに移動
      path2 += abs(y-j);//jに移動
      
      ans[min(path1,path2)] ++;
    }
  }
  rep1(i,n-1) cout << ans[i] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a <= 8 && b <= 8 ? "Yay!" :  ":(");
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <string>
using namespace std;

int main(void)
{
	int n;

	scanf("%d", &n);
	while(n-- > 0){
		int base[3] = {0};
		int score = 0;
		char s[10];
		int out = 0;
		while(out < 3){
			scanf("%s", s);
			string str = s;
			if(str == "HIT"){
				if(base[2] == 1) score++;
				base[2] = base[1];
				base[1] = base[0];
				base[0] = 1;
			}
			else if(str == "HOMERUN"){
				score += base[0];
				score += base[1];
				score += base[2];
				score++;
				base[0] = base[1] = base[2] = 0;
			}
			else {
				out++;
			}
		}
		printf("%d\n", score);
	}
	
	return(0);
}

Measured memory_bytes: 1076
#include <stdio.h>
#include <string.h>
int main(){
	char str[1001],order[8],p[1001],spa[2];
	int i,a,b,q,k,j;
	scanf("%s",str);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%s",order);
		scanf("%d %d",&a,&b);
		if(strcmp(order,"replace")==0){
			scanf("%s",p);
		}
		if(strcmp(order,"print")==0){
			for(k=a;k<=b;k++){
				printf("%c",str[k]);
			}
			printf("\n");
		}else if(strcmp(order,"reverse")==0){
			for(k=0;k<=(b-a)/2;k++){
				spa[1]=str[k+a];
				str[k+a]=str[b-k];
				str[b-k]=spa[1];
			}
		}else if(strcmp(order,"replace")==0){
			j=0;
			for(k=a;k<=b;k++){
				str[k]=p[j];
				j++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  //int ans;
  if(a*n>b) cout << b << endl;
  else cout << a*n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, N-2) {
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#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 REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
//If TLE let's use int instead of ll

ld n;

void solveProblem() {
    ld temp = n / 3;
    temp = temp * temp * temp;

    cout << setprecision(7) << temp << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



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

using namespace std;

typedef long long LL;

int main() 
{
	int N;
	cin >> N;
	int i1, i2, i3, i4;
	i1 = N / 1000;
	i2 = N % 1000 / 100;
	i3 = N % 100 / 10;
	i4 = N % 10;

	if (i1 == i2)
	{
		if (i1 == i3)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		if (i2 == i3)
		{
			if (i2 == i4)
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int f[n+2][n+2];
    int use[n+2][n+2];
    rep(i,n+2){
        rep(j,n+2){
            f[i][j]  = min(min(i,n+1-i),min(j,n+1-j));
            use[i][j] = 0;
        }
    }
    int ans = 0;

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

    int pp[n*n];
    rep(i,n*n)cin >> pp[i];

    rep(i,n*n){
        int p = pp[i];
        p--;
        int a = p/n + 1;
        int b = p%n + 1;
        ans += f[a][b] - 1;
        rep(j,4){
            f[a][b] = min(f[a][b], f[a+dx[j]][b+dy[j]]);
        }
        queue<P> que;
        que.push(P(a,b));
        while(que.size()){
            int x = que.front().first;
            int y = que.front().second;
            que.pop();
            rep(j,4){
                int nx = x+dx[j], ny = y+dy[j];
                if(use[nx][ny] == 1){
                    if(f[x+dx[j]][y+dy[j]] > f[x][y]){
                        f[x+dx[j]][y+dy[j]] = f[x][y];
                        que.push(P(x+dx[j],y+dy[j]));
                    }
                }else{
                    if(f[x+dx[j]][y+dy[j]] > f[x][y] + 1){
                        f[x+dx[j]][y+dy[j]] = f[x][y] + 1;
                        que.push(P(x+dx[j],y+dy[j]));
                    }
                }
                    
            }
        }
        
        use[a][b] = 1;
    }

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




Measured memory_bytes: 6452
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        char[] aArr = new char[b];
        Arrays.fill(aArr, (char)(a + '0'));
        char[] bArr = new char[a];
        Arrays.fill(bArr, (char)(b + '0'));
        if (a <= b) {
            System.out.println(aArr);
        } else {
            System.out.println(bArr);
        }
    }
}

Measured memory_bytes: 21332
<?php
list($s, $t) = explode(" ", trim(fgets(STDIN)));
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$u = trim(fgets(STDIN));
if ($u == $s) {
    $a--;
} elseif ($u == $t) {
    $b--;
}
echo "$a $b" . PHP_EOL;


Measured memory_bytes: 16076
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

  int a, b, c;

  cin >> a >> b >> c;
  cout << a * b / 2 << endl;

  return 0;
}

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

vector<int> func_vec(const string str, const string substr) {
    vector<int> result;

    int substrsize = substr.size();
    int pos = str.find(substr);

    while (pos != string::npos) {
        //Appendしていく
        result.push_back(pos);
        //文字検索位置を更新する
        pos = str.find(substr, pos + substrsize); 
    }
    return result;
}

int main() {
    int N;
    string str ;
    string substr = "ABC";
    cin >> N >> str;

    vector<int> vec = func_vec(str, substr);
    cout << vec.size()<< endl;
    /*for (int i = 0; i < vec.size(); i++)
    {
        std::cout << vec[i] << "\n";
    }*/
}




/*
#include <iostream>
using namespace std;

int main()
{
    int K, N;
    cin >> K >> N;
    if (500 * K>=N)
        cout << "Yes\n";
    else
        cout << "No\n";
}*/


Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{	
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			int month = scanner.nextInt();
			int day = scanner.nextInt();
			
			if(month==0 && day==0)
			{
				break;
			}
			
			System.out.println(getWeek(month, day));
		}
	}
	
	static String getWeek(int month, int day)
	{
		final int[] MONTH_DAY = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		final String[] STR ={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday",};
		
		int week = 3;
		for(int i=0; i<month; i++)
		{
			for(int j=0; j<MONTH_DAY[i]; j++)
			{
				if(i+1==month && j+1==day)
				{
					return STR[week];
				}
				if(++week > 6)
				{
					week = 0;
				}
			}
		}
		return STR[week];
	}
}

Measured memory_bytes: 26188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define MAX_N (100010)
// int A[MAX_N];
vector<int> A;
map<int, int> mp;
typedef long long int ll;

int main()
{
    int N;
    int i;

    scanf("%d", &N);

    for ( i = 0; i < N; i++ ) {
	int a;
	scanf("%d", &a);
	A.push_back(a);
    }

    sort( A.begin(), A.end(), greater<int>() );
    ll x = 0;
    ll y = 0;
    int count = 0;
    for ( i = 0; i < N; i++ ) {
	mp[A[i]]++;
	if ( mp[A[i]] % 2 == 0 ) {
	    if ( count == 0 ) x = A[i];
	    else y = A[i];
	    count++;
	    if ( count == 2 ) break;
	}
    }

    ll ans = x * y;

    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 4600
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	double x0, y0, x1, y1, x, y, xt, yt;
	int i,q;

	cin >> x0 >> y0 >> x1 >> y1;
	double l = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
	
	for (cin >> q, i = 0; cin >> x >> y, i < q; ++i){
		double ang = atan2(y-y0,x-x0) - atan2(y1-y0,x1-x0);
		double t = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0)) * cos(ang);
		
		xt = x0 + (x1-x0)*t/l;
		yt = y0 + (y1-y0)*t/l;

		cout << fixed << setprecision(10) << xt << " " << yt << endl;
	}
}

Measured memory_bytes: 1412
H, W =  map(int, input().split())

S = []
for _ in range(H):
    tmp = list(input())
    S.append(tmp)
    
import numpy as np

def count_light(Gs, h, w):
    Gc = np.empty((h,w))
    for i in range(w):
        if i == 0:
            Gc[:, i] = Gs[:, i]
        else:
            Gc[:, i] = (Gc[:, i-1] + 1) * Gs[:, i]

    return Gc

Gs1 = np.asarray(S) == "."
Gn1 = count_light(Gs1, H, W)

Gs2 = np.rot90(Gs1, k=1)
Gn2 = count_light(Gs2, W, H)

Gs3 = np.rot90(Gs2, k=1)
Gn3 = count_light(Gs3, H, W)

Gs4 = np.rot90(Gs3, k=1)
Gn4 = count_light(Gs4, W, H)

Gn2 = np.rot90(Gn2, k=-1)
Gn3 = np.rot90(Gn3, k=-2)
Gn4 = np.rot90(Gn4, k=-3)

Gsum = Gn1+Gn2+Gn3+Gn4
ans = int(np.max(Gsum)-3)
print(ans)


Measured memory_bytes: 238880
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt64(scanner)
	x := getNextInt64(scanner)
	m := getNextInt64(scanner)
	prev := map[int64]int64{}
	aa := make([]int64, 0)
	var ans, sum int64
	for i := int64(0); i < n; i++ {
		if p, ok := prev[x]; ok {
			for j := p; j < i; j++ {
				sum += aa[j]
			}
			ans += (n - i) / (i - p) * sum
			for j := i + (n-i)/(i-p)*(i-p); j < n; j++ {
				ans += x
				x = x * x % m
			}
			break
		}
		ans += x
		aa = append(aa, x)
		prev[x] = i
		x = x * x % m
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 6624
n = int(input())
li = [[] for _ in range(n+1)]
q = [(1,0)]
ans = [-1]*n

while n>1:
  s,g,c = map(int,input().split())
  li[s] += [(g,c)]
  li[g] += [(s,c)]
  n -= 1
#print(li)

while q:
  s,c = q.pop()
  ans[s-1] = c%2 
  for g, d in li[s]:
    q += [(g, c+d)] * (ans[g-1]<0)
print(*ans)

Measured memory_bytes: 40364
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a+b>c+d)
		puts("Left");
	else
	{	
		if(a+b == c+d)
			puts("Balanced");
		else
			puts("Right");
	} 
	return 0; 
} 

Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;

my @a;
{
    for (my $i=0; $i<$n; $i++)
    {
        $a[$i] = <STDIN>;
        chomp $a[$i];
    }
}
my (@l, @r);
$l[0] = 0;
for (my $i=1; $i<$n; $i++)
{
    $l[$i] = $a[$i-1]>$l[$i-1] ? $a[$i-1] : $l[$i-1];
}
$r[$n-1] = 0;
for (my $i=$n-2; $i>=0; $i--)
{
    $r[$i] = $a[$i+1]>$r[$i+1] ? $a[$i+1] : $r[$i+1];
}
for (my $i=0; $i<$n; $i++)
{
    my $c = $l[$i]>$r[$i] ? $l[$i] : $r[$i];
    print "$c\n";
}

Measured memory_bytes: 69888
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,m,ans=0;
  cin>>n>>m;
  map<int,int>M;
  int a[n],b[n];
  r(i,n)cin>>a[i];
  r(i,n-1)a[i+1]+=a[i];
  r(i,n)b[i]=a[i];
  r(i,n)b[i]%=m;
  r(i,n)M[b[i]]++;
  r(i,n){
    int x=(i?a[i-1]:0);
    x%=m;
    //cout<<x<<endl;
    ans+=M[(x)%m];
    M[b[i]]--;
    //cout<<ans<<endl<<endl;
  }
  cout<<ans<<endl;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int a;
    string s;
    cin >> a >> s;
    cout << (3200 <= a ? s : "red") << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int z = 0;

    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                z = 1;
                break;
            }
        }
        if (z == 1) {
            break;
        }
    }
    if (z == 0) {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;
vector<int> v;
map<int, int>mp;
int main() {
	int N;
	cin >> N;
	REP(i, N) {
		int A;
		cin >> A;
		v.push_back(A);
		mp[A]++;
	}
	VSORT(v);
	ll ans = 0;
	for (int i = 32; i > 0; i--) {
		REP(j, N) {
			if (mp[v[j]] > 0) {
				ll x = pow2(2, i) - v[j];
				if (binary_search(v.begin(), v.end(), x)) {
					if (v[j] == x) {
						if (mp[x] >= 2) {
							ans++;
							mp[x] -= 2;
						}
					}
					else {
						if (mp[x] >= 1) {
							ans++;
							mp[x]--;
							mp[v[j]]--;
						}
					}
				}
			}
		}
	}
	int cnt = 0;
	REP(i, 2000000000)cnt++;
	cout << ans << endl;
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=53,INF=1<<29;

vector<int> G[MAX];
bool SE[MAX][MAX][MAX];
int N;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a;
        a=a*a;
        b/=2;
    }
    return ans;
}

void solve(int a,int b,int id){
    set<int> left;
    vector<int> visit(N);
    
    queue<int> Q;
    Q.push(a);
    visit[a]=1;
    
    while(!Q.empty()){
        int a=Q.front();Q.pop();
        left.insert(a);
        
        for(int to:G[a]){
            if(to==b) continue;
            if(visit[to]) continue;
            Q.push(to);
            visit[to]=1;
        }
    }
    
    for(auto it=left.begin();it!=left.end();it++){
        for(int i=0;i<N;i++){
            if(visit[i]==0){
                int x=min({*it,i}),y=max({*it,i});
                SE[id][x][y]=1;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    vector<int> A(N-1),B(N-1);
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        A[i]=a;
        B[i]=b;
        if(A[i]>B[i]) swap(A[i],B[i]);
    }
    
    for(int i=0;i<N-1;i++){
        solve(A[i],B[i],i);
    }
    
    int M;cin>>M;
    vector<int> C(M),D(M);
    for(int i=0;i<M;i++){
        cin>>C[i]>>D[i];
        C[i]--;
        D[i]--;
        if(C[i]>D[i]) swap(C[i],D[i]);
    }
    
    ll ans=0;
    
    for(int bit=0;bit<(1<<M);bit++){
        vector<int> SS(N-1);
        int tatu=0;
        
        for(int j=0;j<N-1;j++){
            for(int i=0;i<M;i++){
                if(bit&(1<<i)) tatu++;
                else continue;
                
                if(SE[j][C[i]][D[i]]) SS[j]++;
            }
        }
        
        tatu/=(N-1);
        
        int cnt=0;
        
        for(int j=0;j<N-1;j++){
            if(SS[j]) cnt++;
        }
        
        if(tatu%2==0) ans+=rui(2,N-1-cnt);
        else ans-=rui(2,N-1-cnt);
        
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  let modp = n `mod` k
  if modp == 0
    then print 0
    else do
      let modp' = abs (modp - k)
      if modp < modp'
        then print modp
        else print modp'


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

int main() {
  ll N;
  cin>>N;
  ll a[N];
  ll b[100001]={};

  FOR(i,0,N-1){
    cin>>a[i];
    b[a[i]]++;
  }
  ll ans=0;
  FOR(i,0,99998){
    ans=max(ans,b[i]+b[i+1]+b[i+2]);

  }


cout<<ans<<endl;
return 0;

}
 


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  cout << (N+1)/2 << endl;
}


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

int main(){
   int X, N;
   std::cin >> X >> N;
   std::vector<int> p(N);
   if (N == 0){
      std::cout << X << std::endl;
      return 0;
   }
   for (int i=0; i<N; i++){
      std::cin >> p.at(i);
   }
   std::sort(p.begin(), p.end());
   if (X > p.at(N-1)){
      std::cout << p.at(N-1)+1;
   } else if (X < p.at(0)){
      std::cout << p.at(0) - 1;
   } else{
      int dmax = 0;
      int dmin = 0;
      for (int i=0; i<N; i++){
         if (std::find(p.begin(), p.end(), X+i) == p.end()){
            dmax = X+i;
            break;
         }
      }
      for (int i=0; i<N; i++){
         if (std::find(p.begin(), p.end(), X-i) == p.end()){
            dmin = X-i;
            break;
         }
      }
      if (std::abs(dmax-X) == std::abs(dmin-X)){
         std::cout << dmin << std::endl;
      } else{
         if (std::abs(dmax-X) > std::abs(dmin-X)){
            std::cout << dmin << std::endl;
         } else{
            std::cout << dmax << std::endl;
         }
      }
   }

}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, k, len = 0, j = 0, a, ans = 0, sum = 0;
	string s;
	queue<int> que;
	cin >> num >> k >> s;
	vector<int> d(num + 2, 0);
	if (s[0] == '0')
		len++;
	for (i = 0; i < num;) {
		a = 0;
		while (i < num && s[i + a] == s[i])
			a++;
		i += a;
		if (a > 0)
			d[len++] = a;
	}
	if (s[num - 1] == '0')
		len++;
	k = (k << 1) + 1;
	if (k >= len) {
		cout << num << "\n";
		return 0;
	}
	for (i = 0; i < k; i++) {
		que.push(d[i]);
		sum += d[i];
	}
	ans = sum;
	for (; i < len; i += 2) {
		que.push(d[i]);
		que.push(d[i + 1]);
		sum += d[i] + d[i + 1];
		sum -= que.front();
		que.pop();
		sum -= que.front();
		que.pop();
		ans = max(ans, sum);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
	int64_t a,b;cin>>a>>b;
	bitset<32> bit_a(a), bit_b(b);

	cout<<(bit_a&bit_b)<<endl;
	cout<<(bit_a|bit_b)<<endl;
	cout<<(bit_a^bit_b)<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ff(i, x, n, k) for(int i=x;i<n;i+=k)
#define rf(i, x, n, k) for(int i=n-1;i>=x;i+=k)
#define ef(i, x, n, k) for(int i=x;i<=n;i+=k)
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int MOD = 1e9+7;
const ll INF = pow(10, 18)+5;

int main()
{
	fast_cin();
	ll n, m; cin >> n >> m;

	vector <string> maze(n);

	for (int i = 1; i <= n; ++i)
	{
		string str; cin >> str;
		maze[i-1] = str;
		/*
		for (int j = 0; j <= m; ++j)
		{
			maze[i].pb(str[j]);
		}*/
	}

	ll dp[n+2][m+2] = {0};
	for (int i = 0; i <= n+1; ++i)
	{
		for (int j = 0; j <= m+1; ++j)
		dp[i][j] = 0;
	}
	dp[1][1] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (i == 1 && j == 1) continue;
			if (maze[i-1][j-1] == '#'){
				dp[i][j] = 0;
				continue;
			} 

			dp[i][j] = max(dp[i][j], dp[i-1][j]+dp[i][j-1]);
			dp[i][j] %= (long long)MOD;
		}
	}

	/*for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cout << dp[i][j] << " ";
		}
		cout << '\n';
	}*/

	cout << dp[n][m] % (long long)MOD << '\n';

	return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-8;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    double a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        double y=(a*f-c*d)/(a*e-b*d);
        double x=(-b*y+c)/a;
        x*=1000;
        printf("%.3f ",round(x)/1000);
        y*=1000;
        printf("%.3f\n",round(y)/1000);
    }
}


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

int main() {
  string S;
  cin >> S;
  int N = 0;
  int s = S.size();
  for (int i = 0; i < s; i++) {
    if (i % 2 == 0 && S[i] == '0') N += 1;
    if (i % 2 == 1 && S[i] == '1') N += 1;
  }
  
  cout << min(N, s-N) << endl;
}

Measured memory_bytes: 512