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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int keta(int n){
    int k = 0;
    while(n > 0){
        k++;
        n /= 10;
    }
    return k;
}

int main(){
    int N;
    cin >> N;

    int ans = 0;
    for(int i = 1; i <= N; i++){
        int k = keta(i);
        if(k % 2) ans++;
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int gx = sc.nextInt();
		int gy = sc.nextInt();

		for (int i = 0; i < gy - sy; i++) {
			System.out.print("U");
		}
		for (int i = 0; i < gx - sx; i++) {
			System.out.print("R");
		}
		for (int i = 0; i < gy - sy; i++) {
			System.out.print("D");
		}
		for (int i = 0; i < gx - sx; i++) {
			System.out.print("L");
		}
		System.out.print("L");
		for (int i = 0; i < gy - sy + 1; i++) {
			System.out.print("U");
		}
		for (int i = 0; i < gx - sx + 1; i++) {
			System.out.print("R");
		}
		System.out.print("DR");
		for (int i = 0; i < gy - sy + 1; i++) {
			System.out.print("D");
		}
		for (int i = 0; i < gx - sx + 1; i++) {
			System.out.print("L");
		}
		System.out.println("U");
	}

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


Measured memory_bytes: 16416
program align
  implicit none
  integer :: n, a(100000) = 0, b(100000) = 0, i, j
  integer(8) :: x = 0_8, y
  read(*,*) n
  do i = 1, n
    read(*,*) a(i)
  end do
  call quick_sort(a(1:n))
  do j = 1, 2
    if (mod(n,2) == 1) then
      b(1) = a(n/2+1)
      do i = 1, n-1
        if (mod(i,2) == 0) then
          b(i+1) = a(i/2)
        else
          b(i+1) = a(n-i/2)
        end if
      end do
    else
      b(1) = a(n/2)
      do i = 1, n-1
        if (mod(i,2) == 0) then
          b(i+1) = a(i/2)
        else
          b(i+1) = a(n-i/2)
        end if
      end do
    end if
    y = 0_8
    do i = 1, n-1
      y = y+abs(b(i)-b(i+1))
    end do
    x = max(x,y)
    a(1:n) = a(n:1:-1)
  end do
  write(*,'(i0)') x
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program align

Measured memory_bytes: 1408
S = input()
T = input()
cnt = 0
s = S + S
ans = False
if S == T:
    ans = True
else:
    for i in range(len(S)):
        if s[i]==T[0]:
            for j in range(len(T)):
                if s[i+j]==T[j]:
                    cnt +=1
            if cnt%len(T)==0:
                ans = True
            cnt = 0
if ans == True:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38256
PROGRAM-ID.                      ABC_047_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(11).
    01 INP2    PIC X(9).
    01 W       PIC 9(3).
    01 H       PIC 9(3).
    01 N       PIC 9(3).
    01 x       PIC 9(3).
    01 y       PIC 9(3).
    01 a       PIC 9(1).
    01 xs      PIC 9(3).
    01 xl      PIC 9(3).
    01 ys      PIC 9(3).
    01 yl      PIC 9(3).
    01 sq      PIC 9(5).
    01 ans     PIC X(5).
    01 ZS      PIC Z(5)9.
    01 DUMMY   PIC X(1).
    01 i       PIC 9(3).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO W H N.

    MOVE ZERO TO xs.
    MOVE W TO xl.
    MOVE ZERO TO ys.
    MOVE H TO yl.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        ACCEPT INP2

        UNSTRING INP2
        DELIMITED BY SPACE
        INTO x y a

        EVALUATE a
            WHEN 1
                COMPUTE xs = FUNCTION MAX(xs, x)
            WHEN 2
                COMPUTE xl = FUNCTION MIN(xl, x)
            WHEN 3
                COMPUTE ys = FUNCTION MAX(ys, y)
            WHEN 4
                COMPUTE yl = FUNCTION MIN(yl, y)
        END-EVALUATE
    END-PERFORM.

    IF xl <= xs OR yl <= ys THEN
        MOVE ZERO TO sq
    ELSE
        COMPUTE sq = (xl - xs) * (yl - ys)
    END-IF.

    MOVE sq TO ZS.
    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i=0;i<n;i++)

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359

