akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){
    int n;
    cin>>n;
    
    cout<<(n*(n+1))/2;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int Q = in.Int();
            String S = in.next();
            int[] sum = new int[N + 1];
            for (int i = 0; i < N - 1; i++) {
                String S2 = S.substring(i, i + 2);
                if ("AC".equals(S2)) {
                    sum[i + 1]++;
                }
            }
            for (int i = 0; i < N; i++) {
                sum[i + 1] += sum[i];
            }
            for (int i = 0; i < Q; i++) {
                int l = in.Int();
                int r = in.Int();
                out.println(sum[r - 1] - sum[l - 1]);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



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

int main()
{
	while (1)
	{
		priority_queue<int> GAP;
		priority_queue<int> PQ;
		int m, n_min, n_max;
		cin >> m >> n_min >> n_max;
		if (m == 0)break;
		for (int i = 0; i < m; i++)
		{
			int k;
			cin >> k;
			PQ.push(k);
		}
		int index = 0;
		for (int i = n_min; i <= n_max; i++)
		{
			priority_queue<int> tPQ = PQ;
			for (int l = 0; l < i-1; l++)
			{
				tPQ.pop();
			}
			int temp = tPQ.top();
			tPQ.pop();
			int gap = temp - tPQ.top();
			GAP.push(gap);
			if (gap == GAP.top())index = i;
		}
		cout << index << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	map <ll, ll> cnt;
	vector <int> a(n + 3);
	for(int i = 1; i <= n; ++i) cin >> a[i], cnt[a[i]]++;
	for(auto cur : cnt) ans += cur.s * (cur.s - 1) / 2;
	for(int i = 1; i <= n; ++i) cout << ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 2) * (cnt[a[i]] - 1) / 2  << '\n';
	return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    string s; read(s);

    bool f = s == "keyence";
    const int N = s.length();
    rep(i, N) reps(j, i+1, N) {
        string t = "";
        rep(k, N) if (!(i <= k && k < j)) t += s[k];
        f |= t == "keyence";
    }

    print((f) ? "YES" : "NO");
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, c, count=0;
    scanf("%d %d %d", &a, &b, &c);
    
    for(a;a<b+1;a++){
        if(a%c == 0) {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int p[10][10]={0};
	int x,y,s;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		if(s==1){
			p[x][y]+=1;
			if(x-1>=0&&x-1<=9)
			p[x-1][y]+=1;
			if(x+1>=0&&x+1<=9)
			p[x+1][y]+=1;
			if(y-1>=0&&y-1<=9)
			p[x][y-1]+=1;
			if(y+1>=0&&y+1<=9)
			p[x][y+1]+=1;
		}
		else{
			for(int i=x-1;i<=x+1;i++){
				for(int j=y-1;j<=y+1;j++){
					if(i>=0&&i<=9){
						if(j>=0&&j<=9){
							p[i][j]+=1;
						}
					}
				}
			}
			if(s==3){
				if(x-2>=0&&x-2<=9)
				p[x-2][y]+=1;
				if(x+2>=0&&x+2<=9)
				p[x+2][y]+=1;
				if(y-2>=0&&y-2<=9)
				p[x][y-2]+=1;
				if(y+2>=0&&y+2<=9)
				p[x][y+2]+=1;
			}
		}
	}
	int noink=0,dense=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			p[i][j]==0 ? noink++:0;
			dense<p[i][j] ? dense=p[i][j]:0;
		}
	}
	printf("%d\n%d\n",noink,dense);
}

Measured memory_bytes: 3176
n,p = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for a in A:
    if a%2==0: cnt += 1
if n == cnt:
    if p == 0: ans = 2**n
    else: ans = 0
else: ans = 2**(n-1)
print(ans)

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

int A[100001];
int main(){
  int n,k,q;
  int a;
  scanf("%d%d%d",&n,&k,&q);
  
  for(int i=0;i<q;i++){
    scanf("%d",&a);
    A[a]++;
  }
  
  for(int i=1;i<=n;i++){
    if(k-q+A[i]>0)puts("Yes");
    else puts("No");
  }
  
  return 0;
}
      

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    string s;
    cin>>s;
    int n=s.size();
    VVi dp(4,Vi(n+1,0));
    dp[0][0]=1;
    REP(i,0,4){
        REP(j,0,n){
            if(i<3){
                if((i==0 && s[j]=='A') || (i==1 && s[j]=='B') || (i==2 && s[j]=='C')){
                    dp[i][j+1] = (dp[i][j]+dp[i][j+1])%MOD;
                    dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                }else if(s[j]=='?'){
                    dp[i][j+1] = (dp[i][j+1]+3*dp[i][j])%MOD;
                    dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                }else dp[i][j+1] = (dp[i][j]+dp[i][j+1])%MOD;
            }else{
                if(s[j]=='?'){
                    dp[i][j+1] = (dp[i][j+1]+3*dp[i][j])%MOD;
                }else dp[i][j+1] = (dp[i][j]+dp[i][j+1])%MOD;
            }
        }
    }
    cout<<dp[3][n]<<endl;
    return 0;
}


