akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

class Program{
public:
	string name;
	int time;
	bool operator<(const Program program)const{return time<program.time;}
};

vector<Program> program;
vector<int> f;

int main() {
	int n;
	while(n=in()){
		program.clear();
		f.clear();
		int i,j;
		for(i=0;i<n;i++){
			Program buf;
			string name;
			int weekday,start;
			cin>>name>>weekday>>start;
			buf.name=name;
			buf.time=weekday*1440+start/100*60+start%100;
			program.push_back(buf);
		}
		sort(program.begin(),program.end());
		int p=in();
		string fav;
		for(i=0;i<p;i++){
			cin>>fav;
			for(j=0;j<n;j++){
				if(program[j].name==fav){
					f.push_back(program[j].time);
					break;
				}
			}
		}
		sort(f.begin(),f.end());
		for(i=0;i<p-1;i++){
			if(f[i]+30>f[i+1])break;
		}
		if(i!=p-1){
			cout<<-1<<endl;
			continue;
		}
		int res=p,end=0;
		for(i=0;i<n;i++){
			if(end>program[i].time)continue;
			for(j=0;j<p;j++){
				if(program[i].time-30<f[j]&&f[j]<program[i].time+30)break;
			}
			if(j<p)continue;
//cout<<program[i].name<<" "<<program[i].time<<endl;
			res++;
			end=program[i].time+30;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
 
#define debug(P) cout<<#P<<" = "<<P<<endl;
 
typedef long long ll;
typedef long double ld;
 
const int mod = 1e9+7;
 
 
 
 
int main() {
	//freopen("input.txt","r",stdin);
	
	ll k, a, b;
	cin>>k>>a>>b;

	bool poss = 0;

	for(ll x = a; x <= b; ++x){
		if(x%k == 0){
			poss = 1; break;
		}
	}

	if(poss){
		cout<<"OK\n";
	}
	else cout<<"NG\n";
 
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    int h,w,H,W;
    cin >> h >> w >> H >> W;
    cout << h * w - H*w - W*h + H*W << endl;
} 

Measured memory_bytes: 256
#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 ll long long
    # define int long long  //comment it out when MLE
    //# define endl "\n"
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //# define m 163577857
    # define mo 1000000007
    # define pi acos(-1)
    # define fi first
    # define se second
    #define REP(i,n) for (int i = 1; i <= n; i++)
    const ll mod = 1000000007;
    //const int K = 2;
    //typedef vector<vector<int> > matrix;
/*
    int add(int a, int b,int mod) {
        a%=mod;
        b%=mod;
        a += b;
        if (a >= mod) a -= mod;
        if(a<0)
        {
            a += mod;
            a %= mod;
        }
        return a;
    }

    int mul(ll a, int b,int mod) {
        a%=mod;
        b%=mod;
        a *= b;
        a += mod;
        return a % mod;
    }
    int po(int a,int b,int mod)
    {
        if(b==0)
            return 1;
        if(b%2==0)
            return po(mul(a,a,mod),b/2,mod);
        return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
    }


    ll fact[1000003];
    ll inv[1000003];

    void fact0()
    {
        int i,j;
        fact[0]=1;
        for(i=1;i<=600000;i++)
        {
            fact[i]=i*fact[i-1]%mod;
        }
        inv[0]=1;
        inv[1]=1;
        ll p=mod;
        for (i=2; i<=600000; i++)
            inv[i] = (p - (p/i) * inv[p%i] % p) % p;

        for(i=2;i<=600000;i++)
        {
            inv[i]*=inv[i-1];
            inv[i]%=mod;
        }
    }
    int help(int a,int b)
    {
       // cout<<a<<" "<<b<<endl;
        int an = fact[a];
        //cout<<an<<endl;
        an *= inv[b];
        an %= mod;
        an *= inv[a-b];
        an %= mod;
        return an;
    }*/



signed main(){
       gok

     int a,b;
     cin>>a>>b;
     cout<<a*b;

















        return 0;
    }


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
queue<int>q;
vector<int>e[N];
int n,m,ans;
int dp[N],in[N];
signed main(){
	scanf("%d%d",&n,&m);
	for (int i=1,a,b;i<=m;i++){
		scanf("%d%d",&a,&b);
		e[a].push_back(b); 
		in[b]++;
	}
    for(int i=1;i<=n;i++)
		if(in[i]==0)q.push(i) ;
    while(!q.empty()){
    	int now=q.front();
		q.pop();
    	for(int i=0;i<e[now].size();i++){
			int to=e[now][i];
			in[to]--;
			if(!in[to]){
				dp[to]=dp[now]+1;
				q.push(to) ;
			}
		}
	}
	for(int i=1;i<=n;i++)
		ans=max(ans,dp[i]);
	printf("%d\n",ans) ;
	return 0 ;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int max_value = 0, max_index = 0;
int min_value = MAX, min_index = 0;
int sum = 0;

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

int main() {
    cin >> N >> M;
    Pa pa[larg];
    rep(i, N){
        cin >> A >> B;
        pa[i] = make_pair(A, B);
    }
    sort(pa, pa+N);

    priority_queue<int> pri_que;
    int ind = 0;
    rep(i, M){
        while(pa[ind].first == i+1) pri_que.push(pa[ind].second), ind++;
        if(!pri_que.empty()) sum += pri_que.top(), pri_que.pop();
    }
    cout << sum;
}

Measured memory_bytes: 1660
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int firstvariety = 0;
        int[] numofnums = new int[100001];
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            numofnums[tmp]++;
        }
        for (int i = 1; i < numofnums.length; i++) {
            if (numofnums[i] == 0) {
                continue;
            }else{
                firstvariety++;
            }
        }

        // if oddsandends is even(<=> fv is odd), all disappear
        if (firstvariety % 2 != 0) {
            System.out.println(firstvariety);
        } else {
            System.out.println(firstvariety-1);
        }


        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 51688
#include<iostream>
#include<cstring>
#include<algorithm>
//#define I 1000000000+ 7
using namespace std; 
long long a[1000010] = { 0 };
int main()
{
	long long n, k;
	cin >> n >> k;
	for (int i = 0; i <= n; i++) a[i] = i;
	long long sum = 0;
	long long x =0 , y = 0;
	for (int i = n; i > n - k; i--)
	{
		x += a[i];
		//x%= 1000000000 + 7;
	}
	for (int i = 0; i < k; i++)
	{
		y += a[i];
		//y %= 1000000000 + 7;
	}
	sum += (x - y+1);
	//cout << sum << endl;
	long long  p = n - k, q = k;
	for (; p >= 0; p--, q++)
	{
		x += a[p];
		y += a[q];
		sum += (x - y + 1);
		sum %= 1000000000 + 7;
		
	}
	//++sum;
	sum %= 1000000000 + 7;
	cout << sum << endl;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

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

    vector<ll> xs(n), ys(n);
    rep(i, n) cin >> xs[i] >> ys[i];

    map<ll, map<ll, ll>> diffs;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            ll x_diff = xs[i] - xs[j];
            ll y_diff = ys[i] - ys[j];
            diffs[x_diff][y_diff]++;
        }
    }
    ll ma = 0;
    for (auto &horizontal : diffs) {
        for (auto &e : horizontal.second) {
            cmax(ma, e.second);
        }
    }
    cout << n - ma << endl;
}

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

int N; // Ｎ番目を算出
vector<long long> n(87,0);  // 最大８６番目のリュカ数

int main() {
  cin >> N ; // リュカ数の入力
  if (debug) { cout << "N:" << N << endl;}

  rep(i,N+1){
    if ( i== 0 ) {n.at(i) = 2;}
    else if ( i == 1 ) { n.at(i) = 1; }
    else {
      n.at(i) = n.at(i-1) + n.at(i-2);
    }
    if (debug) { cout << i << ":" << n.at(i) << endl;}
  }
  cout << n.at(N) << endl;
}



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

using namespace std;

template <class T> bool uax(T& a, T b) {return a < b ? (a = b, true) : false; }
template <class T> bool uin(T& a, T b) {return a > b ? (a = b, true) : false; }

const int mod = (int) 1e9 + 7;
const int MANY = 1 << 30;
const int N = (int) 1e5 + 10;

int a[N][3], n, m;

int64_t d[N];

int32_t main() {
//#ifndef QQQ
//    freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
    freopen("../input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    cin >> n >> m;
    vector<int> w(n), c(n);
    int64_t maxv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> c[i];
        maxv += c[i];
    }
    fill(&d[1], &d[N - 1], MANY);
    for (int i = 0; i < n; ++i) {
        for (int j = maxv - c[i]; j >= 0; --j) {
            uin(d[j + c[i]], d[j] + w[i]);
        }
    }
    int64_t  ans = -MANY;
    for (int64_t k = 0; k <= maxv; ++k) {
        if (d[k] <= m) uax(ans, k);
    }
    cout << ans;


}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
#include<queue>
#include <sstream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<2*(a+b)<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, k, i, j, ans;
	cin >> n >> k;

	ans = (n + 1 - k);
	
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

bool cmp_fun(const pair<long long,long long>& a,const pair<long long,long long>& b){
	return (a.second<b.second);
}

void solve(){
	int n;
	cin>>n;
	vector<pair<long long,long long>> a(n,{0,0});
	for(int i=0;i<n;i++){
		long long x,y;
		cin>>x>>y;
		a[i].first=x-y;
		a[i].second=x+y;
	}

	sort(full(a),cmp_fun);
	// for(int i=0;i<n;i++){
	// 	cout<<a[i].first<<" " <<a[i].second<<"\n";

	// }
	int ans=1;
	int r=a[0].second;
	for(int i=1;i<n;i++){
		if(r<=a[i].first){
			r=a[i].second;
			ans++;
		}
	}
	cout<<ans<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

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

int main() {
    int r,g,b,k;
    cin >> r >> g >> b >> k;
    while (r >= g && k > 0) {
        g *= 2;
        k--;
    }
    while (g >= b && k > 0) {
        b *= 2;
        k--;
    }
    cout << ((r < g && g < b)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    //最短手数
    vector <int> v;
    int min=0;
    int point=0;
    while(point!=n){
        if(point+m<n){
            int max_walk=m;
            while(s[point+max_walk]!='0'){
                max_walk--;
            }
            if(max_walk==0){
                cout<<-1<<endl;
                return 0;
            }
            else{
                v.push_back(max_walk);
                min++;
                point=point+max_walk;
            }
        }
        else{
            v.push_back(n-point);
            min++;
            point=n;
        }
    }
    for(int i=min-1;i>0;i--){
        cout<<v[i]<<' ';
    }
    cout<<v[0]<<endl;
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }


int main(void){
    // Your code here!
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> e(n+1,0);
    FOR(i,1,n) {
        for (int j = i; j <= n; j += i) {
            e[j]++;
        }
    }
    FOR(i,1,n) ans+= i*e[i];
    cout << ans << endl;
}


Measured memory_bytes: 81384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 100005
#define szz 35

using namespace std;

int main()
{
    ll n,arr[sz];

    scanf("%lld",&n);

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&arr[i]);
    }

    ll cnt=0;

    while(1)
    {
        ll flag=0;

        for(ll i=1; i<=n; i++)
        {
            if(arr[i]%2!=0)
            {
                flag=1;
                break;
            }

            arr[i]=arr[i]/2;
        }

        if(flag==0)
            cnt++;

        else
        {
            cout<<cnt<<endl;
            break;
        }
    }

    return (0);
}




Measured memory_bytes: 256
# 2108
# 解法,せいぜい１００何だから範囲を増やしつつ全探索でいいのでは？
# 実装， 範囲をiとしてiを100まで買えつつX-iとX+iについて，Pにあるかを判定してなければそれが答えになる
X, N = map(int,input().split())
P = list(map(int,input().split()))
P = set(P)

for i in range(100):
    if not X-i in P:
        print(X-i)
        exit()
    if not X+i in P:
        print(X+i)
        exit()


Measured memory_bytes: 9168
#include<iostream>
    using namespace std;
    int main()
    {

        int N, K, Q;
        cin >> N >> K >> Q;
        int correctAnswer[100000] = {0};
        for (int i = 0; i < Q; i++){
                int peopleId;
                cin >> peopleId;
                peopleId--;
                correctAnswer[peopleId]++;
        }
        for (int peopleId = 0; peopleId < N; peopleId++){
            if ((K - Q + correctAnswer[peopleId]) > 0) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }  
        }
    }

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <unordered_map>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;
char str[101];
map<char, char> kako = { { '(',')' },{ '[',']' } };