int main() {
    // input
    ll A, B, K;
    cin >> K >> A >> B;

    // process
    for (ll i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK";
            return 0;
        }
    }

    cout << "NG";
    return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mm(x,n) memset(x,n,sizeof(x))
#define IOS cin.tie(0); ios::sync_with_stdio(0);
#define p2(x) (x*x)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
//const int maxn =
int a[30];

int main(){
	string s;
	cin >> s;
	mm(a,0);
	rep(i,0,s.size()-1)
		a[s[i]-'a']++;
	bool fg = 0;
	rep(i,0,25)
		if(!a[i]){
			cout<<char('a'+i);
			fg = 1;
			break;
		}
	if(!fg) cout<<"None";		
}


Measured memory_bytes: 512
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    map<ll, ll> mp, mn;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll x;
        cin >> x;
        ll p = i - x, q = i + x;
        if(mp.count(p)){
            ans += mp[p];
        }else if(mn.count(q)){
            ans += mn[q];
        }
        mp[i + x]++;
        if(i - x > 0){
            mn[i - x]++;
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 19872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

//bool f[2][100011];
//bool used[100011];

//vector<int> vi[100011];

//void solve(bool g) {
//	queue<int> que;
//	if (g == 0)que.push(0);
//	else que.push(n - 1);
//	while (!que.empty()) {
//		int now = que.front();
//		que.pop();
//		used[now] = 1;
//		f[g][now] = 1;
//		rep(i, vi[now].size()) {
//			int to = vi[now][i];
//			if (g == 0 && f[1][to])continue;
//			else if (g == 1 && f[0][to])continue;
//			if (!used[to])que.push(to);
//		}
//	}
//}

class DK {
public:
	struct edge {
		int to;
		int cost;
	};

	int prev[100010];
	ll d[100010];
	int N;
	vector<edge> G[100010];//各頂点からの辺

	void dijkstra(int start) {
		fill(d, d + 100010, INF);
		d[start] = 0;
		fill(prev, prev + 100010, -1);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, start));

		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (int i = 0; i < G[v].size(); i++) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					prev[e.to] = v;
					que.push(P(d[e.to], e.to));
				}
			}
		}
	}

	vector<int> get_path(int goal) {
		vector<int> path;
		for (int t = goal; t != -1; t = prev[t]) {
			path.push_back(t);
		}//このままでは逆順なのでひっくり返す
		reverse(ALL(path));
		return path;
	}
};

DK dk[2];

int main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dk[0].G[a].push_back({ b,1 });
		dk[0].G[b].push_back({ a,1 });
		dk[1].G[a].push_back({ b,1 });
		dk[1].G[b].push_back({ a,1 });
	}
	dk[0].dijkstra(0);
	dk[1].dijkstra(n - 1);
	int w = 0, b = 0;
	rep(i, n) {
		//cout << dk[0].d[i] << " " << dk[1].d[i] << endl;
		if (dk[0].d[i] <= dk[1].d[i])w++;
		else b++;
	}
	//int k = w + b - n;
	//w -= k;
	//b -= k;
	//cout << w << " "<< " " << b << endl;
	//bool F = 0;
	if (w > b)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	//if (n == 2) {
	//	cout << "Snuke" << endl;
	//	return 0;
	//}
	//rep(i, n - 1) {
	//	if (!F) {
	//		if (k > 0)k--;
	//		else if (w > 0)w--;
	//		else {
	//			cout << "Snuke" << endl;
	//			return 0;
	//		}
	//	}
	//	else {
	//		if (k > 0)k--;
	//		else if (b > 0)b--;
	//		else {
	//			cout << "Fennec" << endl;
	//			return 0;
	//		}
	//	}
	//	F = !F;
	//}
}

Measured memory_bytes: 15500
N, K = map(int, input().split())

