akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll MOD = 1E9 + 7;

ll F[1000010], I[1000010];

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

ll nchoosek(ll a, ll b) {
	ll res = F[a] * I[b];
	res %= MOD;
	res *= I[a - b];
	return res % MOD;
}

void init() {
	F[0] = 1;
	for (int i = 1;i <= 1E6;i++) F[i] = (F[i - 1] * i) % MOD;
	I[1000000] = power(F[1000000], MOD - 2);
    for (int i = 999999;i >= 0;i--) I[i] = (I[i + 1] * (i + 1)) % MOD;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    init();
    ll N;
    cin >> N;
    ll sol = ((N - 1) * F[N - 1]) % MOD;
    // N - 1 cap
    for (int n = 1;n * 2 <= N - 2;n++) {
    	ll num = nchoosek(N - 2 - n, n);
    	num *= (F[n] * F[N - 1 - n]) % MOD;
    	num %= MOD;
    	sol += MOD - num;
    	sol %= MOD;
    }
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main()
{
  string S, T;
  cin >> S >> T;
  
  int res = 0;
  for (int i = 0 ; i < S.size() ; ++i)
    if (S[i] != T[i])
      ++res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    ll ans = 0;
    vector<ll> v(2 * n);
    for (ll i = 0; i < n * 2; i++)
    {
        cin >> v[i];
    }
    sort(ALL(v));
    for (ll i = 0; i < 2 * n; i++)
    {
        if (i % 2 == 0)
        {
            ans += v[i];
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int n,a;
    cin>>n;
    double ans=0.0;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        ans = ans + (1.0/a);
    }
    cout<<1.0/ans<<endl;

    return 0;
}


Measured memory_bytes: 256
use superslice::Ext;
fn main() {
    proconio::input! {
        n: usize,
        xyu: [(i32,i32,char);n],
    }
    let mut u=vec![];
    let mut r=vec![];
    let mut d=vec![];
    let mut l=vec![];
    for (x,y,a) in xyu {
        match a {
            'U' => &mut u,
            'R' => &mut r,
            'D' => &mut d,
            'L' => &mut l,
            _ => panic!("Input error"),
        }.push((x,y));
    }
    let mut t=INF;
    let fx=|p:&(i32,i32)|p.0;
    let fy=|p:&(i32,i32)|p.1;
    let fnx=|p:&(i32,i32)|-p.0;
    let fny=|p:&(i32,i32)|-p.1;
    let faxy=|p:&(i32,i32)|p.0+p.1;
    let fsxy=|p:&(i32,i32)|p.0-p.1;
    t=t.min(f(&mut d, &u, fx, fy)/2);
    t=t.min(f(&mut l, &u, fsxy, fy));
    t=t.min(f(&mut r, &u, faxy, fy));
    t=t.min(f(&mut l, &d, faxy, fny));
    t=t.min(f(&mut r, &d, fsxy, fny));
    t=t.min(f(&mut l, &r, fy, fx)/2);
    t=t.min(f(&mut d, &r, fsxy, fx));
    t=t.min(f(&mut u, &r, faxy, fx));
    t=t.min(f(&mut d, &l, faxy, fnx));
    t=t.min(f(&mut u, &l, fsxy, fnx));
    if t>=INF/2 {
        println!("SAFE");
    }
    else {
        println!("{}",t);
    }
}
const INF: i32=std::i32::MAX;
fn f<F1,F2>(a: &mut Vec<(i32,i32)>, b: &Vec<(i32,i32)>, f1: F1, f2: F2) -> i32 where
  F1: Fn(&(i32,i32))->i32, F2: Fn(&(i32,i32))->i32
{
    let mut t=INF;
    a.sort_by_key(|a|(f1(a),f2(a)));
    for b in b {
        let a=&a[a.equal_range_by_key(&f1(b), |a|f1(a))];
        let i=a.lower_bound_by_key(&f2(b),|a|f2(a));
        if i<a.len() {
            t=t.min((f2(&a[i])-f2(b))*10);
        }
    }
    t
}

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;cin>>n;
    v vec1,vec2;
    f(i,n)

    {
        int a,b;cin>>a>>b;
        vec1.pb(a);
        vec2.pb(b);
    }
    sort(all(vec1));
    sort(all(vec2));
    int m1,m2;
    if(n&1)
    {
        m1=vec1[(n-1)/2];
        m2=vec2[(n-1)/2];
    }
    else
    {
        m1=(vec1[n/2-1]+vec1[n/2]);
        m2=(vec2[n/2-1]+vec2[n/2]);
    }
    cout<<m2-m1+1<<endl;
    return 0;
}

Measured memory_bytes: 6700
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




void solve() {
    ll n;
    ll d[110][110];
    cin>>n;
    rep(i,n)rep(j,2) cin>>d[i][j];
    ll res = 0,ans = 0;
    rep(i,n){
        if(d[i][0]==d[i][1]){
            res++;
        }
        else res=0;
        chmax(ans,res);
    }
    if(ans>=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int n;
		int[] S, C;
		while ((n = scn.nextInt()) != 0) {
			S = new int[n];
			C = new int[n];
			for (int i = 0; i < n; i++) {
				S[i] = scn.nextInt();
			}
			int ans = 0;
			boolean hururu = true;
			while (hururu) {
				hururu = false;
				for (int i = 0; i < n; i++) {
					int num = 0;
					for (int j = 0; j < n; j++) {
						if (S[j] == S[i])
							num++;
					}
					if (S[i] != num)
						hururu = true;
					C[i] = num;
				}
				for(int i = 0; i < n;i++) {
				S[i] = C[i];
				}
				ans++;
			}
			System.out.println(ans - 1);
			for (int i = 0; i < n; i++) {
				System.out.print(S[i]);
				if(i!=n-1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		scn.close();
	}
}




Measured memory_bytes: 30420
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
  if((N.at(0)==N.at(1)&&N.at(0)==N.at(2))||(N.at(1)==N.at(2)&&N.at(1)==N.at(3))){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
      return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int d[500];
int x[10000];
int y[10000];
int min(int a,int b){return a<b?a:b;}
int main(){
    int n,m,i;
    while(1){
    scanf("%d",&n);
    scanf("%d",&m);
    if(n==0)return 0;
    for(i=0;i<n;i++)d[i]=3;
    for(i=0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a==1)d[b-1]=1;
        x[i]=a-1;
        y[i]=b-1;
    }
    for(i=0;i<m;i++){
        if(d[x[i]]==1)d[y[i]]=min(d[y[i]],2);
        if(d[y[i]]==1)d[x[i]]=min(d[x[i]],2);
    }
    int ans=0;
    for(i=1;i<n;i++)if(d[i]<=2)ans++;
    printf("%d\n",ans);
    }
}

Measured memory_bytes: 1108
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];

        var H = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var AB = new HashSet<int>[N];
        for (int i = 0; i < N; i++)
        {
            AB[i] = new HashSet<int>();
        }

        for (int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            AB[A - 1].Add(H[B - 1]);
            AB[B - 1].Add(H[A - 1]);
        }

        var result = 0;
        for (int i = 0; i < N; i++)
        {
            if (AB[i].Count == 0 || H[i] > AB[i].Max())
            {
                result++;
            }
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 76376
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    lint K, X;
    cin >> K >> X;
    if(500*K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

typedef long long ll;

ll N,M,Q;
vector<ll> L; vector<ll> R;
vector<ll> p; vector<ll> q;
vector<vector<ll>> table;

void GetSumTable(vector<ll> L, vector<ll> R){
  table = vector<vector<ll>> (N+10,vector<ll>(N+10,0));
  
  for(ll i = 0; i < (ll) L.size(); i++){
    table[L[i]][R[i]]++;}
  
  for(ll j = 1; j <= N; j++){
    for(ll k = 1; k <= N; k++){
      table[j][k] += table[j-1][k] + table[j][k-1] - table[j-1][k-1];}}
}
    

ll count_table(ll p, ll q){
  return table[q][q] - table[p-1][q] - table[q][p-1] + table[p-1][p-1];}
  




int main(){
 
   cin >> N >> M >> Q;
  L.resize(M); R.resize(M);
  p.resize(Q); q.resize(Q);
  for(ll i = 0; i < M; i++){
    cin >> L[i] >> R[i];}
  for(ll j = 0; j < Q; j++){
    cin >> p[j] >> q[j];}
  
  GetSumTable(L,R);
  
  for(ll a = 0; a < Q; a++){
    cout << count_table(p[a],q[a]) << endl;}
  
  return 0;}


  

Measured memory_bytes: 10112
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	string S;
	int count = 0;
	cin >> S;
	vector<int>V;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '0') {
			V.push_back(0);
		}
		else {
			V.push_back(1);
		}
	}
	while (true) {
		bool can = false;
		if (V.size() == 0)break;
		for (int i = 0; i < V.size() - 1; ++i) {
			if (V[i] != V[i + 1]) {
				can = true;
				V.erase( V.begin() + i,V.begin()+i+2);
				count += 2;
				break;
			}
		}
		if (!can)break;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll X;
    cin>>X;
    ll Maxim=0;
    rep1(b, 1000) reps(p, 2, 11){
        if(pow(b, p)<=X) Maxim=max(Maxim, (ll)pow(b, p));
    }
    cout<<Maxim<<endl;
    return 0;
}


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

int main(){
    char ch;
    
    while(1){
        scanf("%c", &ch);
        if (ch == '\n') { break; }
        
        if (islower(ch)) {
            ch = toupper(ch);
        }
        else if (isupper(ch)) {
            ch = tolower(ch);
        }
        cout << ch;
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1148
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int i,j;
  for(i=0;i<N;i++)cin >> A[i];
  vector<int> cnt(31,0);
  for(i=0;i<N;i++)for(j=0;j<31;j++) {
    if(((1<<j)&A[i]) > 0)cnt[j]++;
  }
  int flip = 0;
  for(i=0;i<31;i++)flip += (1<<i)*(cnt[i]%2);
  for(i=0;i<N;i++)cout << (A[i]^flip) << endl;
}


Measured memory_bytes: 3960
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int K, A, B;
	
	cin>>K>>A>>B;
	
	for(int i = A; i <= B; i++){
		if(i%K == 0){
			cout<<"OK"<<endl; //ABCデビュー！！
			return 0;
		}
	}
	
	cout<<"NG"<<endl;
	
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      char[] c = sc.next().toCharArray();
      int cnt = 0;
      for(int i = 0;i < c.length;i++){
      	if(i%2==0){
        	if(c[i]=='R'||c[i]=='U'||c[i]=='D')cnt++;
        }else{
        	if(c[i]=='L'||c[i]=='U'||c[i]=='D')cnt++;
        }
      }
      if(cnt==c.length)System.out.println("Yes");
      else System.out.println("No");
    }
}

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

using namespace std;

#define endl "\n"
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

const int maxn = 1e5;
const int OO = 1e18;
vector<vi>g(maxn+1);
int sol[maxn+1];
int cont=0;
void dfs(int u)
{
	queue<int>q;
	q.push(u);
	while(q.size())
	{
		int U=q.front();
		q.pop();
		cont++;
		for(auto v:g[U])
		{
			if(sol[v]==0)
			{
				sol[v]=U;
				q.push(v);
			}
		}
	}
}
int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n,m;
	cin >> n >> m;
	
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin >> a >> b;
		g[a].PB(b);
		g[b].PB(a);
	}
	sol[1]=-1;
	dfs(1);
	//cout << cont << endl;
	if(cont==n)
	{
		cout << "Yes" << endl;
		for(int i=2;i<=n;i++)
		cout << sol[i] << endl;
	}
	else
	cout << "No";
	
	return 0;
}


