akhauriyash/Code-Regression huggingface dataset:
n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 10:
    ii = n
    jj = n+1
else:
    ii = 10
    jj = 10

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2])*(tmp1[-j][1]-tmp1[i][1]) >= 0:
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2])*(tmp2[-j][1]-tmp2[i][1]) <= 0:
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 150556
#include<stdio.h>
int main(void){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0&&y==0){
            break;
        }
        if(x>y){
            printf("%d %d\n", y, x);
        }
        else{
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    mint ans = 0;
    rep(i, n) {
        for (int j = i+1; j < n; ++j) {
            if (a[i] > a[j]) ans += k;
        }
    }
    rep(i, n) {
        mint now = 0;
        rep(j, n) {
            if (a[i] > a[j]) now += 1;
        }
        now *= 1LL * (k-1) * k / 2;
        ans += now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	for (ll i = sqrt(n); i >= 1; i--) {
		if (n % i == 0) {
			return cout << i - 1 + n / i - 1, 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int mod = 1e9+7;
const int nax=1005;
char s[nax][nax];
void addself(int &a,int b) {
    a+=b;
    if(a>=mod){
        a-=mod;
    }
}
int main() {
    fast_cin();
    int h,w;
    scanf("%d%d",&h,&w);
    for(int row=0;row<h;row++) {
        scanf("%s",s[row]);
    }
    vector<vector<int>>dp(h,vector<int>(w));
    //dp[i][j] stores number of ways to reach this square
    dp[0][0]=1;
    for(int row=0;row<h;row++) {
        for(int col=0;col<w;col++) {
            for(int r2=row;r2<=row+1;r2++) {
                int c2=col;
                if(r2==row) {
                    c2=col+1;
                }
                if(r2 < h && c2 <w && s[r2][c2]=='.') {
                    addself(dp[r2][c2],dp[row][col]);
                }
            }
        }    
    }
    printf("%d\n",dp[h-1][w-1]);
}    


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
const int MAXN = 1e5 + 10;
int N;
struct Point {
    int x, y, idx;
} P[MAXN];

struct Edge {
    int u, v, d;
    bool operator<(const Edge &rhs) const {
        return make_tuple(d, u, v) < make_tuple(rhs.d, rhs.u, rhs.v);
    }
};
vector<Edge> edges;

struct DisjointSet {
    int N;
    vector<int> p;
    DisjointSet(int n) : N(n) {
        p.resize(N, -1);
    }
    
    int find(int a) {
        if(p[a] < 0) return a;
        return p[a] = find(p[a]);
    }
    
    void merge(int a, int b) {
        a = find(a);
        b = find(b);
        if(a == b) return;
        if(p[a] > p[b]) swap(a, b);
        p[a] += p[b];
        p[b] = a;
    }
};

int main() {
    FAST_IO();
    cin >> N;
    rep(i, N) {
        cin >> P[i].x >> P[i].y;
        P[i].idx = i;
    }
    
    // sort by x
    sort(P, P + N, [] (const auto &lhs, const auto &rhs) {
       return make_pair(lhs.x, lhs.y) < make_pair(rhs.x, rhs.y); 
    });
    rep(i, N - 1) {
        edges.push_back({P[i].idx, P[i + 1].idx, P[i+1].x - P[i].x});
    }
    
    // sort by y
    sort(P, P + N, [] (const auto &lhs, const auto &rhs) {
       return make_pair(lhs.y, lhs.x) < make_pair(rhs.y, rhs.x); 
    });
    rep(i, N - 1) {
        edges.push_back({P[i].idx, P[i+1].idx, P[i+1].y - P[i].y});
    }
    sort(all(edges));
   
    DisjointSet djs(N);
    ll ans = 0;
    for(auto &e : edges) {
        if(djs.find(e.u) == djs.find(e.v)) continue;
        ans += e.d;
        djs.merge(e.u, e.v);
    }
    
    cout << ans << "\n";
}

Measured memory_bytes: 6132
import java.util.Scanner;

public class Main 
{
	static void addition(String a, String b, boolean minus)
	{
		StringBuilder sb = new StringBuilder("");
		
		int maxl = Math.max(a.length(), b.length());
		
		int remainder = 0;
		for(int i = 0; i < maxl; i++)
		{
			int p = 0;
			int q = 0;
			
			if(a.length() >= i+1)
			{
				p = a.charAt(a.length()-1-i)-'0';
			}
			
			if(b.length() >= i+1)
			{
				q = b.charAt(b.length()-1-i)-'0';
			}
			
			int cur = (p+q+remainder)%10 ;
			remainder = (p+q+remainder)/10;
			
			sb.append(cur);
			
//			System.out.println(p + " " + q);
		}
		
		if(remainder > 0)sb.append(remainder);
		
		sb.reverse();
		
		if(minus)
			System.out.println("-" + sb);		
		else
			System.out.println(sb);		
			
	}
	
	static void substraction(String a, String b, boolean minus)
	{
		StringBuilder sb = new StringBuilder("");
		
		int maxl = Math.max(a.length(), b.length());
		
		int pinjem = 0;
		for(int i = 0; i < maxl; i++)
		{
			int p = 0;
			int q = 0;
			
			if(a.length() >= i+1)
			{
				p = a.charAt(a.length()-1-i)-'0';
			}
			
			if(b.length() >= i+1)
			{
				q = b.charAt(b.length()-1-i)-'0';
			}
			
			int cur = p - q - (pinjem/10);
			pinjem = 0;
			if(cur < 0)
			{
				pinjem = 10;
				cur += pinjem;
			}

			sb.append(cur);
//			System.out.println("APPEND " + cur);
//			System.out.println(p + " " + q);
		}
		
		sb.reverse();
		
		for(int i = 0; i < sb.length(); i++)
		{
			if(sb.charAt(i) != '0')
			{
				if(i > 0)
				{
					sb.delete(0, i);
				}
				break;
			}
		}
		
		if(minus)
			System.out.println("-" + sb);		
		else
			System.out.println(sb);		
			
	}	
	
	public static void main(String[] args) 
	{
		String a;
		String b;
		Scanner sc = new Scanner(System.in);
		
		a = sc.next();
		b = sc.next();
		
		if(a.charAt(0) == '-' && b.charAt(0) == '-')
		{
			addition(a.substring(1),b.substring(1), true);
		}
		else if(a.charAt(0) != '-' && b.charAt(0) != '-')
		{
			addition(a,b, false);
		}
		else
		{
			int abigger = 0;
			boolean ma = false;
			boolean mb = false;
			
			if(a.charAt(0) == '-')
			{
				a = a.substring(1);
				ma = true;
			}
			if(b.charAt(0) == '-')
			{
				b = b.substring(1);
				mb = true;
			}
			
			if(a.length() != b.length()) {abigger = (int) Math.signum(a.length() - b.length());}
			else{abigger = (int) Math.signum(a.compareTo(b));}
			
//			System.out.println("abigger " + abigger);
			
			if(!ma && mb)
			{
				if(abigger>0)
				{
					substraction(a,b, false);
				}
				else
				{
					substraction(b,a, true);
				}
			}
			else if(ma && !mb) //-4 + 5
			{
				if(abigger>0)
				{
					substraction(a,b, true);
				}
				else
				{
					substraction(b,a, false);
				}
			}
		}
		
	}

}



Measured memory_bytes: 35276
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  ld a;
  ld b;
  cin>>a>>b;
  ll c=a*b;
  cout<<c<<endl;

  return 0;
}

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

class Program {
  static void Main(string[] args) {
    var s = Console.ReadLine();

    Console.WriteLine(Math.Min(check(s, '0'), check(s, '1')));
  }

  static int check(string s, char c) {
    int ans = 0;
    foreach (char _c in s) {
      if (_c != c) {
        ans++;
      }

      c = (c == '0' ? '1' : '0');
    }

    return ans;
  }
}


Measured memory_bytes: 11232
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=2*1e+5 + 10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main() {
	int N;
	cin >> N;
	FOR(i,1,N+1){
		int t = i * (i + 1) / 2;
		if(t >= N){
			FOR(j,1,i+1){
				if(t - N == j)
					continue;
				printf("%d\n", j);
			}
			return 0;
		}
	}
    return 0;	
}


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

using namespace std;

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

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

#include <algorithm>
#include<iostream>

using namespace std;


int main(){
          
          
    int a;
    int b;
    int c;
    int d;
    
    cin >> a >> b >> c >> d;
   int i = 0;
   int n = 0;
   int k = 0;
   int endnum = 0;
  
    for(i = 0; i < a+1; i++){
      
       for(n = 0; n < b+1; n++){
      
             for(k = 0; k < c+1; k++){
      
       
                 int sum = i*500+n*100+k*50;
                   
                 if(sum==d){
                 
                     endnum++;
                  }
                  
      
             }
      
       }
      
    }
    
    
    
    
   
          cout << endnum << endl;
          
          
     return 0;     
          
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int>v;
int at[100001];
signed main()
{
	int n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%lld",&x);
		at[x]=i;
	}
	v.push_back(0);
	v.push_back(0);
	v.push_back(n+1);
	v.push_back(n+1);
	int ans=0;
	for(int i=n;i>=1;i--)
	{
		int l=lower_bound(v.begin(),v.end(),at[i])-v.begin()-1;
		int r=lower_bound(v.begin(),v.end(),at[i])-v.begin();
		ans+=(v[r+1]-v[r])*(at[i]-v[l])*i;
		ans+=(v[l]-v[l-1])*(v[r]-at[i])*i;
		v.insert(v.begin()+l+1,at[i]);
		//for(int i=0;i<v.size();i++)
		//	printf("%d ",v[i]);
		//printf("\n");
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2168
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	string s, t;
	cin >> N >> s >> t;
	int ans = 2 * N;

	FOR(i, 0, N) {
		// iはsのindex
		if (s.substr(i) == t.substr(0, s.substr(i).length())) {
			ans -= s.substr(i).length();
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, Y;
int main() {
	cin >> n >> Y;
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j <= n - i; j++) {
			int k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) { cout << i << " " << j << " " << k << endl; return 0; }
			if (i == 0 && j == n && 10000 * i + 5000 * j + 1000 * k != Y) { cout << "-1 -1 -1" << endl; return 0; }
		}
	}
}

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

int main(){
	int n,m;	cin>>n>>m;
	vector<vector<int>> light(m);
	for(int i=0;i<m;i++){
		int cnt;	cin>>cnt;
		for(int j=0;j<cnt;j++){
			int s;	cin>>s;
			--s;
			// スイッチ番号を0-オリジンにする
			light[i].push_back(s);
		}
	}

	vector<int> flag(m);	for(int i=0;i<m;i++)cin>>flag[i];

	int ans=0;
	for(int i=0;i<(1<<n);i++){
		vector<bool> Switch(n,false);
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				// j番目のスイッチonになってる
				Switch[j]=true;
			}
		}

		int lightCnt=0;
		for(int j=0;j<m;j++){
			int cnt=0;
			for(int s:light[j]){
				cnt += Switch[s];
			}
			if(cnt%2 == flag[j]){
				lightCnt++;
			}
		}
		if(lightCnt == m)ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x * f;
}
char str[300001];
long long vis[30],ans;
int main()
{
	cin>>str;
	long long len=strlen(str);
	for(int i=0;i<len;i++) vis[str[i]-'a']++;
	for(int i=0;i<26;i++) if(vis[i]>=2) ans+=(vis[i]*(vis[i]-1)/2);
	printf("%lld",(long long)len*(len-1)/2-ans+1);
	return 0;
}

Measured memory_bytes: 384
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=100005;


void solve()
{
    int n,a,b;
    cin>>n>>a>>b;
    int x=n/(a+b);
    int ans=x*a;
    ans=ans+min(n%(a+b),a);
    cout<<ans<<endl;
    
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    
    int t;
    t=1;
     //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static class KnapsackComplete {

        int capacity;
        int n;
        int[] cost;
        int[] value;

        public KnapsackComplete(int n, int capacity, int[] cost, int[] value) {
            this.n = n;
            this.capacity = capacity;
            this.cost = cost;
            this.value = value;
        }

        int solve() {
            int[] rowCurr;
            int[] rowPrev;
            rowCurr = new int[capacity + 1];
            rowPrev = new int[capacity + 1];
            for (int numOfItems = 1; numOfItems <= n; numOfItems++) {
                int[] tmp = rowCurr;
                rowCurr = rowPrev;
                rowPrev = tmp;
                int costThis = cost[numOfItems - 1];
                for (int weight = 1; weight <= capacity; weight++) {
                    rowCurr[weight] = rowPrev[weight];
                    if (weight - costThis >= 0) {
                        rowCurr[weight] = Math.max(rowCurr[weight],
                                rowCurr[weight - costThis] + value[numOfItems - 1]);
                    }
                }
            }
            return rowCurr[capacity];
        }

    }

    static Scanner in = new Scanner(System.in);

    static KnapsackComplete readCase() {
        while (in.hasNext()) {
            int n = in.nextInt();
            int capacity = in.nextInt();
            int[] cost = new int[n];
            int[] value = new int[n];
            for (int i = 0; i < n; i++) {
                value[i] = in.nextInt();
                cost[i] = in.nextInt();
            }
            KnapsackComplete knapsack = new KnapsackComplete(n, capacity, cost, value);
            return knapsack;
        }
        return null;
    }

    public static void main(String[] args) {
        KnapsackComplete knapsack = null;
        while ((knapsack = readCase()) != null) {
            System.out.println(knapsack.solve());
        }
    }

}

Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
int w, h;
vector<vector<int>> a(55, vector<int>(55, 0));
int ct;

void dfs(int y, int x) {
  a[y][x] = 0;
  for(int i = -1; i <= 1; ++i) {
    for(int j = -1; j <= 1; ++j) {
      int ny = y + i, nx = x + j;
      if(0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == 1) {
        dfs(ny, nx);
      }
    }
  }
}

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

    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        if(a[i][j] == 1) {
          ++ct;
          dfs(i, j);
        }
      }
    }
    printf("%d\n", ct);
    ct = 0;
    a.clear();
  }
  return 0;
}

