akhauriyash/Code-Regression huggingface dataset:
// JOI - Prelim  0510
// 得点
#include <bits/stdc++.h>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto As(cin2vec<int64_t>(4));
    const auto Bs(cin2vec<int64_t>(4));

    const int64_t sumA = accumulate(As.cbegin(), As.cend(), 0ll);
    const int64_t sumB = accumulate(Bs.cbegin(), Bs.cend(), 0ll);

    const int64_t ans = max(sumA, sumB);
    cout << ans << endl;
}

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


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

int main() {

	int n, k; cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
int main(){
int max1=-10,j,n,w,l,d,b[15],i,max=-10000000,x,k=0,c[15];
char a[15][30],y[30];
while(1){
for(i=0;i<13;i++){
c[i]=i;
}
scanf("%d\n",&n);
if(n==0){
break;
}
if(k==0){
k++;
}
else{
printf("\n");
}
for(i=0;i<n;i++){
scanf("%s %d %d %d\n",a[i],&w,&l,&d);
b[i]=3*w+d*1;
}
for(i=0;i<n;i++){
for(j=i;j<n;j++){
if(b[j]>max || (b[j]==max && max1>c[j])){
max=b[j];
max1=c[j];
x=b[i];
b[i]=b[j];
b[j]=x;
x=c[i];
c[i]=c[j];
c[j]=x;
strcpy(y,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],y);
}
}
max=-10000000,max1=-10;
}
for(i=0;i<n;i++){
printf("%s,%d\n",a[i],b[i]);
}
}
return 0;
}


Measured memory_bytes: 2028
def add_digit(n, d, x):
    """
    nのd桁目にxを挿入する
    357, 1 -> 357x
    357, 2 -> 35x7
    357, 3 -> 3x57
    357, 4 -> x357
    """
    d1 = (10**(d - 1))
    r = n % d1
    h = n // d1
    return h * d1 * 10 + x * d1 + r


def submit():
    n = int(input())
    satisfied = {357, 375, 537, 573, 735, 753}

    stop = False
    curr_d = 3
    ans = 0
    while True:
        for s in satisfied:
            if s <= n:
                ans += 1
            else:
                stop = True
        
        if stop:
            break

        new_satisfied = []
        for s in satisfied:
            for i in range(1, curr_d + 2):
                new_satisfied.append(add_digit(s, i, 3))
                new_satisfied.append(add_digit(s, i, 5))
                new_satisfied.append(add_digit(s, i, 7))
        satisfied = set(new_satisfied)
        curr_d += 1

    print(ans)


if __name__ == "__main__":
    submit()


Measured memory_bytes: 37556
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;

	void doIt() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n + 1];
		int b = 1;
		double pb = 0;
		for(int i = n; i >= 1; i--) {
			while(i * b < k) {
				b *= 2;
			}
			pb += (double)1 / b;
		}
		System.out.println(pb / n);
	}
	

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844
n = int(input())
ps = list(map(int, input().split()))

matches = [p == i+1 for i, p in enumerate(ps)]
i = 0

cnt = 0
while i < n-1:
  if matches[i] and matches[i+1]:
    matches[i] = False
    matches[i+1] = False
    cnt += 1
    i += 2
  else:
    i += 1

cnt += len([m for m in matches if m])

print(cnt)



Measured memory_bytes: 14008
import sys
from numba import njit, i8


@njit((i8, i8, i8, i8), cache=True)
def floor_sum(n, m, a, b):
    ans = n*(b//m)
    b %= m
    while True:
        ans += (n-1)*n*(a//m)//2
        a %= m
        if a*n+b < m:
            return ans
        y_max = (a*n + b)//m
        b -= y_max*m  # now we have x_max = -(b//a)
        ans += (n + b//a)*y_max
        b %= a
        m, a, n = a, m, y_max


input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))


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

using namespace std;


int main()
{
    int N;
    vector<int> L;

    cin >> N;
    L.resize(N);
    for (int i = 0; i < N; ++i) { cin >> L[i];}

    sort(L.begin(), L.end());

    int count = 0;
    for (size_t i = 0; i < L.size(); ++i)
    {
        for (size_t j = i + 1; j < L.size(); ++j)
        {
            if(L[i] == L[j]) { continue;}

            for (size_t k = j + 1; k < L.size(); ++k)
            {
                if ((L[i] == L[k]) || (L[j] == L[k])) { continue; }

                if (L[k] < (L[i] + L[j]))
                {
                    ++count;
                }
                else
                {
                    break;
                }
            }
        }
    }

    cout << count << endl;


    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int a, b, ans;
	ios::sync_with_stdio(false);
	cin >> a >> b;
	if(1<=b&&b<=9) ans=a*10+b;
	if(10<=b&&b<=99) ans=a*100+b;
	if(100<=b&&b<=999) ans=a*1000+b;
	if(1000<=b&&b<=9999) ans=a*10000+b;
	if(b==10000) ans=a*100000+b;
	for(int i = 1; i <= sqrt(ans); i++) {
		if(i*i==ans) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
} 

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

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

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

int main(){
  int N, M, K; cin >> N >> M >> K;
  
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= M; j++){
      int now = N * j + M * i - 2 * i * j;
      if (now != K) continue;
      Yes(); return 0;
    }
  }
  No();

  return 0;
}


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

