akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,M;
  cin>>N>>M;
  string str;
  cin>>str;
  int index = N;
  vector<int> ANS;
  while(index != 0)
  {
    for (int i = M ; i >= 0; i--)
    {
      if(i == 0)
      {
        // abort();
        cout<<-1<<endl;
        return;
      }

      if(index - i < 0)continue;

      if(str[index - i] == '0')
      {
        ANS.push_back(i);
        index -= i;
        break;
      } 
    // DEBUG(ANS);
    
  }
  if(index == 0)break;
  }
  
  reverse(ALL(ANS));
  for (int i = 0; i < ANS.size(); i++)
  {
    if(i != 0)cout<<" ";
    cout<<ANS[i];

  }
  cout<<endl;
  
  
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //setprecision(7);
    double l;
    cin>>l;
    //cout<<(l/3.0);
    double ans=(l/3.0)*(l/3.0);
    //cout<<ans<<"\n";
    ans=ans*(l/3.0);
    printf("%lf",ans);
}

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

int main(void){
    int row, col, i, j, *row_black, *col_black;
    char **ptr;
    scanf("%d %d", &row, &col);
    
    if((ptr = (char**)calloc(row, sizeof(char*))) == NULL)
        exit(1);
    for(i = 0; i < row; i++)
        if((ptr[i] = (char*)calloc(col, sizeof(char))) == NULL)
            exit(1);
    if((row_black = (int*)calloc(row, sizeof(int))) == NULL)
        exit(1);
    if((col_black = (int*)calloc(col, sizeof(int))) == NULL)
        exit(1);
        
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &ptr[i][j]);
            if(ptr[i][j] == '#'){
                row_black[i] = 1;
                col_black[j] = 1;
            }
        }
    }
    
    for(i = 0; i < row; i++){
        if(row_black[i] == 1){
            for(j = 0; j < col; j++){
                if(col_black[j] == 1){
                    putchar(ptr[i][j]);
                }
            }
            putchar('\n');
        }
    }
    
    free(row_black);
    free(col_black);
    for(i = 0; i < row; i++)
        free(ptr[i]);
    free(ptr);
    return 0;
}

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

using namespace std;

int main()
{
    int S;
    cin >> S;
    //YYMM,MMYY,AMBIGUOUS,NA
    //00~99,01~12
    int f = S / 100;
    int b = S - f * 100;
    if (f >= 1 && f <= 12 && b >= 1 && b <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else if (f >= 1 && f <= 12 && b >= 0 && b <= 99) {
        cout << "MMYY" << endl;
    } else if (b >= 1 && b <= 12 && f >= 0 && f <= 99) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DXorSum4 solver = new DXorSum4();
        solver.solve(1, in, out);
        out.close();
    }

    static class DXorSum4 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            long[] a = new long[n];
            int[] t = new int[61];
            int[] f = new int[61];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }

            for (int i = 0; i < n; i++) {
                long cmp = a[i];
                for (int j = 0; j < 61; j++) {
                    if (cmp % 2 == 1) {
                        t[j]++;
                    } else {
                        f[j]++;
                    }
                    cmp /= 2;
                }
            }

            ModInt ans = new ModInt(0);
            for (int i = 0; i < 61; i++) {
                ModInt ad1 = new ModInt((long) t[i] * (long) f[i]);
                ModInt ad2 = new ModInt((long) Math.pow(2, i));
                ad1 = ad1.mul(ad2);
                ans = ans.add(ad1);
            }

            out.println(ans.getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (int) ((i + MOD) % MOD);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public ModInt mul(ModInt m) {
            return new ModInt(this.val * m.getVal());
        }

        public long getVal() {
            return val;
        }

    }
}