Measured memory_bytes: 4432
n = 999999
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    try:
        n = int(input())
        print(sum(c[:n]))
    except:
        break

Measured memory_bytes: 22096
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    string s;
    cin>>s;
    int n=s.len;
    int cu=0;
    while(cu<n){
        if(n-cu>=6){
            if(s.substr(cu,6)=="eraser"){
                cu+=6;
                continue;
            }
        }
        if(n-cu>=5){
            if(s.substr(cu,5)=="erase"){
                cu+=5;
            }
            else if(s.substr(cu,5)=="dream"){
                if(cu+6<n){
                    if(s[cu+5]=='e'&&s[cu+6]=='r'){
                        if(cu+7<n){
                            if(s[cu+7]=='a'){
                                cu+=5;
                            }
                            else cu+=7;
                        }
                        else cu+=7;
                    }
                    else cu+=5;
                }
                else cu+=5;
            }
            else{
                cout<<"NO";
                return;
            }
        }
        else{
            cout<<"NO";
            return;
        }
    }
    cout<<"YES";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3764
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  int N,K,count=0;
  cin >> N >> K;

  while(N>=K){
    N=N/K;
    count++;
  }
  cout << count+1 << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>

int gcb(int a,int b,int c){
  int d,X,i;
  if(a<=b && a<=c){
    d=a;
  }
  if(b<=a && b<=c){
    d=b;
  }
  if(c<=a && c<=b){
    d=c;
  }
  for(i=1;i<d+1;i++){
    if(a%i==0 && b%i==0 && c%i==0){
      X=i;
    }
  }
  return X;
}

		   

int main(){
  int N,a,b,c;
  long int S=0;
  scanf("%d",&N);
  for(a=1;a<N+1;a++){
    for(b=1;b<N+1;b++){
      for(c=1;c<N+1;c++){
	S+=gcb(a,b,c);
      }
    }
  }
  printf("%ld\n",S);
  return 0;
}


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

#define all(a) (a).begin(), (a).end()


int main(){
	int n;
	cin>>n;
	int a[n];
	bool zero=false;

	long long summ=0;
	int mm=1e+9;
	for (int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i]==0)zero=true;
		summ+=abs(a[i]);
		mm=min(mm,abs(a[i]));
	}
	long long sum=0;
	if(zero){
		for (int i = 0; i < n; ++i){
			sum+=abs(a[i]);
		}
		cout<<sum<<endl;
		return 0;
	}

	for (int i = 0; i < n-1; ++i){
		if(a[i]<0){
			a[i]*=-1;
			a[i+1]*=-1;
		}
		sum+=a[i];
	}

	if(a[n-1]<0){
		cout<<summ-abs(mm)*2<<endl;
		return 0;
	}



	if(abs(a[n-1])>a[n-2]){
		sum+=abs(a[n-1]);
		sum-=a[n-2];
	}else{
		sum+=a[n-1];
	}

	cout<<sum<<endl;


}



Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