int main() {

  int a, b, c;
  int ans = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(int i = a; i <= b; ++i) {
    if( c % i == 0 ) {
      ans += 1;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050
ll dp[50][1<<20];
vector<ll> change(int x){
    vector <ll> v;
    int count=0;
    while(x){
        count++;
        if(x%2){v.pb(count);count=0;}
        x/=2;
    }
    return v;
}
int change2(vector<ll> v){
    ll now=1;
    ll ans=0;
    for(auto e:v){
        rep(i,e)now*=2;
        ans+=now/2;
    }
    return ans;
}
bool judge[N];
ll pw[50];
main(){
    int n=in();
    int x[3];
    rep(i,3)x[i]=in();
    int sum=x[0]+x[1]+x[2];
    ll ans=0;
    pw[0]=1;
    rep(i,20)pw[i+1]=pw[i]*2;
    dp[0][0]=1;
    vec all;
    rep(i,1<<sum){
        if((i&(1<<(x[2]-1))&&(i&(1<<(x[2]+x[1]-1))&&(i&1<<(sum-1)))))judge[i]=1;
        else all.pb(i);
    }
    rep(i,n){
        for(auto k:all){
            if(dp[i][k]==0)continue;
            rep2(j,1,7){
                ll next=(k*pw[j]+pw[j-1])%pw[sum];
                if(!judge[next])
                dp[i+1][next]=(dp[i][k]+dp[i+1][next])%MOD;
            }
            dp[i+1][0]=(dp[i+1][0]+dp[i][k]*3)%MOD;
        }
    }
    ll p=1;
    rep(i,n){
        p=p*10ll%MOD;
    }
    rep(i,1<<sum){
        p=(p-dp[n][i]+MOD)%MOD;
    }
    printf("%lld",p);
}

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

int main(){
  string s; cin>>s;
  for(int i=1;i<=s.length();i++){
    if(i&1){
      if(s[i-1]=='R'||s[i-1]=='U'||s[i-1]=='D'){
      }
      else {
        cout<<"No";
        return 0;}
    }
    else{
      if(s[i-1]=='L'||s[i-1]=='U'||s[i-1]=='D'){}
      else {
        cout<<"No";
        return 0;
      }
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,k,i=0;
  cin>>a>>b>>c>>k;
  while(a>=b){
    b*=2;
    i++;
  }
  while(b>=c){
    c*=2;
    i++;
  }
  if(i<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, a, b;
string s[10010], t, x, y;
int main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	cin >> t;
	rep(i, n) {
		x = y = s[i];
		rep(j, x.size()) {
			if (x[j] == '?')x[j] = 'a';
			if (y[j] == '?')y[j] = 'z';
		}
		if (t < x)b++;
		if (t > y)a++;
	}
	for (int i = a + 1;i <= n - b + 1;i++) {
		if (i == n - b + 1)cout << i << endl;
		else cout << i << " ";
	}
	getchar();getchar();
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int find_x[300];
int find_y[300];
int star_x[1234];
int star_y[1234];
int find_flag;

int main(){
	while (1){
		memset(find_x, 0, sizeof(find_x));
		memset(find_y, 0, sizeof(find_y));
		memset(star_x, 0, sizeof(star_x));
		memset(star_y, 0, sizeof(star_y));
		int m, n;
		int move_x, move_y;
		scanf("%d", &m);
		if (m == 0)return 0;
		for (int a = 0; a < m; a++){
			scanf("%d%d", &find_x[a], &find_y[a]);
		}
		scanf("%d", &n);
		for (int a = 0; a < n; a++){
			scanf("%d%d", &star_x[a], &star_y[a]);
		}
		for (int a = 0; a < n; a++){
			move_x = star_x[a] - find_x[0];
			move_y = star_y[a] - find_y[0];
			for (int b = 0; b < m; b++){
				find_flag = 0;
				for (int c = 0; c < n; c++){
					if (move_x + find_x[b] == star_x[c] &&
						move_y + find_y[b] == star_y[c]){
						find_flag = 1;
						break;
					}
				}
				if (find_flag == 0){
					break;
				}
			}
			if (find_flag == 1) break;
		}
		printf("%d %d\n", move_x, move_y);
	}
	return 0;
}

Measured memory_bytes: 2668
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
    int n, ans = 1e9, i;
    vector <pair<int, int> > v, w;
    map <int, int> mp1, mp2;
    map <int, int>::iterator it;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        int x;

        scanf("%d", &x);

        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }

    mp1[1e9] = 0;
    mp2[1e9] = 0;

    for (it = mp1.begin(); it != mp1.end(); it++)
        v.push_back(make_pair(it->second, it->first));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    for (it = mp2.begin(); it != mp2.end(); it++)
        w.push_back(make_pair(it->second, it->first));
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());

    for (i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++){
            if(v[i].second == w[j].second)
                continue;
            ans = min(ans, n - (v[i].first + w[j].first));
        }
    }

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

    return 0;
}

Measured memory_bytes: 6136
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<limits.h>
#include<queue>
struct S{int x,y,s;S(int x,int y,int s):x(x),y(y),s(s){}};
char o[1002][1003],*p;
int h,w;
int F(int sx,int sy,int gx,int gy)
{
	S s(sx,sy,0);
	std::queue<S>q;
	static int d[1001][1001],i,j,a[]={-1,0,1,0};
	for(i=1;i<=h;++i)for(j=1;j<=w;++j)d[i][j]=INT_MAX;
	q.push(s);
	while(!q.empty())
	{
		s=q.front();q.pop();
		if(o[s.y][s.x]=='X' || d[s.y][s.x]<=s.s)continue;
		d[s.y][s.x]=s.s;
		for(i=0;i<4;++i) q.push(S(s.x+a[i], s.y+a[(i+1)%4],s.s+1));
	}
	return d[gy][gx];
}
int main()
{
	int n,i,j,x[10],y[10],z,s=0;
	scanf("%d%d%d",&h,&w,&n);
	for(i=0;i<h;++i)
	{
		scanf("%s",&o[i+1][1]);
		p=&o[i+1][1];
		while(p=strpbrk(p,"S123456789"))
			z=isdigit(*p)?*p-'0':0,y[z]=i+1,x[z]=p-o[i+1],++p;
	}
	for(j=0;j<w+2;++j)o[0][j]=o[h+1][j]='X';
	for(i=0;i<h+2;++i)o[i][0]=o[i][w+1]='X';
	for(i=0;i<n;++i)s+=F(x[i],y[i],x[i+1],y[i+1]);
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 5676
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
    ll N,M,K;
    ll A[100010],B,C,X;
    bool F=true;
    ll ans=0;
    string S;
    priority_queue<ll,vector<ll>,greater<ll>> Q,W;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        ll a;
        cin>>a;
        if(a%2==0){
            if(a%5!=0&&a%3!=0){
                F=false;
                break;
            }
        }
    }
    cout<<(F?"APPROVED":"DENIED")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];

    int n = inp1;
    vector<int> b = inp(n);

    vector<vector<bool>> used(3, vector<bool>(3, false));
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (a[j][k] == b[i]) {
                    used[j][k] = true;
                }
            }
        }
    }

    bool ok = false;

    rep(i, 3) {
        bool f = true;
        rep(j, 3) {
            f &= used[i][j];
        }
        ok |= f;
    }

    rep(i, 3) {
        bool f = true;
        rep(j, 3) {
            f &= used[j][i];
        }
        ok |= f;
    }

    ok |= (used[0][0] && used[1][1] && used[2][2]);
    ok |= (used[2][0] && used[1][1] && used[0][2]);

    Cout(Yes(ok));

    return 0;
}


