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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const double eps = 1e-6;

inline int dcmp(double x){if(-eps<x && x<eps)return 0;return x>0?1:-1;}

struct points
{
	double x,y;
	points(double _x=0,double _y=0){x=_x,y=_y;}

	inline friend points operator + (points a,points b){return points(a.x+b.x,a.y+b.y);}
	inline friend points operator - (points a,points b){return points(a.x-b.x,a.y-b.y);}
	inline friend points operator * (points a,double b){return points(a.x*b,a.y*b);}
	inline friend points operator / (points a,double b){return points(a.x/b,a.y/b);}

	inline friend int operator == (points a,points b){return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;}

	void takein(){x=ty(),y=ty();}
	void print(char ends='\n'){printf("%.12lf %.12lf",x,y),putchar(ends);}
};

inline double dox(points a,points b){return a.x*b.x+a.y*b.y;}
inline double cox(points a,points b){return a.x*b.y-a.y*b.x;}
inline double length(points a){return sqrt(dox(a,a));}
inline double distan(points a,points b){return length(a-b);}

inline points pervec(points a){if(dcmp(length(a))<=0)return points(0,0);return a/length(a);}

inline int isponl(points p,points a,points b)
{
	return dcmp(cox(p-a,p-b))==0 && distan(a,p)<=distan(a,b) && distan(b,p)<=distan(a,b);
}

inline int iscrashed(points al,points ar,points bl,points br)
{
	double amix=min(al.x,ar.x),amxx=max(al.x,ar.x),amiy=min(al.y,ar.y),amxy=max(al.y,ar.y);
	double bmix=min(bl.x,br.x),bmxx=max(bl.x,br.x),bmiy=min(bl.y,br.y),bmxy=max(bl.y,br.y);
	
	if(amxx<bmix || bmxx<amix || amxy<bmiy || bmxy<amiy)return 0;
	if(isponl(al,bl,br) || isponl(ar,bl,br) || isponl(bl,al,ar) || isponl(br,al,ar))return 1;

	if(dcmp(cox(al-bl,br-bl))!=dcmp(cox(ar-bl,br-bl))
		&& dcmp(cox(bl-al,ar-al))!=dcmp(cox(br-al,ar-al)))return 1;
	return 0;
}

inline points crash(points al,points ar,points bl,points br)
{
	points a=ar-al,b=br-bl;
	double bas=cox(al-bl,b)/cox(b,a);
	return al+a*bas;
}

inline points ortho(points p,points a,points b)
{
	points c=a+pervec(b-a);
	double dis=dox(p-a,c-a);
	points tar=a+(c-a)*dis;
	return tar;
}

inline double distanpl(points p,points a,points b)
{
	if(isponl(p,a,b))return 0;
	points ort=ortho(p,a,b);
	if(isponl(ort,a,b))return distan(p,ort);
	return min(distan(p,a),distan(p,b));
}

void finder()
{
	points al,ar,bl,br;
	al.takein(),ar.takein(),bl.takein(),br.takein();
	
	if(iscrashed(al,ar,bl,br)){printf("%.10lf\n",0.0);return;}
	printf("%.10lf\n",min(min(distanpl(al,bl,br),distanpl(ar,bl,br)),
								 min(distanpl(bl,al,ar),distanpl(br,al,ar))));
}

int main()
{
	int q=ty();
	while(q--)finder();
	
	return 0;
}



Measured memory_bytes: 3248
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

ll table[2010][2010];

int main() {
    int N; cin >> N;
    ll x; cin >> x;
    vector<ll>A(N);
    rep(i,N){
        cin >> A[i];
    }

    for(int j=0; j<N; j++){
        table[0][j]=A[j];
    }
    for(int i=1; i<N; i++){
        for(int j=0; j<N; j++){
            table[i][j]=min(table[i-1][j], A[(i+j)%N]);
        }
    }

    ll ans=INF;

    for(int i=0; i<N; i++){
        ll temp=0LL;
        for(int j=0; j<N; j++){
            temp+=table[i][j];
        }
        temp+=x*i;
        ans=min(ans, temp);
    }

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


Measured memory_bytes: 31616
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori


def main():
    n=int(input())
    print(n+n**2+n**3)


if __name__ == "__main__":

    main()

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

int main()
{
    int A,B;
    string S;
    cin >> A >> B >> S;
    bool check = false;
    for(int i=0; i<S.size(); i++){
        if(S[A] != '-'){
            check = true;
        }else if(i!=A && !(S[i]>='0' && S[i]<='9')){
            check = true;
        }
    }
    if(check){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define debug(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int dp[maxn];
int n;
int arr[maxn];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // File();
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2; i<n; i++)
        dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2]));

    cout<<dp[n-1]<<endl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