const char figure[][4][4] = {
				{
					{'1', '1', '0', '0' },
					{'1', '1', '0', '0' },
					{'0', '0', '0', '0' },
					{'0', '0', '0', '0' }
				},
				{
					{'1', '0', '0', '0' },
					{'1', '0', '0', '0' },
					{'1', '0', '0', '0' },
					{'1', '0', '0', '0' }
				},
				{
					{'1', '1', '1', '1' },
					{'0', '0', '0', '0' },
					{'0', '0', '0', '0' },
					{'0', '0', '0', '0' }
				},
				{
					{'0', '1', '0', '0' },
					{'1', '1', '0', '0' },
					{'1', '0', '0', '0' },
					{'0', '0', '0', '0' }
				},
				{
					{'1', '1', '0', '0' },
					{'0', '1', '1', '0' },
					{'0', '0', '0', '0' },
					{'0', '0', '0', '0' }
				},
				{
					{'1', '0', '0', '0' },
					{'1', '1', '0', '0' },
					{'0', '1', '0', '0' },
					{'0', '0', '0', '0' }
				},
				{
					{'0', '1', '1', '0' },
					{'1', '1', '0', '0' },
					{'0', '0', '0', '0' },
					{'0', '0', '0', '0' }
				}
			};

bool match_pattern (int k, int row, int col, vector <string> plane)
{
	int i,j;

	for (i = 0; i < 4; ++i){
		for (j = 0; j < 4; ++j){
			if (plane[row+i][col+j] == figure[k][i][j]){
				continue;
			}else{
				return false;
			} // end if
		} // end for
	} // end for
	
	return true;
}
	
int main()
{
//	cut here before submit 
//	freopen("testcase.fs", "r", stdin);
	string str = "";
	int count = 0;
	int row  = 0;
	int i,j,k;

	vector <string> plane (11, string(11, '0') );
	
	while (getline (cin, str ) ){
		if (str.empty() && count < 2){
			++count;
			row = 0;
			continue;
		}else{
			count = 0;
		} // end if

		if (count > 1){
			break;
		} // end if

		for (j = 0; j < str.length(); ++j){
			plane[row][j] = str[j];
		} // end for
		++row;
		int res = -1;
		if (row == 8){
			for (i = 0; i < 8; ++i){
				for (j = 0; j < 8; ++j){
					if (plane[i][j] == '0'){
						if (match_pattern (3, i, j, plane) ){
							res = 3;
							goto result;
						} // end if
						if ( match_pattern (6, i, j, plane) ){
							res = 6;
							goto result;
						} // end if			
					}else{	// if (plane[i][j] == '1')
						for (k = 0; k < 7; ++k){
							if (k != 3 && k != 6 && match_pattern (k, i, j, plane) ){
								res = k;
								goto result;
							} // end if
						} // end for
					} // end if
				} // end for
			} // end for
		} // end if
result:
		if (res != -1){
			char c = 'A'+res;
			cout << c << endl;
		} // end if			

	} // end while
		
	return 0;
}

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

using namespace std;
typedef pair<int, int> ii;

const int MOD = 1e9 + 7;

int main() {
    int n; cin >> n;
    char str[n]; cin >> str;

    long long dp[n][n];

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j)
            dp[i][j] = 0;
    }
    dp[0][0] = 1;


    for(int i = 1; i < n; ++i) {

        for(int j = 0; j <= i; ++j) {
            dp[i][j] = 0;
            //arr[i] = j

            if(str[i-1] == '<') {
                if(j-1 >= 0)
                    dp[i][j] = dp[i-1][j-1];
               
            } else {

                dp[i][j] = dp[i-1][i-1];
                if(j > 0) dp[i][j] -= dp[i-1][j-1];
                dp[i][j] %= MOD;
            }
        }
        for(int j = 1; j < n; ++j) {
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    long long ans = dp[n-1][n-1];
    if(ans < 0) ans += MOD;

    cout << ans;

}

Measured memory_bytes: 70656
#include <stdio.h>

int main() {
  int a[5], k;
  int b[5], remain[5], i, min, min_num, sum;
  
  for ( i = 0; i < 5; i++ ) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &k);
  
  for ( i = 0; i < 5; i++ ) {
    remain[i] = a[i] % 10;
  }
  min = 9;
  for ( i = 0; i < 5; i++ ) {
    if ( min > remain[i] && remain[i] != 0 ) {
      min = remain[i];
      min_num = i;
    }
  }
  
  sum = 0;
  for ( i = 0; i < 5; i++ ) {
   	sum += a[i];
    b[i] = a[i];
    if ( i != min_num && remain[i] != 0 ) {
      sum += 10 - remain[i];
      b[i] += 10-remain[i];
    }
  }
  
  printf("%d\n", sum);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
			a[0] = sc.nextInt();
			a[1] = sc.nextInt();
			a[2] = sc.nextInt();
			int hoge;
			for(int i = 0;i < a.length;i++) {
				for(int j = 0 ;j < i ;j++) {
					if(a[i] < a[j]) {
						hoge = a[i];
						a[i] = a[j];
						a[j] = hoge;
					}
				}
			}
			hoge = a[1] - a[0];
			hoge += a[2] - a[1];
			System.out.println(hoge);
	}

}


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

