akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int k, n; cin>>k>>n;
    vi a = READ<int>(n);
    ll sum=0, mx=0;

    FOR(i, n) {
        ll d = a[(i+1)%n]-a[i];
        if(d<0) d+=k;
        sum += d;
        mx |= MAX(d);
    }

    cout<<sum-mx<<endl;
}

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

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "Yes" : "No");


		static void Main(string[] args)
		{
			bool ans = true;
			int[][] c = new int[3][];
			for (int i = 0; i < 3; i++) c[i] = Ins;
			int[] s = new int[3];
			for (int i = 0; i < 3; i++)
			{
				s[i] = sum(c[i][0], c[i][1], c[i][2]);
			}
			try
			{
				int A = f(s[0], s[1]);
				int B = f(s[1], s[2]);
				int C = f(s[2], s[0]);
				if (C != -B - A) ans = false;
			}
			catch
			{
				ans = false;
			}
			for (int i = 0; i < 3; i++)
			{
				s[i] = sum(c[0][i], c[1][i], c[2][i]);
			}
			try
			{
				int A = f(s[0], s[1]);
				int B = f(s[1], s[2]);
				int C = f(s[2], s[0]);
				if (C != -B - A) ans = false;
			}
			catch
			{
				ans = false;
			}
			Out(ans);
		}

		static int sum(int a,int b,int c)
		{
			return a + b + c;
		}

		static int f(int a,int b)
		{
			var A = (a - b);
			if (A % 3 != 0) throw new Exception();
			return A / 3;
		}
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N),b(N);
    REP(i,N) cin>>a[i];
    REP(i,N) cin>>b[i];

    for(int i=1;i<=N-1;i++) a[i]+=a[i-1];
    for(int i=N-2;i>=0;i--) b[i]+=b[i+1];

    int ans=0;
    REP(i,N){
        ans=max(ans,a[i]+b[i]);
    }
    cout<<ans<<endl;

}


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

int main(){
    int N,M;
    cin >> N >> M;
    long a[N],sum=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+N,std::greater<int>());
    for(int i=0; i<N; i++){
        if(i>=M){
            break;
        }
        if( (double) a[i] < ( (double) (( (double) sum) /( (double) 4* ((double) M)) ) ) ){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num;
    scanf("%d", &num);
    if(num < 600){
        printf("8\n");
    }else if(600 <= num && num < 800){
        printf("7\n");
    }else if(800 <= num && num< 1000){
        printf("6\n");
    }else if(1000 <= num && num< 1200){
        printf("5\n");
    }else if(1200 <= num && num< 1400){
        printf("4\n");
    }else if(1400 <= num && num< 1600){
        printf("3\n");
    }else if(1600 <= num && num< 1800){
        printf("2\n");
    }else if(1800 <= num && num< 2000){
        printf("1\n");
    }

    return 0;
}


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

public class Main {
	
	void run() throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] S = br.readLine().split(" ");
		int q = Integer.parseInt(br.readLine());
		String[] T = br.readLine().split(" ");
		
		int count = 0;
		boolean check;
		for (int i = 0; i < q; i++) {
			String searchWord = T[i];
			check = false;
			for (int j = 0; j < n; j++) {
				if (!check && searchWord.equals(S[j])) {
					count++;
					check = true;
				}
			}
		}
		System.out.println(count);
	}

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

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