Measured memory_bytes: 12960
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<std::pair<int,int> > > G(n,std::vector<std::pair<int,int> >());
	rep(i,n-1) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		G[a].emplace_back(b,i);
		G[b].emplace_back(a,i);
	}

	std::vector<int> ans(n-1,0);
	//dfs i, lastcolor, par
	std::function<void(int,int,int)> dfs = [&] (int i, int lastl, int par) {
		int c = 0;
		for(auto x:G[i]) {
			if(x.first==par) continue;
			c++;
			if(c==lastl) c++;
			ans[x.second] = c;
			debug(i,x.first,x.second);
			dfs(x.first, c, i);
		}
		debug(i);
	};
	dfs(0,0,-1);
	int max = 0;
	for(auto i:ans) max = std::max(max,i);
	print(max);
	for(auto i:ans) {
		print(i);
	}

	return 0;
}


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

struct dsu {
    int n;
    vector<int> p;
    dsu(int m) {
        n = m;
        p.resize(n + 10);
        iota(p.begin(), p.end(), 0);
    }
    int get(int u) {
        return p[u] == u ? u : p[u] = get(p[u]);
    }
    int unite(int u, int v) {
        u = get(u);
        v = get(v);
        if(u == v)
            return n;
        p[u] = v;
        n--;
        return n;
    }
};

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for(int i = 1; i <= m; ++i) {
        int u, v, z;
        cin >> u >> v >> z;
        d.unite(u, v);
    }

    cout << d.unite(1, 1) << endl;
}

