akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;
int n, w;

pi items[100];
ll memo[100][100000];
ll dp(int i, ll c)
{
	ll result;
	if(i < 0)
		result = 0;
	else if(memo[i][c] != 0)
		result = memo[i][c];
	else
	{
		int weight = items[i].first;
		int value = items[i].second;
		ll best = dp(i-1, c);
		if(c+weight <= w)
			best = max(best, value + dp(i-1, c+weight));
		memo[i][c] = best;
		result = best;
	}
	return result;
}

int main()
{
	cin >> n >> w;
	for(int i = 0; i < n; i++)
	{
		pi pa;
		cin >> pa.first >> pa.second;
		items[i] = pa;
	}
	cout << dp(n-1, 0LL) << endl;
}


Measured memory_bytes: 74892
# 2020/05/05
# AtCoder Beginner Contest 157 - C

# Input - Line1
n, m = map(int,input().split())
sclist = list()

for i in range(m):
    sc = list(map(int,input().split()))
    sclist.append(sc)
    
sclist.sort()

savs = -1
savc = -1
ans = -2
keta = [-1] * 4
for i in range(m):
    # 2桁以上で1桁目がゼロのケースを-1
    if n > 1 and sclist[i][1] == 0 and sclist[i][0] < 3 - (3-n) and savs == -1:
        ans = -1
        break

    # 同じ桁に対して異なる値の場合は-1
    if savs == sclist[i][0] and savc != sclist[i][1]:
        ans = -1
        break
    savs = sclist[i][0]
    savc = sclist[i][1]
    keta[sclist[i][0]] = sclist[i][1]

strval = ''
if ans != -1:
    for i in range(1, 4-(3-n)):
        if keta[i] == -1:
            strval = strval + '0'
        else:
            strval = strval + str(keta[i])
    ans = int(strval)

    if n == 3 and ans < 100:
        ans = ans + 100
    elif n == 2 and ans < 10:
        ans = ans + 10

# Output
print(ans)


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