int main(){
    int N;cin>>N;
    int array[N];
    map<int,int> dif;
    map<long,int> sum;
    long ans=0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        array[i]=a;
        sum[i+a]++;
        ans+=sum[i-a];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26948
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll y= x/d;
  if(k>=y){
  if((k-y)%2==0)
  {
      cout<< abs(x -(y*d));
  }
  else{
    ll tm1= x-(y*d);
    cout<<min(abs(tm1+d),abs(tm1-d));
  }
  }
  else
  {
      cout<<abs(x-(k*d));
  }
  }

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vvi G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }
    
    double ans = INF;
    rep(i, 0, N) {
        vector<double> dp(N, INF);
        dp[N - 1] = 0;
        rrep(v, 0, N - 1) {
            int deg = sz(G[v]);
            if (i == v && deg > 1) {
                double mx = G[v].front();
                for (int w : G[v]) {
                    if (dp[mx] < dp[w]) mx = w;
                }
                dp[v] = 0;
                for (int w : G[v]) {
                    if (w == mx) {
                        continue;
                    }
                    dp[v] += (dp[w] + 1) / (deg - 1);
                }
            } else {
                dp[v] = 0;
                for (int w : G[v]) {
                    dp[v] += (dp[w] + 1) / deg;
                }
            }
        }
        chmin(ans, dp[0]);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;


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

	int N; cin >> N;
	int a[22], b[22], c[22];
	fill(c, c + N, 0);
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = 1; i <= N; i++) cin >> b[i];
	for (int i = 1; i <= N-1; i++) cin >> c[i];
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += b[a[i]];
	}
	for (int i = 1; i <= N-1; i++) {
		if (a[i + 1] - a[i] == 1)sum += c[a[i]];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort( a, a+3 );

	cout << a[0] * a[1] / 2 << endl;
	return 0;
}

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

int x[90001],y[90001];
int ans[90001];

inline int my_abs(int input){
    if(input < 0){
        input = -input;
    }
    return input;
}

int main() {

    int h,w,d;

    scanf("%d %d %d",&h,&w,&d);

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int a;
            scanf(" %d",&a);
            x[a] = j; y[a] = i;
        }
    }

    for(int i=d+1; i<=h*w; i++){
        ans[i] = ans[i-d] + my_abs(x[i] - x[i-d]) + my_abs(y[i] - y[i-d]);
    }

    int q;

    scanf(" %d",&q);

    while(q--){
        int l,r;

        scanf(" %d %d",&l,&r);

        cout << ans[r] - ans[l] << endl;
    }

    return 0;
}


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

const string K = "keyence";