typedef pair<int, int> Point;

double dist(const Point &p1, const Point &p2) {
    return sqrt(pow(p1.first - p2.first, 2.0) + pow(p1.second - p2.second, 2.0));
}

double bitonic_tsp_distance(const vector<Point> &p) {
    const int N = p.size();
    vector<vector<double> > L(N, vector<double>(N, 0.0));

    for (int j = 1; j < N; j++) {
        for (int i = 0; i < j; i++) {
            if (i == 0 && j == 1) {
                L[i][j] = dist(p[i], p[j]);
            } else if (i < j - 1) {
                L[i][j] = L[i][j - 1] + dist(p[j - 1], p[j]);
            } else {
                L[i][j] = numeric_limits<double>::infinity();
                for (int k = 0; k < i; k++)
                    L[i][j] = min(L[i][j], L[k][i] + dist(p[k], p[j]));
            }
        }
    }

    double ans = numeric_limits<double>::infinity();

    for (int k = 0; k < N - 1; k++)
        ans = min(ans, L[k][N - 1] + dist(p[k], p[N - 1]));

    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > points;

    rep(i, n) {
        int x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }
    double ans = bitonic_tsp_distance(points);

    printf("%.20f\n", ans);

}





Measured memory_bytes: 10792
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;

const int maxn = 3e3 + 100;

int n;
double ans;
double a[maxn];
double dp[maxn][maxn];

int main() {
    cout << fixed << setprecision(10);
    scanf("%d",&n);
    for (int i = 1; i <= n; i++)
        scanf("%lf",&a[i]);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= i; j++){
            if (j > 0)
                dp[i][j] += dp[i-1][j-1] * a[i];
            dp[i][j] += dp[i-1][j] * (1-a[i]);
        }
    for (int i = 0; i <= n ; i++)
        if (n-i < i)
            ans += dp[n][i];
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 72320
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } //最大公約数


int main() {

	//入力
	long long int N, M;
	cin >> N >> M;

	vector<pair<long long int, long long int>>shop;
	for (int i = 0; i < N; ++i) {
		pair<long long int, long long int>tmp;
		long long int a, b;
		cin >> a >> b;
		tmp.first = a; //価格
		tmp.second = b; //提供可能本数
		shop.push_back(tmp);
	}

	//貪欲に求めてみる
	long long int sum_cost = 0; //最安値
	long long int num_cunt = 0; //本数カウンタ

	//shopを価格順でソート
	sort(shop.begin(), shop.end());

	for (int i = 0; i < N; ++i) {
		long long int own_num = 0; //ある価格帯での合計本数
		while (1) {
			if (num_cunt == M) {
				cout << sum_cost << endl;
				exit(0); //合計本数が必要本数と合致
			}
			if(own_num != shop[i].second){
				sum_cost = sum_cost + shop[i].first; //価格を増やす
				num_cunt++; //合計本数を増やす
				own_num++; //その価格帯での本数を増やす
			}
			if (own_num == shop[i].second) {
				break; //ある価格帯の本数上限に到達したとき別の店にする
			}
		}
	}

	if (num_cunt == M) {
		cout << sum_cost << endl;
		exit(0); //合計本数が必要本数と合致
	}
}

Measured memory_bytes: 2420
N = int(input())
import math
INF = 10**9


def dfs(s):
    if int(s) > N:
        return 0
    elif s.count('3') == 0 or s.count('5') == 0 or s.count('7') == 0:
        return 0 + dfs(s + "3") + dfs(s + "5") + dfs(s + "7")
    else:
        # print(s)
        return 1 + dfs(s + "3") + dfs(s + "5") + dfs(s + "7")


print(dfs("0"))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1);
}


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

int BinarySearch(int *,int ,int);

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

  scanf("%d",&n);
  //printf("%d\n",n);

  S = (int *)malloc(n * sizeof(int));
  
  for(i=0;i<n;i++) {
    scanf(" %d",&S[i]);
  }

  scanf("%d",&q);

  T = (int *)malloc((q+1) * sizeof(int));
  for(i=0;i<q;i++) {
    scanf(" %d",&T[i]);
  }

  for(i=0;i<q;i++) { 
    //printf("%d\n",T[i]); 
    number=BinarySearch(S,T[i],n);
    if(number==1) {
      //printf("check");
      count++;
    }
  }

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