const int ALPHABET = 26; // アルファベットの文字数
int main() {
	int N;
	string S;
	cin >> N >> S;
	int alphabet[2][ALPHABET];
	for (int i = 0;i < 2;++ i) for (int j = 0;j < ALPHABET;++ j) alphabet[i][j] = 0;
	for (int i = 0;i < N;++ i) ++ alphabet[0][S[i] - 'a'];
	int tmp = 0, ans = 0;
	for (int i = 0;i < N;++ i) {
		++ alphabet[1][S[i] - 'a'];
		if (alphabet[1][S[i] - 'a'] == 1) ++ tmp;
		if (alphabet[0][S[i] - 'a'] == alphabet[1][S[i] - 'a']) -- tmp;
		ans = max(ans, tmp);
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

切断点を1個ずらしたとき、種類数は高々1個しか変化しないことを利用する
*/

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string num;
	cin >> num;

	int sz = num.size();

	long long sum = 0;
	for (int i = 0; i < (1 << (sz - 1)); ++i) {
		vector<int> plus_pos;
		for (int j = 0; j < sz - 1; ++j) {
			if (i & (1 << j)) {
				plus_pos.push_back(j);
			}
		}

		if (plus_pos.size()) {
			sum += stol(num.substr(0, plus_pos[0] + 1));
			sum += stol(num.substr(*plus_pos.rbegin() + 1, num.size() - *plus_pos.rbegin() - 1));
		} else {
			sum += stol(num);
		}

		for (int j = 1; j < (int) plus_pos.size(); ++j) {
			sum += stol(num.substr(plus_pos[j - 1] + 1, plus_pos[j] - plus_pos[j - 1]));
		}
	}

	cout << sum << "\n";

	return 0;

}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


const int maxn = 20;
int x, y, z;
int dp[2][1<<maxn] = {0};
int f = 0;
const int mod = 1e9+7;
inline void add(int &a, int b)
{
  a += b;
  if (a >= mod)
    a %= mod;
}
int n;
int mask;
bool work[1<<maxn] = {0};
int main()
{
  scanf("%d", &n);
  scanf("%d %d %d", &x, &y, &z);
  int bit = ((((1<<x)+1)<<y)+1)<<(z-1);
  mask = (1<<(x+y+z))-1;
  for (int i = 0; i <= mask; ++i)
    {
      work[i] = true;
      int tmp = i;
      while (tmp)
	{
	  if ((tmp&bit)==bit)
	    {
	      work[i] = false;
	      break;
	    }
	  tmp >>= 1;
	}
    }
  f = 0;
  dp[f][0] = 1;
  for (int i = 0; i < n; ++i)
    {
      f ^= 1;
      memset(dp[f], 0, (mask+1)*sizeof(int));
      for (int j = 0; j <= mask; ++j)
	if (work[j])
	  for (int d = 1; d <= 10; ++d)
	    {
	      int nxt = ((j<<1)|1)<<(d-1);
	      nxt &= mask;
	      if (work[nxt])
		add(dp[f][nxt], dp[f^1][j]);
	    }
    }
  int ans = 0;
  for (int i = 0; i <= mask; ++i)
    add(ans, dp[f][i]);
  ll tot = 1;
  for (int i = 0; i < n; ++i)
    tot = tot * 10 % mod;
  tot -= ans;
  tot %= mod;
  if (tot < 0)
    tot += mod;
  ans = tot;
  printf("%d\n", ans);
  
    
      
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	int sum, rem, mul;

	sum = a + b;
	rem = a - b;
	mul = a * b;

	int m;
	m = max(sum, rem);
	m = max(m, mul);

	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n , m , bomb[55][55] = {};
    char c;
    cin >> n >> m;
    
    for(int i=1 ;i<=n ;i++ ){
        for(int j=1 ;j<=m ;j++ ){
            cin >> c;
            if(c == '#'){
                bomb[i][j] = -100;
            }
        }
    }
    
    for(int i=1 ;i<=n ;i++ ){
        for(int j=1 ;j<=m ;j++ ){
            if(bomb[i][j] < 0){
                for(int k=-1 ;k<=1 ;k++ ){
                    for(int l=-1 ;l<=1 ;l++ ){
                        bomb[i+k][j+l]++;
                    }
                }
            }
        }
    }
    
    for(int i=1 ;i<=n ;i++ ){
        for(int j=1 ;j<=m ;j++ ){
            if(bomb[i][j] < 0){
                cout << '#';
            } else {
                cout << bomb[i][j];
            }
        }
        cout << endl;
    }
   
    return(0);
}

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

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e15;
const int mod=1e9+7;
const int M=100005;
vector<pi>adj[M];
vector<int>Dijkstra(int root)
{
    vector<int>di(M,1e18+7);
    vector<bool>done(M);
    di[root]=0;
    priority_queue<pi,vector<pi>,greater<pi> >q;
    q.push(mp(0,root));
    while(q.size())
    {
        int u=q.top().si;
        int w=q.top().fi;
        q.pop();
        if(done[u])continue;
        done[u]=1;
        for(pi x:adj[u])
        {
            int nw=x.si+w;
            int v=x.fi;
            if(di[v]<=nw)continue;
            di[v]=nw;
            q.push(pi(di[v],v));
        }
    }
    return di;
}
int val[M];
 main()

{
    fast
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    int u[m+2],v[m+2],b[m+2];
    f(i,1,m)
    {
        int a;
        cin>>u[i]>>v[i]>>a>>b[i];
        adj[u[i]].pb(mp(v[i],a));
        adj[v[i]].pb(mp(u[i],a));
    }
   vector<int>dy=Dijkstra(s);
   f(i,1,n)adj[i].clear();
   f(i,1,m)
   {
       int a=b[i];
       adj[u[i]].pb(mp(v[i],a));
       adj[v[i]].pb(mp(u[i],a));
   }
   vector<int>ds=Dijkstra(t);
   set<pi>yo;
   f(i,1,n)
   {
       int x=dy[i];
       int y=ds[i];
       int z=x+y;
       val[i]=z;
       yo.insert(mp(z,i));
   }
   f(i,0,n-1)
   {
       if(i!=0)
       {
           yo.erase(mp(val[i],i));
       }
       int cost=yo.begin()->fi;
       cost=inf-cost;
       cout<<cost<<"\n";
   }
    return 0;

}





































Measured memory_bytes: 21580
import math

N =int(input())
r = 10 ** 9 + 7
num_lis = [2]

for i in range(N+1):
    for j in range(2,i):
        if i % j == 0:
            break
        elif j == i - 1:
            num_lis.append(i)

num_lis2 = [0] * len(num_lis)

tmp1 = 1
tmp2 = 0
for i in range(len(num_lis)):
    count = 0
    tmp1 = 1
    tmp2 = num_lis[i]
    while tmp2 ** tmp1 <= N:
        tmp3 = tmp2 ** tmp1
        count += int(math.floor(N / tmp3))
        tmp1 += 1
    num_lis2[i] = count

Ans = 1
for i in range(len(num_lis2)):
    Ans = Ans * (num_lis2[i] + 1)
    Ans = Ans % r

print(Ans)


Measured memory_bytes: 3064
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const int md=1e8;
  const ll MAX=1e6;
  //
  //
  	void solve(){
  		ll n,sm1=0,sm2=0;
  		cin>>n;
  		int arr[n];
  		rep(i,0,n){
  			cin>>arr[i];
  			sm1+=arr[i];
  		}
  		ll ans=MAX;
  		rep(i,0,n){
  			ans=min(ans,abs(sm1-sm2));
  			sm1-=arr[i];
  			sm2+=arr[i];
  		}
  		cout<<ans;
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long D = sc.nextLong();
		long T = sc.nextLong();
		long S = sc.nextLong();
		if((S*T)>=D){
		    System.out.println("Yes");
		}
		else{
		    System.out.println("No");
		}
	}
}