class P
{
    static void Main(string[] _)
    {
        decimal r = 0;
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[3 * n];
        _ = Console.ReadLine().Split(' ');
        for (int i = 0; i < 3 * n; i++)
        {
            a[i] = int.Parse(_[i]);
        }
        Array.Sort(a);
        for (int i = 3 * n - 2; i >= n; i -= 2)
        {
            r = decimal.Add(r, a[i]);
        }
        Console.WriteLine(r);
    }
}

Measured memory_bytes: 40652
# 最大値と二番目に大きいやつをとっておく。最大値のときだけ二番目に大きいやつ採用
n = int(input())
arr = []
for i in range(n):
  t = int(input()) 
  arr.append([i, t])

sorted_arr = list(sorted(arr, key = lambda x : x[1]))
biggest = sorted_arr[-1]
second_biggest = sorted_arr[-2]

for i in range(n):
  if i != biggest[0]:
    print(biggest[1])
  else:
    print(second_biggest[1])


Measured memory_bytes: 40964
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int t[100005],x[100005],y[100005];
int main()
{
	int n,i,f;
	scanf("%d",&n);
	f=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		if(x[i]+y[i]>t[i])
		{
			f=1;
		}	
	}
	for(i=1;i<n;i++)
	{
		int m,c;
		m=t[i]-t[i-1];
		c=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if((m%2)!=(c%2))
		{
			f=1;break;
		}  
	}
	if(f==1)
	  printf("No\n");
	else
	  printf("Yes\n");
	return 0;
}



Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String T = sc.next();
        StringBuilder strb = new StringBuilder();
        boolean last = false;

        for (int i = 0; i < T.length() - 1; i++) {
            switch (T.charAt(i)) {
                case 'P':
                    if(T.charAt(i+1) == '?'){
                        strb.append("PD");
                        i++;
                    }else{
                        strb.append(T.charAt(i));
                    }
                    break;
                case 'D':
                    strb.append(T.charAt(i));
                    break;
                case '?':
                    if (T.charAt(i + 1) == '?') {
                        strb.append("PD");
                        i++;
                    } else if (T.charAt(i + 1) == 'D') {
                        strb.append('P');
                    } else {
                        strb.append('D');
                    }
                    break;
            }
            if (i == T.length() - 1) {
                last = true;
            }
        }
        if (!last) {
            switch (T.charAt(T.length() - 1)) {
                case 'P':
                case 'D':
                    strb.append(T.charAt(T.length() - 1));
                    break;
                case '?':
                    strb.append('D');
                    break;
            }
        }
        System.out.println(strb.toString());
    }
}

Measured memory_bytes: 41976
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  n = readint()[1]
  a = n%10
  if a == 3
    println("bon")
  elseif a==0 || a==1 || a==6 || a==8
    println("pon")
  else
    println("hon")
  end
end

main()