Measured memory_bytes: 3384
#include<stdio.h>

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

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

int main(){
  int a;
  string b;
  cin >> a >> b;
  int ans=0;
  for(int i=0;i<a-2;i++){
    if(b.at(i)=='A'&&b.at(i+1)=='B'&&b.at(i+2)=='C')ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

int main(void)
{
    ll n,a,b;
    scanf("%ld %ld %ld",&n,&a,&b);

    printf("%ld\n", min(n*a,b));
    return 0;
}


Measured memory_bytes: 128
/*input
3 1
1 2
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 405

int n, m;
vector<pair<int, int> > a;
bitset<N> need[405];
bool sureDead[405];

void make(int u) {
	bitset<N> inset;
	inset[u] = true;
	for (int i = a.size() - 1; i >= 0; i--) {
		int x = a[i].fi; int y = a[i].se;
		if (inset[x] && inset[y]) {
			sureDead[u] = true;
			return;
		}
		else if (inset[x]) {
			inset[y] = true;
		}
		else if (inset[y]) {
			inset[x] = true;
		}
	}
	for (int i = 1; i <= n; i++) need[u][i] = inset[i];
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int x, y; cin >> x >> y;
		a.push_back(mp(x, y));
	}
	for (int i = 1; i <= n; i++) {
		make(i);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (sureDead[i]) continue;
		for (int j = i + 1; j <= n; j++) {
			if (sureDead[j]) continue;
			bitset<N> x = need[i] & need[j];
			if (x.count() == 0) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ans=0;
  vector<int>b(110);
  cin>>n;
  for(int i=0;i<n-1;i++)cin>>b[i];
  for(int i=1;i<n-1;i++)ans+=min(b[i],b[i-1]);
  ans+=b[n-2]+b[0];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3580
N,L=map(int,input().split())

l=[]
for i in range(N):
  l.append(L+(i+1)-1)

s=sum(l)

p=10**10

ans=0
for x in l:
  if p>abs(s-(s-x)):
    p=abs(s-(s-x))
    ans=s-x

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#define PI 3.14159265
using namespace std;

int main()
{
    double a, b, c;

    cin >> a >> b >> c;

    double s = a*b*sin(c*PI/180)/2;
    double h = b*sin(c*PI/180);
    double l = sqrt( a*a + b*b - 2*a*b*cos(c*PI/180) ) + a + b;

    cout << fixed << setprecision(8) << s << "\n" ;
    cout << fixed << setprecision(8) << l << "\n" ;
    cout << fixed << setprecision(8) << h << "\n" ;

	return 0;
}


Measured memory_bytes: 3532
from functools import reduce
import math

MIN = -10 ** 9
MAX = 10 ** 9


def main():
    L, R = [int(a) for a in input().split()]

    if R - L > 2020:
        print(0)
        return

    r = 2 * (10 ** 9)
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            if m < r:
                r = m
    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
before = -1
for i in range(n):
    now = a[i]
    if before + 1 == now:
        ans += c[before-1]
    before = now
print(ans + sum(b))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int x;
    cin >> x;
    int n = 0;
    long long int pri = 100;
    long long int ci = 0;
    do {
        ci = (pri)/100;
        pri = ci+ pri;
        n += 1;
    }
    while(pri < x);
    cout << n;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){

	char str[20] = {},i;
	
	scanf("%s", str);
	
	for (i = 0; i < 20; i++){
		if (str[19 - i] >0){ printf("%c", str[19-i]); }
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 932
#include<iostream>
using namespace std;
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a<b){
        cout<<(a+w<b?b-a-w:0)<<endl;
    }else{
        cout<<(b+w<a?a-b-w:0)<<endl;
    }
    return 0;
}


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

int main(){
  string O,E;
  cin >> O >> E;
  vector<char> ans(O.size()+E.size());
  for(int i = 0; i < O.size(); i++){
    ans.at(2*i) = O.at(i);
  }
  for(int i = 0; i < E.size(); i++){
    ans.at(2*i+1) = E.at(i);
  }
  for(int i = 0; i < O.size()+E.size(); i++){
    cout << ans.at(i);
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
T = [0]+list(map(int, input().split()))+[0]
A = [0]+list(map(int, input().split()))+[0]
ans = 1
MOD = 10**9+7

for i in range(1, N+1):
    if T[i]!=T[i-1] and A[i]!=A[i+1]:
        if T[i]!=A[i]:
            print(0)
            exit()
    elif T[i]!=T[i-1] and A[i]==A[i+1]:
        if T[i]>A[i]:
            print(0)
            exit()
    elif T[i]==T[i-1] and A[i]!=A[i+1]:
        if A[i]>T[i]:
            print(0)
            exit()
    else:
        ans *= min(T[i], A[i])
        ans %= MOD

print(ans)

Measured memory_bytes: 77796
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
  int a[10]{};
  for(int b=0;b<10;b++){
      scanf("%d",&a[b]);
      }
      sort(a,a+10);
      printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef vector<int64_t> vi;
typedef pair< int64_t,int64_t> ii;
typedef vector<pair<int64_t, int64_t> > vp;
typedef vector<pair<int64_t, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int int64_t
void solve();
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    solve();
    return 0;
}
void solve()
{
    int n;
    cin>>n;
    int dp1=0,dp2=0,dp3=0;
    int a,b,c;
    cin>>dp1>>dp2>>dp3;
    int t1=0,t2=0,t3=0;
    for(int i=0;i<n-1;i++)
    {
        cin>>a>>b>>c;
        t1=max(dp3,dp2)+a;
        t2=max(dp3,dp1)+b;
        t3=max(dp1,dp2)+c;
        dp1=t1;
        dp2=t2;
        dp3=t3;
    }
    cout<<max(dp1,max(dp2,dp3))<<"\n";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int D, T, S;
    cin >> D >> T >> S;
    if(D<=T*S){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int actionFunction(vector<long long> &weights, vector<int> &values, long long maxWeightCapacity) {
    if(weights.size()==0 || maxWeightCapacity<0)return 0;
    vector<long long> dp((1e5)+1,0);
    for(int i=0;i<values.size();i++) {
        for(int iter=dp.size();iter>=0;iter--) {
            if(dp[iter]!=0) {
                dp[iter+values[i]]=min(dp[iter]+weights[i],dp[iter+values[i]]==0?(long long)INT_MAX:dp[iter+values[i]]);    
            }
            if(iter==values[i]) {
                dp[iter]=min(weights[i],dp[iter]==0?(long long)INT_MAX:dp[iter]);
            }
        }
    }
    for(int iter=dp.size();iter>=0;iter--) {
        if(dp[iter]!=0 && dp[iter]<=maxWeightCapacity)return iter;
    }
    return 0;
}
int main(void){
    vector<long long> weights;
    vector<int> values;
    int n,k;
    long long tmp;
    int tmpl;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>tmp;
        cin>>tmpl;
        if(tmp>k)continue;
        weights.push_back(tmp);
        values.push_back(tmpl);
    }
    cout<<actionFunction(weights,values,k)<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{

    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vector<ll> dp(n,INT_MAX);
    dp[0]=0;dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int a = ni();
		int b = ni();

		if (a >= 13) {
			out(b);

		} else if (a <= 12 && a >= 6) {
			out(b / 2);
		} else {
			out(0);
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int S[1000000],n;

int b_search(int key){
  int l =0;
  int r = n;
  int m;
  while (l < r){
    m = (l + r)/2;
    if(key == S[m])return 1;
    if (key > S[m])l = m + 1;
    else if (key < S[m])r = m;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for( i=0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(b_search(k))sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2172
import java.util.*;
import java.awt.geom.*;

public class Main{
	int k = 101;
	double EPS = 1.0e-10;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Line2D [] list = new Line2D[n];
			for(int i = 0; i < n; i++){
				int x1 = sc.nextInt();
				int y1 = sc.nextInt();
				Point2D p1 = new Point2D.Double(x1, y1);
				int x2 = sc.nextInt();
				int y2 = sc.nextInt();
				Point2D p2 = new Point2D.Double(x2, y2);
				Point2D pvec = mul(k, sub(p2, p1));
				Point2D p2after = new Point2D.Double(pvec.getX() + p2.getX(), pvec.getY() + p2.getY());
				Point2D p1after = new Point2D.Double(pvec.getX() * -1 + p1.getX(), pvec.getY() * -1 + p1.getY());
				list[i] = new Line2D.Double(p1after, p2after);
			}
			int count = 1;
			for(int i = 0; i < n; i++){
				ArrayList<Point2D> now = new ArrayList<Point2D>();
				for(int j = i-1; j >= 0; j--){
					if(list[i].intersectsLine(list[j])){
						Point2D p = intersectPtSS(list[i], list[j]);
						if(! isOK(p)) continue;
						if(contain(now, p)) continue;
						
						now.add(p);
						
					}
				}
				count += 1 + now.size();
			}
			System.out.println(count);
		}
	}
	private boolean contain(ArrayList<Point2D> now, Point2D p) {
		for(int i = 0; i < now.size(); i++){
			if(Math.abs(p.getX() - now.get(i).getX()) < EPS && 
					Math.abs(p.getY() - now.get(i).getY()) < EPS) return true;
		}
		return false;
	}
	private boolean isOK(Point2D p) {
		if(-100 + EPS < p.getX() && p.getX() < 100 - EPS && -100 + EPS < p.getY() && p.getY() < 100 - EPS){
			return true;
		}
		return false;
	}
	private Point2D intersectPtSS(Line2D l, Line2D m) {
		Point2D lVec = sub(l.getP2(), l.getP1());
		Point2D mVec = sub(m.getP2(), m.getP1());
		Point2D m1l1Vec = sub(m.getP1(), l.getP1());
		double a = cross(m1l1Vec, lVec);
		double b = cross(lVec, mVec);
		if(Math.abs(a) < EPS && Math.abs(b) < EPS){
			//平行な直線同士の場合
			if(l.getP1().distance(m.getP1()) < EPS) return l.getP1();
			if(l.getP1().distance(m.getP2()) < EPS) return l.getP1();
			return l.getP2();
		}
		double t = a / b;
		double resx = m.getX1() + t * mVec.getX();
		double resy = m.getY1() + t * mVec.getY();
		return new Point2D.Double(resx, resy);
	}
	
	private double cross(Point2D p1, Point2D p2) {
		double res = p1.getX() * p2.getY() - p1.getY() * p2.getX();
		return res;
	}
	
	private Point2D sub(Point2D p2, Point2D p1) {
		double x = p2.getX() - p1.getX();
		double y = p2.getY() - p1.getY();
		return new Point2D.Double(x, y);
	}
	
	private Point2D mul(double value, Point2D p) {
		return new Point2D.Double(p.getX() * value, p.getY() * value);
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 53660
N = int(input())
S = [input() for _ in range(N)]

word_list = {}

for i in range(N):
    if S[i] in word_list:
        word_list[S[i]] += 1
    else:
        word_list[S[i]] = 1

word_list_s = sorted(word_list.items(), key=lambda x:x[1], reverse=True)
word_list_s_max = []
for i in range(len(word_list_s)):
    if word_list_s[i][1] == word_list_s[0][1]:
        word_list_s_max.append(word_list_s[i])
word_list_s_2 = sorted(word_list_s_max, key=lambda x:x[0])

for i in range(len(word_list_s_2)):
    print(word_list_s_2[i][0])

Measured memory_bytes: 53768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();

			for (char i = 'a'; i <= 'z'; i++) {
				String tmp = "" + i;
				if (s.indexOf(tmp) < 0) {
					System.out.println(tmp);
					return;
				}
			}

			System.out.println("None");
		}
	}
}


Measured memory_bytes: 26308
#include <stdio.h>
int main(void){
	int a,b;
	int sum;
	scanf("%d %d", &a,&b);
		if(a == b ){
			sum = 2 * a ;
		}else if(a > b) {
			sum = 2 * a -1;	
		}else if(b > a){
			sum = 2 * b -1;
		}
	
		printf("%d",sum);
		return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<random>
using namespace std;
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	mt19937 rng(114514);
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		int d=rng()%D,q=rng()%26;
		now+=change(d,q);
		t[d]=q;
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3660
N=int(input())
S1=input()
S2=input()
MOD=10**9+7

def ranlength(A):
    num = list(A)
    count = 1
    table = []
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
               count = count + 1
            else:
                table.append(count)
                count = 1
        except:
            table.append(count)
    return(table)

T=ranlength(S1)
ans=T[0]*3
for i in range(1,len(T)):
    if T[i-1]==1:
        ans*=2
    elif T[i-1]==2 and T[i]==2:
        ans*=3
    ans%=MOD
print(ans)

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	
	ld a[n];
	
	f(i,0,n)
	{
		cin >> a[i];
		a[i] = (a[i] + 1)/2.0;
	}
	
	ld sum = 0 , ans = 0;
	f(i,0,k) sum += a[i];
	
	ans = sum;
	
	f(i,k,n)
	{
		sum += a[i] - a[i-k];
		ans = max(ans, sum);
	}
	
	cout << fixed << setprecision(10) << ans;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}
typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

ll findSumOfDigits(ll n)
{
    ll digit = 0;
    while (n > 0)
    {
        digit++;
        n /= 10;
    }
    return digit;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    cout << fixed << setprecision(16);
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double kakudo = (30 * H - 6 * M + 0.5 * M);
    if(kakudo > 180){
        kakudo = 360 - kakudo;
    }
    long double ans = sqrt(A * A + B * B - 2 * A * B * cos(kakudo * 3.14159265358979323846 / 180));
    cout << ans<<endl;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#include <algorithm>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long 
#define pb push_back
#define mk make_pair
#define mod 1e9+7
using namespace std;

ll gcd(ll a, ll b){
    return __gcd(a,b);
}

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

bool isPrime(ll n){
    for(ll i=2; i<=sqrt(n); i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}


void solve(){
    ll k;
    cin >> k;
    cout << 360/gcd(360,k) << endl;
}

int main() {
    fast;
    solve();
	//ll t; cin >> t; while(t--){ solve(); }
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    vector<int> dp(n, 2e9);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        for (int j = i - 1; j >= max(0, i - k); j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n - 1];
}

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

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int calc[3] = {A+B, A-B, A*B};
  sort(calc,calc+3);
  reverse(calc,calc+3);
  
  cout << calc[0];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int W,H,N;
vector<tuple<int,int,int>> A;
//=============================
void input()
{
    cin>>W>>H>>N;
    A.resize(N);
    rep(i,0,N-1){
        int x,y,a;
        cin>>x>>y>>a;
        A[i] = make_tuple(x,y,a);
    }

}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int xl = 0;
    int xr = W;
    int yl = 0;
    int yr = H;

    for(auto xxx : A){
        int x,y,a;
        tie(x,y,a) = xxx;
        switch (a) {
            case 1:
                xl = max(xl,x);break;
            case 2:
                xr = min(xr,x);break;

            case 3:
                yl = max(yl,y);break;
            case 4:
                yr = min(yr,y);break;
            default:break;
        }
    }
    cout<<(max(0,yr-yl)*max(0,xr-xl))<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int c = a+b;
	string s;
	cin >> s;
	int r1 = 0, total = 0, r2 = 0;
	for(int i=0; i<n; i++) {
		if(s[i] == 'c') {
			cout << "No" << endl;
		} else if(s[i] == 'a') {
			if(total < c) {
				total++;
				cout << "Yes" << endl;
			}else 
				cout << "No" << endl;
		} else {
			if(total < c) {
				
				r2++;
				if(r2 <=b) {
					total++;
					cout << "Yes" << endl;
				} else
					cout << "No" << endl;
			} else {
				cout << "No" << endl;
			}
		}
	}
}


Measured memory_bytes: 896
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

void solve(){
  int num,w;
  cin >> num >> w;
  std::vector<std::vector<int>> wv(num,vector<int>(2));
  for(int i=0;i<num;i++)
    cin >> wv[i][0] >> wv[i][1];
  std::vector<ll> dp(w+1);
  for(int i=0;i<num;i++){
    std::vector<ll> newdp(w+1);
    for(int j=0;j<=w;j++)
      if(j-wv[i][0]>=0)
        newdp[j]=max(dp[j],dp[j-wv[i][0]]+wv[i][1]);
      else newdp[j]=dp[j];
    dp=newdp;
  }
  ll m;
  for(int i=0;i<=w;i++)
    m=max(m,dp[i]);
  cout << m << endl;
}

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


Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ll N;
    cin>>N;
    vector<ll> A(N);

    for(ll i=0;i<N;i++)
        cin>>A[i];
    
    stack<ll> st;

    vector<ll> nge(N,-1);
    st.push(A[0]);

    for(ll i=1;i<N;i++){

        while(!st.empty()&&A[i]>=st.top())
            st.pop();

        if(!st.empty())
            nge[i]=st.top();
        else nge[i]=-1;

        st.push(A[i]);
    }

    ll ans=0,curr=0;
    for(ll i=0;i<N;i++){
     //   cout<<nge[i]<<" ";
        // if(nge[i]!=-1)
        //     ans+=abs(nge[i]-A[i]);

        if(nge[i]==-1){
            curr=A[i];
        }
        else{
            if(curr>nge[i])
                nge[i]=curr;

        }
    }
        for(ll i=0;i<N;i++){
     //   cout<<nge[i]<<" ";
         if(nge[i]!=-1)
             ans+=abs(nge[i]-A[i]);
        }
 
    cout<<ans<<"\n";


}


Measured memory_bytes: 7872
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def check(n):
    if n == 0:
        return ''
    if n % 2 == 0:
        return check(n // (-2)) + '0'
    return check((n - 1) // (-2)) + '1'


n = int(readline())
if n == 0:
    print(0)
else:
    print(check(n))


Measured memory_bytes: 3060
import sys

#縦k、横kのマスに移動させて考える
n, k = map(int, sys.stdin.readline().strip().split())
x = []
y = []
mx = []
my = []
for _ in range(n):
    xx, yy, c = sys.stdin.readline().strip().split()
    xx = int(xx)
    yy = int(yy)
    if c == 'W':
        xx += k
    xx %= 2 * k
    yy %= 2 * k
    if xx >= k:
        if yy >= k:
            x.append(xx - k)
            y.append(yy - k)
        else:
            mx.append(xx - k)
            my.append(yy)
    else:
        if yy >= k:
            mx.append(xx)
            my.append(yy - k)
        else:
            x.append(xx)
            y.append(yy)

graph = [[0 for _ in range(k)] for __ in range(k)]

#累積和
#lx + lmx = n
lx = len(x)
graph[0][0] += lx
for i in range(lx):
    graph[x[i]][0] -= 1
    graph[0][y[i]] -= 1
    graph[x[i]][y[i]] += 2

lmx = len(mx)
graph[0][0] -= lmx
for i in range(lmx):
    graph[mx[i]][0] += 1
    graph[0][my[i]] += 1
    graph[mx[i]][my[i]] -= 2

for i in graph:
    for j in range(k-1):
        i[j+1] += i[j]

for i in range(k):
    for j in range(k-1):
        graph[j+1][i] += graph[j][i]

#最大値、最小値を取得
big = max([max(i) for i in graph]) + lmx
small = min([min(i) for i in graph]) - lx

if big + small >= 0:
    print(big)
else:
    print(-small)

Measured memory_bytes: 63964