akhauriyash/Code-Regression huggingface dataset:
n,q=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
px=[0 for i in range(n+1)]
for i in range(q):
    p,x=map(int,input().split())
    px[p]+=x
s=[1]
c=[1]*(n+1)
c[1]=0
while s:
    t=s.pop()
    for i in edge[t]:
        if c[i]:
            c[i]=0
            px[i]+=px[t]
            s.append(i)
print(" ".join(map(str,px[1:])))

Measured memory_bytes: 131496
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    min = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            r = (i * j) % 2019 
            if r < min:
                min = r
    print(min)

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> input(n);

	rep(i, n){
		cin >> input[i];
	}

	int head = input[0];

	REP(i, k, n){
		if(head < input[i]) cout << "Yes" << endl;
		else cout << "No" << endl;

		head = input[i - k + 1];
	}

	return 0;
}

Measured memory_bytes: 3996
//| #######################|
//|  ADARSH SINGH KUSHWAHA |
//| ###################### |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Bahut_tej_gand_faad ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frb(i, a, b) for(ll i = a - 1; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define mp map<ll,ll>
#define mps map<char,ll>
#define v vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define mod 1000000007
#define max 1000001
void solve() {
    string s, t;
    cin >> s;
    cin >> t;
    ll  ans = INT_MAX;
    for (ll i = 0; i <= s.size() - t.size(); i++) {
        ll c = 0;
        for (ll j = 0; j < t.size(); j++) {
            if (s[i + j] != t[j]) {
                c++;
            }
        }
        if (c < ans) {
            ans = c;
        }
    }
    cout << ans << endl;
}
int main() {
    Bahut_tej_gand_faad;
    //int t;
    //cin >> t;
    //while (t--) {
    solve();
    //}
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

const int INF = 1001001001;

bool che(string s) {
	if (s[0] != 'A')return false;
	int c = 0;
	for (int i = 2; i < s.size()-1; i++) {
		if (s[i] == 'C')c++;
	}
	if (c != 1)return false;
	int up = 0;
	rep(i, s.size()) {
		if (s[i] >= 'A' && s[i] <= 'Z')up++;
	}
	if (up != 2)return false;
	return true;
}
int main() {
	string s;
	cin >> s;
	if (che(s))cout << "AC";
	else cout << "WA";
	return 0;
}













Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
if c%b==0:
  y=c//b
else:
  y=c//b+1
if a%d==0:
  n=a//d
else:
  n=a//d+1
if n>=y:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=998244353;
const ll INF=0x3f3f3f3f;

ll dp[MAXn],sum[MAXn];
ii d[MAXn];
ll add(ll x,ll y){
    ll ret = x + y;
    if (ret >= MOD) ret -= MOD;
    return ret;
}
ll sub(ll a,ll b){
    ll ret = a - b;
    if (ret < 0) ret += MOD;
    return ret;
}
int main(){
    IOS();
    ll n,k;
    cin >> n >> k;
    for (int i=0;i<k;++i) {
        cin >> d[i].X >> d[i].Y;
    }
    sort(d,d+k);
    
    dp[1] = 1;
    sum[1] = 1;
    for (int i=2;i<=n;++i) sum[i] = 1;
    for (ll i=2;i<=n;++i) {
        for (ll j=0;j<k;++j) {
            debug(i);
            ll r = i-d[j].X, l = max(0LL,i-d[j].Y-1);
            if (r < 0) break;
            debug(l,r);
            dp[i] = add(dp[i],sub(sum[r],sum[l]));
        }
        sum[i] = add(sum[i-1],dp[i]);
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 6788
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif



int main() {
    int N; cin >> N;
    string S; cin >> S;
    ll Rcount = 0, Gcount = 0, Bcount = 0;
    for(int i = 0; i < N; i++){
        char RGB = S[i];
        if(RGB == 'R'){
            Rcount ++;
        }
        else if(RGB == 'G'){
            Gcount ++;
        }
        else if(RGB == 'B'){
            Bcount ++;
        }
    }
    PRINT(Rcount)
    PRINT(Gcount)
    PRINT(Bcount)

    ll sum = Rcount*Gcount*Bcount;

    for(int i = 0; i < N; i++){
        for(int j = 1; i+j*2 < N; j++){
            char first = S[i];
            char second = S[i+j];
            char third = S[i+j*2];
            if(first != second && second != third && third != first){
                sum --;
                PRINT(first)
                PRINT(second)
                PRINT(third)
                PRINT(i)
                PRINT(j)
            }
        }
    }
   cout << sum << endl;
}


Measured memory_bytes: 3572
program guess_the_number
  implicit none
  integer :: n, m, s, i
  character(1) :: c
  character(3) :: x = "   "
  read(*,*) n, m
  do i = 1, m
    read(*,'(i1,x,a)') s, c
    if (n > 1 .and. s == 1 .and. c == "0") then
      write(*,'(a)') "-1"
      stop
    end if
    if (x(s:s) == " " .or. x(s:s) == c) then
      x(s:s) = c
      cycle
    end if
    write(*,'(a)') "-1"
    stop
  end do
  do i = 1, n
    if (x(i:i) == " ") then
      x(i:i) = "0"
    end if
  end do
  if (n > 1 .and. x(1:1) == "0") x(1:1) = "1"
  write(*,'(a)') trim(x)
end program guess_the_number

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    double d, it, gomi, ans; scanf("%lf", &d);
    gomi = modf(d, &it);
    ans = max(d * sqrt(2), it + 1.0);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if LOCAL_ENVIRONMENT == 1
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  string s = input<string>();
  vector<ll> keta;
  for(ll i=0;i<s.size();i++){
    int k = s[i] - '0';
    keta.push_back(k);
  }

  const int choudo = 0;
  const int ookii = 1;
  
  ll dp[s.size()+1][2];

  dp[0][choudo] = 0;
  dp[0][ookii] = 1;

  for(int i=1;i<s.size()+1;i++){
    dp[i][choudo] = min(dp[i-1][choudo] + keta[i-1], dp[i-1][ookii] + (10 - keta[i-1]));
    if(keta[i-1] + 1 < 10){
      dp[i][ookii] = min(dp[i-1][choudo] + (keta[i-1] + 1), dp[i-1][ookii] + (10 - keta[i-1] - 1));
    }
    else{
      dp[i][ookii] = dp[i - 1][ookii];
    }
  }
  
  output(dp[s.size()][choudo]);

  return 0;
}

Measured memory_bytes: 25588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		string n;
		cin>>n;
		ll sum = 0;
		f(i,n.length()) {
			sum += n[i]-48;
		}
		if(sum%9 ==0 ) cout<<"Yes\n";
		else cout<<"No\n";
 	}
 	return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    double a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    double denom = 0;
    for(int i=0; i<n; i++){
        denom += 1.0/a[i];
    }

    cout << setprecision(20) << 1.0/denom;

    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char ch[100002];
bool p,d;
int a;

int main(){
	scanf("%s",&ch);
	a=strlen(ch);
	for(int i=0;i<=a/2+1;++i)
		if(ch[i]!=ch[a-i-1]){
			p=true;
			break;
		}
	for(int i=0;i<=a/2+1;++i)
				if((ch[i]=='p'&&ch[a-i-1]!='q')||(ch[i]=='q'&&ch[a-i-1]!='p')||(ch[i]=='b'&&ch[a-i-1]!='d')||(ch[i]=='d'&&ch[a-i-1]!='b')){
					d=true;
					break;
				}
	if(p&&d) printf("No");
	else printf("Yes");
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a[3];
    int i;
    FOR0(i, 3) cin>>a[i];
    sort(a, a+3);
    int f = a[1] - a[0];
    int ans = f/2;
    int h = a[2];
    if(f%2!=0){h++; ans++;}
    ans += h - a[1];
    cout<<ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i, N) cin >> a[i];
  int n_1 = 0, n_2 = 0, n_4 = 0;
  rep(i, N) {
    if ( a[i] % 2 == 1 ) n_1++;
    else if (a[i] % 4 == 2) n_2++;
    else n_4++;
  }
  string result;
  if ( n_1 + min(1, n_2) <= n_4 + 1 ) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

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

int main() {
  int P;
  cin >> P;
  vector <int> w(P);
  for (int i = 0; i < P; i++) cin >> w.at(i);
  int ans = 0;
  for (int i = 0; i < P;i++){
    int s1 = 0;
    int s2 = 0;
    for (int j = 0; j < P; j++){
      if (i < j) s1 += w.at(j);
      else s2 += w.at(j);
    }
    int ds = s2-s1;
    if (ds < 0) ds = -ds;
    if (i == 0) ans = ds;
    else if (ans > ds) ans = ds;
    else break;
  }
  cout << ans << endl;
}

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

int main(void){
  string s;
  cin >> s;
  map<char, int> m;

  for(int i = 0; i < s.size(); i ++)
    m[s.at(i)] ++;

  for(char i = 'a'; i <= 'z'; i ++)
    if(m[i] >= 2){
      cout << "no" << endl;
      return 0;
    }

  cout << "yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
int p[1010];
int x[1010];
vector<int> G[1010];
bool f = true;
vector<int> dp(5010), tmp(5010);

P dfs(int now){
    vector<P> d;
    rep(i, 0, G[now].size()){
        P p = dfs(G[now][i]);
        d.push_back(p);
    }
    rep(j, 0, x[now] + 1) tmp[j] = INF;
    rep(i, 0, x[now] + 1) dp[i] = INF;
    dp[0] = 0;
    rep(i, 0, d.size()){
        // cout << " " << d[i].first << ' ' << d[i].second << endl;
        repb(j, x[now], 0){
            if(j + d[i].first <= x[now]) tmp[j + d[i].first] = min(tmp[j + d[i].first], dp[j] + d[i].second);
            if(j + d[i].second <= x[now]) tmp[j + d[i].second] = min(tmp[j + d[i].second], dp[j] + d[i].first);
        }
        swap(tmp, dp);
        rep(j, 0, x[now] + 1) tmp[j] = INF;
    }
    int MIN = INF;
    rep(i, 0, x[now] + 1) chmin(MIN, dp[i]);
    // cout << now << " " << MIN << endl;
    return P{x[now], MIN};
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n){
        cin >> p[i];
        p[i]--;
        G[p[i]].push_back(i);
    }
    rep(i, 0, n){
        cin >> x[i];
    }
    P p = dfs(0);
    // cout << p.first << " " << p.second << endl;
    cout << (p.second == INF ? "IMPOSSIBLE" : "POSSIBLE") << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
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 REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int K,S;
    cin >> K >> S;
    ll ans = 0;
    REP(i,K+1){
        REP(j,K+1){
            if(S-i-j >= 0 && S-i-j <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> to[N];
    rep(i, M){
        int a,b;
        cin >> a >> b;
        to[a-1].push_back(b-1);
        to[b-1].push_back(a-1);
    }

    queue<int> q;
    q.push(0);
    vector<int> pre(N, -1);
    while (!q.empty()){
        int v = q.front(); q.pop();
        for (int i : to[v]) {
            if (pre[i] != -1) continue;
            pre[i] = v;
            q.push(i);
        }
    }

    cout << "Yes" << endl;
    rep(i,N){
       if (i == 0) continue;
       cout << pre[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10168
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int d,n;
    cin>>d>>n;
    int ans=1;
    if(d==1){
        ans*=100;
    }
    if(d==2){
        ans*=10000;
    }
  
  if(n==100){
  	n++;
  }

    cout<<ans*n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	cin >> s;
	sort(ALL(s));
	cout << (s == "abc" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int x = r*100+g*10+b;
    if(x%4==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 19924
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1e9 + 7, MAX = 500000;
long long quickPower(long long a, long long b) {
    long long res = 1;
    while (b) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> f(MAX + 1), inv(MAX + 1);
    f[0] = inv[0] = 1LL;
    for (int i = 1; i <= MAX; i++) {
        f[i] = f[i - 1] * i % MOD;
        inv[i] = quickPower(f[i], MOD - 2);
    }
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        long long tmp = f[n] * inv[i] % MOD * inv[n - i] % MOD * f[m - i] %
                        MOD * inv[m - n] % MOD;
        if (i & 1)
            tmp = -tmp;
        ans = (ans + tmp + MOD) % MOD;
    }
    for (int i = m - n + 1; i <= m; i++)
        ans = ans * i % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11172
N = int(input())
tmp = 'abcdefghijklmnopqrstuvwxyz'
num = 26
ans = []
while N != 0:
    if N%num == 0:
        ans.append(tmp[N%num-1])
        N = N//num - 1
    else:
        ans.append(tmp[N%num-1])
        N = N//num
            
new_list = list(reversed(ans))
print(''.join(new_list))

Measured memory_bytes: 9188
N = int(input())
Sss = [input() for _ in range(N)]
Sss_tr = list(map(''.join, zip(*Sss))) # 転置

ans = 0
for k in range(N):
    for i in range(N):
        if (Sss[i][-k:] + Sss[i][:-k]) != Sss_tr[i - k]:
            break
    else:
        ans += N

print(ans)


Measured memory_bytes: 3188
import heapq


nm = list(map(int, input().split()))
n, m = nm[0], nm[1]

prices = list(map(int, input().split()))

prices = list(map(lambda x: x * -1, prices))

heapq.heapify(prices)

while m > 0:
    top = heapq.heappop(prices)
    discounted = ((top * -1) // 2) * -1
    heapq.heappush(prices, discounted)
    m -= 1


print(sum(list(map(lambda x: x * -1, prices))))


Measured memory_bytes: 14180
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 15;
vector<pair<int,int>> p[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int d;
		cin >> d;
		for(int j=0;j<d;j++) {
			int x, y;
			cin >> x >> y;
			x--;
			p[i].push_back(make_pair(x, y));
		}
	}
	int ans = 0;
	for(int i=0;i<(1<<n);i++) {
		int c = 0;
		bool f = false;
		for(int j=0;j<n;j++) {
			if( (i>>j) & 1 ) {
				c++;
				for(auto x : p[j]) {
					if( x.second != ( (i>>x.first) & 1 ) ) {
						f = true;
						break;
					}
				}
			}
			else continue;
		}
		if(!f) ans=max(ans, c);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
fn run() {
    proconio::input! {
        l: usize,
        r: usize,
    }
    const MOD: u64 = 1_000_000_007;
    let mut dp = [[0u64; 2]; 2];
    dp[0][0] = 0;
    for i in (0..60).rev() {
        let mut next = [[0; 2]; 2];
        if l >> i <= 1 && r >> i >= 1 {
            let a = 1 ^ (l >> i & 1);
            let b = (r >> i > 1) as usize;
            next[a][b] += 1;
        }
        for (a, dp) in dp.iter().enumerate() {
            for (b, &v) in dp.iter().enumerate() {
                for &(x, y) in [(0, 0), (0, 1), (1, 1)].iter() {
                    if a == 0 && l >> i & 1 > x {
                        continue;
                    }
                    if b == 0 && r >> i & 1 < y {
                        continue;
                    }
                    let a = (a == 1 || x > (l >> i) & 1) as usize;
                    let b = (b == 1 || y < (r >> i) & 1) as usize;
                    next[a][b] += v;
                }
            }
        }
        next.iter_mut().flatten().for_each(|p| *p %= MOD);
        dp = next;
    }
    let ans = dp.iter().flatten().sum::<u64>() % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2108
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        a: i64, b: i64, n: i64,
    }
    let x = min(b - 1, n);
    puts!("{}\n", (a * x) / b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2268
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a=1e4,n,t,m,l;
  cin>>n>>t;
  for(int i=0;i<n;i++){
    cin>>m>>l;
    if(l<=t){
      a=min(a,m);
    }
  }
  if(a!=1e4){
    cout<<a<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

ll query(ll pos, vi &st)
{
    int a, b;
    a = lower_bound(ALL(st), pos) - st.begin();
    b = upper_bound(ALL(st), pos) - st.begin() - 1;
    return min(abs(st[a] - pos), abs(st[b] - pos));
}
int main()
{
    int A, B, Q;
    vi s, t, x;
    cin >> A >> B >> Q;
    s.resize(A + 1);
    t.resize(B + 1);
    x.resize(Q);
    s[0] = -INF;
    t[0] = -INF;
    FOR(i, 1, A + 1)
    cin >> s[i];
    FOR(i, 1, B + 1)
    cin >> t[i];
    FOR(i, 0, Q)
    cin >> x[i];
    s.push_back(INF);
    t.push_back(INF);

    int idx;
    ll ans;
    REP(i, Q)
    {
        ans = INF;
        idx = lower_bound(ALL(s), x[i]) - s.begin();
        chmin(ans, abs(x[i] - s[idx]) + query(s[idx], t));

        idx = upper_bound(ALL(s), x[i]) - s.begin() - 1;
        chmin(ans, abs(x[i] - s[idx]) + query(s[idx], t));

        idx = lower_bound(ALL(t), x[i]) - t.begin();
        chmin(ans, abs(x[i] - t[idx]) + query(t[idx], s));

        idx = upper_bound(ALL(t), x[i]) - t.begin() - 1;
        chmin(ans, abs(x[i] - t[idx]) + query(t[idx], s));

        cout << ans << endl;
    }
    //system("pause");
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
using namespace std;
long long a[200010] = {};
vector<char> c;
vector<int> v1,v2,v3;
void add(int i,int j,int k){
    //cout << "+ " << i << " " << j << " " << k << endl;
    c.push_back('+'); v1.push_back(i); v2.push_back(j); v3.push_back(k);
    a[k] = a[i] + a[j];
}

void com(int i,int j,int k){
    //cout << "< " << i << " " << j << " "<< k << endl;
    c.push_back('<'); v1.push_back(i); v2.push_back(j); v3.push_back(k);
    a[k] = a[i]<a[j];
}

void rev(int i){
    //cout << "< " << i << " " << 4 << " " << i << endl;
    com(i,4,i);
}

void mult01(int i,int j,int k){
    add(3,3,100000);
    add(i,j,100000);
    com(4,100000,100000);
    add(k,100000,k);
}

void mult2(int i){
    //cout << "+ " << i << " " << i << " " << i << endl;
    add(i,i,i);
}

void input(){
    long long x,y;
    cin >> x >> y;
    a[0] = x; a[1] = y;
}
int main(){
    int i,j,k;
    add(3,0,3); add(3,1,3); com(4,3,4); com(3,3,3);
    for(i=0;i<=60;i++){
        add(5 + i,4 + i,5 + i); add(5 + i,4 + i,5 + i);
    }
    for(i=30;i>=0;i--){
        add(132,i + 4,132);
        com(0,132,133);
        rev(133);
        add(130 - i,133,130 - i);
        for(j=0;j<i;j++) mult2(133);
        add(131,133,131);
        add(3,131,132);
    }
    for(i=30;i>=0;i--){
        add(232,i + 4,232);
        com(1,232,233);
        rev(233);
        add(230 - i,233,230 - i);
        for(j=0;j<i;j++) mult2(233);
        add(231,233,231);
        add(3,231,232);
    }
    for(i=0;i<=30;i++){
        for(j=0;j<=30;j++){
            mult01(100 + i,200 + j,300 + i + j);
        }
    }
    for(i=0;i<=60;i++){
        add(1000*(i + 1) + 1,4,1000*(i + 1) + 1);
        for(j=2;j<=60;j++){
            add(1000*(i + 1) + j - 1,4,1000*(i + 1) + j);
        }
        int sum1 = 0;
        for(j=0;j<=60;j++){
            com(1000*(i + 1) + j,300 + i,1000*(i + 1) + j);
            sum1 += a[1000*(i + 1) + j];
            for(k=0;k<60 - i;k++) mult2(1000*(i + 1) + j);
            add(2,1000*(i + 1) + j,2);
        }
    }
    cout << c.size() << endl;
    for(i=0;i<c.size();i++){
        cout << c[i] << " " << v1[i] << " " << v2[i] << " " << v3[i] << "\n";
    }
}

Measured memory_bytes: 5292
#include<stdio.h>
#include<math.h>

int main( void ){
	
	int n , a , c = 0;
	int prime = 0; //判定フラグ
	int i , j;
	
	scanf( "%d" , &n );
	
	for( i = 0; i < n; i++ ){
		
		scanf( "%d" , &a );
		
		for( j = 2; j <= sqrt(a); j++ ){
			
			if( a % j == 0 ){
				prime = 1;
				break;
			}
		}
		
		if( prime == 0 ){ c++; }
		else{ prime = 0; }
		
	}
	
	printf( "%d\n" , c );
	
	return 0;
}


Measured memory_bytes: 2056
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: x[1],reverse=True)
# print(a)
# print(bc)
i=0
for b,c in bc:
  tb=b
  while tb>0:
    if n==i:
      break
    if a[i]>=c:
      break
    a[i]=c
    tb-=1
    i+=1
  if n==i:break
  if a[i]>=c :
    break
print(sum(a))

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second


map <int,int> dd;
map <ll,ll> dd1,d1,d2;

bool ck(string s)
{
    string s1;
    FORd(i,s.length()-1,0) s1+=s[i];
    if (s1==s) return true;
    else return false;
}

int main()
{
    string s;
    cin >> s;
    if (ck(s)) {
        int len=s.length(),so=(len+3)/2-1;
        string s1=s.substr(0,(len-1)/2);
        string s2=s.substr(so,len-so);
        if (ck(s1)&&ck(s2)) cout << "Yes";
        else cout << "No";
    }
    else cout << "No";
}


Measured memory_bytes: 256
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
c_l=[]
for i in range(n):
    c_i=l[i][0]
    t_i=l[i][1]
    if t_i<= t:
        c_l.append(c_i)
if len(c_l)==0:
    print("TLE")
else:
    print(min(c_l))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            long temp = Long.parseLong(sc.next());
            a[i] = temp;
        }
        long ans1 = 0;
        long ans2 = 0;
        long temp = 0;
        for (int i = 0; i < n; i++) {
            long num = a[i];
            if (i % 2 == 0 && temp + num >= 0) {
                ans1 += temp + num + 1;
                num -= temp + num + 1;
            }
            if (i % 2 != 0 && temp + num <= 0) {
                ans1 += Math.abs(temp + num - 1);
                num += Math.abs(temp + num - 1);
            }
            temp += num;
        }
        temp = 0;
        for (int i = 0; i < n; i++) {
            long num = a[i];
            if (i % 2 == 0 && temp + num <= 0) {
                ans2 += Math.abs(temp + num - 1);
                num += Math.abs(temp + num - 1);
            }
            if (i % 2 != 0 && temp + num >= 0) {
                ans2 += temp + num + 1;
                num -= temp + num + 1;
            }
            temp += num;
        }
        System.out.println(Math.min(ans1, ans2));
    }
}

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

using namespace std;

int N;

int main(int argc, char *argv[]) {
	cin >> N;
	vector<int> a, b;

	for (int i = 0; i < N; i++) {
		int ai;
		cin >> ai;
		a.push_back(ai);
	}

	for (int i = 0; i < N; i++) {
		int bi;
		cin >> bi;
		b.push_back(bi);
	}

	int ans = 0;
	for (int k = 30; k >= 0; k--) {
		int T = 1 << k;
		long cnt = 0;

		sort(begin(b), end(b));

		for (int i = 0; i < N; i++) {
			int x = lower_bound(begin(b), end(b), 2 * T - a[i]) - lower_bound(begin(b), end(b), T - a[i]);
			int y = lower_bound(begin(b), end(b), 4 * T - a[i]) - lower_bound(begin(b), end(b), 3 * T - a[i]);
			cnt += x + y;
		}

		for (int i = 0; i < N; i++) {
			a[i] &= ~T;
			b[i] &= ~T;
		}

		if (cnt % 2 == 1) {
			ans |= T;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

vector<string> id;
map<bool, string> st;
bool isOpen = false;

void solve(string t) {
  if(find(id.begin(), id.end(), t) != id.end()) {
    isOpen = !isOpen;
    cout << st[isOpen] << t << endl;
  }
  else {
    cout << "Unknown " << t << endl;
  }
}

int main() {
  int n, m;
  string buf;
  st.insert(make_pair(true, "Opened by "));
  st.insert(make_pair(false, "Closed by "));
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> buf;
    id.push_back(buf);
  }
  cin >> m;
  for(int i = 0; i < m; ++i) {
    cin >> buf;
    solve(buf);
  }
  return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const int INFTY = (1 << 30);
ll N, M;
void func()
{
    ll X, tmp;
    cin >> X;
    tmp = X * 360 / gcd(X, 360);
    cout << tmp / X << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		int n = cin.nextInt();
		int[][] abs = new int[n - 1][];
		for (int i = 0; i < abs.length; i++)
			abs[i] = new int[] { cin.nextInt(), cin.nextInt() };

		String ans = solve(n, abs);
		cout.println(ans);
	}

	private static String solve(int n, int[][] abs) {
		// Fennecの最善手：1からNに最短距離で向かう
		// Snukeの最善手：Nから1に最短距離で向かう

		TreeSet<int[]> tmap = new TreeSet<>(Comparator.comparingLong((ab) -> (long) ab[0] * Integer.MAX_VALUE + ab[1]));
		for (int[] ab : abs) {
			tmap.add(ab);
			tmap.add(new int[] { ab[1], ab[0] });
		}

		// ダイクストラ法
		PriorityQueue<int[]> q = new PriorityQueue<>((dhc1, dhc2) -> {
			int cmp;
			cmp = Integer.compare(dhc1[0], dhc2[0]);
			if (cmp != 0)
				return cmp;
			return Integer.compare(dhc1[2], dhc2[2]);
		});
		int[] paint = new int[n + 1];
		Arrays.fill(paint, -1);
		final int FENNEC = 0;
		final int SUNUKE = 1;
		q.add(new int[] { 0, 1, FENNEC });
		q.add(new int[] { 0, n, SUNUKE });
		while (!q.isEmpty()) {
			int[] arr = q.poll();
			int dist = arr[0];
			int here = arr[1];
			int color = arr[2];
			if (paint[here] != -1)
				continue;
			paint[here] = color;
			for (int[] edge : tmap.subSet(new int[] { here, 0 }, new int[] { here + 1, 0 })) {
				int to = edge[1];
				if (paint[to] != -1)
					continue;
				q.add(new int[] { dist + 1, to, color });
			}
		}

		long fennec = Arrays.stream(paint).filter(p -> p == FENNEC).count();
		long sunuke = Arrays.stream(paint).filter(p -> p == SUNUKE).count();
		if (fennec > sunuke)
			return "Fennec";
		return "Snuke";
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

}


Measured memory_bytes: 61208
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        for(int i = 1; i < n+1; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        int[] b = new int[n+1];
        
        countingSort(a, b, 10000);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 1; i < n+1; i++){
            sb.append(b[i]).append(" ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);
    }
    
    static void countingSort(int[] a, int[] b, int k){
        
        int[] c = new int[k+1];
        
        for(int j = 1; j < a.length; j++){
            c[a[j]]++;
        }
        
        for(int i = 1; i <= k; i++){
            c[i] = c[i] + c[i-1];
        }
        
        for(int j = a.length-1; j > 0; j--){
            b[c[a[j]]] = a[j];
            c[a[j]]--;
        }
    }
}


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

// simple recursion
int rec(int n, int k, int s)
{
  if(s < 0) return 0;  // no answer
  if(k > n) return 0;  // less elements remain
  if(k == 0) return s == 0 ? 1 : 0; // 0 by 0?
  // using n, or not using n
  return rec(n-1, k-1, s-n) + rec(n-1, k, s);
}
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      cnt = rec(n, k, s);
    }
    cout << cnt << endl;
  }
  return 0;
}



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

int main(){
  int n;
  string s;
  cin>> n >> s;
  
  int ans=1;
  for (int i=0; i<n-1; i++){
    if (s[i]!=s[i+1]) ans++;
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[1]=='R')
    cout<<"ABC"<<endl;
    else
    cout<<"ARC"<<endl;
 return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

    private static String toString(int[] numbers){
        StringBuilder ans = new StringBuilder().append(numbers[0]);
        for (int x = 1; x < numbers.length; x++)
            ans.append(" ").append(numbers[x]);
        return ans.toString();
    }

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

        int n = sc.nextInt();
        int[] A = new int[n];

        // stores all numbers in the array A
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
         /**
        int n = 6;
        int[] A = new int[]{5,6,4,2,1,3};
         */
        int count = 0; // the number of swap operations.
        for (int i = 0; i < n; i++) {
            int mini = i;
            for (int j = i; j < n; j++)
                if (A[j] < A[mini])
                    mini = j;
            // swap operation
            if(mini != i) {
                int temp = A[i];
                A[i] = A[mini];
                A[mini] = temp;
                count++;
            }
        }
        System.out.println(toString(A));
        System.out.println(count);
    }

}



Measured memory_bytes: 26280
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;

int N, M, L;

struct Edge {
	int to, cost, enemy;
	Edge(int _t, int _c, int _e) : to(_t), cost(_c), enemy(_e) {}
};
bool operator > (const Edge& e1, const Edge& e2) {
	if (e1.enemy > e2.enemy) return true;
	else if (e1.to > e2.to) return true;
	return e1.cost > e2.cost;
}
bool operator == (const Edge& e1, const Edge& e2) {
	if (e1.enemy == e2.enemy && e1.to==e2.to && e1.cost == e2.cost) return true;
	return false;
}
bool operator != (const Edge& e1, const Edge& e2) { return !(e1 == e2); }
bool operator < (const Edge& e1, const Edge& e2) { return !(e1 > e2) && (e1 != e2); }
bool operator >= (const Edge& e1, const Edge& e2) { return (e1 > e2) || (e1 == e2); }
bool operator <= (const Edge& e1, const Edge& e2) { return (e1 < e2) || (e1 == e2); }

const int INF = 1e9;
int d[110][110];

int main() {
	while (1) {
		cin >> N >> M >> L; if (N==0 && M==0 && L==0) break;
		vector< vector<Edge> > G(N+1, vector<Edge>());
		
		for (int i=0; i<M; i++) {
			int a, b, d, e; cin >> a >> b >> d >> e;
			G[a].push_back(Edge(b, d, e));
			G[b].push_back(Edge(a, d, e));
		}
		
		for (int i=0; i<=N; i++) fill(d[i], d[i] + L + 1, INF);
		
		d[1][0] = 0;
		
		priority_queue<Edge, vector<Edge>, greater<Edge> > q;
		q.push( Edge(1, 0, 0) );
		
		while (!q.empty()) {
			Edge e = q.top(); q.pop();
			
			for (int i=0; i<(int)G[e.to].size(); i++) {
				Edge ne = G[e.to][i];
				
				if (e.cost + ne.cost <= L) {
					if (d[ne.to][e.cost + ne.cost] > e.enemy) {
						d[ne.to][e.cost + ne.cost] = e.enemy;
						q.push(Edge(ne.to, e.cost + ne.cost, e.enemy));
					}
				}
				
				if (d[ne.to][e.cost] > e.enemy + ne.enemy) {
					d[ne.to][e.cost] = e.enemy + ne.enemy;
					q.push(Edge(ne.to, e.cost, e.enemy + ne.enemy));
				}
			}
		}
		
		int ans = INF;
		for (int i=0; i<=L; i++) ans = min(ans, d[N][i]);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2004
#include <stdio.h>
#include <stdlib.h>
#define MAX 199
void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int x);
int pop(void);
int top;
int S[MAX];
int main(){
  int y1,y2;
  char x[100];
  initialize();
  while(scanf("%s",x)!=EOF){
    if ( x[0] == '+' ){
      y1=pop();
      y2=pop();
      push(y1+y2);
    } else if ( x[0] == '-' ){
      y2=pop();
      y1=pop();
      push(y1-y2);
      
    } else if( x[0] == '*' ){
      y1=pop();
      y2=pop();
      push(y1*y2);
    }
    else {
      y1=atoi(x);
      push(y1);
    }
  }
  printf("%d\n",pop());
  return 0;
}
void initialize(void){
  top=0;
}

int isEmpty(void){
  if(top==0) return 1;
  else return 0;
}
int isFull(void){
  if(top>=MAX-1) return 1;
  return 0;
}
void push(int x){
  
  if(isFull()==1){
    fprintf(stderr,"??¨??????????????????????????????)\n");
    exit(1);
    }
  top++;
  S[top]=x;
}
int pop(void){
  
  if(isEmpty()==1){
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
    return 0;
    }
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=a[0];
    rep(i,n) res=gcd(res,a[i]);
    cout<<res<<endl;
}

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    string s;
    cin >> s;
    int n = s.length();
    int count = 0;
    for(int i = 0; i< n; i++){
        if(s[i] == 'x') count++;
    }
    if(count <= 7) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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


int main() {
  int N;
  cin>>N;
  vector<string> S(N);
  rep(i,N){
      cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  int mx=0,count=1;
  vector<pair<string,int>> num(0);
  
  for(int i=1;i<N;i++){
      if(S.at(i)==S.at(i-1)){
          count++;
      }
      else{
          num.push_back(make_pair(S.at(i-1),count));
          count=1;
      }
  }
  num.push_back(make_pair(S.at(N-1),count));
  int var=num.size();
  rep(i,var){
      mx=max(mx,num.at(i).second);
  }
  rep(i,var){
      if(num.at(i).second==mx){
          cout<<num.at(i).first<<endl;
      }
  }

  //test
  /*rep(i,var){
      cout<<num.at(i).first<<" "<<num.at(i).second<<endl;
  }*/
}

Measured memory_bytes: 17908