Measured memory_bytes: 159772
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    pre = S[0:i]
    back = S[i:N]
    pre_and_back = set(pre) & set(back)
    #print(pre,back)
    #print(list(pre_and_back))
    ans = max(ans,len(pre_and_back))


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define ll long long
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
int main()
{
	int r,g,b,k;
	cin>>r>>g>>b>>k;
	while(r>=g)
	{
		g*=2;
		k--;
	}
	while(g>=b)
	{
		b*=2;
		k--;
	}
	if(r<g&&g<b&&k>=0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
/**************************************************
 *2つのノードのキーを入れ替える
 *@heap: 入れ替える対象の二分木
 *@i: 二分木の添字
 *@j: 二分木の添字
 *添字iとjのノードを入れ替える
 **************************************************/
void swap_node(int heap[], int i, int j){ 
  int tmp;
  tmp=heap[i];
  heap[i]=heap[j];
  heap[j]=tmp;
}
void max_heapify(int heap[], int heap_size, int i){
  int left=2*i, right=2*i+1;
  int largest;
  if((left<=heap_size)&&(heap[left]>heap[i]))
	largest=left;
  else
	largest=i;
  if((right<=heap_size)&&(heap[right]>heap[i]))
	largest=right;
  
  if(largest!=i){
	swap_node(heap, largest, i);
	max_heapify(heap, heap_size, largest);
  }
}
void build_max_heap(int heap[], int heap_size){
  int node;
  for(node=(heap_size)/2; node>=1; --node){
	max_heapify(heap, heap_size, node);
  }  
}
void print(int heap[], int heap_size){
  int i;
  int node;
  for(i=1; i<=heap_size; ++i){
	printf("node %d: ", i);
	printf("key = %d, ", heap[i]);
	if(i!=1)
	  printf("parent key = %d, ", heap[i/2]);
	if(2*i<=heap_size)
	  printf("left key = %d, ", heap[2*i]);
	if((2*i+1)<=heap_size)
	  printf("right key = %d, ", heap[2*i+1]);
	printf("\n");
  }
 
}
int main(){
  int heap_size;
  int heap[256];
  int i;
  //入力
  scanf("%d", &heap_size);
  for(i=1; i<=heap_size; ++i){
	scanf("%d", &heap[i]);
  }
  //maxヒープの作成
  // build_max_heap(heap, heap_size);
  //出力
  print(heap, heap_size);
  return 0;
}



Measured memory_bytes: 2104
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] HN = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
        int[] A = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
        string O = A.OrderByDescending(o => o).Take(HN[1]).Sum() >= HN[0] ? "Yes" : "No";
        Console.WriteLine(O);
    }
}