int main()
{
  string s; cin >> s;
  int n = s.size();

  for (int i=0; i<n; i++) {
    for (int j=i; j<=n; j++) {
      if (K == s.substr(0, i)+s.substr(j)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}
signed main(){
  int n;
  while(cin>>n,n){
    vector<int> x(500,0),y(500,0);
    x[0]=y[0]=0;
    int xmax=0,xmin=0,ymax=0,ymin=0;
    rep(i,n-1){
      int a,d;
      cin>>a>>d;
      x[i+1]=x[a]+dx[d];
      y[i+1]=y[a]+dy[d];
      cmin(xmin,x[i+1]);
      cmin(ymin,y[i+1]);
      cmax(xmax,x[i+1]);
      cmax(ymax,y[i+1]);
    }
    cout<<xmax-xmin+1<<' '<<ymax-ymin+1<<endl;
  }


 return 0;
}



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

int main() {
	int N; long long K; cin>>N>>K;
	vector<pair<int, int> > data(N);
	for(int i = 0; i < N;i++) {
		int a, b; cin>>a>>b;
		data[i] = make_pair(a, b);
	}
	sort(data.begin(), data.end());
	long long sum = 0;
	for(int i = 0; i < N; i++) {
		sum += (long long)data[i].second;
		if(sum >= K) {
			cout << data[i].first << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>
using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}


int main()

  {
    zaroorat()  ;
    string inp;
    cin>>inp;

    if(inp[inp.size()-1]=='s'){
      cout<<inp<<"es"<<endl;
    }else{
      cout<<inp<<"s"<<endl;
    }



      return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL as(n);
  FOR(a,as) {
    cin >> a;
  }
  VL cs(n);
  REP(i,0,n) {
    cs[i] = as[i] - i;
  }
  sort(cs.begin(), cs.end());
  ll b = cs[n/2];
  ll ans = 0;
  FOR(c,cs) {
    ans += abs(c - b);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

H,W=get_i
a=array(H)
H.times do|i|
    a[i]=get_nsp
end
H.times do|i|
    flag=true
    W.times do|j|
        if a[i][j]=="#"
            flag=false
            break
        end
    end
    if flag
        W.times do|j|
            a[i][j]=""
        end
    end
end
W.times do|j|
    flag=true
    H.times do|i|
      if a[i][j]=="#"
          flag=false
          break
      end
    end
    if flag
        H.times do|i|
            a[i][j]=""
        end
    end
end
H.times do|i|
    if a[i].join("")!=""
        puts a[i].join("")
    end
end

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;
long mod = 1000000007;
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    sort(a.begin(), a.end());


    vector<mint> mutplus;
    mint tmp(1);
    rep(i, n + 1){
        mutplus.push_back(tmp);
        tmp *= 2;
    }
    mint ans(0);
    mint mut(0);
    if (n == 1){
        ans = (mint)a[0] * 2;
        cout << ans.x << endl;
        return 0;
    }
    rep(i, n){
        mut = mutplus[n-1] + mutplus[n-2] * (mint)(n-1-i);
        ans += mut * a[i];
    }
    ans *= mutplus[n];

    cout << ans.x << endl;
}

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int len = sc.nextInt();
      Long output = new Long(1);
      int[] checked = new int[len];
      Arrays.fill(checked,0);
      while(sc.hasNext()){
        int tmp = sc.nextInt();
        checked[tmp]++;
      }
      for(int i = (len - 1) % 2; i <= len - 1; i += 2){
        if(i == 0 && checked[i] != 1){
          myout("0");
          return;
        }else if(i != 0 && checked[i] != 2){
          myout("0");
          return;
        }else{
       		output = (output * checked[i]) % 1000000007;
        }
      }
      
      myout(output);
	}
}


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

typedef long long int int64;

typedef struct UnionFind{
  int *parent;
  int64 *add;
  int n;
} UnionFind;

UnionFind* newUnionFind(int n){
  UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
  u->parent=(int *)calloc(n,sizeof(int));
  u->add=(int64 *)calloc(n,sizeof(int64));
  u->n=n;
  for(int i=0;i<n;i++) u->parent[i]=-1;
  return u;
}

int root(UnionFind *u,int x){
  while(u->parent[x]>=0) x=u->parent[x];
  return x;
}

int same(UnionFind *u,int x,int y){
  return root(u,x)==root(u,y);
}

int getSize(UnionFind *u,int x){
  return -u->parent[root(u,x)];
}

void unite(UnionFind *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  if(u->parent[x]>u->parent[y]){
    int swap=x;
    x=y;
    y=swap;
  }
  u->parent[x]+=u->parent[y];
  u->parent[y]=x;
  u->add[y]-=u->add[x];
}

void addVal(UnionFind *u,int x,int64 v){
  x=root(u,x);
  u->add[x]+=v;
}

int64 getVal(UnionFind *u,int x){
  int64 sum=0;
  while(x>=0){
    sum+=u->add[x];
    x=u->parent[x];
  }
  return sum;
}

typedef struct weightEdge{
  int a,b,c;
} edge;

int cmpEdge(const void *a,const void *b){
  return ((edge *)a)->c-((edge *)b)->c;
}

void run(void){
  int n;
  scanf("%d",&n);
  edge *e=(edge *)calloc(n-1,sizeof(edge));
  int i;
  for(i=0;i<n-1;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a--;b--;
    e[i]=(edge){a,b,c};
  }
  qsort(e,n-1,sizeof(edge),cmpEdge);
  UnionFind *u=newUnionFind(n);
  for(i=n-2;i>=0;i--){
    addVal(u,e[i].a,(int64)e[i].c*getSize(u,e[i].b));
    addVal(u,e[i].b,(int64)e[i].c*getSize(u,e[i].a));
    unite(u,e[i].a,e[i].b);
  }
  for(i=0;i<n;i++) printf("%lld\n",getVal(u,i));
}

int main(void){
  run();
  return 0;
}


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

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

  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int groups = 1;
  int B[3] = {0};
  for (int i = 2; i < N;) {
    int a=A[i-2], b=A[i-1], c=A[i];
    if (a == b) {
      i++;
      continue;
    }
    if (b == c) {
      swap(A[i-2], A[i-1]);
      i++;
      continue;
    }
    bool cond1 = a <= b && b <= c;
    bool cond2 = a >= b && b >= c;
    if (cond1 || cond2) i++;
    else {
      groups++;
      i += 2;
    }
  }

  cout << groups << endl;

  return 0;
}


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

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

    string S;
    cin >> S;

    ll r = 0, g = 0, b = 0;
    rep(i,N) {
        if (S[i] == 'R') r++;
        else if (S[i] == 'G') g++;
        else b++;
    }

    ll sum = r * g * b;
    for (int i = 1; i < N; i++) {
        for (int j = i; j + i < N; j++) {
            if (S[j] != S[j - i] && S[j] != S[j + i] && S[j - i] != S[j + i]) sum--;
        }
    }

    cout << sum << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, d;
    cin >> n >> d;
    cout << n / (2 * d + 1) + (n % (2 * d + 1) > 0);
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World";
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 3; ++i){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int d = (N + 1) / 2;
    printf("%.7f\n", (double)d / N);
}

Measured memory_bytes: 256
from collections import defaultdict
N,K = map(int,input().split())

d_snack =defaultdict(int)

for i in range(0,K):
    d = int(input())
    A = list(map(int,input().split()))
    #print(A)
    for j in range(0,len(A)):
        #print("j",A[j])
        d_snack[A[j]] = d_snack[str(A[j])] +1
    #print("dddd",d_snack[3])
count=0
for i in range(0,N):
    #print(d_snack[i+1])
    if d_snack[i+1]==0:
        count +=1
print(count)


Measured memory_bytes: 9388
import math

N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]

possible = 1
for i in range(N):
  if i == 0:
    parity_0 = sum(points[i]) % 2
  else:
    if sum(points[i]) % 2 != parity_0:
      print(-1)
      possible = 0
      break

if possible:
  farthest = max([abs(point[0]) + abs(point[1]) for point in points])
  m = math.ceil(math.log2(farthest + 1))
  d_list = [2**(m-i-1) for i in range(m)]
  if parity_0 == 0:
    m = m + 1
    d_list.append(1)
  print(m)
  print(" ".join(map(str,d_list)))
  uv = [[point[0] + point[1], point[0] - point[1]] for point in points]
  for i in range(N):
    u = uv[i][0]
    v = uv[i][1]
    w = ""
    for d in d_list:
      if u > 0:
        if v > 0:
          w += "R"
          u -= d
          v -= d
        else:
          w += "U"
          u -= d
          v += d
      else:
        if v > 0:
          w += "D"
          u += d
          v -= d
        else:
          w += "L"
          u += d
          v += d
    print(w)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
using namespace std;
const int num = 10001, num1 = 101;
int dp[2][num];
int w[num1], v[num1];
int n, W;
int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];
	for(int i = 0; i < n; i++)
		for (int j = 0; j <= W; j++) {
			if (w[i] > j) dp[i & 1][j] = dp[(i + 1) & 1][j];
			else dp[i & 1][j] = max(dp[i & 1][j - w[i]] + v[i], dp[(i + 1) & 1][j]);
		}
	cout << dp[(n + 1) & 1][W] << endl;
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int n, m;
	cin >> n >> m;
	
	int cnt[31] = {0};
	vector<vector<int> > v = vector<vector<int>>(n);
	for(int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for(int j = 0; j < k; j++) {
			int tmp;
			cin >> tmp;
			cnt[tmp]++;
		}
	}
	
	int ans = 0;
	for(int i = 0; i < 31; i++) {
		if(cnt[i] >= n) {
			ans++;
		}
	}
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 400
#define MM 100000
int x[MM+5],y[MM+5],u[MN+5],g[MN+5][MN+5];
int main()
{
	int n,m,i,j,k,ans=0;
	n=read();m=read();
	for(i=1;i<=m;++i)x[i]=read(),y[i]=read();
	for(i=1;i<=n;++i)
	{
		g[i][i]=1;
		for(j=m;j;--j)
		{
			if(g[i][x[j]]&&g[i][y[j]])u[i]=1;
			g[i][x[j]]|=g[i][y[j]];
			g[i][y[j]]|=g[i][x[j]];
		}
		if(!u[i])for(j=1;j<i;++j)if(!u[j])
			{for(k=1;k<=n;++k)if(g[i][k]&&g[j][k])break;if(k>n)++ans;}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1536
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	int a,b,cnt=0;
	s ss;
	cin>>a>>b>>ss;
	int n=(int)ss.size();
	if(ss[a]!='-'){cout<<"No"<<endl; return 0;}
	for(int i=0;i<n;i++){
		debug(i);
		if(ss[i]>='0'&&ss[i]<='9')cnt++;
		debug(cnt);
		}
	if(cnt==a+b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;


































return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::max;

fn main() {
    let mut a:isize = read!();
    let mut b:isize = read!();
    let mut c:isize = read!();
    println!("{}",max(0,b+c-a));
}

Measured memory_bytes: 2164
import java.util.*; 
public class Main{
    public static void main ( String [] args) {
        // 入力値を二回入力
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt(); 

        sc.close();

        int sum = A + B;

        if (sum % 2 == 0){
            System.out.println(sum / 2);
        
        } else {
        
            System.out.println("IMPOSSIBLE");
        }


    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

struct R{
  char s[11];
  int p,n;
};

int main(void){
  int n,i,j;
  R r[100];
  R tmp;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>r[i].s>>r[i].p;
    r[i].n=i+1;
  }
  int c;
  for(i=0;i<n-1;i++){
    for(j=0;j<n-1;j++){
      c=strcmp(r[j].s,r[j+1].s);
      if(c>0){
        tmp=r[j];
        r[j]=r[j+1];
        r[j+1]=tmp;
      }
      else if(c==0){
        if(r[j].p<r[j+1].p){
          tmp=r[j];
        r[j]=r[j+1];
        r[j+1]=tmp;
        }
      }

    }
  }

  for(i=0;i<n;i++){
    cout<<r[i].n<<endl;
  }
  
	return 0;
}

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

int n, m, d;
uint8_t a[505][505];

inline int aps(int x) {
	return x < 0 ? -x : x;
}

inline bool valid(int i, int j) {
	for (int x=-d; x<=d; x++) {
		for (int y=-d; y<=d; y++) {

			int u = i+x;
			int v = j+y;

			if (aps(u-i) + aps(v-j) != d) {
				continue;
			}

			if (u >= 1 && v >= 1 && u <= n && v <= m) {
				if (a[u][v] == a[i][j]) {
					return false;
				}
			}
		}


	}
	return true;
}

vector<pair<int, int>> fig1, fig2;

inline bool ok(int i, int j) {
	return (i > 0 && j > 0 && i <= n && j <= m);
}

template<class T>
void crtaj(const T& fig, int x, int y, int c) {
	for (auto p : fig) {
		int u = p.first + x;
		int v = p.second + y;
		if (ok(u, v)) {
			a[u][v] = c;
		}
	}
}



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

	cin >> n >> m >> d;

	memset(a, 4, sizeof(a));

	if (d == 1) {
		for (int i=1; i<=n; i++) {
			for (int j=1; j<=m; j++) {
				a[i][j] = (i+j) % 2;
			}
		}
	} else {
		if (d % 2 == 1) {
			for (int x=-d-2; x<=d+2; x++) {
				for (int y=-d-2; y<=d+2; y++) {
					if (aps(x) + aps(y) <= d/2) {
						fig1.push_back({x, y});
					}

					if (aps(x) + aps(y) < d/2 ||
						aps(x-1) + aps(y) < d/2 ||
						aps(x) + aps(y-1) < d/2 ||
						aps(x-1) + aps(y-1) < d/2)
					{
						fig2.push_back({x, y});
					}
				}
			}

			for (int i=-4*d; i<=n+4*d; i+=d) {
				for (int j=-4*d; j<=m+4*d; j+=d) {
					int c = (i/d + j/d + 16) % 2;
					crtaj(fig1, i, j, c);
				}
			}

			for (int i=-4*d; i<=n+4*d; i+=d) {
				for (int j=-4*d; j<=m+4*d; j+=d) {
					int c = (i/d + j/d + 16) % 2;
					crtaj(fig2, i+d/2, j+d/2, 2 + c);
				}
			}

		} else {

			for (int x=-d-2; x<=d+2; x++) {
				for (int y=-d-2; y<=d+2; y++) {
					if (aps(x) + aps(y) < d/2 ||
						aps(x) + aps(y-1) < d/2)
					{
						fig1.push_back({x, y});
					}

					if (aps(x) + aps(y) < d/2 ||
						aps(x-1) + aps(y) < d/2)
					{
						fig2.push_back({x, y});
					}
				}
			}

			for (int i=-4*d; i<=n+4*d; i+=2*d) {
				for (int j=-4*d; j<=m+4*d; j+=2*d) {

					crtaj(fig1, i, j, 0);
					crtaj(fig1, i+d, j+d, 0);

					crtaj(fig1, i+d-1, j, 1);
					crtaj(fig1, i+d+d-1, j+d, 1);

					
					crtaj(fig2, i+d/2-1, j+d/2+1, 2);
					crtaj(fig2, i-d/2-1, j-d/2+1, 2);

					crtaj(fig2, i+d/2-1, j+d/2+d, 3);
					crtaj(fig2, i-d/2-1, j-d/2+d, 3);
					
				}
			}
		}
	}

	bool invalid = false;

	// validate
	/*
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if (!valid(i, j)) {
				invalid = true;
			}
		}
	}
	*/

	if (invalid) {
		cerr << "invalid\n";
	}

	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			cout << "RGBY "[a[i][j]];
		}
		cout << '\n';
	}
}

Measured memory_bytes: 10336
import operator


while True:
    a, op, b = input().split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    c = 0
    if op == '+':
        c = a+b
    elif op == '-':
        c = a-b
    elif op == '*':
        c = a*b
    else:
        c = a//b
    print(c)

    
    


Measured memory_bytes: 5676
a = [int(input())]
for i in range(1000000):
	if a[i] % 2 == 0:
		a.append(a[i] // 2)
	else:
		a.append(3 * a[i] + 1)
	if a[i + 1] in a[: i]:
		print(i + 2)
		break


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		
		while (n != 0) {
			int grid[][] = new int[n + 2][n + 2];
			int maxLen = 0;
			
			for(int i = 1; i <= n; i++) {
				String s = scanner.nextLine();
				for(int j = 1; j <= n; j++) {
					grid[j][i] = Integer.parseInt(s.substring(j - 1, j));
				}
			}
			
			for(int x = 1; x <= n; x++) {
				for(int y = 1; y <= n; y++) {
					if (n - x + 1 <= maxLen && n - y + 1 <= maxLen) {
						break;
					}
					
					int len = 0;
					for(int px = x; px <= n; px++) {
						if (grid[px][y] == 0) {
							break;
						}
						len++;
					}
					if (len > maxLen) {maxLen = len;}

					len = 0;
					for(int py = y; py <= n; py++) {
						if (grid[x][py] == 0) {
							break;
						}
						len++;
					}
					if (len > maxLen) {maxLen = len;}

					len = 0;
					for(int px = x; px >= 1; px--) {
						if (grid[px][y + (x - px)] == 0) {
							break;
						}
						len++;
					}
					if (len > maxLen) {maxLen = len;}

					len = 0;
					for(int px = x; px <= n; px++) {
						if (grid[px][y + (px - x)] == 0) {
							break;
						}
						len++;
					}
					if (len > maxLen) {maxLen = len;}
				}
			}
			System.out.println(maxLen);
			n = Integer.parseInt(scanner.nextLine());
		}
	}

}

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