int BinarySearch(int *A,int key,int n) {
  int left=0,right=n,mid;
  while(left < right) {
    mid = (left+right) / 2;
    //printf("S:%d\n",A[mid]);
    if(A[mid] == key) return 1;
    else if(key<A[mid]) right=mid;
    else left = mid+1;
  }
  return -1;
}




Measured memory_bytes: 2284
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var L=Arr.shift();
var arr=[[],[],[],[],[],[]];
for(var i=0;i<L;i++){
   if(185<=Arr[i])arr[5].push("*");
   else if(180<=Arr[i])arr[4].push("*");
   else if(175<=Arr[i])arr[3].push("*");
   else if(170<=Arr[i])arr[2].push("*");
   else if(165<=Arr[i])arr[1].push("*");
   else arr[0].push("*");
}

for(var i=0;i<arr.length;i++){
   console.log((i+1)+":"+arr[i].join(""));
}

Measured memory_bytes: 7644
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll n, m, k; cin >> n >> m >> k;
	vector<ll> a(n + 1), b(m + 1);
	rep(i, n)
	{
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	rep(i, m)
	{
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	int res = 0;
	rep(i, n + 1)
	{
		if (a[i] > k)break;
		int tmp = i;
		tmp += upper_bound(all(b), k - a[i]) - b.begin() - 1;
		chmax(res, tmp);
	}
	cout << res << endl;
}

Measured memory_bytes: 6412
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        char[] c = sc.next().toCharArray();
        int ans=0;
        int max=0;
        for(int i=0;i<=2;i++){
            //str.append(c[i]+" ");
            if(c[i]=='R')
                ans++;
            else 
                ans=0;
            
            if(max<ans)
                max=ans;
        }
        str.append(max);
        
        
        
        
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 32904
#include <iostream>
//#include <string>
//#include <cmath>
//#include <cstdlib>
#include <algorithm>
//#include <functional>
//#include <array>
#include <vector>
#include <climits>

using sll = signed long long;
using ull = signed long long;

int N = 0;
ull A[2*100002] = {0};

ull lsum[2*100001] = {0};
ull rsum[2*100001] = {0};

int main(void) {
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  lsum[0] = A[0];
  rsum[N-1] = A[N-1];
  for (int i = 1; i < N; i++) {
    lsum[i] += lsum[i-1] + A[i];
    int ri = N - 1 - i;
    rsum[ri] += rsum[ri+1] + A[ri];
  }

  //for (int i = 0; i < N; i++) {
    //std::cout << lsum[i] << "," << rsum[N-1-i] << std::endl;
    //std::cout << rsum[i] << std::endl;
  //}

  ull group[4] = {0};
  ull result_diff = LLONG_MAX;
  int blidx = 1;
  int bridx = 3;
  for (int i = 2; i < N-1; i++) {

    ull ldiff = std::abs(lsum[i - 1] - 2 * lsum[blidx - 1]);
    while(blidx < i - 1) {
      ull diff = std::abs(lsum[i - 1] - 2 * lsum[blidx]);
      if (ldiff > diff) {
        ldiff = diff;

        blidx++;
      } else {
        break;
      }
    }

    if (bridx < i + 1) bridx = i + 1;

    ull rdiff = std::abs(rsum[i] - 2 * rsum[bridx]);
    while(bridx < N - 1) {
      ull diff = std::abs(rsum[i] - 2 * rsum[bridx + 1]);
      if (rdiff > diff) {
        rdiff = diff;

        bridx++;
      } else {
        break;
      }
    }

    group[0] = lsum[blidx - 1];
    group[1] = lsum[i -1] - lsum[blidx - 1];
    group[2] = rsum[i] - rsum[bridx];
    group[3] = rsum[bridx];

    //std::cout << " " << group[0] << " " << group[1] << " " << group[2] << " " << group[3] << std::endl;
    std::sort(group, group + 4);
    ull diff = group[3] - group[0];
    if (result_diff > diff) {
      result_diff = diff;
    }
  }

  std::cout << result_diff << std::endl;

  return 0;
}

Measured memory_bytes: 4992
from collections import deque

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if len(ret) > 0 and ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))


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

#define rep(i,m,n) for(int i=m;i<n;i++)
#define pb push_back
#define ll long long 
#define out(n) cout<<#n<<' = '<<'\n'

using namespace std;

int main()
{
    
    cout<<fixed<<setprecision(15);
    int r;
    cin>>r;
    double a=2*r*(3.14);
    cout<<a;
    return 0;
}