Measured memory_bytes: 19040
#include<stdio.h>
#include<string.h>
int main(){
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H'){
        if(b=='H'){
            printf("H\n");
        }
        else if(b=='D'){
            printf("D\n");
        }
    }

    else{
        if(b=='H'){
            printf("D\n");
        }
        else if(b=='D'){
            printf("H\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int, input().split()))
s = 0
check = 0
for i in range(n):
  if h[i] > s:
    s = h[i] - 1
  elif h[i] == s:
    continue
  else:
    check = 1 
    break
if check:
  print("No")
else:
  print("Yes")

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

int main()
{
  int a,b,x,A,B;

  cin >> x >> a >> b;

  A = x-a;
  B = x-b;

  if(std::abs(A) > std::abs(B))
  {
   cout << "B" << endl;
  }else{
   cout << "A" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
S = input()
S = S[::-1]
C = ['maerd', 'remaerd', 'esare', 'resare']
ans = False
s = 0
for i in range(len(S)+1):
    if S[s:i] in C:
        s = i
        ans = True
    else:
        ans = False
if ans:
    print("YES")
else:
    print("NO")


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

int main()
{
	int i, n, q, flag, l, r;
	string s;

	cin >> n >> q;
	cin >> s;
	
	int ans[n+1];
	ans[0]=0;

	flag=0;
	for(i=1; i<=n; i+=1)
	{
		if(s[i-1]=='A')
		{
			flag=1;
			ans[i]=ans[i-1];
		}
		else if(s[i-1]=='C')
		{
			if(flag==1)
			{
				ans[i]=ans[i-1]+1;
				flag=0;
			}
			else
				ans[i]=ans[i-1];
		}
		else
		{
			flag=0;
			ans[i]=ans[i-1];
		}
	}

	for(i=0; i<q; i+=1)
	{
		cin >> l >> r;
		cout << ans[r]-ans[l] << endl;
	}
}

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

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

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

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n;
    cin >> n;
    vector<set<i64>> v(3, set<i64>());
    rep(i, 3){
        i64 c;
        cin >> c;
        rep(j, c){
            i64 x;
            cin >> x;
            v[i].insert(x);
        }
    }
    set<i64> x, y, z;
    set_difference(v[2].begin(), v[2].end(), v[0].begin(), v[0].end(), inserter(x, x.end()));
    set_intersection(v[1].begin(), v[1].end(), v[2].begin(), v[2].end(), inserter(y, y.end()));
    set_union(x.begin(), x.end(), y.begin(), y.end(), inserter(z, z.end()));
    cout << z.size() << endl;
}


Measured memory_bytes: 3200
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll siz;
ll ofst;
vvll seg;

void change(ll i, char c) {
  i += ofst;
  rep(ii, 26) seg[i][ii] = (ii == c - 'a');
  while (true) {
    i /= 2;
    if (i == 0) break;
    rep(ii, 26) seg[i][ii] = seg[2 * i][ii] + seg[2 * i + 1][ii];
  }
}

ll get(ll l, ll r) {
  vll ans(26, 0);
  l += ofst, r += ofst + 1;
  while (l < r) {
    if (l % 2 == 1) {
      rep(ii, 26) ans[ii] += seg[l][ii];
      l++;
    }
    l /= 2;
    if (r % 2 == 1) {
      rep(ii, 26) ans[ii] += seg[r - 1][ii];
      r--;
    }
    r /= 2;
  }
  ll ret = 0;
  rep(ii, 26) ret += (ans[ii] > 0);
  return ret;
}

int main() {
  ll n, q;
  string s;
  cin >> n >> s >> q;

  siz = 1;
  while (siz < 2 * n) siz <<= 1;
  ofst = siz >> 1;
  seg.resize(siz, vll(26, 0));
  rep(i, n) change(i, s[i]);

  rep(i, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      ll i;
      char c;
      cin >> i >> c;
      i--;
      change(i, c);
    } else {
      ll l, r;
      cin >> l >> r;
      l--;
      r--;
      cout << get(l, r) << endl;
    }
  }

  return 0;
}


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

#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)

int main(){
    int n;
    cin >> n;
    double p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i]; 
    }
    double dp[n + 1][n + 1];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
            dp[i][0] = 0;
    }
    for(int i = 1; i <= n; i++){
            dp[0][i] = dp[0][i - 1] * (1 - p[i - 1]);
            for(int j = 1; j <= n; j++){
                    dp[j][i] = dp[j][i - 1]*(1 - p[i - 1]) + (dp[j - 1][i - 1]*p[i - 1]); 
            }
            
    }
    double sum = 0;
    for(int i = n; i > n/2; i--){
            sum += dp[i][n];
    }
    cout << setprecision(11) << sum << "\n";

}

Measured memory_bytes: 70528
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif


    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a){
        b *= 2;
        k--;
    }
    while(c<=b){
        c *= 2;
        k--;
    }
    if(k<0) puts("No");else puts("Yes");
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a,b;
  cin >> a >> b;
  int c = stoi(a + b);
  string res = "No";
  for(int i = 0; i < 400; ++i){
    if(i * i == c){
      res = "Yes";
    }
  }
  cout << res << endl;
}

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

using namespace std;
using ll = long long;

typedef pair<int, int> pii;

#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define ff first
#define ss second

int main() {
    // read;
    // write;
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        int n, k, c = 0;
        cin >> n >> k;
        int a[n + 1] = {0};
        for (int i = 1; i <= k; ++i) {
            int d;
            cin >> d;
            while (d--) {
                int x;
                cin >>x;
                a[x] = 1;
            }
        }
        for (int i = 1; i <= n; ++i) {
            if (a[i] == 0) c++;
        }
        cout << c << "\n";
    }

    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

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

	  while(true){
	     int H = sc.nextInt();
	     int W = sc.nextInt();
	     
		 if ( H == 0 && W == 0) break;
	     
	     for ( int i = 0; i < H; i++ ){
	    	    for ( int j = 0; j < W; j++ ){
	    	        System.out.print("#");		       
	    	    }
	    	System.out.println("");		       
	     }
	     System.out.println();	
	  }
   }
}