Measured memory_bytes: 640
from itertools import permutations

n=int(input())
nn=[]
for i in range(1,n+1):
  nn.append(i)
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))

s=list(permutations(nn))
#print(s)
a=s.index(p)
b=s.index(q)

print(abs(a-b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double a,b,c,degC,S,L,h;
    cin >> a >> b >> degC;
    double radC;
    double PI = acos(-1);
    radC = degC*PI/180;
    S = a * b * 0.5 * sin(radC);
    c = sqrt(a*a + b*b - (2*a*b*cos(radC)));
    L = a + b + c;
    h = 2 * S / a;
    cout << fixed << setprecision(10) << S << endl;
    cout << fixed << setprecision(10) << L << endl;
    cout << fixed << setprecision(10) << h << endl;
    
}


Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int cnt = 0;

		for ( int i = 1; i <= n; i++ ) {
			if(getDigits(i) %2 == 0) {
				continue;
			}else {
				cnt++;
			}
		}
		System.out.println(cnt);
		in.close();
	}

	// 桁数を返す
	public static int getDigits(int n) {
		int d = 0;
		while ( n >= 1 ) {
			n /= 10;
			d++;
		}
		return d;
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=2019;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	cout << fixed << setprecision(12);
	print1(n*2*3.141592654);
	return 0;
}

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