Measured memory_bytes: 35772
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1e9+7;
#define N 505
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,cnt[N],ans,fac[N],inv[N];
int dp[2][N][N]; // 区间长度到i，区间个数j，区间长度和 k。 
inline int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
inline int C(int n,int m){
	return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i){
		++cnt[read()];
	}
	init(m);
	dp[(m+1)&1][0][0]=1;
	for(int i=m;i>=1;--i){
		memset(dp[i&1],0,sizeof(dp[i&1]));
		for(int j=0;j<=m/i;++j){
			for(int k=j;k<=m;++k){
				if(!dp[(i+1)&1][j][k])continue;
				int lim=min((m-k)/i,m-j);
				for(int p=0;p<=lim;++p){
					dp[i&1][j+p][k+p*i]=(dp[i&1][j+p][k+p*i]+1LL*dp[(i+1)&1][j][k]*inv[p])%mod;
				}
			}
		}
		for(int j=0;j<=m;++j){
			for(int k=j*(i-1);k<=m;++k){
				dp[i&1][j][k]=1LL*dp[i&1][j][k]*qpow(k-j*(i-1),cnt[i])%mod;
			}
		}
	}
	for(int j=0;j<=m;++j){
		for(int k=0;k<=m;++k){
			ans=(ans+1LL*fac[j]*dp[1][j][k]%mod*C(m-k+1,j)*((m-k)&1?-1:1))%mod;
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}



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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)>abs(x-b))
    cout << "B" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
sun = 0
ans1 = 0
for i in range(n):
  if i == 0:
    SUN = 1
  else:
    SUN = sun
  now = a[i]
  if SUN * (sun+now) >= 0:
    ans1 += abs(sun+now) + 1
    if SUN > 0:
      sun = -1
    else:
      sun = 1
  else:
    sun += now
sun = 0
ans2 = 0
for i in range(n):
  now = a[i]
  if i == 0:
    SUN = -1
  else:
    SUN = sun
  if SUN * (sun+now) >= 0:
    ans2 += abs(sun+now) + 1
    if SUN > 0:
      sun = -1
    else:
      sun = 1
  else:
    sun += now
#print(ans1,ans2)
print(min(ans1,ans2))

Measured memory_bytes: 14468
#include<stdio.h>
int main()
{
    int x,y,z;
     
    for(;scanf("%d %d",&x,&y);)
    {
        if(x==0 && y==0)
        break;
        else if(x>y)
      {  z=x;
        x=y;
        y=z;
         }
         
        printf("%d %d\n",x,y);
    }
     
    return 0;
}


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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

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

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	ll N, x;
	cin >> N >> x;
	vll a(N);
	cin >> a;

	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i] + a[i + 1] - x;
			a[i + 1] -= min(a[i] + a[i + 1] - x, a[i + 1]);
		}
	}

	say(ans);

	return 0;
}

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