Measured memory_bytes: 33188
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	int sum = 0;

	int x = N;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}

	if (N % sum == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  string s,t;
  cin >> s >> t;
  bool flg = true;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != t[i]) flg = false;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
    vector<int> menu (5);
    int m = 10; int place = 0;
    for(int i = 0 ; i < 5 ; i++){
        cin >> menu[i];
        //0を除く最も1の位が小さいものを覚えておく
        if((menu[i] - 1) % 10 < m){
            m = (menu[i] - 1) % 10;
            place = i;
        }
    }
    int ans = 0;
    for(int i = 0 ; i < 5 ; i++){
        if(i == place) continue;
        if( menu[i] % 10 == 0) ans += menu[i];
        else ans += menu[i] + (10 - menu[i] % 10);
    }
    ans += menu[place];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  string s; cin >> s;
  --k;
  s[k] = (char) (s[k] - 'A' + 'a');
  cout << s;
  
  return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

VVI graph;
VI parent;
VL ans, counter;

void build_tree(int i) {
    for (int adj : graph[i]) {
        if (parent[adj] != -1) continue;
        parent[adj] = i;
        build_tree(adj);
    }
}

ll dfs(int i) {
    if (ans[i] != -1) return ans[i];
    if (i == 0) return ans[i] = counter[i];
    return ans[i] = counter[i] + dfs(parent[i]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    graph.resize(n);
    parent.resize(n, -1);
    counter.resize(n, 0);
    ans.resize(n, -1);
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    build_tree(0);

    REP(i, q) {
        ll p, x;
        cin >> p >> x;
        counter[p - 1] += x;
    }

    REP(i, n) {
        cout << dfs(i);
        if (i == n - 1)
            cout << ln;
        else
            cout << " ";
    }
    return 0;
}


Measured memory_bytes: 27404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    ll g;
    cin>>d>>g;
    vector<ll> p(d),c(d);
    rep(i,d) cin>>p[i]>>c[i];
    ll ans=1e15;
    rep(i,1<<d){
      ll now=0,cnt=0;
      rep(j,d){
        if(i & (1<<j)){
          cnt+=p[j];
          now+=(j+1)*100*p[j]+c[j];
        }
      }
      if(now>=g){
        //cout<<i<<' '<<now<<' '<<cnt<<endl;
        ans=min(ans,cnt);
        continue;
      }
      for(ll j=d-1;j>=0;j--){
        if(!(i & (1<<j))){
          ll ret=(g-now+(j+1)*100-1)/((j+1)*100);
          if(ret>=p[j]){
            now+=(j+1)*100*p[j]+c[j];
            cnt+=p[j];
          }else{
            now+=(j+1)*100*p[j];
            cnt+=ret;
          }
          break;
        }
      }
      if(now>=g){
        //cout<<i<<' '<<now<<' '<<cnt<<endl;
        ans=min(ans,cnt);
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, M;
    cin >> N >> M;
    vector2d<int> edge(N);
    for(int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        edge[--s].push_back(--t);
    }
    double ans = 1e8;
    // O(NM)
    // (i, j) -> O(M), (k) -> O(N)
    for (int i = 0; i < N - 1; i++) {
        vector<double> dp(N, 0);
        for (int k = N - 1; k >= 0; k--) {
            int j = -1;
            double sz = edge[k].size();
            if(i == k && sz > 1) {
                for(int j_ : edge[k]) {
                    if(j < 0 || dp[j] < dp[j_]) {
                        if(j < 0) sz--;
                        j = j_;
                    }
                }
            }
            for(int l : edge[k]) {
                if(l != j) dp[k] += (1 + dp[l]) / sz;
            }
        }
        ans = min(ans, dp[0]);
    }
    cout << std::fixed << std::setprecision(10) << ans << endl;
    return 0;
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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


int main() {

	ll N,C;
    cin >>N>>C;

    vector<vector<bool>> r(C+1,vector<bool>(MAX,0));

    repn(i,N){
        ll s,t,c;
        cin >>s>>t>>c;

        for(ll i=s; i<=t; i++){
            r[c][i]=1;
        }
    }

    ll ans=0;

    rep(i,MAX){
        ll v=0;
        repn(j,C){v+=r[j][i];}
        ans=max(ans,v);
        //if(v!=0)cout <<i<<v<<endl;
    }

    cout <<ans;

}


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

int a[200010];

int main()
{
  int N; cin >> N;
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a, a + N, greater<int>());
  int counter = N - 1;
  long long ans = a[0];
  counter--;
  
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (counter <= 0) goto end;
      ans += a[i];
      counter--;
    }
  }
  end:;
  
  cout << ans << endl;
}


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

