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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long H, long long W, long long A, long long B){
    REP(i, H-B) {
        REP(j, W-A) {
            cout << "0";
        }
        REP(j, A) {
            cout << "1";
        }
        cout << endl;
    }

    REP(i, B) {
        REP(j, W-A) {
            cout << "1";
        }
        REP(j, A) {
            cout << "0";
        }
        cout << endl;
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(H, W, A, B);
    return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int x, y, z, m;
	scanf("%d%d%d%d", &x, &y, &z, &m);
	vll a(x), b(y), c(z);
	for (int i = 0; i < x; i++) scanf("%lld", &a[i]);
	for (int i = 0; i < y; i++) scanf("%lld", &b[i]);
	for (int i = 0; i < z; i++) scanf("%lld", &c[i]);
	sort(all(a), greater<ll>());
	sort(all(b), greater<ll>());
	sort(all(c), greater<ll>());
	vll v;
	for (int i = 0; i < x; i++)
		for (int j = 0; j < y; j++)
			for (int k = 0; k < z; k++) {
				if ((i+1) * (j+1) * (k+1) > m) break;
				v.push_back(a[i] + b[j] + c[k]);
			}
	sort(all(v), greater<ll>());
	for (int i = 0; i < m; i++) printf("%lld\n", v[i]);
}


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

const int maxn=105;
int n,m,k,mod;
int fac[maxn],ifac[maxn],pw[maxn][maxn];
int f[maxn][maxn][maxn],g[maxn][maxn][maxn];
void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int main(){
	scanf("%d%d%d%d",&n,&m,&k,&mod);
	fac[0]=ifac[0]=fac[1]=ifac[1]=1;
	for(int i=2;i<=max(n,m);i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	for(int i=1;i<=max(n,m);i++)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	pw[0][0]=1;
	for(int p=1;p<=k;p++){
		pw[p][0]=1;
		for(int i=1;i<=max(n,m);i++)pw[p][i]=1LL*pw[p][i-1]*p%mod;
	}
	f[0][0][0]=1;
	for(int p=0;p<=k;p++)for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
		if(g[p][i][j]){
			Add(f[p][i][j],g[p][i][j]);
			int coef=g[p][i][j],mul=pw[k-p+1][i]-pw[k-p][i];
			if(mul<0)mul+=mod;
			mul=1LL*mul*pw[p][n-i]%mod;
			for(int jj=j+1;jj<=m;jj++){
				coef=1LL*coef*mul%mod;
				Add(f[p][i][jj],1LL*ifac[jj-j]*coef%mod);
			}
		}
		if(p<k&&f[p][i][j]){
			Add(g[p+1][i][j],f[p][i][j]);
			int coef=f[p][i][j],mul=pw[p+1][m-j]-pw[p][m-j];
			if(mul<0)mul+=mod;
			mul=1LL*mul*pw[k-p][j]%mod;
			for(int ii=i+1;ii<=n;ii++){
				coef=1LL*coef*mul%mod;
				Add(g[p+1][ii][j],1LL*ifac[ii-i]*coef%mod);
			}
		}
	}
	printf("%d\n",1LL*f[k][n][m]*fac[n]%mod*fac[m]%mod);
	return 0;
}

Measured memory_bytes: 9088
(setq c 0)(setq s(read-line))(setq a"")
(loop for i from(1-(length s))downto 0 do(if(char=(char s i)#\B)(incf c)(if(> c 0)(decf c)(setq a(format nil"~A~A"(char s i)a)))))
(princ a)

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	float v[n];
	for (int i = 0; i < n; ++i) {
    	cin >> v[i];
    }
	sort(v, v+n);
	for (int i = 0; i < n-1; ++i) {
		float a = v[i];
    	float b = v[i+1];
        v[i+1] = (a + b) / 2.0;
    }
	cout << v[n-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N + 1) cin >> A[i];
	ll res = 0;
	rep(i, 0, N) {
		ll b; cin >> b;

		rep(j, 0, 2) {
			ll v = min(A[i + j], b);
			res += v;
			b -= v;
			A[i + j] -= v;
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

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

	int L=0,R=S.length()-1;

	while(S[L]=='T')L++;
	while(S[R]=='S')R--;

	int cnt=0;
	int ans=S.length();
	for(int i=L;i<=R;i++){
		if(S[i]=='S')cnt++;
		else if(S[i]=='T'){
			if(cnt){
				cnt--;
				ans-=2;
			}
		}
	}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Look at me please ... that's what she said
#define MOD 1000000007
using namespace std;
const int INF = 1e6 + 9;
int main(){
    ios::sync_with_stdio(false);
    //cin.tie(0); ///activate when submit
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n&1)cout<<"No"<<'\n';
    else{
    	if(s.substr(0,n/2)==s.substr(n/2,(int)s.size()))cout<<"Yes"<<'\n';
    	else cout<<"No"<<'\n';
    }
    return 0;
}    

Measured memory_bytes: 256
#include<stdio.h>

int binarySearch(int,int);
int A[100000];

int main(){

  int B[50000],N,M,i,count=0;

  scanf("%d",&N);
  
  for(i=0 ; i<N ; i++){
    scanf("%d",&A[i]);
  }  

  scanf("%d",&M);
  
  for(i=0 ; i<M ; i++){
    scanf("%d",&B[i]);
  }  

  for(i=0 ; i<M ; i++){    

    if( binarySearch(N,B[i]) == 1)count++;

  }
    printf("%d\n",count);
    return 0;
  }

int binarySearch(int right,int key){

  int left=0,mid;

  while (left < right){
    mid = (left + right)/2;
      if(A[mid] == key){
        mid = 1;
	return mid;
      }else if(key < A[mid]){
	right = mid;
      }else{
	 left = mid + 1;
      }
  }
  mid=0;
  return mid;
}
	   



Measured memory_bytes: 2352
#include<iostream>
#include<string>

using namespace std;

int main(){
  int N,A,B; cin >> N >> A >> B; int sum1 = A + B;  int sum2 = B;
  string S; cin >> S;
  
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'a' && sum1 > 0){ cout << "Yes" << endl; sum1--;}
    else if( S[i] == 'b' && sum1 > 0 && sum2 >0){ cout << "Yes" << endl; 
                                                sum1--; sum2--;}
    else{ cout << "No" << endl; }
  }
  return 0;}

Measured memory_bytes: 896
import numpy as np

arr = np.array([list(map(int, input().split())) for _ in range(3)])


n = int(input())

for _ in range(n):
    b = int(input())
    arr[np.where(arr == b)] = 0

ans1 = (np.sum(arr, axis=0) == 0).sum() >= 1
ans2 = (np.sum(arr, axis=1) == 0).sum() >= 1
ans3 = (np.diag(arr) == 0).sum() == 3
ans4 = (np.diag(np.rot90(arr)) == 0).sum() == 3

print("Yes" if ans1 or ans2 or ans3 or ans4 else "No")

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, m;
int a[105];
void solve() {
    cin >> n >> m;
    int sum = 0;
    rep(i, n) { cin >> a[i]; sum += a[i]; }

    int ans = 0;
    rep(i, n) if (4 * m * a[i] >= sum) ++ans;
    if (ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 998244353;
ll pw(ll a, ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        x /= 2; (a *= a) %= mod;
    }
    return ret;
}
ll dp[3010][3010] = {};
int main(){
    int i,j,n,s; cin >> n >> s;
    ll inv = pw(2,mod - 2);
    dp[0][0] = 1;
    for(i=1;i<=n;i++){
        ll a; cin >> a;
        for(j=0;j<=s;j++){
            dp[i][j] = dp[i - 1][j];
        }
        for(j=0;j<=s - a;j++){
            (dp[i][j + a] += inv*dp[i - 1][j]%mod) %= mod;
        }
    }
    cout << pw(2,n)*dp[n][s]%mod << endl;
}

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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

int main(){
    int N;
    cin >> N;
    vector<int>X(N);
    int sum = 0;
    REP(i, N) cin >> X.at(i);
    int ans = INF;
    REP(i, 110){
        int tmp = 0;
        REP(j, N){
            tmp += pow(abs(i - X.at(j)) , 2);
        }
        chmin(ans, tmp);
    }
    print(ans);
}

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

int gcd(int x, int y) {
  int r;
  if (x < y) swap(x, y);

  while ( y > 0 ) {
    r = x % y;
    x = y;
    y = r;
  }

  return x;

}

int main() {
  int a, b;

  cin >> a >> b;

  cout << gcd(a, b) << endl;

  return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int i = 0;
		int j = 0;
		int max = 0;
		if (x == 1) {
			max = 1;
		} else {
			for (i = 2; i <= x; i++) {
				for (j = 2; Math.pow(i, j) <= x; j++) {
					int p = (int) Math.pow(i, j);
					if (max < p) {
						max = p;
					}
				}
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23252
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int N = sc.nextInt();
        int[] a = new int[N];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            ans += (a[i]-1);
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 27632
/**************************************************
  Solution to: ABC 174 B - Distance
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
long long n,D;
long long x,y;
long long cnt=0;
int main(){
	cin>>n>>D;
	for(long long i=0;i<n;i++){
		x=0,y=0;
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=D){
			cnt++;
//			cout<<"Pass"<<endl;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS

    constexpr int N = 100000;
    vector<int> prime(N+5);
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime[i] = true;
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }

    vector<int> p(N+5);
    for(int i = 1; i < p.size(); i += 2) {
        if (prime[i] && prime[(i+1)/2]) p[i] = p[i-2]+1;
        else p[i] = p[i-2];
    }

    int q; cin >> q;
    REP(i,q) {
        int l, r;
        cin >> l >> r;
        OUT(p[r] - p[l-2])
    }

    return 0;
}

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

typedef long long ll;
const ll MOD = 998244353;

int main(){
	static int n;
	static int d[100010];
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++)scanf("%d",&d[i]);
	
	if(d[1] != 0){
		cout << 0 << endl;
		return 0;
	}
	
	sort(d+1,d+1+n);
	static int cnt[100010] = {};
	static ll ret = 1;
	cnt[0] ++;
	for(int i = 2 ; i <= n ; i ++){
		ret *= cnt[d[i]-1];
		ret %= MOD;
		cnt[d[i]] ++;
	}
	cout << ret << endl;
}

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

int main() {
    string s; cin >> s;
    int N = s.length();
    vector<int> S(s.length()); for (int i = 0; i < s.length(); i++) S[i] = s[i] -'0';
    vector<int> m(s.length());
    m[N-1] = S[N-1];
    ll t = 1;
    for (int i = N-2; 0 <= i; i--) {
        t = (t * 10) % 2019;
        m[i] = (m[i+1] + S[i] * t) % 2019;
    }
    map<int, ll> ans;
    for (int i = 0; i < N; i++) {
        ans[m[i]]++;
    }
    ll a = 0;
    for (auto x : ans) {
        a += x.second * (x.second - 1) / 2;
    }
    cout << a + ans[0] << endl;
}


Measured memory_bytes: 5140
#include <iostream>
using namespace std;
int main()
{
	int n;
	long long a;
	long long MAX=0,MIN=1000000001;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		MAX=max(a,MAX);
		MIN=min(a,MIN);
	}
	cout<<MAX-MIN;
	return 0;
}
  

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

typedef double R;
typedef complex<R> P;
const R PI = acos(-1.0);

int main() {
	int N, L; cin >> N >> L;
	vi vec(N);
	rep(i, N) cin >> vec[i];

	P ans(0.0, 0.0);

	rep(i, N) {
		for (int j = i + 1; j < N; ++j) {
			int a = j - i - 1;
			int b = N - 2 - a;
			P p = P(-1, 0) * polar(1.0, PI / L * (vec[i] + vec[j]));
			ans += p * (R)(a - b);
		}
	}
	double k = 6.0 / N / (N-1) / (N-2);
	ans = ans * k;
	printf("%.10f %.10f\n", ans.real(), ans.imag());
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define pqi                priority_queue<ll>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  100005
ll n,w;
ll k[101][N];
pii a[N];
ll ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    cin>>n>>w;
    rep(i,0,n)
    cin>>a[i].F>>a[i].S;
    sort(a,a+n);
    rep(i,0,n+1)
    {
        rep(j,0,w+1)
        {
            k[i][j]=0;
        }
    }
    rep(i,0,n+1)
    {
    	rep(j,0,w+1)
    	{
    		if(i==0 || j==0)
    			k[i][j]=0;
    		else if(a[i-1].F<=j)
    			{
                    k[i][j]=max(k[i-1][j-a[i-1].F]+a[i-1].S,k[i-1][j]);
                }
    		else
    			k[i][j]=k[i-1][j];
    	}
    }/*
    rep(i,0,n+1)
    {
        rep(j,0,w+1)
        {
            cout<<k[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<k[n][w];
}
    return 0;
}

Measured memory_bytes: 79232
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, x;
    cin >> N >> x;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    // 合計の食べた量
    ll eat_num = 0;
    
    if(A[0]>x){
        eat_num = A[0] - x;
        A[0]-=eat_num;
    }
    ll stomach = A[0];
 
    FOR(i, 1, N){
        if(stomach + A[i] > x){
            ll diff = stomach + A[i] - x;
            eat_num += diff;
            A[i] -= diff;
        }
        stomach = A[i];
    }

    p(eat_num);
    
    return 0;
}

Measured memory_bytes: 1024
function Main(input) {
  const D = parseInt(input.split(" ")[0])
  const T = parseInt(input.split(" ")[1])
  const S = parseInt(input.split(" ")[2].trim())
  
  D / S <= T ? console.log("Yes") : console.log("No")
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29696
<?php

fscanf(STDIN, '%d', $length);
$min = 0;
$result =0;
for ($i = 0; $i < $length; ++$i) {
    fscanf(STDIN, '%d', $R);
    if ($i === 0) {
        $min = $R;
        continue;
    }
    if ($i > 2) {
        $result = max($result, $R-$min);
    }
    else {
        $result = $R - $min;
    }
    $min = min($min, $R);
}
echo $result, PHP_EOL;


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

int main() {
  int h, w; cin >> h >> w;
  vector<string> b(h); rep(i, h) cin >> b[i];
  vector<bool> hf(h), wf(w);
  rep(i, h) rep(j, w) if (b[i][j] == '#') {
        hf[i] = true;
        wf[j] = true;
      }
  rep(i, h) {
    rep(j, w) if (hf[i] && wf[j]) {
        cout << b[i][j];
      }
    cout << endl;
  }
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 11;
ll p[T], c[T];

int main() {
    ios_base::sync_with_stdio(false);
    ll d,g; cin >> d >> g;
    g /= 100;

    for(int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    int gol = (1<<d);
    ll ans = INF;

    for(ll mask = 0; mask < gol; mask++) {
        ll points = 0;
        ll solve = 0;
        for(ll j = 0; j < d; j++) {
            if(mask&(1<<j)) {
                solve += p[j];
                points += (j+1)*p[j]+c[j];
            }
        }
        for(ll j = d-1; j >= 0 and points < g; j--) {
            if(mask&(1<<j)) continue;
            ll ok = 0;
            while(ok < p[j] and points < g) {
                points += (j+1);
                solve++;
                ok++;
            }
            if(ok == p[j]) points += c[j];
        }
        if(points >= g) ans = min(ans,solve);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static Scanner scanner;
 
    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int n = nextInt();
        for (int i = 1; i < 11; i++) {
            if (n <= i * 1000) {
                System.out.println(i * 1000 - n);
                return;
            }
        }
    }
 
    public static void println(Object o) {
        System.out.println(o);
    }
 
    public static void print(Object o) {
        System.out.print(o);
    }
 
    public static void printf(String format, Object... o) {
        System.out.printf(format, o);
    }
 
    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }
 
    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }
 
    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }
 
    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }
 
    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }
 
    public static void printYes() {
        System.out.println("Yes");
    }
 
    public static void printYES() {
        System.out.println("YES");
    }
 
    public static void printNo() {
        System.out.println("No");
    }
 
    public static void printNO() {
        System.out.println("NO");
    }
 
    public static String nextLine() {
        return scanner.nextLine();
    }
 
    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }
 
    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];
 
    public static void combinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
 
    public static long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
 
    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

Measured memory_bytes: 29352
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int x, y;
    cin >> x>> y;
    int ret = 0;
    if (x == 1 && y == 1) {
        ret += 400000;
    }
    if (x == 1)
        ret += 300000;
    else if (x == 2)
        ret += 200000;
    else if (x == 3)
        ret += 100000;
    if (y == 1)
        ret += 300000;
    else if (y == 2)
        ret += 200000;
    else if (y == 3)
        ret += 100000;
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using llng = long long;
template<typename T> using v = vector<T>;
template<typename T> using vv = v<v<T> >;

int main() {
    int H, W; cin >> H >> W;
    int N; cin >> N;
    v<int> a(N+1); for (int i=1; i<=N; i++) cin >> a[i];
    vv<int> c(H, v<int>(W));

    int ai = 1;
    for (int i=0; i<H; i++) {
        if (i % 2 == 0) {
            for (int j=0; j<W; j++) {
                c[i][j] = ai;
                a[ai]--; if (a[ai] == 0) ai++;
            }
        } else {
            for (int j=W-1; j>=0; j--) {
                c[i][j] = ai;
                a[ai]--; if (a[ai] == 0) ai++;
            }
        }
    }

    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define rep for(int i = 0; i<n; i++)

using namespace std;

int main()
{	
	int c, b ,d,a;
	cin >> c >> b >> d;
	
	if (c == b && c != d) a = d;
	else if (b == d && b != c) a = c;
	else if (d == c && d != b) a = b;

	cout << a << endl;

    return 0;
}

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

using namespace std;

const int WHITE=0, GRAY=1, BLACK=2;

struct DFS {
    int n;
    vector<vector<int>> g;
    vector<int> group;
    vector<int> state;
    int groupId = 0;
    
    DFS(int n):n(n) {
        g.assign(n, vector<int>());
        group.assign(n, -1);
        state.assign(n, WHITE);
    }
    
    void addEdge(int u, int v) {
        g[u].push_back(v);
    }
    
    void solve() {
        for (int i = 0; i < n; i++) {
            if (state[i] == WHITE) {
                groupId++;
                dfs(i);
            }
        }
    }
    
    void dfs(int u) {
        state[u] = GRAY;
        group[u] = groupId;
        for (int v : g[u]) {
            if (state[v] == WHITE) {
                dfs(v);
            } 
        }
        state[u] = BLACK;
    }
    
    void print() {
        for (int i = 0; i < n; i++) {
            cout << i << ":";
            for (int v : g[i]) {
                cout << v << " ";
            }
            cout << endl;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    int n, e;
    cin >> n >> e;
    
    DFS dfs(n);
    
    for (int i = 0; i < e; i++) {
       int u, v;
       cin >> u >> v;
       dfs.addEdge(u, v);
       dfs.addEdge(v, u);
    }
   
    dfs.solve();
    
    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        if (dfs.group[u] == dfs.group[v]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 11772
import math

def is_prime(num):
	prime = True
	for i in range(2,int(math.sqrt(num))+1):
		if num%i == 0:
			prime = False
			break
	return prime

num_set = set()
try:
	while True:
		num_set.add(eval(input()))
except EOFError:
	count = 0
	for x in num_set:
		count = count + (1 if is_prime(x) else 0)
	print(count)

Measured memory_bytes: 8300
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        if(n == 0){
            System.out.println(x);
            return;
        }else{
            boolean[] forbit = new boolean[202];
            for(int i = 0; i < n; i++){
                forbit[sc.nextInt()+100] = true;
            }
            if(!forbit[x+100]){
                System.out.println(x);
                return;
            }else{
                int left = x-1;
                int right = x+1;
                while(left >= 0 && right < 202){
                    if(!forbit[left+100]){
                        System.out.println(left);
                        return;
                    }else if(!forbit[right+100]){
                        System.out.println(right);
                        return;
                    }
                    left--;
                    right++;
                }
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25400
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 311;
LL d[SIZE][SIZE],e[SIZE][SIZE];
int main(){
    int N,M,L;
    R(N,M,L);
    FOR(i,1,N)FOR(j,1,N)d[i][j]=1e18;
    FOR(i,1,N)d[i][i]=0;
    REP(i,M){
        int x,y,v;R(x,y,v);
        d[x][y]=d[y][x]=v;
    }
    FOR(k,1,N)FOR(i,1,N)FOR(j,1,N){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    FOR(i,1,N)FOR(j,1,N){
        if(d[i][j]<=L)e[i][j]=1;
        else e[i][j]=500;
    }
    FOR(k,1,N)FOR(i,1,N)FOR(j,1,N){
        e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
    }
    int Q;
    R(Q);
    while(Q--){
        int s,t;
        R(s,t);
        if(e[s][t]>=500)W(-1);
        else W(e[s][t]-1);
    }
    return 0;
}


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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];

        int[] snk = new int[n];

        for (int i = 0; i < k; i++)
        {
            var d = int.Parse(Console.ReadLine());
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int t = 0; t < tmp.Length; t++)
            {
                snk[tmp[t] - 1]++;
            }
        }

        var ans = snk.Where(x => x == 0).Count();

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28784
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n ;
 cin >> n ;
 vector<int> A(n) ;
 rep(i,n) cin >>A[i] ;
 vector<int> B(n) ;
 rep(i,n) B[A[i]-1] =i;
 ll ans=0 ;
 ll len=1 ;
 rep(i,n-1){
   if(B[i]<B[i+1]) {
    len ++ ;
  }
  else len=1 ;
   ans= max(ans,len) ;
 }
  if(n==1)
  cout <<0 <<endl ;
   else
   cout << n-ans <<endl ;
     return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int w,h;
int d[60][30][2];
char s[60][30];
struct point{
    int y,x,f;
    point(int y,int x,int f):y(y),x(x),f(f){};
    bool operator<(const point& a)const{
        return true;
    }
};

using P=pair<int,point>;

bool is_valid(int y,int x){
    return 0<=y&&y<h&&0<=x&&x<w;
}

void run(){
    cin>>w>>h;
    if(!w)return;
    rep(i,h)rep(j,w)rep(k,2)d[i][j][k]=inf;
    priority_queue<P,vector<P>,greater<P>> q;
    rep(i,h)rep(j,w){
        cin>>s[i][j];
        if(s[i][j]=='S'){
            q.push(mp(0,point(i,j,0)));
            q.push(mp(0,point(i,j,1)));
            d[i][j][0]=d[i][j][1]=0;
        }
    }
    int ans=inf;
    while(!q.empty()){
        P p=q.top();
        q.pop();
        point v=p.se;
        if(d[v.y][v.x][v.f]<p.fi)continue;
        int dy[]={-2,-1,-1,0,0,0,1,1,2},dx[]={1,1,2,1,2,3,1,2,1};
        rep(i,9){
            int y=v.y+dy[i],x=v.x+(v.f?-dx[i]:dx[i]),f=!v.f;
            if(!is_valid(y,x))continue;
            if(s[y][x]=='T')ans=min(ans,p.fi);
            else{
                int c;
                if(s[y][x]=='S')c=0;
                else if(s[y][x]=='X')c=inf;
                else c=s[y][x]-'0';
                if(d[y][x][f]>d[v.y][v.x][v.f]+c){
                    d[y][x][f]=d[v.y][v.x][v.f]+c;
                    q.push(mp(d[y][x][f],point(y,x,f)));
                }
            }
        }
    }
    cout<<(ans!=inf?ans:-1)<<endl;
    run();
}


Measured memory_bytes: 3396
import sys

input = sys.stdin.readline

d = '.'
dn = '#'

def isPaintable(h, w, x, y, canvas):
    if x > 0:
        if canvas[y][x-1] == dn:
            return True
    if x < w-1:
        if canvas[y][x+1] == dn:
            return True
    if y > 0:
        if canvas[y-1][x] == dn:
            return True
    if y < h-1:
        if canvas[y+1][x] == dn:
            return True
    return False

def main():
    ans = 'Yes'
    h, w = map(int, input().split())
    canvas = []
    for _ in range(h):
        s = list(input().rstrip('\n'))
        canvas.append(s)
    for y in range(h):
        if ans == 'No':
            break
        for x in range(w):
            if canvas[y][x] == dn and not isPaintable(h, w, x, y, canvas):
                ans = 'No'
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
import numpy
N, K = map(int, input().split())
P = [int(i) for i in input().split()]
P = [0]+list(map(lambda x: (x+1)/2, P))

S = numpy.cumsum(P)

ans = 0
for i in range(K, N+1):
    ans = max(ans, S[i]-S[i-K])
print(ans)


Measured memory_bytes: 33612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, k, s, u;
  in(n);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  vector<vector<ll>> d(n, vector<ll> (0));
  rep(i, n){
    bitset<20> t(c[i]);
    rep(j, 20){
      if(t.test(j))
        d[i].pb(j);
    }
  }
  vector<bool> h(20, false), g(20);
  s = 0;
  u = 0;
  k = 0;
  rep(i, n){
    k = 0;
    while(u < n){
      rep(l, 20)
        g[l] = h[l];
      rep(j, d[u].size()){
        if(!g[d[u][j]])
          g[d[u][j]] = true;
        else
          k = 1;
      }
      if(k)
        break;
      u++;
      rep(l, 20)
        h[l] = g[l];
    }
    s += u - i;
    rep(l, 20)
      g[l] = h[l];
    rep(j, d[i].size())
      g[d[i][j]] = false;
    rep(j, 20)
      h[j] = g[j];
  }
  out(s);
  memi;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll x; cin>>x;
	ll ans=360/gcd(360,x);
	cout<<ans<<endl;

	return 0;
}


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

int binarySearch(int *,int,int);

int main(){
  int i,count=0;
  int n,q,T;
  int *S;

  scanf("%d",&n);
  if(0>n || n>100000)return 0;

  S = (int *)malloc(sizeof(int) * n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(0>S[i] || S[i]>1000000000)return 0;
  }

  scanf("%d",&q);
  if(0>q||q>50000)return 0;



  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(0>T || T>1000000000)return 0;
    if(binarySearch(S,n,T)==1)count++;
  }

printf("%d\n",count);

return 0;
}

int binarySearch(int S[],int n,int T){
  int left = 0,mid;
  int right = n;
  while(left<right){
    mid = (left  + right)/2;

    if(S[mid] == T)return 1;

    else if(T<S[mid])right =  mid;

    else left = mid + 1;
  }
  return 0;
}



Measured memory_bytes: 2240
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int h, w;
	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <utility>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  int i,j;
  int sum;
  int inp;
  std::vector<int> l;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> inp;
    l.push_back(inp);
  }
  sort(l.begin(), l.end());
  sum = 0;
  for (i = 0; i < n-2; i++) {
    for (j = i+1; j < n-1; j++) {
      auto itr = lower_bound(l.begin(), l.end(), l[i] + l[j]);
      int ng = distance(itr, l.end());
      sum += n - j - 1 - ng;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    long long a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;

    if ((v-w)*t>=abs(a-b)){
        cout<<"YES"<<endl;
    }

    else {
        cout<<"NO"<<endl;
    }




}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N;
    int K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> nums;
    int counter = 0;
    int now = 1;
    for(int i = 0; i < N; i++){
        if(S[i] == (char)(now + '0')) counter++;
        else{
            nums.push_back(counter);
            now = 1 - now;
            counter = 1;
        }
    } 
    if(counter != 0) nums.push_back(counter);
    if(nums.size()%2 == 0) nums.push_back(0);//最後が0カウンタならば架空の1の個数0を付け足す。1-0-1-0-1とかにしたい

    vector<int> sums(nums.size()+1);
    for (int i = 0; i < nums.size(); i++)
    {
        sums[i + 1] = sums[i]+nums[i];
    }


    int ans = 0;
    int left = 0;
    int right = 0;
    int Add = 2*K+1;
    int temp;
    for (int i = 0; i < sums.size(); i+=2)
    {
        left = i;
        right = min(i + Add, (int)nums.size());
        temp = sums[right] - sums[left];
        ans = max(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1272