int main() {
	int n;
	map<char, int> mo = { { 'm',1000 },{ 'c', 100 },{ 'x', 10 },{ 'i',1 } };
	array<char, 4> om = { 'm','c','x','i' };
	scanf("%d", &n);

	REP(i, n) {
		char s[9], s2[9];

		scanf("%s %s", s, s2);
		int n = 1;
		int a = 0;
		REP(j, strlen(s)) {
			if (s[j] <= '9') n = s[j] - '0';
			else {
				a += n * mo[s[j]];
				n = 1;
			}
		}
		REP(j, strlen(s2)) {
			if (s2[j] <= '9') n = s2[j] - '0';
			else {
				a += n * mo[s2[j]];
				n = 1;
			}
		}

		REP(j, 4) {
			n = a / mo[om[j]];
			a -= n*mo[om[j]];
			if (n == 1) printf("%c", om[j]);
			else if (n)printf("%d%c", n, om[j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 3152
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	class Edge{
		int to;
		int rev;
		int cap;
		public Edge(int to, int rev, int cap) {
			this.to=to;
			this.rev=rev;
			this.cap=cap;
		}
	}

	class Axis{
		int x;
		int y;
		public Axis(int x, int y) {
			this.x=x;
			this.y=y;
		}
	}
	ArrayList<ArrayList<Edge>> g = new ArrayList<ArrayList<Edge>>();
	boolean used[];
	public void run() {
		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int s = n+n;
		int t = s+1;
		used=new boolean[t+1];
		for(int i=0; i<t+1; i++) {
			g.add(new ArrayList<Edge>());
		}

		ArrayList<Axis> red = new ArrayList<Axis>();
		for(int i=0; i<n; i++) {
			red.add(new Axis(sc.nextInt(), sc.nextInt()));
		}

		ArrayList<Axis> blue = new ArrayList<Axis>();
		for(int i=0; i<n; i++) {
			blue.add(new Axis(sc.nextInt(), sc.nextInt()));
		}

		//red 0-n-1 blue n-2n-1
		//sからred
		for(int i=0; i<n; i++) {
			addFlow(s, i, 1);
		}
		//blueからt
		for(int i=n; i<2*n; i++) {
			addFlow(i, t, 1);
		}
		//redからblue
		for(int i=0; i<n; i++) {
			Axis r = red.get(i);
			for(int j=0; j<n; j++) {
				Axis b = blue.get(j);
				if(r.x<b.x && r.y<b.y) {
					addFlow(i, n+j, 1);
				}
			}
		}
		//計算
		int ans = maxFlow(s,t);
		System.out.println(ans);
		sc.close();
	}

	private int maxFlow(int s, int t) {
		int flow=0;
		while(true) {
			Arrays.fill(used, false);
			int f = dfs(s, t, Integer.MAX_VALUE);
			if(f==0) {
				break;
			}
			flow+=f;
		}
		return flow;
	}


	private int dfs(int s, int t, int f) {
		used[s]=true;
		if(s==t) {
			return f;
		}
		for(Edge e : g.get(s)) {
			if(!used[e.to] && e.cap>0) {
				int flow = dfs(e.to, t, Math.min(f, e.cap));
				if(flow>0) {
					e.cap -= flow;
					g.get(e.to).get(e.rev).cap += flow;
					return flow;
				}
			}
		}
		return 0;
	}

	private void addFlow(int from, int to, int cap) {
		g.get(from).add(new Edge(to, g.get(to).size(), cap));
		g.get(to).add(new Edge(from, g.get(from).size()-1, 0));
	}
}


Measured memory_bytes: 23256
package main
import (
  "fmt"
  "bufio"
  "os"
  "strings"
)
func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  var s []string
  ret := 0
  s = strings.Split(sc.Text(),"")
  for _,i := range(s) {
    if i == "+" {
      ret = ret + 1
    } else if i == "-" {
      ret = ret - 1
    }
  }
  fmt.Println(ret)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool check_palindrome(string str) {
	bool flag = false;
	string reverse_str = string(str.rbegin(), str.rend());
	if (str == reverse_str) {
		flag = true;
	}
	return flag;
}

int main()
{
	string str;
	cin >> str;

	int full_size = str.size();
	bool flag = false;

	if (check_palindrome(str) && check_palindrome(str.substr(0, (full_size - 1) / 2)) &&
		check_palindrome(str.substr((full_size + 1) / 2, full_size))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
n,m = map(int, input().split())

oks = [True for _ in range(n + 1)]
for _ in range(m):
  a = int(input())  
  oks[a]=False


dp = [0 for _ in range(n+1)]
dp[0] = 1
for now in range(n):
  for next in range(now+1, min(n, now+2)+1):
    if(oks[next]):
      dp[next]+=dp[now]
      dp[next]%=10**9+7
print(dp[n])

Measured memory_bytes: 51104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  vector<int> b(n+1);
  for(int i=n;i>0;i--){
    int p=2;
    int ff=a[i-1];
    while(i*p<=n){
      ff+=b[i*p];
      p++;
    }
    b[i]=ff%2;
    ans+=b[i];
  }
  cout<<ans<<endl;
  for(int i=0;i<n+1;i++){
   if(b[i]==1){
     cout<<i<<" ";
   }
  }
  cout<<endl;
}

Measured memory_bytes: 2432
import sys
sys.setrecursionlimit(10**9)

h,w = map(int, input().split())
board = [[int(j=="#") for j in input()] for i in range(h)]
dxdy = [(0,1), (0,-1), (1,0), (-1,0)]

def dfs(i, j, k, prev):
    if used[i][j] or board[i][j] == prev:
        return
    used[i][j] = 1
    k[board[i][j]] += 1
    for dx, dy in dxdy:
        nx, ny = i+dx, j+dy
        if 0 <= nx < h and 0 <= ny < w and not used[nx][ny] and board[nx][ny] != board[i][j]:
            dfs(nx,ny,k,board[i][j])

used = [[0]*w for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if used[i][j]:
            continue
        k = [0]*2
        dfs(i,j,k, -1)
        ans += k[0]*k[1]
print(ans)


Measured memory_bytes: 190832
#include <bits/stdc++.h>
#define size 3000
using namespace std;
double dp[size+1][size+1];
double p[size+1];
double solve(int i,int x)
{
    if(x<=0)
    return 1.0;
    if(i==0)
    return 0.0;
    if(dp[i][x]>-0.9)
    return dp[i][x];

    double a=p[i]*solve(i-1,x-1)+(1-p[i])*solve(i-1,x);
    return dp[i][x]=a;
}
int main() {
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    //double p[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        //cout<<p[i]<<" ";
    }
    cout<<fixed<<setprecision(10);
    cout<<solve(n,(n+1)/2);
    return 0;
}


Measured memory_bytes: 74340
#include <stdio.h>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    
    string g="RUD", k="LUD";
    
    bool is_yes = true;
    for (int i=0;i<s.size();i++){
        bool ok=false;
        if (i%2==0){
            for (int j=0;j<g.size();j++){
                if (g[j]==s[i]){
                    ok=true;
                }
            }
        }else{
            for (int j=0;j<k.size();j++){
                if (k[j]==s[i]){
                    ok=true;
                }
            }
        }
        if (!ok){
            is_yes = false;
            break;
        }
    }
    if (is_yes) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
X, N = map(int,input().split())
P = list(map(int,input().split()))
P.sort()

diff = 10**10
ans = -1
for p in range(102):
    #print(p)
    if p in P:
        continue
    if abs(X-p) < diff:
        diff = abs(X-p)
        ans = p
print (ans)

Measured memory_bytes: 9188
#include <iostream>
using namespace std;
int main()
{
    int a = 0;
    int b = 0;
    cin >> a >> b;

    if((a * b * 1) % 2 != 0
        ||(a * b * 2) % 2 != 0
        ||(a * b * 3) % 2 != 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


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

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

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

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (1 <= i && i <= 9)
            cnt++;
        else if (100 <= i && i <= 999)
            cnt++;
        else if (10000 <= i && i <= 99999)
            cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3636
import math
a, b, x = map(int, input().split())
v = a * a * b
if 2 * x <= v:
    print(math.degrees(math.atan((a*b*b) / (2*x))))
else:
    print(math.degrees(math.atan((2 * (v - x) / (a * a)) / a)))



Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String[]args){

        Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x - r >= 0 && y - r >=0){
			if(x + r <= W && y + r <= H){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
    }
}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    string s; cin >> s;
    if (s[5] == '0' && s[6] <= '4') cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

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

int main(){
  int A,B;
  int count=0;
  cin >> A >> B;
  if(A>B){
    count+=A;
    A--;
  }else{
    count+=B;
    B--;
  }
  if(A>B){
    count+=A;
    A--;
  }else{
    count+=B;
    B--;
  }
  cout << count << endl;
}

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

template<typename T>
struct LazySegtreeAdd {
    int n;
    T e;
    vector<T> dat, laz;
    typedef function<T(T a, T b)> Func;
    Func f;

    LazySegtreeAdd(int n_input, Func f, T e_input):f(f), e(e_input){
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
        laz.resize(2*n-1, 0);
    }

    void initialize(vector<T>& v){
        for(int i=0; i<v.size(); i++) dat[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) dat[i] = f(dat[i*2+1], dat[i*2+2]);
        fill(laz.begin(), laz.end(), 0);
    }

    void eval(int k, int l, int r){
        if(laz[k] == 0) return;
        dat[k] += laz[k];
        if(r-l > 1){
            laz[2*k+1] += laz[k];
            laz[2*k+2] += laz[k];
        }
        laz[k] = 0;
    }

    void add_between(int a, int b, T x){
        add(a, b+1, x, 0, 0, n);
    }

    void add(int a, int b, T x, int k, int l, int r){
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            laz[k] = x;
            eval(k, l, r);
        }else{
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get_between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        eval(k, l, r);
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    static vector<int> L2R[200001];
    for(int i=0; i<N; i++){
        int l, r;
        cin >> l >> r;
        L2R[l].push_back(r);
    }

    LazySegtreeAdd<int64_t> st(M+2, [](int64_t a, int64_t b){ return max(a, b);}, -1e9);
    vector<int64_t> init(M+2);
    for(int i=0; i<=M+1; i++) init[i] = i-M-1;
    st.initialize(init);

    int64_t ans = max(0, N-M);
    for(int l=0; l<M; l++){
        for(int r : L2R[l]) st.add_between(0, r, 1);
        ans = max(ans, st.get_between(l+2, M+1) - l);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100000

int n,m,x,y,ans;
int cnt[MAXN+3];
bool vis[MAXN+3];
int main() {
	vis[1]=1;fill(cnt,cnt+MAXN+1,1);
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++) {
		scanf("%d %d",&x,&y);
		cnt[x]--,cnt[y]++;
		if(vis[x])vis[y]=1;
		if(cnt[x]==0)
			vis[x]=0;
	}
	for(int i=1;i<=n;i++)
		if(vis[i])ans++;
	printf("%d\n",ans);
	return 0;
}

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

int r, d;
vector<int> x(11);

int main(){
  cin >> r >> d >> x.at(0);
  
  rep(i, 10){
    x.at(i+1) = r*(x.at(i)) - d;
    cout << x.at(i+1) << endl;
  }
  
  
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	//range_startは範囲の始まり、range_endは範囲の終わり、count_divisorは約数の数を格納
	int range_start, range_end, base;
	int i, count_divisor;

	scanf("%d %d %d", &range_start, &range_end, &base);
	//初期値は0
	count_divisor = 0;

	//範囲の間だけ繰り返す
	for(i = range_start; i <= range_end; i++){
		//(base / i)の余りが0なら約数
		if(!(base % i)){
			count_divisor++;
		}
	}

	//結果を出力
	printf("%d\n", count_divisor);

	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    int n;
    cin >> n;

    vector<int> ans(n);
    rep(i,n){
        int a;
        cin >> a;
        ans[a-1] = i;
    }
  
    rep(i,n) cout << ans[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <map>

using namespace std;

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

    map<int, bool> mp;
    mp[s] = true;
    int ans = 1;
    while (1) {
        ans++;
        if (s%2)
            s = 3*s + 1;
        else
            s = s/2;

        if (mp[s])
            break;
        else
            mp[s] = true;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int_fast32_t n;
    string s;

    cin >> n >> s;

    vector<int_fast32_t> pr, pg, pb;

    for(int_fast32_t i = 0; i < n; ++i) {
        switch(s.at(i)) {
            case 'R':
                pr.emplace_back(i);
                break;
            case 'G':
                pg.emplace_back(i);
                break;
            case 'B':
                pb.emplace_back(i);
                break;
        }
    }

    uint_fast32_t ans = pr.size() * pg.size() * pb.size();

    for(int_fast32_t i: pr) {
        for(int_fast32_t j: pg) {
            if(i < j) {
                if(2 * i - j >= 0 && s.at(2 * i - j) == 'B') --ans;
                if(2 * j - i < n && s.at(2 * j - i) == 'B') --ans;
                if((j - i) % 2 == 0 && s.at((i + j) / 2) == 'B') --ans;
            }
            if(i > j) {
                if(2 * j - i >= 0 && s.at(2 * j - i) == 'B') --ans;
                if(2 * i - j < n && s.at(2 * i - j) == 'B') --ans;
                if((i - j) % 2 == 0 && s.at((i + j) / 2) == 'B') --ans;
            } 
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>

int main(){
    int ans[26];
    char s[1200];
    bool flag = false;
    for(int i = 0; i<26; i++){
        ans[i] = 0;
    }
    while(scanf("%s", s) != EOF){
        for(int i = 0; s[i] != '\0'; i++){
            if('a' <= s[i] && s[i] <= 'z'){
                ans[(int)s[i] - (int)'a'] += 1;
            }else if('A' <= s[i] && s[i] <= 'Z'){
                ans[(int)s[i] - (int)'A'] += 1;
            }
        }
    ;
    }
    for(int i = 0; i<26; i++){
        printf("%c : %d\n", 'a' + i, ans[i]);
    }
    return 0;
}


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

signed main() {
int n,m;
cin>>n>>m;
vector<int>c(m);
rep(i,m){
  cin>>c[i];
}
//dp[i][j] 1~iでj円を支払うときのコインの最小の枚数
int dp[21][50001];
rep(i,21){
  rep(j,50001){
    dp[i][j]=INF;
  }
}
dp[0][0]=0;
rep(i,m){
  rep(j,n+1){
    if(j-c[i]>=0){
      dp[i+1][j]=min(dp[i+1][j-c[i]]+1,dp[i][j]);
      dp[i+1][j]=min(dp[i][j-c[i]]+1,dp[i+1][j]);
    }
    else dp[i+1][j]=dp[i][j];
  }
}
cout<<dp[m][n]<<endl;
}



Measured memory_bytes: 11300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x, y) cout << x << " " << y << endl
const int N = 2e5+10;
int f[N], d[N];
int Find(int x) {
    if(f[x] == x) return x;
    int root = Find(f[x]);
    d[x] = d[ f[x] ] + d[x];
    return f[x] = root;
}

int join(int x, int y, int z) {
    int fx = Find(x);
    int fy = Find(y);
    if(fx == fy) return z == d[y] - d[x];
    f[fy] = fx;
    d[fy] = d[x] + z - d[y];
    return 1;
}
int main() {
    int n, m;
    int ok = 1;
    cin >> n >> m;
    for(int i=1; i<=n; ++i) f[i] = i;
    for(int i=1; i<=m; ++i) {
        int x, y, z; cin >> x >> y >> z;
        if(ok) ok = join(x, y, z);
    }
    printf(ok ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Satisfaction> aList = new ArrayList<>();
        for(int i = 0; i < n; i++){
            Satisfaction s = new Satisfaction();
            s.setA(sc.nextInt());
            s.setB(sc.nextInt());
            s.culcS();
            aList.add(s);
        }
        Collections.sort(aList, new Comparator<Satisfaction>(){
            @Override
            public int compare(Satisfaction s1, Satisfaction s2){
                if(s1.getS() == s2.getS()){
                    return 0;
                }
                return s1.getS() - s2.getS() > 0 ? -1 : 1;
            }
        });
        long tPoint = 0;
        int tIndex = 0;
        long aPoint = 0;
        int aIndex = 0;
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                tPoint += aList.get(i).getA();
            }else{
                aPoint += aList.get(i).getB();
            }
        }
        System.out.println(tPoint - aPoint);
    }
    
    public static class Satisfaction{
        private long a;
        private long b;
        private long s;
        private boolean canGet = true;
        
        public void setA(long a){
            this.a = a;
        }
        
        public void setB(long b){
            this.b = b;
        }
        
        public void setS(long s){
            this.s = s;
        }

        public void culcS(){
            s = a + b;
        }
        
        public long getA(){
            return a;
        }
        
        public long getB(){
            return b;
        }
        
        public long getS(){
            return s;
        }

        public boolean canGet(){
            return canGet;
        }
        
        public void setCanGet(boolean canGet){
            this.canGet = canGet;
        }
    }
}


Measured memory_bytes: 90704
/* C - Traveling Salesman around Lake */

#include <stdio.h>

int main(void){
  int K, N, i, A[200000], max;
  scanf("%d %d", &K, &N);
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
    if(i == 0){
      max = A[i];
    }
    if(i > 0){
      if(A[i] - A[i - 1] > max){
        max = A[i] - A[i - 1];
      }
      if(i == N - 1){
        if(A[0] + (K - A[i]) > max){
          max = A[0] + (K - A[i]);
        }
      }
    }
  }
  printf("%d\n", K - max);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef pair<char,int> P;
int main(void){
  string s;cin>>s;
  int n=s.size();
  vector<int> ans(n,0);
  map<int,P> rlt;//run length table
  char search='L';
  int idx=0;
  int next=s.find(search,idx);
  while(next!=string::npos){
    search=search=='L'?'R':'L';
    rlt[idx]=P(search,next-idx);
    idx=next;
    next=s.find(search,idx);
  }
  rlt[idx]=P(search=='L'?'R':'L',n-idx);
  for(auto it=rlt.begin();it!=rlt.end();++it){
    int start=it->first;
    char ch=it->second.first;
    int count=it->second.second;
    if(ch=='R'){
      ans[start+count-1]+=(count+1)/2;
      ans[start+count]+=count/2;
    }else{
      ans[start]+=(count+1)/2;
      ans[start-1]+=count/2;
    }
  }

  for(int i=0;i<n;i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}

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

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, 26) cin >> c[i];
    rep(i, D) {
        rep(j, 26) { cin >> s[i][j]; }
    }

    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    vector<int> t(D);
    ll v = 0;
    vector<vector<ll>> Cost(D, vector<ll>(26, 0));
    rep(i, 26) Cost[0][i] = c[i];
    rep(i, D) {
        vector<ll> X(26);
        rep(j, 26) X[j] = s[i][j] + Cost[i][j];
        auto it = max_element(X.begin(), X.end());
        int index = it - X.begin();
        t[i] = index;
        Cost[i][index] = 0;
        v += s[i][index];
        rep(j, 26) {
            v -= Cost[i][j];
            if(i + 1 < D)
                Cost[i + 1][j] = Cost[i][j] + c[j];
        }
    }
    // rep(i, D) cout << t[i] + 1 << endl;

    end = chrono::system_clock::now();
    auto elapsed =
        std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
            .count();
    srand(time(NULL));
    while(elapsed < 1900) {
        int d, q;
        d = rand() % D;
        q = rand() % 26;
        vector<vector<ll>> Cost2 = Cost;
        ll v2 = v;
        int x = d + 1;
        v2 += s[d][q] - s[d][t[d]];
        v2 += Cost2[d][q];
        Cost2[d][q] = 0;
        while(x < D && t[x] != q) {
            v2 += Cost2[x][q];
            Cost2[x][q] = Cost2[x - 1][q] + c[q];
            v2 -= Cost2[x][q];
            x++;
        }

        x = d + 1;
        int y = t[d];
        if(d == 0) {
            Cost2[d][y] = c[y];
            v2 -= Cost2[d][y];
        } else {
            Cost2[d][y] = Cost2[d - 1][y] + c[y];
            v2 -= Cost2[d][y];
        }
        while(x < D && t[x] != y) {
            v2 += Cost2[x][y];
            Cost2[x][y] = Cost2[x - 1][y] + c[y];
            v2 -= Cost2[x][y];
            x++;
        }
        if(v < v2) {
            t[d] = q;
            Cost = Cost2;
            v = v2;
        }
        end = chrono::system_clock::now();
        elapsed =
            chrono::duration_cast<chrono::milliseconds>(end - start).count();
        // cout << v << endl;
    }
    rep(i, D) cout << t[i] + 1 << endl;
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

struct edge {ll from,to,cost;};

int main()
{
    ll n,k;
    cin >> n >> k;
    ll p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < k; i++){
        tmp += p[i];
    }
    ans = tmp;
    for(int i = 0; i < n-k; i++){
        tmp -= p[i];
        tmp += p[i+k];
        if(ans < tmp) ans = tmp;
    }
    ans += k;
    double a = ans / 2.0;

    printf("%.8lf",a);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L

int main(){
	cout << setprecision(12) << fixed;
	long double a , b;
	cin >> a >> b;

	long double hour , minute;
	cin >> hour >> minute;

	long double temp= 2 * PI * ((hour/12) + ((minute/12)/60) - (minute/60));
	long double ans = (a*a) + (b*b) - (2*a*b*cos(temp));
	
	cout << sqrt(ans) << endl;
	return 0;
}



Measured memory_bytes: 4172
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner scan1 = new Scanner(System.in);
        int length = scan1.nextInt();
        int[] arr = new int[length];
        long sum = 0;



            for (int i = 1; i <= length; i++)
            {
                if (i%3 == 0 && i%5 == 0)
                    arr[i-1] = 0;
                else if (i%3 == 0 || i % 5 == 0)
                    arr[i-1] = 0;
                else
                    arr[i-1] = i;
            }
            for (int j : arr )
            {
                sum += j;
            }
        System.out.println(sum);
    }
}


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

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

int dp[1 << 26];

signed main() {
    string s;
    int n, bit = 0;

    cin >> s;
    n = s.size();

    fill_n(dp, 1 << 26, INF);
    dp[0] = 0;
    Rep(i, n) {
        bit ^= 1 << (s[i] - 'a');
        Rep(j, 26) {
            dp[bit] = min(dp[bit], dp[bit ^ (1 << j)] + 1);
        }
    }

    cout << max(1, dp[bit]) << endl;
    return 0;
}


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

#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    ll i,j,n,k;
    cin>>n>>k;
    vector<ll> l(n),r(n);
    for(i=0;i<n;i++) cin>>l[i]>>r[i];
    vector<ll> dp(n+2,0),dpsum(n+2,0);
    dp[1] = 1;
    dpsum[1] = 1;
    ll mod = 998244353;
    for(i=2;i<=n;i++)
    {
        for(j=0;j<k;j++)
        {
            ll li = i-r[j];
            ll ri = i-l[j];
            if(ri<0) continue;
            li = max(li,1ll);
            dp[i] += dpsum[ri] - dpsum[li-1];
            dp[i]= (dp[i] + mod)%mod;
        }
        dpsum[i] = dpsum[i-1] + dp[i];
        dpsum[i]%=mod;
    }
    cout<<dp[n];
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = r[0];
            var M = r[1];
            var acList = new HashSet<int>();
            Dictionary<int,int> waDic = new Dictionary<int, int>();
            for (int i = 0; i < M; i++)
            {
                var l = Console.ReadLine().Split().ToArray();
                var t = int.Parse(l[0]);
                var kekka = l[1];
                if (acList.Contains(t))
                {
                    continue;
                }
                if (kekka == "WA")
                {
                    if (!waDic.ContainsKey(t))
                    {
                      waDic.Add(t,1);  
                    }
                    else
                    {
                        waDic[t]++;
                    }
                }
                else if(kekka == "AC")
                {
                    acList.Add(t);
                }
            }

            var waCount = 0;
            foreach (var ac in acList)
            {
                if (waDic.ContainsKey(ac))
                {
                    waCount += waDic[ac];
                }
                
            }
            Console.WriteLine(acList.Count + " " + waCount);

        }

    }
}

Measured memory_bytes: 19532
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
  int a,b;
  long k;
  
  scanf("%d %d",&a,&b);
  
  k=(a+b)%2;
  
   if(k==0){
     k=(a+b)/2;
     printf("%d",k);
   }
  else{
    printf("IMPOSSIBLE");
  }
   return 0;
}

Measured memory_bytes: 128
int main(void){
    int i,j,a[101],n;
    long long int b[101][21];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    
    for(i=0;i<n;i++)
        for(j=0;j<=20;j++)
            b[i][j]=0;
    
    
    b[0][a[0]]=1;
    
    for(i=1;i<n-1;i++){
        for(j=0;j<=20;j++)
            if(b[i-1][j]>0){
                if(j+a[i]<=20)
                    b[i][j+a[i]]+=b[i-1][j];
                if(j-a[i]>=0)
                    b[i][j-a[i]]+=b[i-1][j];
            }
    }
    printf("%lld\n",b[n-2][a[n-1]]);
    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  sort(a, a + n);

  int target = a[n - 1] / 2;
  int* lb = lower_bound(a, a + n - 1, target);

  int ans;
  if(lb != a){
    if(lb == a + n - 1) ans = *(lb - 1);
    else if(abs(*lb - target) <= abs(*(lb - 1) - target))
      ans = *lb;
    else ans = *(lb - 1);
  }
  else{
    ans = *lb;
  }

  cout << a[n - 1] << " " << ans << endl;

  return 0;
}


Measured memory_bytes: 640