# setについての詳細:
# https://docs.python.org/ja/3/library/stdtypes.html#set-types-set-frozenset

has_snack = set()  # 1つ以上のお菓子を持っているすぬけ君を入れておくset
for i in range(K):
    d = int(input())  # d を読む（使わないけど）
    A = set(map(int, input().split()))  # A を set として読む
    has_snack |= A  # has_snackとの和集合を求め、それをhas_snackに代入

# len(has_snack) でhas_snackの要素数を求め、総数 N から引く
print(N-len(has_snack))


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

int main(){

    int money;
    int cnt_500, cnt_5;
    int happy;

    cin >> money;

    if (money >= 500){
        cnt_500 = money/500;
        money -= 500*cnt_500;
    }
//    else if (money >= 5){
        cnt_5 = money/5;
        money -= 5*cnt_5;
//    }
    
    happy = cnt_500*1000 + cnt_5*5;

    cout << happy << endl;

    return 0;
}

Measured memory_bytes: 256
//file_name:ABC76_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    int ans = 2*m - n;

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



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int dp[50][500][500];

int main(){
    ios::sync_with_stdio(false);
    rep(i,50)rep(j,500)rep(k,500) dp[i][j][k] = inf;
    int N,A,B;
    cin >> N >> A >> B;
    vector<int> a(N),b(N),c(N);
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0][0] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<500; j++){
            for(int k=0; k<500; k++){
                if(dp[i][j][k] == inf) continue;
                chmin(dp[i+1][j][k],dp[i][j][k]);
                if(j+a[i] < 500 && k+b[i] < 500){
                    chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]);
                }
            }
        }
    }
    int ans = inf;
    for(int i=1; i<500; i++){
        if(i*A>500 || i*B>500) break;
        chmin(ans,dp[N][i*A][i*B]);
    }
    if(ans == inf){
        cout << -1 << "\n";
    }else{
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 52488
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
www = na()
s1 = 0
s2 = sum(www)
m = s2
for w in www:
    s1 += w
    s2 -= w
    if m > abs(s1 - s2):
        m = abs(s2 - s1)
print(m)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
    cin >> x;
    if(x < 100)
        return cout << 0 << '\n', 0;
    int d = x / 100;
    int m = x % 100;
    for(int i = 5 ; i >= 1 ; --i){
        while(d && m >= i) d--, m -= i;
    }
    cout << (m == 0 ? 1:0) << '\n';
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/
// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;
constexpr int cm = 1<<17;
char buff[cm], *ci = buff + cm, ct;

inline char readchar() {
  if (ci - buff == cm) {
    fread(buff, 1, cm, stdin);
    ci = buff;
  }
  return *ci++;
}

inline int readint() {
  int num = 0;
  if (ci - buff + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  }
  return num;
}
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
vector<int> graph[202020];
vector<int> score(202020, 0);

void dfs(int cur, int prev) {
  score[cur] += score[prev];
  for (int next : graph[cur]) {
    if (next == prev) continue;
    dfs(next, cur);
  }
}

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

  int n = readint(), q = readint();
  for (int i = 0; i < n - 1; ++i) {
    int a = readint(), b = readint();
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }

  for (int i = 0; i < q; ++i) {
    int p = readint(), x = readint();
    score[p] += x;
  }

  dfs(1, 0);

  for (int i = 1; i <= n; ++i) {
    fastout(score[i]);
  }

  return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int n;

int pow(int a,int b){
	if(b==0)return 1;
	if(b%2)return a*pow(a,b-1);
	else return pow(a*a,b/2);
}

int transform(string s){
	int res=0;
	rep(i,s.size()){
		res+=(int)(s[i]-'0')*pow(10,s.size()-1-i);
	}
	return res;
}

int func(string s,int a,int b,int c){
	if(s.size()>9)return 0;
	if(transform(s)>n)return 0;
	int res=0;
	res+=func(s+"3",a+1,b,c);
	res+=func(s+"5",a,b+1,c);
	res+=func(s+"7",a,b,c+1);
	if(transform(s)<=n&&a>=1&&b>=1&&c>=1)res++;
	return res;
}

int main(){
	cin>>n;
	cout<<func("",0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
long long gcd(long long x, long long y) {
    if (y == 0)return x;
    else return gcd(y, x % y);
}
signed main(){
    int n;
    cin>>n;
    long long a;
    cin>>a;
    long long L=a,G=a;
    for(int i=0;i<n-1;i++){
        long long t;
        cin>>t;
        G=gcd(L,t);
        L=L/G*t;
    }
    cout<<L<<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>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



int dp[2020][2020];
int N, M;
int S[2020], T[2020];

int func(int i, int j) {
	if (dp[i][j] != 0) {
		//printf("%lld %lld: %lld\n", i, j, dp[i][j]);
		return dp[i][j];
	}
	if (S[i-1] != T[j-1]) {
		int res = func(i - 1,j) + func(i,j - 1) - func(i - 1,j - 1);
		if (res >= MOD)res -= MOD;
		else if (res < 0)res += MOD;
		dp[i][j] = res;
		//printf("%lld %lld: %lld\n", i, j, dp[i][j]);
		return dp[i][j];
	}
	else {
		int res = func(i - 1, j) + func(i, j - 1);
		if (res >= MOD)res -= MOD;
		dp[i][j]=res;
		
		//printf("%lld %lld: %lld\n", i, j, dp[i][j]);
		return dp[i][j];
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	REP(i, N)cin >> S[i];
	REP(j, M)cin >> T[j];
	REP(i, N+1) {
		dp[i][0] = 1;
	}
	REP(j, M+1) {
		dp[0][j] = 1;
	}
	print(func(N, M));
}


Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back
#define sz(a) (int)a.size()

void solve();

signed main() {
#ifdef ONPC
    freopen("in.txt", "r", stdin);
#endif // ONPC
    //freopen("time.in", "r", stdin);
    //freopen("time.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}
#define int ll
const int N = 2005;
int n, dp[N][N], pos[2][N], pref[2][N + N][N];
vector<pair<int, int>> v;
const int INF = 1e18 + 7;

void solve() {
    cin >> n;
    v.pb({0, 0});
    for (int i = 1; i <= 2 * n; ++i) {
        char c;
        int x;
        cin >> c >> x;
        pos[c == 'B'][x] = i;
        for (int j = 0; j <= n; ++j) {
            pref[0][i][j] = pref[0][i - 1][j];
            pref[1][i][j] = pref[1][i - 1][j];
        }
        for (int j = x; j <= n; ++j) {
            ++pref[c == 'B'][i][j];
        }
        v.pb({c == 'B', x});
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j] = INF;
        }
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i == j && i == 0) {
                dp[i][j] = 0;
                continue;
            }
            int ind = i + j;
            if (i != 0) {
                int kek = pos[0][i];
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + pref[0][kek][n] - pref[0][kek][i] + pref[1][kek][n] - pref[1][kek][j]);
            }
            if (j != 0) {
                int kek = pos[1][j];
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + pref[0][kek][n] - pref[0][kek][i] + pref[1][kek][n] - pref[1][kek][j]);
            }
        }
    }
    cout << dp[n][n];
}