const ll INF = 1000000007;

int main() {
  int n;
  cin >> n;
  ll ans =1;
  for (int i = 1; i <= (n); ++i){
    ans *=  i;
    ans %= INF;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(b == 1) cout << "0" << endl;
	else
	{
		for(int i = 1;i <= 40;i++)
		{
			if(i * a - (i - 1) >= b)
			{
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
typedef long long LL;
using namespace std;
const int maxn = 2E5 + 5;
int n;
LL T, ans, t[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> T;
	ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> t[i];
		if(t[i] - t[i - 1] >= T) ans = ans + T;
		else ans = ans + t[i] - t[i - 1];
	}
	cout << ans+T << endl;
	return 0 ;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		for(int i=0;i<s.length();i+=2){
			System.out.print(s.charAt(i));
		}
		System.out.println();;
	}

}


Measured memory_bytes: 31560
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static long[] maxPas = new long[5];
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] A = new double[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextDouble();
		}
		//　偶数だったら、すべてプラスにできる
		//　奇数だったら、一つだけマイナスにできる
		int minusCnt = 0;
		for(int i=0; i<N; i++) {
			if(A[i] < 0) {
				minusCnt ++;
			}
		}
		
		double ans = 0;
		double[] absA = new double[N];
		for(int i=0; i<N; i++) {
			absA[i] = Math.abs(A[i]);
		}
		if(minusCnt % 2 == 0) {
			for(int i=0; i<N; i++) {
				ans += absA[i];
			}
		} else {
			Arrays.sort(absA);
			ans -= absA[0];
			for(int i=1; i<N; i++) {
				ans += absA[i];
			}
		}
		
		System.out.println(BigDecimal.valueOf(Math.round(ans)).toPlainString());
	}
}

Measured memory_bytes: 98732
import numpy as np

from itertools import combinations, product

H, W, K = map(int, input().split())

ls = []

for h in range(H):
    ls.append(
        list(
            map(
                lambda x : 1 if x == "#" else 0, list(input())
                )
            )
        )

ls = np.array(ls)

all_sum = np.sum(ls)

cnt = 0

bool_ind_h = np.array([False for _ in range(H)])
bool_ind_w = np.array([False for _ in range(W)])
ls_tmp = ls.copy()

for h in range(H + 1):
    for w in range(W + 1):
        ls_tmp = ls.copy()
        comb_h = combinations(range(H), h)
        comb_w = combinations(range(W), w)
        for ch, cw in product(comb_h, comb_w):
            ls_tmp = ls.copy()
            ls_tmp[list(ch), :] = 0
            ls_tmp[:, list(cw)] = 0
            if np.sum(ls_tmp) == K:
                cnt += 1

print(cnt)



Measured memory_bytes: 26744
N=int(input())
plus=[input() for i in range(N)]
M=int(input())
minus=[input() for i in range(M)]
S=list(set(plus+minus))
ans=0
for i in S:
    point=0
    point=plus.count(i)-minus.count(i)
    ans=max(ans,point)
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double alpha = (h/12.0 + m/12.0/60.0) * 2.0 * M_PI;
	double beta = (m/60.0) * 2.0 * M_PI;
	double ans;
	ans = a*a + b*b - 2.0*a*b*cos(beta-alpha);
	printf("%.12lf\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 4188