Measured memory_bytes: 3772
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> grid(h);
    rep(i, h)
    {
        cin >> grid[i];
    }

    const int INF = 1'000'000;
    vector<vector<int>> dist(h * w, vector<int>(h * w, INF));
    rep(i, h * w)
    {
        dist[i][i] = 0;
    }

    rep(i, h - 1) rep(j, w)
    {
        if (grid[i][j] == '.' && grid[i + 1][j] == '.')
        {
            dist[i * w + j][(i + 1) * w + j] = dist[(i + 1) * w + j][i * w + j] = 1;
        }
    }

    rep(j, w - 1) rep(i, h)
    {
        if (grid[i][j] == '.' && grid[i][j + 1] == '.')
        {
            dist[i * w + j][i * w + j + 1] = dist[i * w + j + 1][i * w + j] = 1;
        }
    }

    rep(k, h * w) rep(i, h * w) rep(j, h * w)
    {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    int result = 0;
    rep(i, h * w) rep(j, h * w)
    {
        if (dist[i][j] < INF)
        {
            result = max(result, dist[i][j]);
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 896
import java.io.*;
import java.util.Arrays;

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

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

          final int mod = 1_000_000_007;

          String[] ln = in.readLine().split(" ");
          final int n = atoi(ln[0]);
          final int m = atoi(ln[1]);

          boolean[] isBroken = new boolean[n+2];
          for (int i = 0; i < m; i++) {
            int x = atoi(in.readLine());
            isBroken[x] = true;
          }

          long[] dp = new long[n+2];
          dp[0] = 1L;
          for (int i = 0; i < n; i++) {
            for (int j = i+1; j <= i+2; j++) {
              if(!isBroken[j]) {
                dp[j] += dp[i];
                dp[j] %= mod;
              }
            }
          }

          final long ans = dp[n];
          out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int  atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s);   }
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e6+55,mod = 1e9+7;
vpii v[N];
ll mark[N],low[N],tim[N],t;
bool b[N];
void dfs(ll s,ll p){
	b[s]=true;
	tim[s]=low[s]=t++;
	ll i,j,x,y;
	for(i=0;i<v[s].size();i++){
		x=v[s][i].ff;y=v[s][i].ss;
		if(x==p)continue;
		if(!b[x]){
			dfs(x,s);
			low[s]=min(low[s],low[x]);
			if(low[x]>tim[s]){
			mark[y]=1;
		}
		}
		else{
			low[s]=min(low[s],tim[x]);
		}
	}
}
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll n,m,q,i,j,x,y,z,c=0;
	sc(n);sc(m);
	for(i=1;i<=m;i++){
		sc(x);sc(y);
		v[x].pb(mp(y,i));
		v[y].pb(mp(x,i));
	}
	for(i=1;i<=n;i++){
		if(!b[i]){
			dfs(i,0);
		}
	}
	for(i=1;i<=m;i++)if(mark[i])c++;
	pr(c);

}

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

using namespace std;

int main(){
	int n; cin >> n;
  	int a[n];
  	for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    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] << endl;
}

Measured memory_bytes: 1024
#include <iostream>

int main() {

	int a, b;

	std::cin >> a >> b;

	if (a < b) {
		std::cout << "a < b"
			<< std::endl;
	}
	else if (a > b) {
		std::cout << "a > b"
			<< std::endl;
	}
	else{
		std::cout << "a == b"
			<< std::endl;
	}
		return 0;
}



Measured memory_bytes: 3096
m,*f=10**9+7,1
eval'H,W,A,B='+`tr ' ' ,`
200000.times{|i|f<<f[-1]*-~i%m}
p (B...W).sum{|i|f[H-A-1+i]*f[A+W-i-2]*(f[H-A-1]*f[i]*f[A-1]*f[W-1-i]).pow(m-2,m)}%m

Measured memory_bytes: 16208
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    s = m + f
    if m == -1 or f == -1:
        print("F")
    elif s >= 80:
        print("A")
    elif s >= 65:
        print("B")
    elif s >= 50 or r >= 50:
        print("C")
    elif s >= 30:
        print("D")
    else:
        print("F")

Measured memory_bytes: 7684
n=int(input())
m=[]
a=[]
r=[]
c=[]
h=[]
for _ in range(n):
    x=input()
    if x[0]=="M":
        m.append(x)
    elif x[0]=="A":
        a.append(x)
    elif x[0]=="R":
        r.append(x)
    elif x[0]=="C":
        c.append(x)
    elif x[0]=="H":
        h.append(x)
l=[len(m),len(a),len(r),len(c),len(h)]
ans=0
for x in range(3):
    for y in range(x+1,4):
        for z in range(y+1,5):
            ans+=l[x]*l[y]*l[z]