int main(){
    int a,b;
    cin>> a >> b;
    
    if( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s  = sc.next();

		s = s.replace('A', '#');
		s = s.replace('T', '#');
		s = s.replace('G', '#');
		s = s.replace('C', '#');
		s = s + "?";
		String[] y = s.split("");

		int count = 0;
		int ans = 0;

		for(int i = 0; i<s.length(); i++){
			if(y[i].equals("#")){
				count++;
			}else{
				if(ans<count){
					ans=count;
					count = 0;
				}
			}
		}

		System.out.println(ans);
		
	}
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int X[1010];
int Y[1010];
ll X2[1010];
ll Y2[1010];

void solve_large(){
    int freq[2] = {};
    for(int i = 0; i < N; i++) freq[(X[i] + Y[i]) % 2] |= 1;
    // 和が奇数のみ or 偶数のみ でないと不可能
    if(freq[0] + freq[1] >= 2){
        cout << -1 << endl;
        return;
    }

    for(int i = 0; i < N; i++){
        X2[i] = X[i] + Y[i];
        Y2[i] = X[i] - Y[i];
    }

    vector<ll> D;
    // Dとしては 2^31 ぐらいまであれば十分なので、それで構築する
    for(int i = 0; i < 32; i++) D.push_back(1LL << i);
    reverse(D.begin(), D.end());
    if(X2[0] % 2 == 0) D.push_back(1);

    cout << (int)D.size() << endl;
    for(ll a : D) cout << a << " ";
    cout << endl;

    for(int i = 0; i < N; i++){
        vector<bool> ang[2];
        ll tmp[] = {X2[i], Y2[i]};
        for(int k = 0; k < 2; k++){
            const ll a = tmp[k];
            // 大きい数字から順番に利用する
            ll pos = 0;
            for(int j = 0; j < (int)D.size(); j++){
                if(a >= pos){
                    ang[k].push_back(true);
                    pos += D[j];
                }
                else{
                    ang[k].push_back(false);
                    pos -= D[j];
                }
            }
            if(pos < a) ang[k].push_back(true);
            else if(pos > a) ang[k].push_back(false);
        }
        for(int s = 0; s < (int)ang[0].size(); s++){
            if(ang[0][s] && ang[1][s]) cout << "R";
            else if(ang[0][s] && !ang[1][s]) cout << "U";
            else if(!ang[0][s] && ang[1][s]) cout << "D";
            else cout << "L";
        }
        cout << endl;
    }
    
}

void solve_small(){
    int freq[2] = {};
    for(int i = 0; i < N; i++){
        freq[(X[i] + Y[i]) % 2] |= 1;
        if(abs(X[i]) + abs(Y[i]) >= 21) return;
    }
    
    if(freq[0] + freq[1] >= 2){
        cout << -1 << endl;
    }
    else{
        int m = 0;
        if(freq[0] > 0) m = 40;
        else m = 39;

        cout << m << endl;
        for(int i = 0; i < m; i++){
            cout << 1 << " ";
        }
        cout << endl;

        for(int i = 0; i < N; i++){
            string ans;
            for(int j = 0; j < abs(X[i]); j++){
                if(X[i] >= 0) ans += 'R';
                else ans += 'L';
            }
            for(int j = 0; j < abs(Y[i]); j++){
                if(Y[i] >= 0) ans += 'U';
                else ans += 'D';
            }
            // 残った要素数で計算
            for(int j = 0; j < m - (abs(X[i]) + abs(Y[i])); j++){
                if(j % 2 == 0) ans += 'L';
                else ans += 'R';
            }
            cout << ans << endl;
        }
    }
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    solve_large();

    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n
        self.size = n

    def find(self, id):
        if id != self.parent[id]:
            self.parent[id] = self.find(self.parent[id])
        return self.parent[id]

    def union(self, id1, id2):
        par1, par2 = self.find(id1), self.find(id2)
        if par1 == par2:
            return
        if self.rank[par1] > self.rank[par2]:
            self.parent[par2] = par1
        else:
            self.parent[par1] = par2
            if self.rank[par1] == self.rank[par2]:
                self.rank[par2] += 1
        self.size -= 1

nVertices, nEdges = map(int, input().split())
unionFind = UnionFind(nVertices)
for _ in range(nEdges):
    u, v, _ = map(lambda x: int(x) - 1, input().split())
    unionFind.union(u, v)
print(unionFind.size)

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

int main() {
  int r,b,g,n,ans = 0;
  cin >> r >> b >> g >> n;
  for(int i = 0; i <= n / r; i++){
    for(int j = 0; j <= (n - r * i) / b; j++){
      if((n - r * i - b * j) % g == 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

ll d[102][102];
int V;

void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main() {
    int N, M;
    ll edge[102][102];
    cin >> N >> M;
    V = N;
    rep(i, N) {
        rep(j, N) {
            if (i == j) {
                d[i][j] = 0;
            } else {
                d[i][j] = 100000000000;
            }

            edge[i][j] = -1;
        }
    }



    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cin >> d[a][b];
        edge[a][b] = d[a][b];
        d[b][a] = d[a][b];
        edge[b][a] = d[b][a];

    }

    warshall_floyd();
    int ans = 0;
    rep(i, N) {
        rep(j, N) {
//            cout << d[i][j] << endl;
            if (edge[i][j] != -1 && edge[i][j] != d[i][j]) {
                ans++;
            }
        }
    }

    cout << ans/2 << endl;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    string s = gs;
    vec<string> words = {"dream", "dreamer", "erase", "eraser"};
    bool cont = true;
    while (cont) {
        cont = false;
        for (string word: words) {
            int wordsize = word.size();
            int ssize = s.size();
            if (ssize >= wordsize) {
                if (s.substr(ssize-wordsize, wordsize) == word) {
                    s = s.substr(0, ssize - wordsize);
                    cont = true;
                }
            }
        }
    }
    YESNO2(s == "");
    //debug(s);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}

Measured memory_bytes: 512
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

template<class T> void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
template<class T> void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}



template<class T> void read(T& a) {
    std::cin>>a;
}
template<class T> void read(T& a,const int sidx, const int eidx) {
    for(int i=sidx; i<eidx; i++)
        std::cin>>a[i];
}



using namespace std;
using namespace __gnu_pbds;

const int maxn=100005;


vector<int>pr;
bool mark[maxn];

void si()
{
    mem(mark,0);
    for(int i=4; i<maxn; i+=2) mark[i]=1;
    for(int i=3; i*i<maxn; i+=2)
    {
        if(!mark[i])
            for(int j=i*i; j<maxn; j+=2*i)
                mark[j]=1;
    }

    pr.pb(2);
    for(int i=3; i<maxn; i+=2)
        if(!mark[i])
            pr.pb(i);
}


void solve()
{
	ll n;
	cin>>n;
	
	ll ara[n+2];
	
	ll tot=0;
	
	for(int i=0;i<n;i++)
	{
		cin>>ara[i];
		tot^=ara[i];
	}
	
	int ans[n+2];
	
	for(int i=0;i<n;i++)
	{
		ans[i]=tot^ara[i];
		cout<<ans[i]<<' ';
	}
    
	
}


int main()
{
    fast_cin;
    // si();

    //while(scanf("%d",&n)!=EOF)
//case
    {
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


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

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

  while(n!=0){
    vector<int> e(3); cin>>e[0]>>e[1]>>e[2]; 

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

    if(e[2]*e[2]==e[1]*e[1]+e[0]*e[0])
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;

    --n;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1204
#[allow(unused)]
use std::io::Write;

#[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 main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s
    };

    let arr: Vec<char> = s.chars().collect();
    let len = arr.len();
    let mut count = 0;
    for i in 0..len {
        if arr[i] != arr[len - i - 1] {
            count += 1;
        }
    }
    println!("{}", count / 2);
}


Measured memory_bytes: 4352
s = list(input())
ans_1 = 1
ans_2 = 1
i = 0
while i < len(s)-1:
  
  if i == len(s)-2 and s[i] == s[i+1]:
    break
    
  elif i == len(s)-3 and s[len(s) - 3] == s[len(s) - 2]:
    ans_1 += 1
    break
  elif s[i] == s[i+1]:
    i += 3
    ans_1 += 2
  else:
    i += 1
    ans_1 +=1
    
k = 1
while k < len(s)-1:
  
  if k == len(s)-2 and s[k] == s[k+1]:
    break
  elif k == len(s)-3 and s[len(s) - 3] == s[len(s) - 2]:
    ans_2 += 1
    break
  elif s[k] == s[k+1]:
    k += 3
    ans_2 += 2
  else:
    k += 1
    ans_2 +=1
print(max(ans_1,ans_2))

Measured memory_bytes: 4968
#include <iostream>

using namespace std;

int main() {

	int x, y;

	cin >> x >> y;

	if(x > y) 
		cout << "a > b" << endl;
	else if(x < y) 
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;

	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int A,B,C;
    cin >> A >> B >> C;
    int ans = 0;
    if(A*B > C){
        cout << C << endl;
    }
    else cout << A*B << endl;
}

Measured memory_bytes: 256
x_1,y_1,x_2,y_2=map(int,input().split())
temp = [x_2-x_1,y_2-y_1]
x_3 = x_2 - temp[1]
y_3 = y_2 + temp[0]
x_4 = x_1 - temp[1]
y_4 = y_1 + temp[0]

print(str(x_3) + " " + str(y_3) + " " + str(x_4) + " " + str(y_4))

Measured memory_bytes: 3064
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ans := 0
	for i := 1; i <= n; i++ {
		c := n / i
		if n%i == 0 {
			c--
		}
		ans += c
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1796
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    if (abs(A - B) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        int a = A, b = B;
        int ans1 = a - 1;
        ans1 += (B - ans1 + 1) / 2;
        a = A, b = B;
        int ans2 = N - B;
        ans2 += (N - (A + ans2) + 1) / 2;
        cout << min(ans1, ans2) << endl;
        //cout << ans1 << " " << ans2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		int k;
		k=a>b?a:b;
		k=k>c?k:c;
		if(k==a)
			if(k==b+c)
				printf("Yes\n");
			else printf("No\n");
		else if(k==b)
			if(k==a+c)
				printf("Yes\n");
			else printf("No\n");
		else 
			if(k==a+b)
				printf("Yes\n");
			else printf("No\n");
		
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

#define p2(a, b) cout << a << "\t" << b << endl
#define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl

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

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans;
    if (n == 1) {
        if (m == 1) {
            ans = 1;
        } else if (m == 2) {
            ans = 0;
        } else {
            ans = m - 2;
        }
    } else if (n == 2) {
        ans = 0;
    } else {
        if (m == 1) {
            ans = n - 2;
        } else if (m == 2) {
            ans = 0;
        } else {
            ans = n*m+4-(2*n+2*m);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000

int n, A[N];

int solve(int, int);

int main(){
  int q, m, i;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &m);
    if ( solve(0, m)==1){
      printf("yes\n");
    }
    else printf("no\n");
  }
  return 0;
}
int solve(int i, int m){
  if ( i >= n ) return 0;
  if ( A[i] == m ) return 1;
  if ( solve(i+1, m) ) return 1;
  if ( solve(i+1, m-A[i]) ) return 1;
  return 0;
}

Measured memory_bytes: 580
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var K = ReadLine();
            var D = Sarray()[0];
            var sum = new long[D, 2];
            sum[0, 1] = 1;
            var pretk = 0L;
            for (var i = 0; i < K.Length; ++i)
            {
                var aftsum = new long[D, 2];
                var tk = int.Parse(K[i].ToString());
                for (var j = 0; j < D; ++j)
                {
                    for (var k = 0; k < 10; ++k)
                    {
                        var mk = (k + j) % D;
                        aftsum[mk, 0] = (aftsum[mk, 0] + sum[j, 0]) % Mod;
                    }
                    for (var k = 0; k < tk; ++k)
                    {
                        var mk = (k + j) % D;
                        aftsum[mk, 0] = (aftsum[mk, 0] + sum[j, 1]) % Mod;
                    }
                }
                aftsum[(tk + pretk) % D, 1] = sum[pretk % D, 1] % Mod;
                pretk = (tk + pretk) % D;
                sum = aftsum;
            }
            WriteLine((sum[0, 0] + sum[0, 1]+Mod - 1) % Mod);//0がDに対応。0オンリーを引いておく
        }
    }
}

Measured memory_bytes: 17424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int x= std::stoi(s+t);
  int ans=0;
  for(int i=0;i<1000;i++){
    
    if(x==i*i){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}



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

int main(){
	vector<int>cnt(4);
	rep(i,6){
		int x;
		cin>>x;
		cnt[x-1]++;
	}
	sort(cnt.begin(),cnt.end());
	vector<int> ret={1,1,2,2};
	if(cnt==ret)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();

    if (a * b * c % 2 == 0) {
      System.out.println(0);
    } else {
      System.out.println(Math.min(Math.min(a * b, b * c), c * a));
    }

  }
}

Measured memory_bytes: 35828
n = gets.to_i
a = gets.split.map(&:to_i)

abssum = 0
absmin = 10**9+1
minuscnt = 0
for i in 0..(n-1)
  minuscnt += 1 if a[i] < 0
  abssum += a[i].abs
  absmin = a[i].abs if absmin > a[i].abs
end

if minuscnt % 2 == 0
  puts abssum
else
  puts abssum - (absmin * 2)
end

Measured memory_bytes: 10404
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#s = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意

print(max(a)-min(a))

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

int main()
{
  int n, i, j, ans;
  cin >> n;
  vector<int> a(n), count(1);
  for(i=0; i<n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  j = 0;
  count[0] = 1;
  for(i=0; i<n; i++)
  {
    if(a[i] == a[i+1]) count[j] += 1;
    else 
    {
    count.push_back(1);
    j++;
    }
  }
  count.pop_back();
  ans = 0;
  for(i=0; i<count.size(); i++)
  {
    if((count[i]%2)!=0)ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define revrep(i,x,N) for(int i=x;i>=N;i--)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://dmoj.ca/problem/dpv

const int MAXN = 1e5 + 10;

vector<int> g[MAXN];
ll dp[MAXN],c[MAXN],ans[MAXN];
int N,M;

void dfs1(int e,int p){
	dp[e]=1;
	vi cdrn;
	for(int& u : g[e]){
    if(u!=p) {
      dfs1(u,e);
      dp[e]=(dp[e]*(dp[u]+1))%M;
      cdrn.pb(u);
    }
	}

	vll ps,ss;
	ll pref=1,suf=1;
	forn(i,vsize(cdrn)) {
    ps.pb(pref);
		pref=(pref*(dp[cdrn[i]]+1))%M;
	}
	revrep(i,vsize(cdrn)-1,0) {
    ss.pb(suf);
		suf=(suf*(dp[cdrn[i]]+1))%M;
	}
	reverse(all(ss));
	forn(i,vsize(cdrn)) {
		c[cdrn[i]]=(ps[i]*ss[i])%M;
	}
}

void dfs2(int e,int p){
	ans[e]=(dp[e]*c[e])%M;
	for(int& u: g[e]){
      if(u!=p) {
      c[u]=(c[u]*c[e]+1)%M;
      dfs2(u,e);
    }
	}
}

int main(){

cin>>N>>M;
forn(i,N-1) {
  int u,v;
  cin>>u>>v;
  g[u].pb(v);
  g[v].pb(u);
}

dfs1(1,-1);
c[1]=1;
dfs2(1,-1);

rep(i,1,N)
  cout<<ans[i]<<endl;
return 0;
}


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

int main() {
  int N, i, sum=0;
  cin >> N;
  int A[N];
  
  for(i=0; i<N; i++)
    cin >> A[i];
  
  while(1) {
    for(i=0; i<N; i++)
      if(A[i]%2 != 0)
        break;
    if(i!=N)
      break;
    
    sum++;
    for(i=0; i<N; i++)
      A[i] /= 2;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
num = r*g*b
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >=n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -=1
print(num)

Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long n, a, b, c[100000]; bool used[100000]; vector<long long>x[100000]; bool OK = true;
long long solve(long long p) {
	if (OK == false)return 1LL << 62;
	long long y = 0; vector<long long>z; used[p] = true;
	for (long long i = 0; i < x[p].size(); i++) {
		if (used[x[p][i]] == false) {
			long long w = solve(x[p][i]); y += w; z.push_back(w);
		}
	}
	if (x[p].size() == 1)return c[p]; sort(z.begin(), z.end());
	long long L1 = 0, L2 = 0, L = 0;
	L1 = z[z.size() - 1];
	for (int i = 0; i < z.size() - 1; i++)L2 += z[i];
	L = min(y, L2 * 2); L /= 2;

	long long LB = y - L;
	long long RB = y;
	if (!(LB <= c[p] && c[p] <= RB)) { OK = false; return 1LL << 62; }
	long long H = y - (y - c[p]) * 2;
	return H;
}
int main() {
	cin >> n; for (long long i = 0; i < n; i++)cin >> c[i];
	for (long long i = 0; i < n - 1; i++) { cin >> a >> b; a--; b--; x[a].push_back(b); x[b].push_back(a); }

	if (n == 2) { if (c[0] != c[1]) { cout << "NO" << endl; } else { cout << "YES" << endl; }return 0; }

	long long r = 0; for (long long i = 0; i < n; i++) { if (x[i].size() >= 2)r = i; }
	long long f = solve(r);
	if (f == 0) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 16512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var d = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(d);
        WriteLine(d[N/2]-d[N/2-1]);
    }
}


Measured memory_bytes: 36036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//template<typename T>
#define o_set(T) tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//use it like o_set(ll) x;  --> x.order.....
//-->for pair<ll,ll> : second element as index and for search use INT_MAX...
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


#define fast ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(25)
#define pb push_back
#define I insert
#define F first
#define S second
#define digit(x) floor(log10(x))+1
const long long M1=1000000007;
const long long  M2=998244353;
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
template<typename T>
void showArr(T a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
bool isValid(ll x,ll y,ll n,ll m){
    return (x>=0 and y>=0 and x<n and y<m);
}
ll power(ll a,ll n,ll m){
    ll ans=1;
    while(n>0){
        if(n&1){
            ans=(ans%m * a%m)%m;
        }
        n=n>>1;
        a=(a%m*a%m)%m;
    }
    return ans;
}
ll MMI(ll a,ll m){
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1){
        ll q=a/m,t=m;
        m=a%m,a=t,t=y,y=x-q*y,x=t;
    }
    if(x<0) x+=m0;
    return x;
}

ll dx[]={-1,1,0,0},dy[]={0,0,-1,1};
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    string s;
    cin>>s;
    ll ans=0;
    for(auto i : s){
        ans+=(i-48);
    }
    if(ans%9!=0){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
    return 0;
}

Measured memory_bytes: 3768
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    int N = sc.nextInt();
    int a[]=new int[10001];
    int b[]=new int[10001];
    int c[]=new int[10001];
    
    for(int x=1;x<100;x++){
      for(int y=x;y<100;y++){
        for(int z=y;z<100;z++){
          int answer=((x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x))/2;
          if(answer<10001){
          	if(x==y&&y==z) a[answer]++;
          	else if(x==y||y==z) b[answer]++;
          	else c[answer]++;
          }
        }
      }
     }
     
     for(int i=1;i<=N;i++){
       System.out.println(a[i]+b[i]*3+c[i]*6);
     }
    
  }
}

Measured memory_bytes: 38880
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    String ans;

    boolean result = str_scan.endsWith("s");

    if (result){
      ans = str_scan + "es";
    }else{
      ans = str_scan + "s";
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 38484
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
typedef long long int ll;
using namespace std;
#define INF 1234567890
#define LIMIT 1

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

	int n;
	cin >> n;
	int sum = 0;
	int limit = 0;
	vector<int> res;
	for (int i = 1; i <= n; i++) {
		sum += i;
		if (sum >= n) {
			limit = i;
			break;
		}
	}
	for (int i = limit; i >= 1; i--) {
		if (n < i)
			continue;
			
		res.push_back(i);
		n -= i;
		
	}
	for (int i = res.size() - 1; i >= 0; i--) {
		cout << res[i] << "\n";
	}

	return 0;
}



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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max({A + B, 2 * A - 1, 2 * B - 1}) << endl;
}


Measured memory_bytes: 256