int main(){

    int n;
    cin >> n;

    vector<int> v;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    reverse(v.begin(), v.end());

    for(int i=0; i<n; i++){
        if(i!=n-1) cout << v[i] << " ";
        else cout << v[i] << endl;
    }

    return 0;
}


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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  ll n; cin >> n;
  vector<ll> v(n, 0);
  rep(n, i) cin >> v[i];

  ll res = 0;
  rep(n, i) {
    ll bit = v[i];
    ll cnt = 0;
    while (bit % 2 == 0) {
      ++cnt;
      bit >>= 1;
    }
    res += cnt;
  }

  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ar = new long[n];
        for (int i = 0; i < ar.length; i++) {
            ar[i] = sc.nextLong();
        }
        Arrays.sort(ar);
        long curr = ar[0];
        int start = 0;
        for(int i = 1; i < n; i++){
            if(2 * curr >= ar[i])
                curr += ar[i];
            else{
                start = i;
                curr += ar[i];
            }
        }
        System.out.println(n - start);
    }
}


Measured memory_bytes: 49908
n = gets.to_i
b_array = gets.chomp.split(" ").map(&:to_i)

pre_a = b_array[0]
ret = pre_a
(0...(n-1)).each do |i|
    if i < n-2 && b_array[i] > b_array[i+1]
        pre_a = b_array[i+1]
    elsif pre_a < b_array[i]
        pre_a = b_array[i]
    end
    ret += pre_a