Measured memory_bytes: 256
// インクルード(GCC only)
#include <bits/stdc++.h>

// 長い型名
using namespace std;
typedef long long LL;

// 省略記法
#define INF 1e9
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n), i=(i##_len-1); i>=0; ++i)
#define FOR(i,m,n) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sizei(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define printvector(x) rep(i,sizei(x)){cout << x[i] << endl;}
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 (b<a) { a=b; return 1; } return 0; }

// mod付き四則演算(mod関数のオーバーヘッドが重いかも)
// TODO: 二項係数、離散対数、平方剰余の実装
#define MOD 1000000007
inline LL mod(LL const &a) { return (a % MOD + MOD) % MOD; }
inline LL madd(LL const &a, LL const &b) { return mod(mod(a) + mod(b)); }
inline LL msub(LL const &a, LL const &b) { return mod(mod(a) - mod(b)); }
inline LL mmul(LL const &a, LL const &b) { return mod(mod(a) * mod(b)); }
inline LL mpow(LL a, LL b) {
  LL r = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) (r *= a) %= MOD;
    (a *= a) %= MOD;
  }
  return r;
}
inline LL minv(LL const &a) { return mpow(a, MOD-2); }
inline LL mdiv(LL const &a, LL const &b) { return mod(mod(a) * minv(b)); }