Measured memory_bytes: 98156
#include <iostream>
#include <stdio.h>
using namespace std;
int main (){
	
	int d,r,a,b;
	double f;
	cin >> a >> b; 
	
	d=a/b;
	r=a%b;
	f=(double)a/b;

	printf("%d %d %lf",d,r,f);
	
	
return 0;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a,b;
  cin >> a >> b;
  int maxn;
  maxn = max(a+b,a-b);
  maxn = max(a*b,maxn);
  cout << maxn << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n - 1) {
    vb a(26, false), b(26, false);
    rep(j, i + 1) a[s[j] - 'a'] = true;
    rep2(j, i + 1, n) b[s[j] - 'a'] = true;
    int now = 0;
    rep(j, 26) if(a[j] && b[j]) now++;
    ans = max(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    ll ans = 0; 
    for (ll i=1; i<(n+1); i++){
        ans += n / i - (n%i==0);
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXK=1e5+69,MOD=1e9+7;
int n,k,ans;
int cnt[MAXK];
int luythua(int x,int y){
    if(y==0)return 1;
    if(y==1)return x;
    int k=luythua(x,y/2);
    return k*k%MOD*luythua(x,y&1)%MOD;
}
signed main(){
    cin>>n>>k;
    for(int i=k;i>=1;i--){
        cnt[i]=luythua(k/i,n);
        for(int j=i*2;j<=k;j+=i)cnt[i]=(cnt[i]-cnt[j]+MOD)%MOD;
        ans=(ans+cnt[i]*i%MOD)%MOD;
    }
    cout<<ans;
}

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

int main() {
    int n, m; cin >> n >> m;
    for (int g = m / n; g > 0; g--) {
        if (m % g == 0) {
            cout << g << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int a,b,n;
	int cna=0,cnb=0;
	string s;
	cin>>n>>a>>b;
	cin>>s;
	for(int i=0;i<n;i++){
		if(cna+cnb<a+b){
		if(s[i]=='a'){
			cout<<"Yes"<<endl;
			cna++;
		}
		else if(s[i]=='b'){
			if(cnb<b){
				cout<<"Yes"<<endl;
				cnb++;
			}
			else{
			cout<<"No"<<endl;
			}
		}
		else{
			cout<<"No"<<endl;
		}
		}
		else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

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


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

    int n,ans=0;
    string a, b, c;
    cin >> n >> a >> b >> c;

    rep(i,n){
        if(a[i]==b[i]&&a[i]==c[i])
            continue;
        else if(a[i]==b[i])
            ans++;
        else if(a[i]==c[i])
            ans++;
        else if(b[i]==c[i])
            ans++;
        else
            ans += 2;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//

int main() {
  ll n;
  cin >> n;
  cout << (24 - n) + 24 << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;



signed main() {
    int s,w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}




Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int m, f, b;
    cin >> m >> f >> b;
    if(m >= b){
        cout << 0 << endl;
    }else if(m + f >= b){
        cout << b - m << endl;
    }else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;

int sum[501];
int b[501][501];
int n,m;

int dfs(int k,int num){
    if(k==n){
        for (int i = 0; i < m; i++) {
            if(sum[i]%2) return 0;
        }
        return num;
    }
    int ret = dfs(k+1,num);
    for (int i = 0; i < m; i++) {
        sum[i] ^= b[k][i];
    }
    ret = max(ret,dfs(k+1,num+1));
    for (int i = 0; i < m; i++) {
        sum[i] ^= b[k][i];
    }
    return ret;
}

int main(){
    while(cin >> n >> m){
        if(!n&&!m) break;
        string s[n];
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        memset(b,0,sizeof(b));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(s[i][j]=='1') b[i][j] = 1;
            }
        }
        if(m<n){
            vector<vector<int>> dp(2,vector<int>(1<<(m+1),-1));
            vector<int> x(n+1,0);
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if(b[i][j]) x[i]+=(1<<j);
                }
            }
            dp[0][0] = 0;
            for (int i = 0; i < n; i++) {
                for (int k = 0; k < (1<<m); k++) {
                    if(dp[0][k]==-1) continue;
                    int nx = k^x[i];
                    dp[1][k] = max(dp[0][k],dp[1][k]);
                    dp[1][nx] = max(dp[1][nx],dp[0][k]+1);
                }
                dp[0] = dp[1];
            }
            cout << dp[0][0] << endl;
        }
        else{
            cout << dfs(0,0) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 53176
import sys
from bisect import bisect_right, bisect_left
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    cnt = Counter(a + b)
    e, num = cnt.most_common(1)[0]
    if num > n:
        print("No")
    else:
        step = 0
        for e in set(a) & set(b):
            s = bisect_right(a, e) - bisect_left(b, e)
            step = max(step, s)
        ans = [0] * n
        for i in range(n):
            ans[i] = b[(i - step) % n]
        print("Yes")
        print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68400
#include<iostream>
using namespace std;
int main()
{
  int count=0,max=0;
  string s;
  cin>>s;
  char temp=s[0];
  for(int i=0;i<3;i++)
  {
    if(s[i]!=temp)
    {
      if(max<=count)
    	max=count;
      count=0;
    }  
    if(s[i]=='R')
      count++;
    temp=s[i];
  }
  if(max<=count)
	max=count;
  cout<<max<<endl;
  return 0;
} 

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n;
void dfs(string ans, int max){
  if(ans.size()==n){
    cout << ans << endl;
    return;
  }
  rep(i,max+1) {
    string s = ans;
    s += 'a' + i;
    dfs(s, (i==max?i+1:max));
  }
}

int main() {
  cin >> n;
  dfs("",0);
}


Measured memory_bytes: 1536
def fib(n):
  if F[n] != 0:
    return F[n]
  elif n==0 or n==1:
    F[n] = 1
  else:
    F[n] = fib(n-1) + fib(n-2)

  return F[n]



n = input()
F = [0 for row in range(n+1)]
print fib(n)

Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{

    string S, sum;
    cin >> S;

    rep(i, S.size())
    {
        if (i % 2 == 0)
        {
            sum += S[i];
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, ans = 0;
  cin >> n;
  VLL A(n), B(n);
  REP(int, i, n) cin >> A[i] >> B[i];
  REPR(int, i, n) if ((A[i]+ans) % B[i]) ans += B[i] - ((A[i]+ans) % B[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4796
#include<stdio.h>

int main(void){
   int i, e;
   static int n[26];
   char st, a[53]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

   do{
   e = scanf("%c", &st);

   for(i=0;i<52;i++){
     if(a[i] == st){
        n[i%26]++;
          }
   }
   }while(e !=EOF);

   for(i=0;i<26;i++){
      printf("%c : %d\n", a[i],n[i]);
   }
   return 0;
}


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

struct Edge {
    int s;
    int t;
    int w;
    bool operator < (const Edge& tgt) const {
	return w > tgt.w;
    }
};
inline int Prim(const vector<vector<Edge>>& g) {
    const int V = g.size();
    priority_queue<Edge> pq;
    set<int> used;
    used.insert(0);
    for(auto& e : g[0]) {
	pq.push( e );
    }
    int ans = 0;
    while( used.size() != V and pq.size()>0 ) {
	auto e = pq.top(); pq.pop();
	if( used.find(e.s) != used.end() and  used.find(e.t) != used.end() ) continue;
	ans += e.w;
	used.insert(e.s);
	used.insert(e.t);
	for(auto& ne : g[e.s])
	    pq.push(ne);
	for(auto& ne : g[e.t])
	    pq.push(ne);
    }
    return ans;
}

/*
inline int Kruskal(const vector<vector<Edge>>& g) {
    const int V = g.size();
    vector<Edge> edges;
    for(auto& u_edges : g)
	for(auto& e : u_edges)
	    edges.push_back(e);

    sort(edges.begin(), edges.end());
//    for(auto& e : edges) cout << e.w << endl;

    int ans = 0;
    set<int> used;
    for(auto& e : edges) {
	if( used.size() == V ) break;
	if( used.find(e.s) == used.end() or used.find(e.t) == used.end() ) {
	    used.insert(e.s);
	    used.insert(e.t);
	    ans += e.w;
	}
    }
    return ans;
}
*/

int main () {

    int V,E;
    cin >> V >> E;

    vector<vector<Edge>> g(V);
    for (int i=0; i<E; ++i) {
	int s,t,w;
	cin >> s >> t >> w;
	g[s].push_back(Edge{s,t,w});
	g[t].push_back(Edge{t,s,w});
    }
    int ans = Prim(g);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13332
module Main(main) where
import Data.List

attack katana h =
  let as = map head katana
      bs = map (head . tail) katana
      ma = foldl max 1 as
      tk = reverse $ sort $ filter (> ma) bs
      simulate :: Int -> Int -> [Int] -> Int
      simulate cnt rest [] =
        if rest > 0 then simulate (cnt+1) (rest - ma) []
        else cnt
      simulate cnt rest (x:xs) =
        if rest > 0 then simulate (cnt+1) (rest - x) xs
        else cnt
  in simulate 0 h tk

main :: IO ()
main = do
  [n,h] <- map read . words <$> getLine :: IO [Int]
  katana <- (map $ map read . words) <$> (sequence $ replicate n getLine) :: IO [[Int]]
  print $ attack katana h



Measured memory_bytes: 170364
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

int blur[3][5][5] = {
	{
		{ 0,0,1,0,0 },
		{ 0,1,1,1,0 },
		{ 0,0,1,0,0 },
		{ 0,0,0,0,0 },
		{ 0,0,0,0,0 },
	},
	{
		{ 0,0,1,1,1 },
		{ 0,0,1,1,1 },
		{ 0,0,1,1,1 },
		{ 0,0,0,0,0 },
		{ 0,0,0,0,0 },
	},
	{
		{ 0,0,1,0,0 },
		{ 0,1,1,1,0 },
		{ 1,1,1,1,1 },
		{ 0,1,1,1,0 },
		{ 0,0,1,0,0 },
	}
};
int A[20][20] = {};

bool check(int b, int i, int j) {
	rep(p, 0, 5)rep(q, 0, 5) if (A[i + p][j + q - 2] - blur[b][p][q] < 0)return false;
	return true;
}

void fblur(int b, int i, int j) {
	rep(p, 0, 5)rep(q, 0, 5) A[i + p][j + q - 2] -= blur[b][p][q];
}

void frblur(int b, int i, int j) {
	rep(p, 0, 5)rep(q, 0, 5) A[i + p][j + q - 2] += blur[b][p][q];
}

bool rec(int n, int i, int j) {
	if (n < 0)return false;
	if (i == 10 && n == 0)return true;
	if (A[i][j] == 0)return rec(n, i + (j == 9), (j + 1) % 10);
	rep(b, 0, 3) {
		if (!check(b, i, j))continue;
		fblur(b, i, j);
		if (rec(n - 1, i, j)) {
			cout << j + (b == 1) << " " << i + 1 + (b == 2) << " " << b + 1 << endl;
			return true;
		}
		frblur(b, i, j);
	}
	return false;
}

signed main() {
	int n; cin >> n;
	rep(i, 0, 10)rep(j, 0, 10)cin >> A[i][j];
	rec(n, 0, 0);
	return 0;
}

Measured memory_bytes: 3124
package main

import (
	"fmt"
)

func reverse(s string, a, b int) string {
	n := b - a + 1
	t := []rune(s)
	for i := 0; i < n/2; i++ {
		t[i+a], t[b-i] = t[b-i], t[i+a]
	}
	return string(t)
}

func main() {

	var str string
	var n int
	fmt.Scan(&str, &n)

	for ; n >=0 ; n-- {
		var cmd string
		var a, b int
		fmt.Scan(&cmd, &a, &b)

		switch cmd {
		case "replace":
			var s  string
			fmt.Scan(&s)
			str=str[:a] + s + str[b+1:]
		case "reverse":
			str=reverse(str,a,b)
		case "print":
			fmt.Println(str[a : b+1])
		}
	}
}



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

int main()
{
	int N;
	while (cin >> N, N) {
		int ma = 0, sum = 0, dsum = 0;
		vector<int> r(N), w(N);
		for (int i = 0; i < N; i++) {
			cin >> r[i] >> w[i];
			sum += r[i];
			ma = max(ma, r[i]);
			dsum += r[i] + w[i];
		}
		if (ma * 2 <= sum) {
			cout << dsum << endl;
		}
		else {
			int W = ma * 2 - sum;
			vector<vector<int>> dp(N + 1, vector<int>(W + 1));
			dp[0][0] = 1;
			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= W; j++) {
					if (r[i] != ma && j - w[i] >= 0 && dp[i][j - w[i]]) {
						dp[i + 1][j] = 1;
					}
					else if (dp[i][j]) {
						dp[i + 1][j] = 1;
					}
				}
			}
			int wma = 0;
			for (int i = 0; i <= W; i++) {
				if (dp[N][i]) {
					wma = i;
				}
			}
			cout << dsum + W - wma << endl;
		}
	}
	return 0;
}

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

int main() {
	string a;
	cin >> a;
	int b=0;
	for (char c : a) {
		if (c == 'p')b++;
	}
	int d = a.length() / 2;
	cout << d - b << endl;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec H(N); cin >> H;
    bool f = true;
    H[0]--;
    FOR(i, 1, N){
        if(H[i] < H[i - 1]){
            f = false;
            break;
        }else if(H[i] > H[i - 1]) H[i]--;
    }
    Ans(f, "Yes", "No");

    return 0;
}


Measured memory_bytes: 1024
A,B,C = [int(x) for x in input().split()]
x = abs((A//2)*B*C-((A-(A//2))*B*C))
y = abs((B//2)*A*C-((B-(B//2))*A*C))
z = abs((C//2)*A*B-((C-(C//2))*A*B))
print(min(x,y,z))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std; 
long long grid[3001][3001]; long long dp[3001][3001][4];
int main() {
    long long r, c, k; cin >> r >> c >> k;  
    for (long long i = 0; i < k; i ++) {long long a, b, v; cin >> a >> b >> v; grid[a-1][b-1]=v;}
    for (long long i = 0; i < r; i ++) {
        for (long long j = 0; j < c; j ++) {
            if (i == 0 && j == 0) {dp[i][j][0] = 0; dp[i][j][1] = grid[i][j]; dp[i][j][2] = 0; dp[i][j][3] = 0; continue;}
            if (i == 0) {
                dp[i][j][0] = 0; 
                dp[i][j][1] = max(dp[i][j-1][1], dp[i][j-1][0] + grid[i][j]);
                dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + grid[i][j]);
                dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + grid[i][j]);
            } else if (j == 0) {
                dp[i][j][0] = max(max(dp[i-1][j][0], dp[i-1][j][1]), max(dp[i-1][j][2], dp[i-1][j][3]));
                dp[i][j][1] = max(grid[i][j], dp[i][j][0] + grid[i][j]); dp[i][j][2] = 0; dp[i][j][3] = 0;
            } else {
                dp[i][j][0] = max(dp[i-1][j][0], max(max(dp[i-1][j][0], dp[i-1][j][1]), max(dp[i-1][j][2], dp[i-1][j][3])));
                dp[i][j][1] = max(dp[i][j-1][1], max(dp[i][j-1][0] + grid[i][j], dp[i][j][0] + grid[i][j]));
                dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + grid[i][j]);
                dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + grid[i][j]);
            }
        }
    } long long ans = dp[r-1][c-1][0]; for (long long k = 0; k < 4; k ++) ans = max(ans, dp[r-1][c-1][k]); cout << ans << endl;
}

Measured memory_bytes: 355112
#include<stdio.h>

int main(void){
    int input_s,h,m,s;

    scanf("%d", &input_s);

    m = input_s / 60;
    s = input_s % 60;
    h = m / 60;
    m = m % 60;

    printf("%d:%d:%d\n", h,m,s);

    return 0;
}



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

#define TIMES(cnt,a,b) for(int cnt=a; cnt<b; ++cnt)


int main(void){
	string s;
	string c = "CODEFESTIVAL2016";
	int ans=0;

	cin >> s;
	TIMES(i,0,16) {
		ans += s[i]==c[i] ? 0:1;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import sys
INF = float("inf")
readline = sys.stdin.readline
min_r = INF
ans = -INF
n = int(readline())
for i in range(n):
    r = int(readline())
    if ans < r - min_r:
        ans = r - min_r
    if min_r > r:
        min_r = r
print(ans)

Measured memory_bytes: 7720
#include <stdio.h>
int main(void){
	int a[4], b[4];
	int i, j;
	int hit, blow;

	while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) == 4) {
		scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
		hit = blow = 0;
		for (i = 0; i < 4; i++) {
			if (a[i] == b[i]) hit++, a[i] = -1, b[i] = -2;
		}
		if (hit < 4) {
			for (i = 0; i < 4; i++) {
				if (a[i] < 0) continue;
				for (j = 0; j < 4; j++) {
					if (a[i] == b[j]) blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n,m,v,p;
vll a;
vll sum;

// mid ... 添え字 => a[mid]は採用されるか
// midが採用される 
// midがp以内である(n-mid+<=p) => ok
// midがpより後である =>
// midを+1, 0~mid-1を+1する。残り v-(mid+1)
// midがp番目になるには2つ条件が必要
// - v-(mid+1)<=p-1
// - a[mid]+m>=a[n-p (p番目)]
bool isOk(ll mid){
  if(n-mid<=p) return 1;
  
  ll rem=v-(mid+1)-(p-1); // midを選ぶ上で1人が影響のない分を投票した残り
  
  if(rem<=0){
    if(a[mid]+m>=a[n-p]) return 1;
  }else{
    ll cnt=(n-(p-1))-(mid+1);
    ll d=(sum[n-(p-1)]-sum[mid+1]);
    ll x=(a[mid]+m)*cnt-d;
    // cout<<mid<<' '<<d<<' '<<x<<' '<<rem<<' '<<cnt<<endl;
    if(x>=rem*m && a[mid]+m>=a[n-p]) return 1;
  }
  return 0;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n>>m>>v>>p;
  
  a.resize(n);
  rep(i,n) cin>>a[i];
  vsort(a);
  sum.resize(n+1);
  rep(i,n) sum[i+1]=sum[i]+a[i];
  
  // rep(i,n) cout<<a[i]<<' ';
  // cout<<endl;
  
  ll ng=-1, ok=n-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid)) ok=mid;
    else ng=mid;
  }
  ll ans=n-ok;
  
  cout<<ans<<endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  vector<int> r, g, b;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'R') r.emplace_back(i);
    else if (s.at(i) == 'G') g.emplace_back(i);
    else b.emplace_back(i);
  }
  
  if (r.size() == 0 || g.size() == 0 || b.size() == 0) {
    cout << "0\n";
    return 0;
  }
  
  ll ans = 0;
  for (int i = 0; i < r.size(); i++) {
    for (int j = 0; j < g.size(); j++) {
      int left = r.at(i), right = g.at(j);
      if (left > right) swap(left, right);
      int keep = b.size();
      if ((2 * right - left < n) && *lower_bound(b.begin(), b.end(), 2 * right - left) == 2 * right - left && lower_bound(b.begin(), b.end(), 2 * right - left) != b.end()) {
      keep--;
      }
      if ((2 * left - right >= 0) && *lower_bound(b.begin(), b.end(), 2 * left - right) == 2 * left - right && lower_bound(b.begin(), b.end(), 2 * left - right) != b.end()) {
      keep--;
      }
      if (((left + right) % 2 == 0) && *lower_bound(b.begin(), b.end(), (left + right) / 2) == (left + right) / 2) keep--;
      ans += keep;
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3652
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    double N, M; cin >> N >> M;
    vector<double>A(N); rep(i, N)cin >> A[i];
    sort(all(A), greater<int>());
    double sum = 0;
    for (auto x : A)sum += x;
    double kijun = sum * (1 / (4 * M));
    auto b = true;
    rep(i, M) {
        if (A[i] < kijun) {
            b = false;
            break;
        }
    }
    if (b)puts("Yes");
    else puts("No");
}



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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();
    int n;
    string s;
    cin>> n>> s;

    int c= count(s.begin(), s. end(), 'R');
    c-=count(s.begin(), s.begin()+ c, 'R');

    cout<< c;
    nl;

    return 0;
}




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

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

int N,M;

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

	cin >> N >> M;
	int a[100],b[100];
	int ans = 0;

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

	for (int i = 0;i < M;i++){
		vector<int> G[100];
		for (int j = 0;j < M;j++){
			if(i == j) continue;
			G[a[j]].push_back(b[j]);
			G[b[j]].push_back(a[j]);
		}
		queue<int> que;
		bool used[100]; memset(used,0,sizeof(used));
		used[1] = true;
		que.push(1);
		int cnt = 1;
		while(que.size()){
			int now = que.front(); que.pop();
			for (int j = 0;j < G[now].size();j++){
				int to = G[now][j];
				if(!used[to]){
					cnt++;
					used[to] = true;
					que.push(to);
				}
			}
		}
		if(cnt != N) ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

#define N 305
dd dp[N][N][N];

ll cnt[3];
ll n;
dd dfs(ll i,ll j,ll k){
    if(dp[i][j][k]>=-1.5)return dp[i][j][k];
    if(i==0&&j==0&&k==0)return dp[i][j][k]=0.0;
    dp[i][j][k]=n;
    if(i-1>=0)dp[i][j][k]+=i*dfs(i-1,j,k);
    if(j-1>=0)dp[i][j][k]+=j*dfs(i+1,j-1,k);
    if(k-1>=0)dp[i][j][k]+=k*dfs(i,j+1,k-1);
    dp[i][j][k]/=(dd)(i+j+k);
    return dp[i][j][k];
}

int main(){fastio
    rep(i,0,N-1)rep(j,0,N-1)rep(k,0,N-1)dp[i][j][k]=-2.5;
    cin>>n;
    rep(i,1,n){
        ll c;cin>>c;cnt[c-1]++;
    }
    
    cout<<setprecision(20)<<dfs(cnt[0],cnt[1],cnt[2])<<endl;
    /*
    cout<<endl;
    rep(i,0,3){
        rep(j,0,3){
            rep(k,0,3){
                cout<<setprecision(20)<<dp[i][j][k]<<" ";
            }cout<<endl;
        }cout<<endl;
    }cout<<endl;*/
    
    return 0;
}



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

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = k; i < n; i++) 
    cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; string s; cin>>N>>s;
	long dp[N][N] = {}; dp[0][0] = 1;
	rep(i,1,N){
		if(s[i-1] == '<'){
			for(int j = 1; j <= i; j++) (dp[i][j] += dp[i][j-1] + dp[i-1][j-1] % mod) %= mod;
		}else{
			for(int j = i-1; j >= 0; j--) (dp[i][j] += dp[i][j+1] + dp[i-1][j] % mod) %= mod;
		}
	}
	long ans = 0;
	rep(i,0,N) (ans += dp[N-1][i]) %= mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 70528
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        try (Scanner sc = new Scanner(System.in)){
            while(sc.hasNextDouble()){
                double x1 = sc.nextDouble();
                double y1 = sc.nextDouble();
                double x2 = sc.nextDouble();
                double y2 = sc.nextDouble();
                double x3 = sc.nextDouble();
                double y3 = sc.nextDouble();
                double xp = sc.nextDouble();
                double yp = sc.nextDouble();
                double v1 = (x1-x3)*(yp-y3)-(xp-x3)*(y1-y3);
                double v2 = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
                double v3 = (x3-x2)*(yp-y2)-(xp-x2)*(y3-y2);
                if ((v1<0 && v2<0 && v3<0) || (v1>0 && v2>0 && v3>0)){
                    System.out.println("YES");
                }else{
                    System.out.println("NO");
                }
            }
        }
    }
}


Measured memory_bytes: 30660
a=[]
b=[]
x=0
y=0
z=x-y
ans=[]

N=int(input())
for i in range(N):
  c=input()
  a.append(c)
M=int(input())
for i in range(M):
  c=input()
  b.append(c)
  
for i in a:
  for j in a:
    if(i==j):
      x+=1
  for k in b:
    if(i==k):
      y+=1
  z=x-y
  if(z<=0):
    z=0
  ans.append(z)
  x=0
  y=0
  z=0

d=max(ans)
print(d)

  
   
    

  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int maxn=1e5+5;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int a=0,b=0;
    rep(i,n)
    {
        if(s[i]=='R') a++;
        else b++;
    }
    printf("%s\n",a>b?"Yes":"No");
}


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

typedef long long ll;
typedef long double ld;

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

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

    if(b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for(int i=0; i<N; i++) cin >> x[i];
    for(int i=0; i<M; i++) cin >> y[i];
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if(x[N-1] < y[0]){
        for(int i=x[N-1]+1; i<=y[0]; i++){
            if(X<i && i<=Y){
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    cout << "War" << endl;
}


Measured memory_bytes: 256
while True:
    n=int(input())
    a=0
    if n==0:
        break
    while True:
        if n==1:
            print(a)
            break
        elif n%2==1:
            n*=3
            n+=1
            a+=1
        elif n%2==0:
            n/=2
            a+=1


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] msg = Console.ReadLine().Split(' ');
            int sx = int.Parse(msg[0]);
            int sy = int.Parse(msg[1]);
            int tx = int.Parse(msg[2]);
            int ty = int.Parse(msg[3]);

            string result = "";
            //sx,sy => 辺に沿って移動
            for (int i = sy; i < ty; i++) result += "U";
            //右に折り返すとtx,tyに到達する
            for (int i = sx; i < tx; i++) result += "R";
            //下に折り返す
            for (int i = ty; i > sy; i--) result += "D";
            //左に折り返すとsx,xyに戻る
            for (int i = tx; i > sx; i--) result += "L";
            //sx,xyから外に一歩
            result += "L";
            //sx-1,sy => 辺に沿って移動してty + 1まで
            for (int i = sy; i < ty + 1; i++) result += "U";
            //右に折り返すとtx,ty + 1に到達する
            for (int i = sx - 1; i < tx; i++) result += "R";
            //下と右に一歩づつ
            result += "DR";
            //下に折り返す
            for (int i = ty; i > sy - 1; i--) result += "D";
            //左に折り返すとsx,xy - 1に戻る
            for (int i = tx + 1; i > sx; i--) result += "L";
            //上に一歩で元のさやに
            result += "U";

            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 26568
// 21:12
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

string ln;
int p;
vector< vector<int> > V;
vector<string> name;
vector<int> cntt;

int f(int dep = 0){
	//if( ln[p] != '~' && ln[p] == '<' && ln[p+1] != '/'){
		
		p++;
		string s;
		while(ln[p] != '>'){
			s += ln[p++];
		}
		p++;
		int c = 0;
		vector<int> w(4);
		stringstream ss;
		string t;
		while(ln[p] != '<'){
			t += ln[p++];
		}
		for(int i = 0 ; i < t.size() ; i++) if( t[i] == ',' ) t[i] = ' ';
		ss << t;
		assert((ss >> w[0] >> w[1] >> w[2] >> w[3]));
		int aaa=0;
		while( ln[p] == '<' && ln[p+1] != '/'){
			f(dep+1);
			aaa++;
		}
	//}
	V.push_back(w);
	name.push_back(s);
	cntt.push_back(aaa);	
	if( ln[p] == '~' ) return 0;
	p++;
	p++;
	string cnt;
	
	while(ln[p] != '>')cnt += ln[p++];
	p++;
	assert(cnt == s);
	return 0;
}
int main(){
	int n;
	while(cin >> n && n){
		cin >> ln;
		ln += "~";
		p = 0;
		V.clear();
		name.clear();
		f();
		cntt.clear();
		int fst = 0;
		assert(ln[p] == '~');
		for(int i = 0 ; i < n ; i++){
			int x,y;
			cin >> x >> y;
			int ok = 1e9 , idx = -1 , c = 0;
			for(int j = 0 ; j < V.size() ; j++){
				vector<int> &v = V[j];
				if( v[0] <= x && x <= v[2] && v[1] <= y && y <= v[3] ){
					if( (v[2]-v[0])*(v[3]-v[1]) < ok ){
						ok = (v[2]-v[0])*(v[3]-v[1]);
						idx = j;
					}
				}
			}
			if( idx == -1 ){ cout << "OUT OF MAIN PANEL 1" << endl; continue; }
			
			cout << name[idx] << " " << cntt[idx] << endl;
		}
		
	}
}

Measured memory_bytes: 1264