akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        vi dp(1);
        dp[0] = 1;
        REPS(i, n-1) {
            char c;
            cin >> c;
            vi nxt(i + 1);
            ll sum = 0;
            if (c == '<') {
                REP(i, dp.size()) {
                    sum += dp[i];
                    nxt[i + 1] = sum % MOD;
                }
            } else {
                RREP(i, dp.size()) {
                    sum += dp[i];
                    nxt[i] = sum % MOD;
                }
            }
            swap(dp, nxt);
        }
        cout << accumulate(ALL(dp), 0ll) % MOD << endl;
    }
    return 0;
}


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

int main(){
		int x,a,b;
		cin >> x >> a >> b;
		if(a-b>=0){
				cout << "delicious" << endl;
		}else if (a+x>=b){
				cout << "safe" << endl;
		}else{
				cout << "dangerous" << endl;
		}
		return 0;
}


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

int main() {
    int W,a,b;
    cin >> W >> a >> b;
    if (W+a <= b) {
        cout << b-W-a << endl;
    }
    else if (b+W < a) {
        cout << a-b-W << endl;
    }
    else {
        cout  << 0 << endl;
    }
}

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

int main(){
    double x, h;
    while(cin >> x >> h, x != 0 || h != 0){
	printf("%.9lf\n", x * x + 2 * x * hypot(x / 2, h));
    }
    return 0;
}

Measured memory_bytes: 1248
input = input().split()
num = []
x3 = 0
y3 = 0
x4 = 0
y4 = 0
for i in range(len(input)):
    num.append(int(input[i]))

a1 = num[2]-num[0]
a2 = num[3]-num[1]

x3 = num[2] - a2
y3 = num[3] + a1
x4 = x3 - a1
y4 = y3 - a2

print(x3, end="")
print(" ", end="")
print(y3, end="")
print(" ", end="")
print(x4, end="")
print(" ", end="")
print(y4, end="")
print()


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