print(ans)


Measured memory_bytes: 10184
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
  int X,Y;
  //  char c;
  scanf("%d %d",&X,&Y);
  if(X*4 < Y){
    printf("No");
    return 0;
  }
  else if(X*2 > Y){
    printf("No");
    return 0;
  }
  else if(Y%2 == 1){
    printf("No");
    return 0;
  }
  else{
    printf("Yes");
    return 0;
  }
    
  
  return 0;


}


Measured memory_bytes: 1704
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		//amount of items
		int N = inputs.nextInt();
		//maximum allowed weight
		int W = inputs.nextInt();
		int[] weights = new int[N];
		int[] values = new int[N];
		for(int i=0;i<N;i++) {
			weights[i] = inputs.nextInt();
			values[i] = inputs.nextInt();
		}
		//stores if visited and totalweight
		long[][] dp = new long[100001][2];
		dp[0][0] = 1;
		for(int k = 0;k<N;k++) {
			for(int i = 100000;i>=values[k];i--) {
				if(dp[i-values[k]][0]==1&&dp[i-values[k]][1] +weights[k]<=W) {
					dp[i][0] = 1;
					if(dp[i][1]==0) {
						dp[i][1] = dp[i-values[k]][1] +weights[k];
					}
					else {
						if(dp[i][1]<dp[i-values[k]][1] +weights[k])
							continue;
						else
							dp[i][1] = dp[i-values[k]][1] +weights[k];
					}
				}
			}
		}
		long ans = 0;
		for(int i =100000;i>=0;i--) {
			if(dp[i][0]==1&&dp[i][1]<=W) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}

}



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

int main() {
  int N;
  cin >> N;
  int ans=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(i%2==0&&a%2==1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
int n,i,a[300001],b[300001],c[300001],j,max;
int main(void)
{
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<300000;i++) b[i]=0,c[i]=0;
	max=1;
	//printf("%d\n",n);
	for(i=0;i<n;i++){
		max--;
		b[i]=1;
		if(max<=a[i]/10) max=a[i]/10;
		if(max==0) break;
	}
	//printf("BB\n");
	if(b[n-1]==1){
		for(i=n-1;i>=0;i--){
			max--;
			c[i]=1;
			if(max<=a[i]/10) max=a[i]/10;
			if(max==0) break;
		}
	}
	//printf("cc\n");
	if(c[0]==1) printf("yes\n");
	else printf("no\n");
	return 0;
}


Measured memory_bytes: 6108
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！
		// APPROVED
		// DENIED

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int max = 1;
		String w = "";
		Map<String, Integer> map = new HashMap<>();
		List<String> strArr = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			w = sc.next();
			if (map.get(w) == null) {
				map.put(w, 1);
			} else {
				map.put(w, map.get(w) + 1);
				if (map.get(w) > max) {
					max = map.get(w);
				}
			}
		}
		for (Entry<String, Integer> entry : map.entrySet()) {
			if (entry.getValue() == max) {
				strArr.add(entry.getKey());
			}
		}
		Collections.sort(strArr);

		for (String str : strArr) {
			System.out.println(str);
		}

	}

}

Measured memory_bytes: 82244
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
	long long N,A,B;
	cin>>N>>A>>B;

	long long ma = B*(N-1)+A;
	long long mi = B+A*(N-1);

	if (ma<mi){
		ma=mi-1;
	}
	cout << ma-mi+1 << endl;

}


Measured memory_bytes: 256
import numpy as np

N = int(input())
a = [list(map(int,input().split())) for i in range(N)]

for j in range(101):
    for k in range(101):
        needH = -1
        for i in range(N):
            if a[i][2] > 0:
                temp = a[i][2] + np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH == -1:
                    needH = temp
                else:
                    if needH != temp:
                        needH = -2
                        break
        if needH == -2:
            continue
            
        for i in range(N):
            if a[i][2] == 0:
                dist = np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH > dist:
                    needH = -2
                    break
        if needH == -2:
            continue
            
        print("{} {} {}\n".format(j, k, needH))
         



Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n;
  cin>>n;
  vector<int>t(n+1);
  vector<int>x(n+1);
  vector<int>y(n+1);
  x[0]=0;t[0]=0;y[0]=0;
  rep(i,n){
    cin>>t[i+1]>>x[i+1]>>y[i+1];
  }
  bool planex=true;
  rep(i,n){
    int dt=t[i+1]-t[i];
    int f=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(f>dt) planex=false;
    if(f%2 != dt%2) planex=false;
  }
  if(planex==false) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// Node :