int main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i, N){
        cin >> A[i] >> B[i];
    }
    vector<ll> dp(10010, 1e9); 
    //dp[h] := 与えたダメージがhのときの魔力の合計の最小値
    //dp初期条件: 
    dp[0] = 0;

    rep(i, N){
        for(ll j = 0; j <= H; j++){
            dp[min(H, j+A[i])] = min(dp[min(H, j+A[i])], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
}

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

int main(){
	int n[101], k, max=0;
	string ans;

	for (int i = 0; i < 101; i++) {
		n[i] = 0;
	}

	while(true){
		cin >> k;
		if (cin.eof()) { break; }
		n[k]++;
	}
	for(int i = 0;i<101;i++){
		if(max == n[i]){
			ans += "\n";
			ans += to_string(i);
		}
		else if (max < n[i]){
			ans = to_string(i);
			max = n[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3268
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int x, y, s;
  while (1) {
    scanf("%d%d%d", &x, &y, &s);
    if (x == 0) break;
    int m = 0;
    int before[1000], after[1000];
    for (int i = 1; i < s; i++) {
      before[i] = i * (100 + x) / 100;
      after[i] = i * (100 + y) / 100;
    }
    for (int i = 1, j = s - 1; i <= j; i++) {
      while (before[i] + before[j] > s) j--;
      if (before[i] + before[j] == s) m = max(m, after[i] + after[j]);
    }
    printf("%d\n", m);
  }
}



Measured memory_bytes: 2748
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

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

int main() {
  ll n, k, r, s, p;
  string str;
  cin >> n >> k >> r >> s >> p >> str;

  ll ans = 0;
  string hst = "";
  for (ll i = 0; i < n; i++) {
    if (i - k >= 0) {
      if (str[i] == 'r') {
        if (hst[i - k] != 'p') {
          hst += 'p';
          ans += p;
        } else {
          hst += 'x';
        }
      }
      if (str[i] == 's') {
        if (hst[i - k] != 'r') {
          hst += 'r';
          ans += r;
        } else {
          hst += 'x';
        }
      }
      if (str[i] == 'p') {
        if (hst[i-k] != 's') {
          ans += s;
          hst += 's';
        } else{
          hst += 'x';
        }
      }
    } else {
      if (str[i] == 'r') {
        ans += p;
        hst += 'p';
      }
      if (str[i] == 's') {
        ans += r;
        hst += 'r';
      }
      if (str[i] == 'p') {
        ans += s;
        hst += 's';
      }
    }
  }

  cout << ans << endl;
  //cout << hst << endl;

  return 0;
}


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

int data[10][10000];
int R,C;

int next(int count,bool gyou[11]) {
	if (count == R) {
		int d[10][10000];
		for (int i = 0;i < R;i++) {
			for (int j = 0;j < C;j++) {
				d[i][j] = data[i][j];
			}
		}
		for (int j = 0;j < C;j++) {
			int sum = 0;
			for (int i = 0;i < R;i++) {
				if(gyou[i]) {
					if(d[i][j] == 0) sum++;
				}
				else {
					sum += d[i][j];
				}
			}
			if(sum > R/2) {
				for (int i = 0;i < R;i++) {
					if(d[i][j] == 0) {
						d[i][j] = 1;
					}
					else {
						d[i][j] = 0;
					}
				}	
			}
		}
		for (int i = 0;i < R;i++) {
			if (!gyou[i]) continue;
			for (int j = 0;j < C;j++) {
				if(d[i][j] == 0) {
					d[i][j] = 1;
				}
				else {
					d[i][j] = 0;
				}
			}
		}
		int result = 0;
		for (int i = 0;i < R;i++) {
			for (int j = 0;j < C;j++) {
				if(d[i][j] == 0) result++;
			}
		}
		return result;
	}
	int a = next(count + 1,gyou);
	gyou[count] = !gyou[count];
	int b = next(count + 1,gyou);
	return max(a,b);
}
int main() {
	// your code goes here
	while(true){
		cin >> R >> C;
		if(R==0&&C==0) break;
		for (int i = 0;i < R;i++){
			for (int j = 0;j < C;j++){
				cin >> data[i][j];
			}
		}
		bool first[11];
		for (int i = 0;i <11;i++) {
			first[i] = false;
		}
		cout << next(0,first) << endl;
	}
	return 0;
}

Measured memory_bytes: 2024
#include<iostream>

namespace Arrenged
{
class vector{
public:
	void push_back(int x);
	int  size();
	int& operator[](int n);
	const vector& operator=(const vector& X);
	vector();
	~vector();
	void resize(int n);
	void reserve(int n);
	vector(const vector& X);
private:
	int  Size;
	int* Point;
	int  Domain;
};
	int& vector::operator[](int n)
	{
		return Point[n];
	}
	
	const vector& vector::operator=(const vector& X)
	{
		Size = X.Size;
		Domain = X.Domain;
		Point = new int[X.Size];
		for(int i = 0; i < X.Size; i++){
			Point[i] = X.Point[i];
		}
		return *this;
	}
	
	vector::vector()
	{
		Point = NULL;
		Size = 0;
		Domain = 0;
	}
	
	vector::~vector()
	{
		if(Point) delete[] Point;
	}
	
	vector::vector(const vector& X)
	{
		Size = X.Size;
		Domain = X.Domain;
		Point = new int[X.Size];
		for(int i = 0; i < X.Size; i++){
			Point[i] = X.Point[i];
		}
	}
	
	void vector::resize(int n)
	{
		if(Domain < n) reserve(n);
		Size = n;
	}
	
	void vector::reserve(int n)
	{
		if(n <= Domain) return;
		int* CPoint = new int[n];
		for(int i = 0; i < Size; i++){
			CPoint[i] = Point[i];
		}
		delete[] Point;
		Point = CPoint;
		Domain = n;
	}
	
	void vector::push_back(int x)
	{
		if(Size + 1 > Domain){
			reserve(2 * Size);
		}
		resize(Size + 1);
		Point[Size - 1] = x;
	}
	
	int  vector::size()
	{
		return Size;
	}
}//Arrenged????????????

using namespace Arrenged;
vector Sort(vector A, int i){
    int j = i - 1;
    while(j >= 0 && A[j] > A[j+1]){
        int v = A[j+1];
        A[j+1] = A[j];
        A[j] = v;
        j--;
    }
	return A;
}
 
int main(){
    int N;
    std::cin >> N;
    vector A;
    for(int i = 0; i < N; i++){
        int a;
        std::cin >> a;
        A.push_back(a);
    }
	A.resize(N);
    for(int i = 0; i < N; i++){
        A = Sort(A, i);
        for(int j = 0; j < N-1; j++) std::cout << A[j] << ' ';
        std::cout << A[N-1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
 int main(){
 int n,m;
 cin >> n >> m;
 int A[100][100];
 int B[100];
 int C[100];
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
          cin >> A[i][j];
        }  
    }
    for(int i=0;i<m;i++){
        cin >> B[i];
    }
    for(int i=0;i<n;i++){
        C[i]=0;
        for(int j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
    }
    for(int i=0;i<n;i++){
        cout << C[i] << endl;
    }
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  int nn = 3*n;
  vi a(nn); rep(i, nn) std::cin >> a[i];
  sort(rng(a));
  ll ans = 0;
  rep(i, n) {
    ans += a[nn-2-(i*2)];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
	char x, y;
	cin >> x >> y;

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


	system("pause");
	return 0;
}

Measured memory_bytes: 504
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans = 0
(1..(n - 1)).each do |i|
  d = a[i - 1] + a[i] - x
  if d > 0
    a[i] -= [a[i], d].min
    ans += d
  end
end
puts ans


Measured memory_bytes: 11140
F =-> {gets.split.map &:to_i}
N,W = F[]
D = [0]
N.times {
	w,v = F[]
    W.downto(w) {|i| x=D[i-w] and (D[i]||0) < x+=v and D[i]=x}
}
p D.map{_1||0}.max

Measured memory_bytes: 15896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int cnt[20][20];

int main(){
    int n,m;
    int i,j,k;
    LL a,b,c;
    LL s=0;
    string sa;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>sa;
        a=0;
        for(j=0,k=-1;j<sa.size();j++){
            if(sa[j]=='.'){
                k++;
                continue;
            }
            if(k>=0)k++;
            a*=10,a+=(int)sa[j]-(int)'0';
        }
        if(k==-1)k=0;
        for(b=0;a%5==0;b++){
            a/=5;
        }
        for(c=0;a%2==0;c++){
            a/=2;
        }
        b+=9-k,c+=9-k;
        b=min(b,(LL)18),c=min(c,(LL)18);
        s+=cnt[18-b][18-c];
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                cnt[j][k]++;
            }
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 200001
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back 
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll l,r,d,ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>l>>r>>d;
	for(int i=1;i<=(r+1)/d;i++){
		if(i*d>=l && i*d<=r){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= x; i++) {
            if (i%3 != 0 && i%5 != 0) {
                sum+= i;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 27196
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string s;
  cin >> s;

  long g_num = 0;
  long p_num = 0;

  for (char c: s) {
    if (c == 'g') g_num++;
    else p_num++;
  }

  cout << (g_num - p_num) / 2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int ddx[6]={0,1,0,-1,1,-1},ddy[6]={-1,0,1,0,1,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;

int main(){
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

// --------------------------------------------------------------------------------
#define fast_IO	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve()
{
 	int n;cin>>n;
 	int arr[n];
 	bool hash[1000009];
 	map<int,int>mp;
 	mset(hash,1);
 	set<int>st;
 	int maxi = -1;
 	frepi(0,n-1,1)
 	{
 		cin>>arr[i];
 		maxi = max(maxi,arr[i]);
 		mp[arr[i]]++;
 		st.insert(arr[i]);
 	}
 	for(auto x:st)
 	{
 		if(mp[x]>1)hash[x]=false;
 		for(int i=x+x;i<=maxi;i+=x)
 			hash[i]=false;
 	}
 	int count = 0;
 	for(auto x:st)
 	{
 		if(hash[x])
 		{
 			count+=mp[x];
 		}
 	}
 	cout<<count<<"\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 24016
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*50+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*50+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)




Measured memory_bytes: 95452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionE
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            var length = s.Length;

            var count = 0;

            for(int i = 0; i < length; i++) {
                if(s[i] == 'S') {
                    count++;
                } else {
                    count = Math.Max(0, count - 1);
                }
            }

            Console.WriteLine(count * 2);

            Console.Out.Flush();
        }
    }
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 100010;

int fa[N];

int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int n, m;
vector<int> G[N], rev[N], blk[N];

int dep[N];
bool vis[N];

void DFS(int o){
	vis[o] = true;
	for(int v : G[o]){
		if(vis[v]) continue;
		dep[v] = dep[o] + 1;
		DFS(v);
	}
	for(int v : rev[o]){
		if(vis[v]) continue;
		dep[v] = dep[o] - 1;
		DFS(v);
	}
}

int main(){
	scanf("%d%d", &n, &m);
	For(i, 1, n) fa[i] = i;
	For(i, 1, m){
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v), rev[v].pb(u);
		fa[find(u)] = find(v);
	}
	For(i, 1, n) blk[find(i)].pb(i);

	long long ans = 0;
	For(i, 1, n) if(fa[i] == i){
		
		vis[i] = true, dep[i] = 0;
		DFS(i);
		bool checked = false;
		int sz = blk[i].size(), cnt = 0;

		for(int o : blk[i]){
			for(int v : G[o]){
				if(((dep[v] - dep[o]) % 3 + 3) % 3 != 1){
					checked = true;
					break;
				}
				++cnt;
			}
			if(checked) break;
		}

		if(checked){
			ans += 1ll * sz * sz;
			continue;
		}
		
		int tot[3] = {0};
		for(int o : blk[i]) tot[(dep[o] % 3 + 3) % 3]++;
		if(!tot[0] || !tot[1] || !tot[2]){
			ans += cnt;
			continue;
		}

		For(j, 0, 2) ans += 1ll * tot[j] * tot[(j + 1) % 3];
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
vector< int> e[200005];
bool has[200006];

int main(){
    memset(has,false,sizeof(has));
    int n, m;
    cin >> n >> m;
    bool ans = false;
    for(int i= 0; i < m;  i++){
        int a,b;cin >>a >> b;
        if(a == n || b == n){
            has[a] = true;;
            has[b] = true;
        }
        e[a].push_back(b);
        e[b].push_back(a);
    }
    for(int i = 0; i < e[1].size(); i++){
        if(has[e[1][i]]){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 12144
#include <stdio.h>

int main(){
	int H,W;
	int i,j;

	while(1){
		scanf("%d %d", &H,&W);
		if(H==0 && W==0)
			break;
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if(i%2==1 && j%2==1 || i%2==0 && j%2==0)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
const ll mod=1e9+7;
ll fac[N];

void init()
{
    fac[0]=1;
    for(int i=1;i<=N;i++)
        fac[i]=fac[i-1]*i%mod;
}
ll qpow(ll x,ll k)
{
    ll res=1;
    while(k)
    {
        if(k&1)
            res=res*x%mod;
        x=x*x%mod;
        k>>=1;
    }
    return res;
}
ll C(ll n,ll k)
{
    ll res=fac[n]*qpow(fac[n-k]+mod,mod-2)%mod;
    res=res*qpow(fac[k],mod-2)%mod;
    return res;
}
int main()
{
    init();
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    ll ans=C(n*m,k)*C(k,2)%mod;
    ans=ans*(n+m)%mod;
    ans=ans*qpow(3,mod-2)%mod;
    cout<<ans%mod;
    return 0;
}


Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var ret = -1;
        for (int i = 0; i <= sL - 2; i++)
        {
            if (s[i] == s[i + 1]) { ret = i; break; }
            if (i != sL - 2 && s[i] == s[i + 2]) { ret = i; break; }
        }
        if (ret == -1) Console.WriteLine("-1 -1");
        else if (sL == 2) Console.WriteLine("1 2");
        else Console.WriteLine("{0} {1}",ret+1, ret +3);
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true){
			int number = Integer.parseInt(sc.nextLine());

			if (number == 0)
				return;
			int a_player = 0;
			int b_player = 0;

			for (int i = 0; i < number; i++){
				String input[] = sc.nextLine().split(" ");
				int a = Integer.parseInt(input[0]);
				int b = Integer.parseInt(input[1]);

				if (a == b){
					a_player += a;
					b_player += b;
				}
				else if (a < b) {
					b_player += a + b;
				}
				else {
					a_player += a + b; 
				}
			}

			System.out.println(a_player + " " + b_player);
		}
	}
}

Measured memory_bytes: 67084
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

int main(void){
  int n;
  cin>>n;
  string iS;
  cin>>iS;
  int ans=0;
  rep(u,n){
    string S = iS.substr(n-1-u);
    int A[S.size()];
    A[0]=S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
      while (i+j < S.size() && S[j] == S[i+j]) ++j;
      A[i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
      i += k; j -= k;
    }
    rep(t,S.size()){
      if(t>=A[t]){
        ans=max(ans,A[t]);

      }
      //cout<<A[t]<<" ";
    }
    //cout<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
count = 0
preemos = []

is_prime = [True] * 55555
is_prime[0],is_prime[1] = False, False

for i in range(2, 55555):
  if count == n: break
  if is_prime[i]:
    if i % 10 == 1:
      count += 1
      preemos.append(i)
    for j in range(i, 55555, i):
      is_prime[j] = False
      
for i in preemos:
  print(i, end = " ")

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

int N, M , A[10010], B[10010], COST[10010];
int P[10010];
int Rank[10010];
pair<int, int> bridge[10010];

void init(int N){
	for(int i = 0; i < N; ++i){
		P[i] = i;
		Rank[i] = 0;
	}
}

int root(int a){
	if(P[a] == a) return a;
	return (P[a] = root(P[a]));
}

bool IsSameSet(int a, int b){
	return root(a) == root(b);
}

void unite(int a, int b){
	P[root(a)] = root(b);
}

void link(int a, int b){
	if(Rank[a] > Rank[b]){
		P[b] = a;
	} else {
		P[a] = b;
		if(Rank[a] == Rank[b]) Rank[a]++;
	}
}

int main(){
	int a,b;
	while(cin >> N >> M, N > 0 && M > 0){
		init(N);
		for(int i=0; i<M; i++){
			cin >> A[i] >> B[i] >> COST[i];
			bridge[i].first = COST[i];
			bridge[i].second = i;
		}		
		sort(bridge, bridge + M);
		int sum = 0;
		for (int i = 0; i < M; ++i){
			int a = A[bridge[i].second];
			int b = B[bridge[i].second];
			if(IsSameSet(a,b)) continue;
			unite(a,b);
			sum += bridge[i].first;
		}
		cout << sum << endl;

	}

}

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

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

    int ans = 0;
    int l, r;
    for(int i = 0;i < n;i++){
        cin >> l >> r;
        ans += (r-l+1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
inl = list(map(str, input().split()))

stack = []
for n in inl:
    if n == '+':
        stack.append(stack.pop() + stack.pop())
    elif n == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif n == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(n))
print(stack.pop())


Measured memory_bytes: 5596