Measured memory_bytes: 157440
N = gets.to_i
Blues = []
N.times { Blues << gets.strip }
M = gets.to_i
Reds = []
M.times { Reds << gets.strip }
results = Hash.new

Blues.each do |blue|
  if results[blue].nil?
    results[blue] = 1
  else
    results[blue] += 1
  end
end
Reds.each do |red|
  if results[red].nil?
    results[red] = -1
  else
    results[red] -= 1
  end
end
answer = results.max_by { |k, v| v }
puts answer[1] < 0 ? 0 : answer[1]

Measured memory_bytes: 1788
#include<set>
#include<iostream>
#include<string>

using namespace std;

int main ()
{
	set<string> dictionary;
	string command;
	string word;
	int n,i;

	cin>>n;

	for(i=0;i<n;i++){
		if(cin>>command&&command=="insert"){
			cin>>word;
			dictionary.insert(word);
		} else{
			cin>>word;
			if(dictionary.count(word)){
				cout<<"yes"<<endl;
			} else {
				cout<<"no"<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 32568
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void) {
	int R[MAX], n;
	
	cin >> n;
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1; i<n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 3856
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	string a[3];
	int index[3] = {0, 0, 0};
	
	FOR1(3){
		cin >> a[i];
	}
	int player = 0;
	while(!a[player].empty()){
		char tmp = a[player][0];
		a[player].erase(a[player].begin());
		player = (int)(tmp - 'a');
	}
	printf("%c", (char)(player+65));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n;
int a[N], dp[N];

int f(int idx) {
    if(idx > n) return INF;
    if(idx == n) return 0;
    int &sol = dp[idx];
    if(sol != -1) return sol;
    return sol = min(f(idx + 1) + abs(a[idx] - a[idx + 1]), 
                     f(idx + 2) + abs(a[idx] - a[idx + 2]));
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1) << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 7532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

inline ll lcm(ll x, ll y)
{
    if(x==0) return y;
    if(y==0) return x;
    return x/__gcd(x,y)*y;
}

struct LCMSegTree{
    int n; vector<ll> dat;
    //?????????
    LCMSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
    }
    //k??????(0-indexed)?????????a????????´
    void update(int k, ll a){
        k+=n-1;
        dat[k]=a;
        //??´??°
        while(k>0){
            k=(k-1)/2;
            dat[k]=lcm(dat[2*k+1],dat[2*k+2]);
        }
    }
    //?????¨??????????????????????????¨???
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return 0;

        if(a<=l && r<=b) return dat[k];

        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return lcm(vl,vr);
    }
    //[a,b)???LCM????±???????
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

const int mod=1e9+7;
const int N=100000;

int cycle[N];
int val[N][40];
int pre[N][40]={};

vector<int> sum[41][41];
vector<int> idx[41];

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

    vector<int> p(n);
    rep(i,n)
    {
        scanf(" %d", &p[i]);
        --p[i];
    }

    rep(i,41)rep(j,41) sum[i][j].pb(0);
    rep(i,41) idx[i].pb(-1);

    LCMSegTree st(n);
    rep(i,n)
    {
        int now = p[i];
        cycle[i] = 1;
        while(1)
        {
            val[i][cycle[i]-1] = now+1;
            if(now == i) break;

            now = p[now];
            ++cycle[i];
        }

        st.update(i,cycle[i]);

        pre[i][0] = val[i][0];
        for(int j=1; j<cycle[i]; ++j) pre[i][j] = pre[i][j-1]+val[i][j];

        sum[cycle[i]][0].pb(0);
        rep(j,cycle[i]) sum[cycle[i]][j+1].pb(pre[i][j]);
        idx[cycle[i]].pb(i);
    }

    rep(i,41)rep(j,41)
    {
        int SZ = sum[i][j].size();
        rep(k,SZ-1) (sum[i][j][k+1] += sum[i][j][k])%=mod;
    }

    while(Q--)
    {
        int l,r;
        scanf(" %d %d", &l, &r);
        --l;
        --r;

        // ??¨???
        ll c = st.query(l, r+1);
        ll ans = 0;
        for(int i=1; i<=40; ++i)
        {
            int lidx = lower_bound(all(idx[i]),l) - idx[i].begin() - 1;
            int ridx = upper_bound(all(idx[i]),r) - idx[i].begin() - 1;

            ll q=c/i;
            q%=mod;
            (ans+=q*(sum[i][i][ridx]-sum[i][i][lidx]+mod)%mod)%=mod;

            ll rem=c%i;
            (ans+=(sum[i][rem][ridx]-sum[i][rem][lidx]+mod)%mod)%=mod;
        }

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

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

ll lcm(ll a, ll b) {
    return a/gcd(a,b)*b;
}

int main(){
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    Rep(i,(1<<n)-1) {
        bitset<20> b(i);
        ll l = 1;
        rep(j,n) {
            if(b[j]) l = lcm(l, a[j]);
        }
        bool ok = true;
        rep(j,n) {
            if(!b[j] && l % a[j] == 0) ok = false; 
        }
        ans += ok;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
package main

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

func main() {
  n,m := NextInts()
  id := make([]int,n+2)
  for i:=0;i<m;i++ {
    l,r := NextInts()
    id[l]++
    id[r+1]--
  }
  for i:=1;i<n+2;i++ { id[i] += id[i-1] }
  c := 0
  for i:=1;i<n+1;i++ {
    if id[i] == m { c++ }
  }
  fmt.Println(c)
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInts() (int,int) {
  s := strings.Split(NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll nCr(ll n,ll r){
	ll x=1,y=1;
	rep(i,r){
		x=x*(n-i)%mod;
		y=y*(i+1)%mod;
	}
	return x*powmod(y,mod-2)%mod;
}

int main()
{
	ll n,k;
	cin >> n >> k;
	for(ll i=1;i<=k;i++){
		cout << nCr(n-k+1,i)*nCr(k-1,i-1)%mod << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using pii = pair<int, int>;

signed main() {
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    map<int, vector<pii>> pos[2];
    vector<vector<bool>> ok[2];
    ok[0].assign(n, vector<bool>(n, false));
    ok[1].assign(n, vector<bool>(n, false));
    vector<bool> skip_row[2];
    skip_row[0].assign(n, false);
    skip_row[1].assign(n, false);
    vector<bool> skip_col[2];
    skip_col[0].assign(n, false);
    skip_col[1].assign(n, false);
    vector<bool> skip_d[2];    
    skip_d[0].assign(2, false);
    skip_d[1].assign(2, false);

    int fin[2] = {};
    rep(k, 0, 2) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                int x;
                cin >> x;
                pos[k][x].push_back({i, j});
            }
        }
    }
    
    vector<int> card(m);
    rep(i, 0, m) {
        cin >> card[i];
    }

    auto check_row = [&](vector<vector<bool>> &ok, int r) {
        bool f = true;
        rep(i, 0, n) {
            if (!ok[r][i]) f = false;
        }
        return f;
    };
    auto check_col = [&](vector<vector<bool>> &ok, int c) {
        bool f = true;
        rep(i, 0, n) {
            if (!ok[i][c]) f = false;
        }
        return f;
    };
    auto check_d = [&](vector<vector<bool>> &ok, int p) {
        bool f = true;
        if (p) {
            rep(i, 0, n) {
                if (!ok[i][i]) {
                    f = false;
                }
            }
        } else {
            rep(i, 0, n) {
                if (!ok[i][n - i - 1]) {
                    f = false;
                }
            }
        }
        return f;
    };


    int ans = -1;
    rep(i, 0, m) {
        rep(k, 0, 2) {
            for (pii p : pos[k][card[i]]) {
                int y, x;
                tie(y, x) = p;
                ok[k][y][x] = true;
                if (!skip_row[k][y] && check_row(ok[k], y)) {
                    skip_row[k][y] = true;
                    fin[k]++;
                }
                if (!skip_col[k][x] && check_col(ok[k], x)) {
                    skip_col[k][x] = true;
                    fin[k]++;
                }
            }
            if (!skip_d[k][0] && check_d(ok[k], 0)) {
                skip_d[k][0] = true;
                fin[k]++;
            }
            if (!skip_d[k][1] && check_d(ok[k], 1)) {
                skip_d[k][1] = true;
                fin[k]++;
            }
            if (n == 1 && fin[k] > 0) fin[k] = 1;
        }

//        cerr << "2: fin1: " << fin1 << ", fin2: " << fin2 << ", card[i]: " << card[i] << endl;
        if (fin[0] >= u && fin[1] >= v) {
            break;
        }
        if (fin[0] >= u) {
            ans = 0;
            break;
        }
        if (fin[1] >= v) {
            ans = 1;
            break;
        }
    }

    if (ans == -1) {
        cout << "DRAW" << endl;
    } else if (ans == 0) {
        cout << "USAGI" << endl;
    } else {
        cout << "NEKO" << endl;
    }
    return 0;
}



Measured memory_bytes: 36596
#include<stdio.h>

int main(int argc, char const *argv[]){
	long long n,t,now,ans=0,i,ti;
	scanf("%lld %lld",&n,&t);
	scanf("%lld",&now);
	ans+=t;
	for(i=1;i<n;i++){
		scanf("%lld",&ti);
		if(ti-now>=t) ans+=t;
		else ans+=ti-now;
		now=ti;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
    for(int i=1;i<=5;i++)
        cin>>a[i];
    int ans=1e9;
    while(1)
    {
        int res=0;
        for(int i=1;i<=5;i++)
        {
            if(i==5) res+=a[i];
            else
            {
                if(a[i]%10)
                    res+=(a[i]/10+1)*10;
                else res+=a[i];
            }
        }
        ans=min(ans,res);
        if(!next_permutation(a+1,a+1+5)) break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n , mod , now , ans , base = 1;
string s;
map<int , int>vis;
signed main()
{
	cin >> n >> mod >> s ;
	if(mod == 2 || mod == 5)
	{
		for(int i = 0 ; i < n ; i ++)
		{
			int x = s[i] - '0';
			if(x % mod == 0) ans += i + 1 ;
		}
		return cout << ans << '\n' , 0;
	}
	reverse(s.begin() , s.end()) , vis[0] = 1;	
	for(auto i : s)
	{
		int x = i - '0';
		now = (now + x * base) % mod;
		ans += vis[now]; 
		vis[now] ++ , base *= 10 , base %= mod;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <stdio.h>
using namespace std;

int N,A[310];
double dp[310][310][310];

double rec(int i,int j,int k){
	if(dp[i][j][k]!=-1) return dp[i][j][k];
	double n = i+j+k;
	dp[i][j][k] = 1.0*N/(i+j+k);
	if(i!=0) dp[i][j][k] += rec(i-1,j,k)*i/n;
	if(j!=0) dp[i][j][k] += rec(i+1,j-1,k)*j/n;
	if(k!=0) dp[i][j][k] += rec(i,j+1,k-1)*k/n;
	return dp[i][j][k];
}

int main(){
	cin >> N;
	int cnt[4] = {0};
	for(int i=1;i<=N;i++){
		cin >> A[i];
		cnt[A[i]]++;
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N;k++){
				dp[i][j][k] = -1;
			}
		}
	}
	dp[0][0][0] = 0;
	printf("%.10f\n",rec(cnt[1],cnt[2],cnt[3]));
}

Measured memory_bytes: 227584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.nextLine().toCharArray();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if(i % 2 == 0) sb.append(String.valueOf(a[i]));
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 27328
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define LL long long
#define Maxn 1010

int a[Maxn],op[Maxn];
LL s1=0,s2=0;

int main()
{
	int n,st,ed=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i+=2) if(a[i]>0) s1+=a[i];
	for(int i=2;i<=n;i+=2) if(a[i]>0) s2+=a[i];
	if(s1==0&&s2==0)
	{
		int mx=a[1],id=1;
		for(int i=1;i<=n;i++) if(a[i]>mx)
			mx=a[i],id=i;
		printf("%d\n",mx);
		printf("%d\n",n-1);
		for(int i=n;i>id;i--) printf("%d\n",i);
		for(int i=id-1;i>=1;i--) printf("1\n");
	}
	else{
		if(s1>=s2)
		{
			printf("%lld\n",s1);
			st=1;
		}
		else
		{
			printf("%lld\n",s2);
			st=2;
		}
		op[0]=0;
		for(int i=st;i<=n;i+=2) if(a[i]>0) ed=i;
		for(int i=ed;i>=1;i-=2) if(a[i]>0) st=i;
		for(int i=n;i>ed;i--) op[++op[0]]=i;
		for(int i=ed-2;i>=st;i-=2)
		{
			if(a[i]>0) op[++op[0]]=i+1;
			else op[++op[0]]=i;
		}
		for(int i=st-1;i>=1;i--) op[++op[0]]=1;
		printf("%d\n",op[0]);
		for(int i=1;i<=op[0];i++) printf("%d\n",op[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
ll judge(ll b,ll n){
    ll ret=0;
    while(n){
        ret+=n%b;
        n/=b;
    }
    return ret;
}
int main(){
    ll n,s;cin >> n >> s;
    ll k=n-s;
    if(k<0)cout << -1 <<endl,exit(0);
    if(k==0){
        cout << n+1 <<endl;return 0;
    }
    vl div=divisor(k);
    for(auto p:div){
        if(s==judge(p+1,n)){
            cout << p+1 <<endl;
            return 0;
        }
    }
    cout << -1 <<endl;
}

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

int main(void)
{
	char before[32][9] = { 
		"100101", "10011010", "0101", "0001", "110", "01001",
		"10011011", "010000", "0111", "10011000", "0110", "00100",
		"10011001", "10011110", "00101", "111", "10011111", "1000",
		"00110", "00111", "10011100", "10011101", "000010",
		"10010010", "10010011", "10010000", "101", "000000", "000011",
		"10010001", "010001", "000001"
	};
	char after[32][6] = {
		"00000", "00001", "00010", "00011", "00100", "00101", "00110",
		"00111", "01000", "01001", "01010", "01011", "01100", "01101",
		"01110", "01111", "10000", "10001", "10010", "10011", "10100",
		"10101", "10110", "10111", "11000", "11001", "11010", "11011",
		"11100", "11101", "11110", "11111"
	};
	
	char str[512], str2[2048];
	int i, j, len;
	
	while (fgets(str, 512, stdin) != NULL){
		for (i = 0; i < 128; i++){
			str2[i] = '\0';
		}
		
		i = 0;
		while (str[i] != '\0'){
			if (str[i] >= 'A' && str[i] <= 'Z'){
				strcat(str2, before[str[i] - 'A']);
			}
			switch (str[i]){
				case ' ':
				strcat(str2, before[26]);
				break;
				
				case '\'':
				strcat(str2, before[27]);
				break;
				
				case ',':
				strcat(str2, before[28]);
				break;
				
				case '-':
				strcat(str2, before[29]);
				break;
				
				case '.':
				strcat(str2, before[30]);
				break;
				
				case '?':
				strcat(str2, before[31]);
				break;
			}
			i++;
		}
		
		len = strlen(str2);
		while (len % 5 != 0){
			strcat(str2, "0");
			len++;
		}
		
		i = 0;
		while (len - i > 0){
			for (j = 0; j < 32; j++){
				if (strncmp(&str2[i], after[j], 5) == 0){
					if (j >= 0 && j <= 25){
						printf("%c", j + 'A');
					}
					else {
						switch (j){
							case 26:
							printf(" ");
							break;
							
							case 27:
							printf(".");
							break;
							
							case 28:
							printf(",");
							break;
							
							case 29:
							printf("-");
							break;
							
							case 30:
							printf("\'");
							break;
							
							case 31:
							printf("?");
							break;
						}
					}
				}
			}
			
			i += 5;
		}
		
		puts("");
	}
	
	return (0);
}

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

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

using namespace std;

int main(){
	string o,e; cin>>o>>e;
	rep(i,o.size()){
		cout<<o[i];
		if(i<e.size()) cout<<e[i];
	}
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 256
def check(a):
    i=0
    j=len(a)-1
    b=True
    while(i<=j):
        if(a[i]!=a[j]):
            return False
        i+=1;
        j-=1
    return b


a=(input())
b=a[:(len(a)-1)//2:]
c=a[(len(a)+2)//2::]
#print(a,b,c)
if(check(a)==True and check(b)==True and check(c)==True):
    print("Yes")
else:
    print("No")
           

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int v = 1; v <= n; v++) {
        ans += (ll)v * (n + 1 - v);
    }
    int u, v;
    rep(i, n - 1) {
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= (ll)u * (n + 1 - v);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592