type Node struct {
	to []int
}

var dp [100100]int

func check(n int, node []Node) int {
	if dp[n] != -1 {
		return dp[n]
	}
	res := 0
	for _, v := range node[n].to {
		res = max(res, check(v, node)+1)
	}
	dp[n] = res
	return res
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()

	node := make([]Node, N)
	for i := 0; i < M; i++ {
		from, to := getInt()-1, getInt()-1
		node[from].to = append(node[from].to, to)
	}

	for i := 0; i < N; i++ {
		dp[i] = -1
	}

	res := 0
	for i := 0; i < N; i++ {
		res = max(res, check(i, node))
	}

	fmt.Println(res)
}


Measured memory_bytes: 18560
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int max(int a, int b) { return a > b ? a : b; }
int main(void){
    int i,k,n,tmp,ans=0,a[200000],d[200000];
    scanf("%d %d\n",&k,&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=0; i<n-1; i++){
        d[i]=a[i+1]-a[i];
    }
    d[n-1]=k-(a[n-1]-a[0]);
    for(i=0; i<n; i++){
        tmp=max(tmp,d[i]);
    }
    ans=k-tmp;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1792
A,B=map(int,input().split())

a=A//0.08
b=(A+1)//0.08
answer=-1

for i in range(int(a),int(b)+1):
    #print(i)
    #print(i*0.1)
    if int(i*0.1)==B and int(i*0.08)==A:
        answer=i
        break
print(answer)

Measured memory_bytes: 3064
s = input()
Q = int(input())
count = 0
right = []
left = []
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
    else:
        if (count%2 == 0 and int(q[1]) == 1) or (count%2 == 1 and int(q[1]) == 2):
            left.append(q[2])
        else:
            right.append(q[2])

left = "".join(left)
right = "".join(right)
if count%2 == 0:
    left = left[::-1]
    print(left+s+right)
else:
    s = s[::-1]
    right = right[::-1]
    print(right+s+left)

Measured memory_bytes: 70488
def f_last(d, i, lt):
  idx = []
  if i in lt[0:d]:
    idx = [j+1 for j, x in enumerate(lt[0:d]) if x == i]
  else:
    idx.append(0)
  return idx[-1]

d = int(input())
lc = list(map(int, input().split()))
ls = []
lt = []
for _ in range(d):
  ls.append(list(map(int, input().split())))

for _ in range(d):
  lt.append(int(input()))

v = 0
for dd in range(1, d+1):
  v_d = 0
  for i in range(len(lc)):
    v_d += lc[i]*(dd-f_last(dd, i+1, lt))
  v = v + ls[dd-1][lt[dd-1]-1] - v_d
  print(v)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W, K;
std::string s[310];
int a[310][310];
bool used[310][310];

void dfs(int y, int x, int c){
    used[y][x] = true;
    a[y][x] = c;

    if(x - 1 >= 0 && !used[y][x-1]){
        dfs(y, x - 1, c);
    }

    if(y - 1 >= 0 && !used[y-1][x]){
        dfs(y - 1, x, c);
    }
}

void dfs2(int y, int x, int c){
    used[y][x] = true;
    a[y][x] = c;

    if(x - 1 >= 0 && !used[y][x-1]){
        dfs2(y, x - 1, c);
    }

    if(x + 1 < W && !used[y][x+1]){
        dfs2(y, x + 1, c);
    }

    if(y - 1 >= 0 && !used[y-1][x]){
        dfs2(y - 1, x, c);
    }
}

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

  std::cin >> H >> W >> K;

  for(int i=0;i<H;++i){
      std::cin >> s[i];
  }

  int c = 1;

  for(int i=0;i<H;++i){
      auto lastSharpIndex = s[i].find_last_of('#');

      if(lastSharpIndex == std::string::npos){
          continue;
      }

      for(int j=0;j<W;++j){
          if(s[i][j] == '#'){
              if(j < lastSharpIndex){
                  dfs(i, j, c);
              }else{
                  dfs2(i, j, c);
              }

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

  for(int i=0;i<H;++i){
      for(int j=0;j<W;++j){
          std::cout << a[i][j] << " \n"[j + 1 == W];
      }
  }
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int LCS(char *, char *);

int main(){
  int n, *q;
  int i;
  char a[1001], b[1001];

  a[0] = NULL;
  b[0] = NULL;

  scanf("%d", &n);

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

  for(i = 0; i < n; i++){
    scanf("%s", a);
    scanf("%s", b);

    q[i] = LCS(a, b);
  }

  for(i = 0; i < n; i++){
    printf("%d\n", q[i]);
  }

  return 0;
}


int LCS(char *a, char *b){
  int i, j;
  int m, n;
  int flag = 0;
  int c[1001][1001];

  m = strlen(a);
  n = strlen(b);

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(a[i - 1] == b[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;

      else if(c[i - 1][j] >= c[i][j - 1]) c[i][j] = c[i - 1][j];

      else c[i][j] = c[i][j - 1];
    }
  }

  return c[m][n];
}



Measured memory_bytes: 5620
//階層型→木→フラクタル→再帰
//深さを管理しつつのfor文とかやると死にそう.投票数[深さ][地区の番号]とかね。
//括弧の整合性は見なくてよさそう

//なぜかバグっている
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<stdio.h>
using namespace std;
typedef pair<int,int> PI;//投票数,カーソル末尾
char s[10010];

class Solver{
public:
	
	PI solve( int st, int ed, int dep=0 ){
		int i;
		int num=0;
		vector<int> tohyo;
		PI ret = PI(0,0);
		int cnt = 0;
		
		for( i = st; i < ed; i++ ){
			if( '0' <= s[i] && s[i] <= '9' ){
				num *= 10;
				num += s[i]-'0';
			}
			if( s[i] == '[' ){
				cnt++;
				PI res =  solve( i+1, ed, dep+1 );
				tohyo.push_back( res.first );
				i = res.second;
			}
			if( s[i] == ']' ){
				cnt--;
				if( cnt < 0 ){
					break;
				}
			}
		}
		if( tohyo.size() == 0 ){
			//printf("st=%d   ed=%d   ret=%d\n",st,ed,num/2+1);
			return PI( num/2+1, i );
		}
		sort( tohyo.begin(), tohyo.end() );
		ret.second = i;
		
		//printf("st=%d ed=%d dep=%d size=%d\n",st,ed,dep,tohyo.size());
		for( i = 0; i < tohyo.size()/2 + 1; i++ ){
			ret.first += tohyo[i];
		}
		//printf("st=%d   ed=%d   ret=%d\n",st,ed,ret.first);
		return ret;
	}
};

Solver test[101];
int main(){
	int i;
	int n;

	cin >> n;
	for( i = 0; i < n; i++ ){
		cin >> s;
		PI res = test[i].solve(0,strlen(s) );
		cout << res.first << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
   ll x;
   mint(ll x = 0) { (this->x = (x + MOD)) %= MOD; }
   mint& operator+=(const mint a) {
      if ((this->x += a.x) >= MOD) x -= MOD;
      return *this;
   }
   mint& operator-=(const mint a) {
      if ((this->x += MOD - a.x) >= MOD) this->x -= MOD;
      return *this;
   }
   mint& operator*=(const mint a) {
      (this->x *= a.x) %= MOD;
      return *this;
   }
   mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
   }
   mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
   }
   mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
   }
   mint pow(ll 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 {
      mint res(*this);
      return res /= a;
   }
};

mint c[4005][4005];
void init() {
   c[0][0] = 1;
   rep(i, 0, 4001) {
      rep(j, 0, i + 1) {
         c[i + 1][j] += c[i][j];
         c[i + 1][j + 1] += c[i][j];
      }
   }
}
mint comb(int x, int y) {
   return c[x][y];
}
mint f2(int x, int y) {
   return comb(x + y - 1, y - 1);
}

mint f(int x, int y) {
   if (x == 0 && y == 0) return 1;
   if (y < 1) return 0;
   if (x < y) return 0;
   return f2(x - y, y);
}

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   init();
   int n, k;
   cin >> n >> k;
   rep(i, 1, k + 1) {
      mint blue = 0, red = 0;
      blue = f(k, i);
      red += f(n - k, i - 1);
      red += f(n - k, i);
      red += f(n - k, i);
      red += f(n - k, i + 1);
      mint ans = blue * red;
      printf("%lld\n", ans.x);
   }
   return 0;
}

Measured memory_bytes: 125568
package main

import "fmt"

func main() {
	var x, p int
	sum := 0
	max := 0
	for i := 0; i < 5; i++ {
		fmt.Scan(&x)
		sum += x
		if v := x % 10; v != 0 {
			p = 10 - v
			sum += p
			if p > max {
				max = p
			}
		}
	}
	fmt.Println(sum - max)
}


Measured memory_bytes: 512
import java.util.Scanner;

// https://atcoder.jp/contests/abc155/tasks/abc155_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		boolean flag = true;
		for(int i=0;i<N;i++) {
			int n = array[i];
			if(n%2==0) {
				if((n%3==0)||(n%5==0)) {

				}else {
					flag = false;
				}
			}
		}

		if(flag) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}



	}

}