// デバッグ用
#ifdef LOCAL
    #define eprint(...) fprintf(stderr, __VA_ARGS__)
    #define eprintvector(x) printvector(x)
#else
    #define eprint(...) 42
    #define eprintvector(x) 42
#endif

int main(void)
{
  string S;
  cin >> S;
  LL len = (LL)(S.length());

  char even = '0';
  char odd = '1';
  if (S[0] != even) {
    even = '1';
    odd = '0';
  }

  int count = 0;
  rep(i, len) {
    if (i % 2 == 0) {
      if (S[i] != even) {
        count ++;
      }
    }
    else {
      if (S[i] != odd) {
        count ++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
int color[N];
vector<pii> t[N];

void dfs(int cur, int par, int col){
	color[cur] = col;
	for(pii child:t[cur]){
		if(child.F != par){
			dfs(child.F, cur, col^child.S);
		}
	}
}

int main(){
	fast_io();
	int n;
	cin >> n;
	cu(i,0,n-1){
		int x,y,w;
		cin >> x >> y >> w;
		t[x].pb({y,w&1});
		t[y].pb({x,w&1});
	}
	dfs(1,0,1);
	fu(i,1,n){
		cout << color[i] << '\n';
	}
}


Measured memory_bytes: 8448
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
if N >= M:
  print(0)
  exit()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N-1):
  xx[j] = 0
ans = sum(xx)
print(ans)

Measured memory_bytes: 13968
#ABC051b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

k, s = map(int, input().split())
c = 0
for x in range(k + 1):
    for y in range(k + 1):
        if (0 <= s - x - y <= k):
            c += 1
print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int n, m;
int a[300][300];

bool check(int k){
    // cout << k << endl;
    VI ind(n), pass(m), sum(m);
    REP(i,n) sum[a[i][0]]++;
    while (1){
        // REP(i,m) cout << pass[i] << " ";
        // cout << endl;
        int x = -1;
        REP(i,m){
            if (sum[i] > k){
                x = i;
                break;
            }
        }
        if (x == -1) return true;
        pass[x] = 1;
        sum[x] = 0;
        REP(i,n){
            if (a[i][ind[i]] != x) continue;
            while (ind[i] < m && pass[a[i][ind[i]]]) ind[i]++;
            if (ind[i] == m) return false;
            sum[a[i][ind[i]]]++;
        }
    }
    return true;
}

int main(void){
    cin >> n >> m;
    REP(i,n) REP(j,m){
        scanf("%d", &a[i][j]);
        a[i][j]--;
    }

    int ok = n, ng = 0;
    while (ok - ng > 1){
        int mi = (ok + ng) / 2;
        if (check(mi)) ok = mi;
        else ng = mi;
    }
    cout << ok << endl;
}

Measured memory_bytes: 640
n, y = map(int, input().split())
for i in range(n + 1):
	# if 1000 * i > y:
	# 	break
	for j in range(n + 1):
		k = n - (i + j)
		# if 1000*i + 5000*j + 10000*k > y or k < 0 or k > 2000:
		# 	break
		if 0 <= k <= 2000 and 1000*i + 5000*j + 10000*k == y:
			print(k, j, i)
			exit()
print("-1 -1 -1")

Measured memory_bytes: 40812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int h[] = new int[100010];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(str[i]);
		}

		int dp[] = new int[100010];
		for (int i = 0; i < 100010; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		dp[0] = 0;

		for (int i = 1; i < n; i++) {
			dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			if (i > 1)
				dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		}

		System.out.println(dp[n - 1]);
	}
}


Measured memory_bytes: 33432
import copy
import bisect
S=input()
T=input()

sbasic=[[] for _ in range(26)]
for i,s in enumerate(S):
  sbasic[ord(s)-ord("a")].append(i)

for t in set(T):
    if len(sbasic[ord(t)-ord("a")])==0:
        print(-1)
        exit()

slist=copy.deepcopy(sbasic)
index=-1
roop=0
for t in T:
  if len(sbasic[ord(t)-ord("a")])==0:
    roop+=1
    #slist=copy.deepcopy(sbasic)
    index=-1
  pos=bisect.bisect_right(sbasic[ord(t)-ord("a")],index)
  if pos==len(sbasic[ord(t)-ord("a")]):
    roop+=1
    #slist=copy.deepcopy(sbasic)
    index=-1
    pos=0
  index=sbasic[ord(t)-ord("a")][pos]
  
print(len(S)*roop+index+1)
  
  
  
  
  

Measured memory_bytes: 71536
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    int a, b; cin >> a >> b;
    cout << ((a-1)*(b-1)) << endl;
}

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