int main() {
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    rep(i,n) {
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for (auto v : mp) {
        ll res=v.second;
        ans+=res*(res-1)/2;
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 11136
z=list(map(int,input().split()))
n=z[0]
y_y=z[1]
y=int(y_y/1000)
for e in range(0,n+1):
    if e*10 <= y:
        x=y-e*10
        for f in range(0,n+1):
            if f*5 <= x:
                z=x-5*f
                if z!=n-e-f :
                    a,b,c=-1,-1,-1
                else:
                    a,b,c=e,f,z
                    break
        else:
            continue
        break
      




print("{0} {1} {2}".format(a,b,c))


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, p: "List[int]"):
    sorted_p = sorted(p)
    ans = [i!=j for i,j in zip(p,sorted_p)]
    if sum(ans) <= 2:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> T(n);
  REP(i, n)
    cin >> T[i];
  int m;
  cin >> m;
  vector<int> P(m), X(m);
  REP(i, m)
    cin >> P[i] >> X[i];
  REP(i, m) {
    int ans = 0;
    REP(j, n) {
      if (j == P[i] - 1)
        ans += X[i];
      else
        ans += T[j];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 764
// AOJ 0386: Transporter
// 2019.2.20 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#define M 1000000007
char s[100002], t[100002];
int  cnt[128];

int main()
{
	int i, N;

	scanf("%d%s%s", &N, s, t);
	cnt[s[0]] = 1;
	for (N--, i = 1; i < N; i++) {
		cnt[s[i]] += cnt[t[i]];
		if (cnt[s[i]] >= M) cnt[s[i]] -= M;
	}
	printf("%d\n", cnt[t[N]]);
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;i++)
typedef long long int LL;

const LL mod=1000000007;

int main(){
    LL N;
    in>>N;
    std::vector<LL>A(N);
    rep(i,N) in>>A[i];
    std::vector<LL>cnt(61);
    rep(i,61){
        rep(j,N) cnt[i]+=((A[j]&(1LL<<i)) ? 1: 0);
    }

    LL ans=0;
    rep(i,61){
        LL a=cnt[i],b=N-cnt[i];
        (ans+=(((a*b)%mod)*((1LL<<i)%mod))%mod)%=mod;
    }
    out<<ans<<std::endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    ll ans[n+1] = {};
    for(int i=1;i<=n;i++){
        for(int j=1;j*j<=i;j++){
            for(int k=j;k*k<=i;k++){
                for(int l=k;l*l<=i;l++){
                    if((j+k+l)*(j+k+l)-(j*k+k*l+l*j) == i){
                        if(j == k && k == l){
                            ans[i]++;
                        }
                        else if(j == k || k == l || l == j){
                            ans[i] += 3;
                        }
                        else ans[i] += 6;
                    }
                }
            }
        }
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3620
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string S = Console.ReadLine();
    if (N % 2 == 0) {
      int n = N / 2;
      Console.WriteLine(S.Substring(0, n) == S.Substring(n, n) ? "Yes" : "No");
    } else {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){

    char recent_char;
    unsigned int i = 0, alphabet_list[26] = {0};

    while( scanf("%c", &recent_char) != EOF ){

        if('a' <= recent_char && recent_char <= 'z'){
            alphabet_list[ recent_char - 'a' ] += 1;
        }else if('A' <= recent_char && recent_char <= 'Z'){
            alphabet_list[ recent_char + 32 - 'a'] += 1;
        }

    }

    for(i = 97; i < 123; i++){
        printf("%c : %d\n", i, alphabet_list[i-97]);
    }

    return 0;

}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
#define mx 200005
#define mod 1000000007
using namespace std;

ll dp[mx];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll a[mx],i,n,j;
    cin>>n;
    for(i=1;i<n+1;i++)
    cin>>a[i];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(i=3;i<n+1;i++)
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int count=0;
		if(a%10==2) {
			count++;
		}
		a/=10;
		if(a%10==2) {
			count++;
		}
		a/=10;
		if(a%10==2) {
			count++;
		}
		a/=10;
		if(a%10==2) {
			count++;
		}
		System.out.println(count);
		}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<bool> toll(n+1);
  frn(i,m) {
    int x; cin>>x;
    toll[x] = true;
  }
  int left = 0, right = 0;
  fr(i,x+1,n) {
    if(toll[i]) right++;
  }
  for(int i = x-1;i >= 0;i--) {
    if(toll[i]) left++;
  }
  cout<<min(left,right);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()

const ll m = 1000000000000000000;
#define debug(x) cout<<#x<<" = "<<(x)<<endl

#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"

int main(){
  int N;cin>>N;
  ll ans = 1;
  vector<ll> A(N);
  vector<double> B(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
    B[i] = log10(A[i]);
  }
  if(find(all(A), 0) != A.end()){
    cout<<0<<endl;
    return 0;
  }
  double logans = 0;
  for(int i=0; i<N; i++){
    ans *= A[i];
    logans += B[i];
  }
  if(logans > 18){
    //cout<<"logans"<<endl;
    cout<<-1<<endl;
    return 0;
  }
  if(ans > m){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <sstream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>
#define has(g, i) (g.find(i) != g.end())
#define ll long long
#define MAX 100000
using namespace std;
#define ll long long
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vvll vector<vll>
#define pq priority_queue
#define x first
#define y second

struct Segment {
	
	vector<ll> a, t, prev;
	Segment(int n) : a(n), t(4 * n), prev(4 * n) {

	}
	

	void update(int v, int tl, int tr, int l, int r, ll add = 0) {
		if (l > r)
			return;
		if (l == tl && tr == r) {
			t[v] += 1;
			prev[v] += add - 1;
		}
			
		else {
			int tm = (tl + tr) / 2;
			update(v * 2, tl, tm, l, min(r, tm), add);
			if (tm >= l && r >= max(l, tm + 1)) {
				add += tm - l + 1;
			}
			update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, add);
		}
	}

	ll get(int v, int tl, int tr, int pos) {
		if (tl == tr)
			return t[v] + prev[v] ;
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			return t[v] * (pos - tl + 1) + prev[v] + get(v * 2, tl, tm, pos);
		else
			return t[v] * (pos - tl + 1) + prev[v] + get(v * 2 + 1, tm + 1, tr, pos);
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<int> arr(n);
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}

	Segment tree(m + 1);
	for (int i = 1; i < n; ++i) {
		if (arr[i] > arr[i - 1]) {
			sum += arr[i] - arr[i - 1];
			tree.update(1, 0, m , arr[i - 1] + 1, arr[i]);
		}
		else {
			sum += m - arr[i - 1] + arr[i];
			tree.update(1, 0, m, arr[i - 1] + 1, m);
			tree.update(1, 0, m, 1, arr[i], m - arr[i - 1]);
		}
		/*for (int j = 0; j <= m; ++j) {
			cout << tree.get(1, 0, m, j) << " ";
		}
		cout << endl;*/
	}

	ll maxVal = 0;
	for (int i = 0; i <= m; ++i) {
		ll v = tree.get(1, 0, m, i);
		maxVal = max(maxVal, v);
		//cout << v << " ";
	}

	cout << sum - maxVal << endl;
}


Measured memory_bytes: 7680
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main(){
    int K=read(),X=read();
    for(int i=max(-1000000,X-K+1);i<=min(1000000,X+K-1);i++)
        printf("%d ",i);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace std;


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

	int n;
	cin >> n;
	vector<pair<string, int>> a;
	vector<pair<string, int>> b;
	for (int i = 0; i < n; i++)
	{
		char s[11];
		int x;
		cin >> s >> x;
		a.emplace_back(s, -x);
		b.emplace_back(s, -x);
	}
	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (a[i].second == b[j].second)
			{
				cout << j + 1 << '\n';
				break;
			}
		}
	}
	return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  for(int i=0;i<S.size();i++) {
    if(S.at(i)!=T.at(i)) {
      cout << "No" << endl;
      break;
    } else {
      if(i==S.size()-1) {
        cout << "Yes" << endl;
      }
    }
  }
}

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

const long long mod = 1e9+7;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> a(N+1,true);
    for(int i=1;i<=M;i++) {
        int ok;
        cin >> ok;
        a[ok] = 0;
    }
    vector<int> dp(N+1);
    dp[0] = 1;
    for(int now=0;now<=N;now++) {
        for(int next=now+1;next<=min(N,now+2);next++) {
            if(a[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
long long array[1000001]={0};
int main(int argc, const char * argv[]) {
    int n;
    
    scanf("%d",&n);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        array[a[i]]++;
    }
    qsort(a,n,sizeof(long long),compare);
    
   
    long long ans=0;
    for(int i=0;i<n;i++){
        for(long long j=2;j*a[i]<=a[n-1];j++){
            if(array[a[i]*j]>0){
                array[a[i]*j]=0;
                //printf("%d is deleted\n",array[a[i]*j]);
            }
        }
        if(array[a[i]]>1){
            array[a[i]]=0;
            //printf("array %d is deleted bs2\n",array[a[i]]);
        }
    }
    for(int i=0;i<=a[n-1];i++){
        ans+=array[i];
    }
    printf("%lld",ans);
    
    return 0;
}


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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())

int main() {
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 256
n = int(input())
f = [[int(i) for i in input().split()] for _ in range(n)]
p = [[int(i) for i in input().split()] for _ in range(n)]


ans = -999999999999999999
for item in range(1, 1024):
    fund = 0
    for i in range(n): # 店の数
        cou = 0
        for x in range(10):
            if (item >> x) % 2 == 1 and f[i][x] == 1:
                cou += 1
        fund += p[i][cou]
    ans = max(ans, fund)

print(ans)

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m;
pair < int, int > a[N];
int dp[N];
int sum;
int cur;

int main () {
   SpeedForce;
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i].F >> a[i].S;
	}
	sort(a + 1, a + n + 1);

	for (int i = 1; i <= n; i ++) {
		for (int j = m - 1; j >= 0; j --) {
			 dp[j + a[i].F] = max(dp[j + a[i].F], dp[j] + a[i].S);
		}
	}
	
	cout << *max_element(dp, dp + N) << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (r <= x&&x <= (W - r) && r <= y&&y <= (H - r))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
using namespace std;

typedef vector<int> vint;

inline string to_s(int n){static char v[32];sprintf(v,"%d",n);return string(v);}

set<string> st;
int u[4];

void act(vint &v,int n){
  sort(u,u+n);
  do{
    string s;
    REP(i,n) s+=to_s(v[u[i]]);
    st.insert(s);
  }while(next_permutation(u,u+n));
}

int main(){
  int n,k;
  while(cin >> n >> k && n|k){
    vint v(n);
    REP(i,n) cin >> v[i];

    st.clear();

    if(k==2){
      REP(i,n) REP(j,i){
	u[0]=i, u[1]=j; act(v,2);
      }
    }
    if(k==3){
      REP(i,n) REP(j,i) REP(l,j){
	u[0]=i, u[1]=j; u[2]=l; act(v,3);
      } 
    }
    if(k==4){
      REP(i,n) REP(j,i) REP(l,j) REP(m,l){
	u[0]=i, u[1]=j; u[2]=l, u[3]=m; act(v,4);
      }
    }

    // EACH(it,st) cout << *it << ' '; cout << endl;
    
    cout << st.size() << endl;
  }
}

Measured memory_bytes: 1076
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        vector<int> upuse(n);
        int ins;
        scanf("%d",&ins);
        upuse[0]=ins;
        int ma=ins;
        for(int i=1;i<n;i++){
            scanf("%d",&ins);
            upuse[i]=max(ins,upuse[i-1]+ins);
            ma=max(upuse[i],ma);
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                               

using namespace std;
#define ll long long

int main(){
  ll X, A, B;
  cin >> X >> A >> B;
  if(- A + B > X)
    cout << "dangerous" << endl;
  else if(- A + B > 0)
    cout << "safe" << endl;
  else
    cout << "delicious" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 3001
typedef long double ld;
ld dp[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout.precision(10);
	cout<<fixed;
	
	int n;
	cin>>n;
	vector<ld> p(n);
	for(int i=0; i<n; i++) cin>>p[i];
	dp[0][0] = 1.0;
	for(int i=1; i<=n; i++){
		for(int j=0; j<N-1; j++){
			dp[i][j] += dp[i-1][j] * (1.0 - p[i-1]);
			dp[i][j+1] += dp[i-1][j] * p[i-1];
		}
	}
	
	ld ans = 0;
	for(int i = (n+1)/2; i<=n; i++)
		ans += dp[n][i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 140928
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static int gcd(int a, int b){
    	return b == 0 ? Math.abs(a) : gcd(b, a % b);
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int[] a = new int[n];

        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }

        int ans = gcd(a[0], a[1]);
        for(int i=2;i<n;i++) {
            ans = gcd(ans, a[i]);
        }

        pw.println(ans); 

        pw.close();
	}

}

Measured memory_bytes: 37260
#include <iostream>

using namespace std;

int main(void){
  string str[3]={"Sunny", "Cloudy", "Rainy"};
  string S;
  cin >> S;  
 
  int i;
  for(i=0; i<3; i++)
    if(str[i] == S)
      break;

  i=(i+1)%3;
  cout << str[i] << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int face[] = new int[6];

	static void dice(int[] num) {
		for (int i = 0; i < 6; i++) {
			Main.face[i] = num[i];
		}
	}

	static void order(String str) {
		char[] order = str.toCharArray();
		int tmp;
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				tmp = face[0];
				face[0] = face[1];
				face[1] = face[5];
				face[5] = face[4];
				face[4] = tmp;
				break;
			case 'S':
				tmp = face[0];
				face[0] = face[4];
				face[4] = face[5];
				face[5] = face[1];
				face[1] = tmp;
				break;
			case 'E':
				tmp = face[0];
				face[0] = face[3];
				face[3] = face[5];
				face[5] = face[2];
				face[2] = tmp;
				break;
			case 'W':
				tmp = face[0];
				face[0] = face[2];
				face[2] = face[5];
				face[5] = face[3];
				face[3] = tmp;
				break;
			}
		}
	}

	public static int getFace() {
		return Main.face[0];
	}

	public static void setFace(int[] face) {
		Main.face = face;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		Main.setFace(num);
		String str = sc.next();
		Main.order(str);
		System.out.println(Main.getFace());
		sc.close();
	}
}


Measured memory_bytes: 26324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  std::vector<int> d(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> d[i];
  }

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


  printf("%d\n",d[n/2]-d[n/2-1]);




  return 0;
}


Measured memory_bytes: 640
def divisionize(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors = sorted(divisors) # ソートが必要であれば
    return divisors
n,m = map(int, input().split())
dm = divisionize(m)
print(max([d for d,d_ in zip(dm,dm[::-1]) if d_>=n]))

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

/**
 * 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;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int d = in.nextInt();
			if((Math.abs(a - b) <= d && Math.abs(b - c) <= d) || Math.abs(a - c) <= d) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int N, K; cin >> N >> K;
  vector<int> H(N,0);
  rep(i,N) cin >> H[i];
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  ll attack = 0;
  for(int i = K; i < N; i++){
    attack += H[i];
  }

  cout << attack << endl;
	return 0;
}



Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    cout <<(min(A,B)+min(C,D))<<endl;

    return 0;
}








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

int group(int x){
	switch(x){
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		return 0;
	case 4:
	case 6:
	case 9:
	case 11:
		return 1;
	case 2:
		return 2;
	}
	return 0;
}

int main(){
	int x, y;
	cin >> x >> y;
	if(group(x) == group(y))
		cout << "Yes";
	else
		cout << "No";
	return 0;
}



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

void Main() {
  int n;
  cin >> n;

  map<string, int> m;
  int max_cnt = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
    max_cnt = max(max_cnt, m[s]);
  }
  for(auto cnt: m) {
    if (cnt.second == max_cnt) cout << cnt.first << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n;cin >> n;
    int sum = 0;
    int arr[n + 5];
    for(int i = 0;i < n - 1;i++)cin >> arr[i];
    for(int i = 0;i < n;i++){
        sum += min(arr[min(i, n - 2)], arr[max(0, i - 1)]);
    }
    cout << sum;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	int WA[n+1];
	bool AC[n+1];
	int WAcnt = 0, ACcnt = 0;
	
	for (int i = 1; i <= n; ++i)
	{
		WA[i] = 0;
		AC[i] = false;
	}
	
	for (int i = 0; i < m; ++i)
	{
		int p;
		string s;
		cin >> p >> s;
		
		if (AC[p])
		{
			continue;
		}
		
		if (s == "AC")
		{
			AC[p] = true;
			ACcnt++;
			WAcnt += WA[p];
		}
		else
		{
			WA[p]++;
		}
	}
	
	cout << ACcnt << " " << WAcnt << endl;
	
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<unordered_map>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>
#define mk_re(a) if(a){RE();}
int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size-1) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	if (r < 0 || n < r) { return 0; }
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

int per(int a, int b) {
	int ans = a % b;
	if (ans < 0) { ans += b; }
	return ans;
}
vel uni(vel v) {
	sor(v);
	vel ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i-1]) { ans.push_back(v[i]); }
	}
	return ans;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
bool is_prime(int i) {
	for (int j = 2; j*j <= i; j++) {
		if (i%j == 0) { return false; }
	}
	return true;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
void sz_tree(int ce0, V<V<pin>> &chi,vel &sz) {
	for (auto x : chi[ce0]) {
		sz_tree(x.first, chi, sz);
		sz[ce0] += sz[x.first];
	}
}
int ord(int n) {
	if (n % 2 == 1) { return 0; }
	return 1 + ord(n / 2);
}
int msb(int l) {
	if (l == 1) { return 0; }
	return 1 + msb(l / 2);
}
int rui_2(int a) {
	if (a == 0) { return 1; }
	return 2 * rui_2(a - 1);
}
signed main() {
	int n; cin >> n;
	V<V<bool>> ans(n, veb(n, true));
	int sum = n - 1;
	if (sum % 2 == 0) { sum--; }
	int count = 0;
	rep(i, n) {
		int to = sum - i;
		if (to >= 0) { ans[i][to] = false; }
		rep(j, i) { if (ans[i][j]) { count++; } }
	}
	cout << count << endl;
	rep(i, n) {
		rep(j, i) {
			if (ans[i][j]) { cout << i+1 << " " << j+1 << endl; }
		}
	}
	return 0;
}
/*
11:23~

*/

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

using namespace std;

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 long long INF = 1LL << 60;

int main(){
    int N, K;
    cin >> N >> K;
    long long arr[N];
    long long dp[N+K];
    for (int i = 0; i < N; ++i){
        cin >> arr[i];
        dp[i] = INF;
    }
    dp[0]=0;

    for(int i =0 ; i < N; ++i){
        for (int j=1; j <=K; ++j){
            chmin(dp[i+j], dp[i]+abs(arr[i+j]-arr[i]));
        }        
    }
    cout << dp[N-1] << endl;
    return 0;
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    int itiman = -1, gosen = -1, sen = -1;
    for(int x = 0;x <= N; x++){
        for(int y = 0;y <= N-x; y++){
            int c = N-x-y;
            int total = 10000*x + 5000*y + c*1000;
            if(Y == total){
                itiman = x;
                gosen = y;
                sen = N -x - y;

            }
        }
    }
    cout << itiman << " " << gosen << " " << sen << endl; 
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A((1 << N) + 1);
    for (int i = 0; i < (1 << N); ++i) {
        cin >> A[i];
    }
    A[1 << N] = -1;

    vector<int> best1(1 << N, 1 << N), best2(1 << N, 1 << N);
    vector<int> answer(1 << N, 0);
    for (int i = 0; i < (1 << N); ++i) {
        for (int j = 0; j < N; ++j)
            if ((1 << j) & i) {
                int k = i - (1 << j);
                if (A[best2[k]] > A[best1[i]]) {
                    best2[i] = best1[i];
                    best1[i] = best2[k];
                } else if (A[best2[k]] > A[best2[i]] && best2[k] != best1[i]) {
                    best2[i] = best2[k];
                }
                if (A[best1[k]] > A[best1[i]]) {
                    best2[i] = best1[i];
                    best1[i] = best1[k];
                } else if (A[best1[k]] > A[best2[i]] && best1[k] != best1[i]) {
                    best2[i] = best1[k];
                }
            }
        if (A[i] > A[best1[i]]) {
            best2[i] = best1[i];
            best1[i] = i;
        } else if (A[i] > A[best2[i]]) {
            best2[i] = i;
        }
        answer[i] = A[best1[i]] + A[best2[i]];
        for (int j = 0; j < N; ++j)
            if ((1 << j) & i) {
                int k = (i & ((1 << j) - 1));
                k = i - k - 1;
                answer[i] = max(answer[i], answer[k]);
            }
    }

    for (int i = 1; i < (1 << N); ++i)
        cout << answer[i] << "\n";
}

Measured memory_bytes: 7404
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	ll k;
	cin >> k;
	ll n=0;
	for(ll i=1;i<=1000000;i++){
		n=n*10+7;
		n=n%k;
		if(n==0){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;


signed _main(){
  int N,K; cin >> N >> K;
  N%=K;
  int res=abs(N-K);
  cout << min(res,N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;


int main() {
    ll N, M;
    cin>>N>>M;
    
    ll ans=0;
    if(2*N<=M){
        ans += N;
        M -= 2*N;
        ans += M/4;
    }else{
        ans += M/2;
    }
    cout1(ans);
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  if ( N % 2 == 0 ) {
    int num = N / 2;
    for (int i = 0; i < num; i++) {
      if ( S[i] != S[num+i] ) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin >> n;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    string s="";
    int cnt=0;
    while(n!=0){
        if(abs(n)%2)s="1"+s;
        else s="0"+s;
        n-=(abs(n)%2)*pow(-1,cnt);
        n/=2;
        DEBUG{
            cout << n << endl;
        }
        cnt++;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    int64_t n;
    cin >> n;
    auto a = n / 2;
    auto c = n % 2;
    if (c == 0) {
        a--;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
"use strict";let a=require('fs').readFileSync('/dev/stdin','utf8').trim().split("\n");a.shift();let d = a.map(e => {let r = e.split(" ").map(Number);return [r[0]-r[1],r[1]+r[0]];}).sort((a,b) => {return a[1]-b[1];});let s = 0;let P = Number.MIN_SAFE_INTEGER;for(let i=0;i<d.length;i++){if(P<=d[i][0]){s++;P = d[i][1];}}console.log(s);

Measured memory_bytes: 52852
#include <vector>
#include <map>
#include <iostream>

using namespace std;
typedef long long int ll;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(int argc, const char * argv[]) {
    
    ll N;
    cin >> N;
    
    ll last2 = 0;
    ll last = 0;
    ll current;
    ll count = 0;
    for (ll i = 0; i < N; i++) {
        cin >> current;
        if (i > 1) {
            if ((last2 > last && last > current) || (last2 < last && last < current)) {
                count++;
            }
        }
        last2 = last;
        last = current;
    }
    
    cout << count;
    
    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int a[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
int main(void){
	long n=nextlong();
	int ans=0;
	{int i=2; int b=0; while(n%i==0){ n/=i; b++; } ans+=a[b];}
	{int i=3; int b=0; while(n%i==0){ n/=i; b++; } ans+=a[b];}
	{int i=5; int b=0; while(n%i==0){ n/=i; b++; } ans+=a[b];}
	int m=sqrt(n);
	for(int i=7; i<m;){
		{int b=0; while(n%i==0){ n/=i; b++; } ans+=a[b];}
		i+=4;
		{int b=0; while(n%i==0){ n/=i; b++; } ans+=a[b];}
		i+=2;
	}
	printf("%d\n", ans+(n>1));
}


Measured memory_bytes: 1940
#第三問　reconciled
mod=10**9+7
n,m=map(int,input().split())
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
p=find_power(10**5+4)
if abs(n-m)>1:
    print(0)
elif n==m:
    print(p[n]*p[m]*2%mod)
else:
    print(p[n]*p[m]%mod)


Measured memory_bytes: 7284
import Control.Monad

main=do
  [n,m]<-map read.words<$>getLine
  lrs<-replicateM m$(\[a,b]->(a,b)).map read.words<$>getLine
  let (ls,rs) = unzip lrs
  print $ max 0 (minimum rs - maximum ls + 1)

Measured memory_bytes: 81276
N = int(input())
Ws = list(map(int, input().split(' ')))

S = sum(Ws)

_S = 0
for i in range(len(Ws)):
    _Sn = _S + Ws[i]

    if _Sn * 2 > S:
        print(min(S - 2 *_S, 2 * _Sn - S))
        break

    _S = _Sn


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

int main() {
  int N,T;cin>>N>>T;
  int m=99999;
  for(int i=0; i<N; i++){
    int c,t;cin>>c>>t;
    if(T>=t)m=min(c,m);
  }
  if(m==99999)cout<<"TLE"<<endl;
  else cout<<m<<endl;
}

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

int main(void) {
    int k; cin >> k;
    if (k % 2 == 0) {
        cout << (k / 2) * (k / 2) << endl;
    }
    else {
        cout << (k / 2) * (k / 2 + 1) << endl;        
    }
    return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

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

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    
    i64 N,K;
    cin >> N >> K;
    
    long double ans=0;
    rep(i,1,N+1){
        i64 score=i,num=0;
        while(score<K){
            score*=2;
            ++num;
        }
        long double p=1;
        rep(j,0,num) p/=2;
        ans+=1/(long double)N*p;
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256