end

puts ret

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

using namespace std;

const long long MOD = (long long)1e9 + 7;
long long func[100010];

void init_func(){
    func[0] = 1;
    for(int i = 1; i <= 100001; i++){
        func[i] = (func[i - 1] * i) % MOD; 
    }
}

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

long long comb(long long x, long long y){
    if(x < y) return 0;
    return (((func[x] * mod_pow(func[y], MOD - 2)) % MOD) * mod_pow(func[x - y], MOD - 2)) % MOD;
}

int main(){
    int n, ans = 0, l, r;
    cin >> n;
    vector<int> b(n + 1, -1);
    for(int i = 0; i < n + 1; i++){
        int x;
        cin >> x;
        if(b[x] == -1)
            b[x] = i;
        else{
            l = b[x];
            r = n - i;
            break;
        }
    }
    init_func();
    for(int i = 1; i <= n + 1; i++){
        cout << (comb(n + 1, i) - comb(l + r, i - 1) + MOD) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define erep(i,container) for (auto i : container)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int a,b;
    std::cin >> a>>b;
    if(a*b==15)std::cout << '*' << std::endl;
    else if(a+b==15)std::cout << '+' << std::endl;
    else std::cout << 'x' << std::endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
   public static void main(String[] $) {
       int n=sc.nextInt();
       long[] a=new long[n];
       for (int i = 0; i < n; i++) {
           a[i]=sc.nextLong();
       }
       int m=sc.nextInt();
       long[] b=new long[m];
       for (int i = 0; i < m; i++) {
           b[i]=sc.nextLong();
       }
       int temp=0;
       for (int i = 0; i < m; i++) {
           if(Arrays.binarySearch(a,b[i])>=0)temp++;
       }
       out.println(temp==m?1:0);
       out.close();
   }

   static PrintWriter out = new PrintWriter(System.out);

   static class sc {
       static Scanner s = new Scanner(System.in);

       static String next() {
           return s.next();
       }

       static String nextLine() {
           return s.nextLine();
       }

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

       static long nextLong() {
           return Long.parseLong(s.next());
       }

       static double nextDouble() {
           return Double.parseDouble(s.next());
       }

       static boolean hasNext() {
           return s.hasNext();
       }
   }
}


Measured memory_bytes: 74840
#include<queue>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int M, K;
int A[1<<18];
int mi[1<<18], ma[1<<18];
pair<int, int> X[1<<18];
int ans[1<<18];

int rev(int x) {
    int r = 0;
    REP (i, K) if (x>>i&1) r |= 1<<(K-1-i);
    return r;
}

void MAIN() {
    scanf("%d", &K);
    M = 1<<K;
    REP (i, M) scanf("%d", A+i), A[i]--;
    memset(ma, 0x3f, sizeof ma);
    memset(mi, 0xc0, sizeof mi);
    REP (i, M) if (A[i] != -1) {
	mi[rev(i)] = ma[rev(i)] = A[i];
    }

    REP (t, K) REP (i, M) if (i>>t&1) {
	int k = i ^ (1<<t);
	amin(ma[k], ma[i]-1);
	amax(mi[i], mi[k]+1);
    }

    REP (i, M) {
	if (ma[i] < mi[i]) {
	    puts("NO");
	    return;
	} else {
	    X[i] = make_pair(mi[i], i);
	}
    }

    sort(X, X+M);

    int pos = 0;
    priority_queue<pair<int, int>> Q;

    REP (i, M) {
	while (pos < M && X[pos].first <= i) {
	    Q.emplace(-ma[X[pos].second], X[pos].second);
	    pos++;
	}
	if (Q.empty()) {
	    puts("NO");
	    return;
	}

	int limit = -Q.top().first;
	int idx = Q.top().second;
	Q.pop();
	if (i <= limit) {
	    ans[idx] = i+1;
	} else {
	    puts("NO");
	    return;
	}
    }

    puts("YES");
    rprintf("%d", ans, ans+M);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 9840
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll oni = v * t;
	ll nige = w * t;
	if(a < b){
		oni += a;
		nige += b;
		if(oni >= nige) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else{
		oni = a - oni;
		nige = b - nige;
		if(oni <= nige) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <set>

using namespace std;

int main(){

    int n; 
    cin >> n;

    int nums[n];

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


    set<int> second (nums,nums+n);       
    cout << second.size() << endl;



    return 0;
}

Measured memory_bytes: 256
# 175 B
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(0, len(L)):
    for j in range(i+1, len(L)):
        for k in range(j+1, len(L)):
            if L[i] != L[j] and L[j] != L[k] and (L[k] < L[i] + L[j]):
                ans += 1
print(ans)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
 int w,d;
  while(cin>>w>>d,d){

int ww[300]={},dd[300]={};
for(int i=0;i<w;i++){int a;cin>>a;ww[a]++;}
for(int i=0;i<d;i++){int a;cin>>a;dd[a]++;}
int ans=0;
for(int i=0;i<300;i++){ans+=i*min(ww[i],dd[i]);ans+=i*(abs(ww[i]-dd[i]));}
cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

typedef pair<int, int> P;
typedef pair<P, int> PP;

signed main() {
    int n;
    cin >> n;
    int c[n];
    int ans = 0;
    rep(n, i) {
        int a, b;
        cin >> a >> b;
        ans -= b;
        c[i] = a + b;
    }
    sort(c, c + n, greater<int>());
    rep(n, i) {
        if (i % 2) continue;
        ans += c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=105;
const int M=10005;

struct node{
	int c,s;
}c[M];
int h,w,n,x,y,d;
int a[N][N];

bool cmp(node a,node b){
	return a.s<b.s;
}

void nxt(int &x,int &y,int &d){
	if (y==w&&d==0){
		x++,d^=1;
		return;
	}
	if (y==1&&d==1){
		x++,d^=1;
		return;
	}
	if (!d) y++;
	else y--;
}

int main(){
	int i,j;
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&c[i].s),c[i].c=i;
	sort(c+1,c+1+n,cmp);
	x=1; y=1; d=0;
	for (i=1;i<=n;i++){
		for (j=1;j<=c[i].s;j++){
			a[x][y]=c[i].c;
			nxt(x,y,d);
		}
	}
	for (i=1;i<=h;i++){
		for (j=1;j<=w;j++) printf("%d ",a[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

  vector<int> lefts(m);
  vector<int> rights(m);
  for (int i = 0; i < m; i++) {
    cin >> lefts.at(i) >> rights.at(i);
  }

  int distance = *min_element(rights.begin(), rights.end()) - *max_element(lefts.begin(), lefts.end());
  if (distance < 0) {
    cout << 0 << endl;
  }
  else {
    cout << distance + 1 << endl;
  }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){ break;}
			Print(H, W);
		}
		scanner.close();
	}
	
	
	public static void Print(int H , int W){
		for(int y = 0; y < H ; y++){
			for(int x = 0 ; x < W ; x++){
				System.out.print("#");
			}
			System.out.println("");
		}
                System.out.println("");
		return ;
	}

}

Measured memory_bytes: 35208