Measured memory_bytes: 23764
while True:
    
    l = input().split()
    h = int(l[0])
    w = int(l[1])

    if h == 0 and w ==0:
        break
    
    flag = 0

    for i in range(h*(w+1)):
        if (i+1) % (w+1) == 0:
            print("")
            if w % 2 == 0:
                flag += 1
            if i == h*(w+1)-1:
                print("")


        else:
            if flag % 2 == 0:
             print("#", end="")
             flag += 1
            else:
             print(".", end="")
             flag += 1

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

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

int main()
{
	int n, k;
	cin >> n >> k;
	if (k == 1) cout << 0;
	else cout << n - k;
}


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

#define jaldi ios_base::sync_with_stdio(false)
#define fr(i,j,n) for(i=j;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppii pair<int,int> 
#define ppll pair<long long,long long>
#define ppcc pair<char,char>
#define ppss pair<string,string> 
#define vpll vector<pair<long long,long long>>
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

int main()
{
    jaldi;
    precision(20);
    
    ll n,k,ans=0,i;
    cin>>n>>k;

    vll dp(n+1);
    dp[0]=0;
    fr(i,1,n+1)
        dp[i]=(dp[i-1]+i)%mod;

    fr(i,k,n+1)
    {
        ll x;
        ll fk = dp[i-1];
        ll sk = (dp[n]-dp[n-i]+mod)%mod;
        
        
        x = (sk-fk+1+mod)%mod;
        // cout<<fk<<" "<<sk<<endl;
        ans=(ans+x)%mod;
        // cout<<ans<<" ";
    }

    cout<<(ans+1)%mod<<endl;
    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    long long h;
    cin>>n>>h;
    vector<long long> a(n), b(n), c(n);
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    sort(b.begin(),b.end(), greater<long long>());
    
    c[0]=b[0];
    
    long long ans=MOD;
    if(b[0]>=h){
        cout<<1;
        return 0;
    }
    for(int i=1; i<n; i++){
        c[i]=c[i-1]+b[i];
        if(ans==MOD && c[i]>=h) ans=i+1;
    }
    //cout<<h-c[n-1]<<endl;
    
    for(int i=0; i<n; i++){
        if(a[i]>=b[0]){
            long long ansT=h/a[i]+(bool)(h%a[i]);
            ans=min(ans,ansT);
            continue;
        }
        int l=0, r=n-1;
        while(l<r){
            int mid=(l+r)/2;
            if(b[mid]>a[i]) l=mid+1;
            else r=mid;
        }
        if(b[l]<a[i]) l--;
        long long htemp=h;
        htemp-=c[l];
        if(htemp<=0) continue;
        long long ansT=l+1;
        ansT+=htemp/a[i]+(bool)(htemp%a[i]);
        ans=min(ans,ansT);
    }
    cout<<ans;
    
    
    
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int memo[3][301];

int main(){
	for(int n,m;cin>>n>>m;){
		for(int i=0;i<3;i++)for(int j=0;j<=m;j++)	memo[i][j]=(j?-1:0);

		int ans=0;
		while(n--){
			getchar();	while(getchar()!='\n');
			int cost,prm[3];
			cin>>cost>>prm[0]>>prm[1]>>prm[2];
//			scanf("%d%d%d%d ",&cost,prm,prm+1,prm+2);
			for(int i=0;i<3;i++)for(int j=0;j+cost<=m;j++){
				if(memo[i][j]==-1)	continue;
				memo[i][j+cost]=max(memo[i][j+cost],memo[i][j]+prm[i]);
				ans=max(ans,memo[i][j+cost]);
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 876
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string s;
    cin >> s;
    const ll n = s.size();
    if (s[n - 1] == '1' || s[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    for (ll i = 0; i < n - 1; i++) {
        if (s[i] != s[n - 2 - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    s[n - 1] = '1';
    vector<ll> parent(n, n - 1);
    for (ll i = n - 2; i >= 0; i--) {
        if (s[i + 1] == '1') {
            parent[i] = i + 1;
        } else {
            parent[i] = parent[i + 1];
        }
    }
    for (ll i = 0; i < n - 1; i++) {
        printf("%lld %lld\n", i + 1, parent[i] + 1);
    }
}

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

int main(){
    string s;
    string t = "CODEFESTIVAL2016";
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256