int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    vec[i]-=i+1;
  }
  sort(vec,vec+n);
  ll ans=1e15;
  if(n%2==0){
    for(int j=n/2-1;j<=n/2;j++){
      ll sum=0;
      for(int i=0;i<n;i++){
        sum+=abs(vec[i]-vec[j]);
      }
      ans=min(ans,sum);
    }
    ll x=(vec[n/2-1]+vec[n/2])/2;
    for(int j=x-1;j<=x+1;j++){
      ll sum=0;
      for(int i=0;i<n;i++){
        sum+=abs(vec[i]-j);
      }
      ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
  }
  for(int j=n/2-1;j<=n/2+1;j++){
    ll sum=0;
    for(int i=0;i<n;i++){
      sum+=abs(vec[i]-vec[j]);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

int main(){
    int A, B, C; // それぞれ500, 100, 50円玉の個数
    int X; // 合計金額。50の倍数の制約あり

    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    
    int count = 0;
    int use500 = 0;
    int use100 = 0;
    int use50 = 0;

    while (use500 <= A){
        while (use100 <= B){
            while(use50 <= C){
                if (500 * use500 + 100 * use100 + 50 * use50 == X) {
                    count = count + 1;
                    break;
                }else
                {
                    use50 = use50 + 1;
                }    
            }
            use100 = use100 + 1;
            use50 = 0;
        }
        use500 = use500 + 1;
        use100 = 0;
    }

    cout << count << endl;
    return 0;
}

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

long long ans=0;
int tot=0,h[100005];
int n,m,x,y,S,T,k[100005],siz[100005];
int s[100005],top;
bool odd;
struct Edge{
    int x,next;
}e[200005];

inline void add_edge(int x,int y){
    e[++tot].x=y;
    e[tot].next=h[x],h[x]=tot;
}

void dfs1(int x,int fa){
    for(int i=h[x];i;i=e[i].next){
        if(e[i].x==fa)continue;
        if(siz[e[i].x]){
            if(siz[x]==siz[e[i].x])odd=true;
            S=x,T=e[i].x;
        }else{
            siz[e[i].x]=-siz[x];
            dfs1(e[i].x,x);
        }
    }
}

void dfs2(int x,int fa){
    for(int i=h[x];i;i=e[i].next){
        if(e[i].x==fa||(x==S&&e[i].x==T)||(x==T&&e[i].x==S))continue;
        dfs2(e[i].x,x);
        siz[x]+=siz[e[i].x];
        k[x]+=k[e[i].x];
    }
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        add_edge(x,y);
        add_edge(y,x);
    }
    siz[1]=1,dfs1(1,0);
    int sum=0;
    for(int i=1;i<=n;i++)sum+=siz[i];
    if(m==n-1){
        if(sum)return printf("-1"),0;
    }else{
        if(odd){
            if(sum&1)return printf("-1"),0;
            ans+=abs(sum>>1);
            siz[S]-=sum>>1,siz[T]-=sum>>1;
        }else{
            if(sum)return printf("-1"),0;
            else k[S]=1,k[T]=-1;
        }
    }
    dfs2(1,0);
    for(int i=1;i<=n;i++){
        if(k[i])s[++top]=k[i]*siz[i];
        else ans+=abs(siz[i]);
    }
    s[++top]=0;
    sort(s+1,s+top+1);
    int mid=s[top+1>>1];
    for(int i=1;i<=top;i++)ans+=abs(s[i]-mid);
    printf("%lld",ans);
}

Measured memory_bytes: 14640
n = int(input())
a = list(map(int, input().split()))
cnt = [0]*(n+1)
for i in range(n):
    cnt[a[i]]+=1
res = 0
for i in range(n+1):
    res+=cnt[i]*(cnt[i]-1)//2
for i in range(n):
    c = cnt[a[i]]
    print(res-c*(c-1)//2+(c-1)*(c-2)//2)

Measured memory_bytes: 85836
#include<iostream>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans;
  if(k<a){
    ans=k;
  }else if(k<a+b){
    ans=a;
  }else{
    ans=a-(k-a-b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
import java.math.BigDecimal
import java.math.RoundingMode
 
fun main(args: Array<String>) {
    val(h, w) = readLine()!!.split(" ").map(String::toLong)
    if(h == 1L || w == 1L) {
      println(1)
      return
    }
    val s = BigDecimal.valueOf(h).multiply(BigDecimal.valueOf(w)).add(BigDecimal.ONE)
    val a = s.divide(BigDecimal.valueOf(2), 0, RoundingMode.FLOOR)
    println(a.toPlainString())
}


Measured memory_bytes: 37728
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int cache[99999];
long long int solve(int idx,vector<int> &v,int &n){
    if(idx == n-1)
    {
        return 0;
    }
    if(idx >= n)
    {
        return INT_MAX;
    }
    if(cache[idx] != -1)
    {
        return cache[idx];
    }
    long long int ans=INT_MAX;
     if(idx+2 < n)
    {
     ans=min(ans,abs(v[idx] - v[idx+2]) + solve(idx+2,v,n));
    }
    if(idx+1 < n)
    {
     ans =min(ans,abs(v[idx]-v[idx+1]) + solve(idx + 1,v,n));
    }
    return cache[idx]=ans;
}
int main() {
	int n;
	cin>>n;
	memset(cache,-1,sizeof(cache));
	vector<int> v(n);
	for(int i=0;i<n;i++){
	   cin>>v[i];
	}
	cout<<solve(0,v,n);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    int s = 0;
    for (int &x : arr)
        cin >> x, s += x;
    m *= 4;
    int ans = 0;
    for (int x : arr)
    {
        ans += ((s + m - 1) / m) <= x ? 1 : 0;
    }
    cout << (ans >= m / 4 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll A[301][301];

int main(){
    int N;
    cin >> N;
    rep(i,N) rep(j,N) cin >> A[i][j];

    vector<vector<ll>> dp(N,vector<ll>(N));
    rep(i,N) rep(j,N) dp[i][j] = A[i][j];
    rep(k,N) rep(i,N) rep(j,N) dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);

    rep(i,N)rep(j,N){
        if(dp[i][j] < A[i][j]){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<vector<bool>> valid(N,vector<bool>(N,true));
    rep(i,N) rep(j,i){
        bool ok = true;
        rep(k,N) if(k!=i and k!=j){
            if(dp[i][k] + dp[k][j] == dp[i][j]){
                valid[i][j] = valid[j][i] = false;
                break;
            }
        }
    }

    ll sum = 0;
    rep(i,N) rep(j,i) if(valid[i][j]){
        sum += dp[i][j];
    }

    cout << sum << endl;
}


Measured memory_bytes: 1664
ans = ""
for i in range(1000):
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for j in range(H):
            if j == 0 or j == H-1:
                for _ in range(W):
                    ans += "#"
                print(ans)
                ans = ""
            else:
                for _ in range(W):
                    if _ == 0 or _ == W-1:
                        ans += "#"
                    else:
                        ans += "."
                print(ans)
                ans = ""
    print("")



Measured memory_bytes: 5608
def f(x):
    if x%4 == 0:
        return x
    elif x%4 == 1:
        return 1
    elif x%4 == 2:
        return x+1
    elif x%4 == 3 or a == 0:
        return 0

a,b = map(int,input().split())
print(f(b)^f(a-1))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define lson l, mid
#define rson mid+1, r
#define PII pair<int, int>
#define Size(x) (int)(x.size())
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
const int N = 1e5+5;

int a[N];

int GCD(int u, int v) {
    if(!v)
        return u;
    return GCD(v, u%v);
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    bool flag = false;
    int maxx = 0, gcd = 0;
    for(int i=1; i<=n; i++) {
        scanf("%d", &a[i]);
        maxx = max(maxx, a[i]);
        if(i == 1)
            gcd = a[i];
        else
            gcd = GCD(gcd, a[i]);
        if(a[i] == k)
            flag = true;
    }
    if(flag) {
        printf("POSSIBLE\n");
        return 0;
    }
    if(maxx < k) {
        printf("IMPOSSIBLE\n");
        return 0;
    }
    if(k % gcd == 0) {
        printf("POSSIBLE\n");
        return 0;
    } else {
        printf("IMPOSSIBLE\n");
    }
}






Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define PuB push_back

using namespace std;

const int N=1e5+10, Mod=1e9+7;
int n;
ll dp[2][N];
int par[N];
bool visible[N]={};
vector<int> adj[N];

void dfs(int x){
    bool leaf=1;
    for(int v:adj[x]){
        if(v!=par[x]){
            leaf=0;
            if(visible[v]) continue;
            par[v]=x;
            visible[v]=1;
            dfs(v);
        }
    }
    if(leaf){
        dp[0][x]=1;
        dp[1][x]=2;
        return;
    }
    ll blval=1, whval=1;
    for(int u:adj[x]){
        if(u!=par[x]){
            blval*=dp[0][u];
            blval%=Mod;
            whval*=dp[1][u];
            whval%=Mod;
        }
    }
    dp[0][x]=whval;
    dp[1][x]=(whval+blval)%Mod;
}

int main()
{
    cin>>n;
    for(int i=0; i<n-1; i++){
        int x, y;
        cin>>x>>y;
        x--; y--;
        adj[x].PuB(y);
        adj[y].PuB(x);
    }
    par[0]=-1;
    visible[0]=1;
    dfs(0);
    cout<<dp[1][0];
}

























Measured memory_bytes: 14720
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
#include <numeric>
#include <iostream>
#include <array>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;
ll gcd(ll x, ll y)
{
  if(x<y)
  {
    swap(x,y);
  }
  while(y>0)
  {
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}



int main(){
  string s;cin>>s;
  ll sum=0;
  for(int i=0;i<s.size();i++){
    sum+=s[i]-'0';
    sum%=9;
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int GCD(int a, int b){
  
  int c;
  c=a%b;
  a=b;
  b=c;
  
  if(c==0){
    return a;
  }else{
    return GCD(a, b);
  }
}

int main(){
  
  int N, i, j, mn=1000000000;
  cin>>N;
  vector<int> A(N);
  for(i=0; i<N; i++) cin>>A[i];
  for(i=0; i<N-1; i++){
    mn=min(mn, GCD(A[i], A[i+1]));
  }
  cout<<mn<<endl;
  return 0;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main() {
	int N, V[21], C[51], mouke = 0, max = 0;
	cin >> N;
    for(int i = 0; i<N; i++){
        cin >> V[i];
    }
    for(int i = 0; i<N; i++){
        cin >> C[i];
    }
    for(int i = 0; i<N; i++){
        mouke = V[i] - C[i] ;
        if(mouke > 0) max += mouke;
    }
	cout << max << endl;
	return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define int ll
// 辺を表す構造体 {行先、容量、逆辺}
struct edge { ll to, cap, rev; };
#define V 1010
int s, t; //sがstart, tがgoal
vector< vector<edge> > G(V, vector<edge>());; //グラフの隣接リスト表現
vector<bool> used(V); //DEFで調べたかのフラグ

					  //fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(ll from, ll to, ll cap) {
	edge a;
	a.to = to; a.cap = cap; a.rev = G[to].size();
	G[from].push_back(a);
	a.to = from; a.cap = 0; a.rev = G[from].size() - 1;
	G[to].push_back(a);
}

int dfs(int v, int t, ll f) {
	if (v == t) {
		return f;
	}
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while (true) {
		fill(used.begin(), used.end(), false);
		ll f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

signed main() {
  int n, i, j;
  cin >> n;
  vl a(n);
  ll sum = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += max(a[i], 0LL);
  }
  for (i = 1; i <= n; i++) {
    for (j = 2; i*j <= n; j++) {
      add_edge(i, i*j, INF);
    }
  }
  for (i = 0; i < n; i++) {
    if (a[i] < 0) {
      add_edge(0, i + 1, -a[i]);
    }
    else {
      add_edge(i + 1, n + 1, a[i]);
    }
  }
  cout << sum - max_flow(0, n + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  double n,d;
  cin>>n>>d;
  int cnt=0;
  for (int i = 0; i < n; ++i)
  {
    double x,y;
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=d) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <string.h>
#include<iostream>

using namespace std;

int main(){
  char str[1000];

  int length;

 cin>>str;

 length=strlen(str);

 for(int n=length-1;n>=0;n--){
	cout<< str[n];
 }
cout<<"\n";



 

















return 0;
}

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

using namespace std;

using intL = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  int n, a, b, cnt = 0;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    int table = i+1, sum = 0;
    while (table > 0) {
      sum += table%10;
      table /= 10;
    }
    if (a <= sum && sum <= b) {
      cnt += i+1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 550;
int bs[MM];
int main() {
	int n;
	cin >> n;
	int ct = 0;
	for(int i=0;i<n;i++) {
		cin >> bs[i];
		bs[i]--;
		if(bs[i] != i) {ct++;}
	}
	if(ct <= 2) {
		cout << "YES\n";
	} else {
	cout << "NO\n";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename H, typename ...T> void qqbx(const char *s, const H &h, T&&...a) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr<<*s;
    std::cerr<<" = "<<h<<(sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, a...);
}
#else
#define debug(...) ((void)0)
#endif // local
#define pb emplace_back
#define all(v) begin(v),end(v)

using namespace std;
const int MOD = 1000000007, N = 200025, inf = 2e9;
int a[N], b[N], ca[N], cb[N];
int A[N], B[N];
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) ++ca[a[i]];
    for(int i = 0; i < n; i++) ++cb[b[i]];
    for(int i = 1; i <= n; i++) if(ca[i] + cb[i] > n) return cout << "No\n", 0;
    for(int i = 1; i <= n; i++) ca[i] += ca[i-1];
    for(int i = 1; i <= n; i++) cb[i] += cb[i-1];
    int mx = 0;
    for(int i = 1; i <= n; i++) mx = max(mx, ca[i] - cb[i-1]);
    cout << "Yes\n";
    for(int i = 0; i < n; i++)
        cout << b[(i+n-mx)%n] << ' ';
    cout << '\n';
}


Measured memory_bytes: 6744
n,k = map(int,input().split())
lista = [int(i) for i in input().split()]

minv = 10**9

for i in range(n-k+1):
    head = lista[i]
    tail = lista[i+k-1]
    if head*tail <0:
        if abs(head)>abs(tail):
            temp = abs(head) + 2*abs(tail)
        else:
            temp = 2*abs(head) + abs(tail)
        if minv>temp:
            minv=temp
    else:
        temp = max(abs(head),abs(tail))
        if minv>temp:
            minv=temp
            
print(minv)

Measured memory_bytes: 14224
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.length()<b.length())cout<<"LESS"<<endl;
	else if(a.length()>b.length())cout<<"GREATER"<<endl;
	else{
		int d=0;
        while(a[d]!='\0'){
            if(a[d]>b[d]){
                cout<<"GREATER"<<endl;
                return 0;
            }else if(a[d]<b[d]){
                cout<<"LESS"<<endl;
                return 0;
            }
            d++;
        }
		cout<<"EQUAL"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

# aの時針が12時を0度にしたときに何度にあるか
# 時間分の角度 + 分針分の角度(60分で1/12度進むのでb分で何度進むかというとb*1/12 = 60 * x )
a_angle = h/12 + m*1/12/60
# 分針の角度
b_angle = m/60

# θはラジアン(円の半径に等しい長さの弧の中心に対する角度)である点に注意
# 要は360度 = 2*π
angle = abs(a_angle - b_angle)*2*math.pi

# 余弦定理より
# c^2 = a^2 + b^2 - 2*a*b*math.cos(angle)
print(math.sqrt(a*a + b*b - 2*a*b*math.cos(angle)))

# 別解それぞれの座標は以下の通りなので、座標間の距離を出しても良い
# a: (a*cos(a_angle),a*sin(a_angle)) b:(b*cos(b_angle),b*sin(b_angle))

#a_angle = a_angle * math.pi*2
#b_angle = b_angle * math.pi*2
#x1 = a*math.cos(a_angle)
#y1 = a*math.sin(a_angle)
#x2 = b*math.cos(b_angle)
#y2 = b*math.sin(b_angle)
#
#print(math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)))

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

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

  if (x == 0) {
    puts("1");
  } else {
    puts("0");
  }

  return 0;
}


Measured memory_bytes: 1660
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    // テストコードをここにコピペする
r"101
" => r"2",

r"000
" => r"0"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: String,
    }
    return s.chars().filter(|&c| c == '1').count().to_string();
    // 問題を解くコード
}


Measured memory_bytes: 4352
use std::collections::HashMap;
use whiteread::parse_line;

fn main() {
    let mut map: HashMap<String, i32> = HashMap::new();

    let n: usize = parse_line().unwrap();
    for _ in 0..n {
        let s: String = parse_line().unwrap();
        map.entry(s).and_modify(|x| *x += 1).or_insert(1);
    }

    let m: usize = parse_line().unwrap();
    for _ in 0..m {
        let t: String = parse_line().unwrap();
        map.entry(t).and_modify(|x| *x -= 1);
    }
    println!("{}", map.values().max().unwrap().max(&0));
}


Measured memory_bytes: 2160