akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var S = Reader.String();
        int N = S.Length;
        bool win = (N - 2 - (S[0] == S[N - 1] ? 1 : 0)) % 2 == 1;
        Console.WriteLine(win ? "First" : "Second");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[110];
int main() {
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)    cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=0;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            for(ll k=j+1;k<=n;k++){
                if(a[i]!=a[j]&&a[j]!=a[k]){
                    if(a[i]+a[j]>a[k]){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


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

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

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

using namespace std;

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

    vector<vector<int>> input(N, vector<int>(3));
    vector<vector<int>> dp(N, vector<int>(3, 0));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> input[i][j];
            dp[i][j] = 0;
        }
    }

    // 1日目
    for (int j = 0; j < 3; j++)
    {
        dp[0][j] = input[0][j];
    }

    // 2日目以降
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j != k)
                {
                    chmax(dp[i][j], dp[i - 1][k] + input[i][j]);
                }
            }
        }
    }

    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 10000000
typedef pair<int, int>P;
int h, w;
int f[1005][1005] = { 0 };
int cnt[1005][1005] = { 0 };
int t[1005][1005] = { 0 };
int res = 0;
void bfs() {
	queue<P>que;
	queue<P>que2;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (f[i][j]) {
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (f[i + k][j + l] == 0) cnt[i][j]++;
					}
				}
				if (cnt[i][j] >= f[i][j]) {
					que.push(P(i, j));
					t[i][j] = 1;
					que2.push(P(i, j));
				}
			}
			else cnt[i][j] = -1;
		}
	}
	while (!que2.empty()) {
		P p = que2.front();
		que2.pop();
		f[p.first][p.second] = 0;
	}
	while (true) {
		P p = que.front();
		que.pop();
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				int nx = p.first + i;
				int ny = p.second + j;
				cnt[nx][ny]++;
				if (f[nx][ny]) {
					if (cnt[nx][ny] == f[nx][ny]) {
						que2.push(P(nx, ny));
						t[nx][ny] = t[p.first][p.second] + 1;
						res = max(res, t[nx][ny]);
					}
				}
			}
		}
		if (que.empty()) {
			if (que2.empty()) goto e;
			while (!que2.empty()) {
				P p = que2.front();
				que2.pop();
				f[p.first][p.second] = 0;
				que.push(P(p.first, p.second));
			}
		}

	}
e:;
	cout << res << endl;
	return;
}
int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '.') f[i][j] = 0;
			else f[i][j] = c - '0';
		}
	}
	bfs();
}



Measured memory_bytes: 14920
#include<stdio.h>

int main()

{
	int n;

	scanf("%d", &n);

	if (n < 3 * 5 * 7) {
		printf("0\n");

	}
	else if (n < 3 * 5 * 9) {
		printf("1\n");

	}
	else if (n < 3 * 5 * 11) {
		printf("2\n");
	}
	else if (n < 3 * 7 * 9) {

		printf("3\n");

	}
	else if (n < 3 * 5 * 13) {

		printf("4\n");

	}
	else {
		printf("5\n");

	}

	return 0;



}

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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    for (int i = 0;i < S.size();i++) {
        if(S[i] == 'A'||S[i] == 'C'||S[i] == 'G'||S[i] == 'T'){
           cnt++;
        }else{
            if(ans < cnt){
                ans = cnt;
            }
           cnt = 0;
        }

    }
    if(ans < cnt){
        ans = cnt;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

def check_str(s,t):
    com = 0
    if len(t) > len(s):
        return 0
    for a,b in zip(s,t):
        if a == b:
            com += 1
    return com

def main():
    s = input()
    t = input()

    common = 0
    for i in range(len(s)):
        common = max(common, check_str(s[i:],t))

    print(len(t)-common)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9072
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double n,k;
	cin >> n >> k;
	double ans = 0;
	reps(i,n){
		int pnt = i,cnt = 0;	
		double x = 1;
		while(pnt < k){
			pnt *= 2;
			++cnt;
		}
		reps(j,cnt){
			x /= 2;
		}
		ans += 1 / n * x;
		//cout << ans << '\n';
	}
	cout << Fixed <<  ans << '\n';
	return 0;	
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    execute();
  }

  private static void execute() throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    long a = Long.parseLong(line);

    System.out.println((calc(a)));
  }

  private static long calc(long a) {
    long stepCount = a;
    for (long i = 1; i <= a; i++){
      double remain = (double)a / i;
      if(remain - (long) remain == 0.0){
        stepCount = Math.min(stepCount, i + (long) remain);
      }
      if(i*i > a){
        break;
      }
    }
    if(stepCount == a){
      return --stepCount;
    }
    return stepCount - 2;
  }
}

Measured memory_bytes: 23252
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        for (int i=0; i<3; i++)
        {
            if (s[i] == s[i+1])
            {
                Console.WriteLine("Bad");
                return;
            }
        }
        Console.WriteLine("Good");
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main() {
int N, Y, flag = 1;
cin >> N >> Y;
for (int x = 0; x <= N; ++x) {
        if (10000 * x > Y or flag == 0) break;
        for (int y = 0; y <= N; ++y) {
                if (10000*x + 5000*y > Y) break;
                if (10000*x + 5000*y + 1000*(N - x - y) == Y) {
                        cout << x << " " << y << " " << N - x - y << endl;
                        flag = 0;
                        break;
                }   
        }   
}
if (flag) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int h,w; cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i,h) rep(j,w) cin >> s[i][j];

  vector<int> dx = {1, 0};
  vector<int> dy = {0, 1};
  vector<vector<int>> d(h, vector<int>(w, 1e+9));
  if(s[0][0] == '#') d[0][0] = 1;
  else d[0][0] = 0;

  rep(i,h) rep(j,w) {
    if(i+1 < h) {
      if(s[i][j] == '.' && s[i+1][j] == '#') chmin(d[i+1][j], d[i][j]+1);
      else chmin(d[i+1][j], d[i][j]);
    }
    if(j+1 < w) {
      if(s[i][j] == '.' && s[i][j+1] == '#') chmin(d[i][j+1], d[i][j]+1);
      else chmin(d[i][j+1], d[i][j]);
    }      
  }

  cout << d[h-1][w-1] << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  double a,m1=0,m2;
  int b=0;
  while(scanf("%lf",&a)!=EOF){
    if(b==0)m1=a,m2=a,b=1;
    else if(m1<a)m1=a;
    else if(m2>a)m2=a;
  }
  printf("%f\n",m1-m2);
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;
	vector<lli> a[2];
	REP(i,0,2)REP(j,0,n){
		lli b;
		cin>>b;
		a[i].push_back(b);
	}

	lli ans = -INF;
	REP(i,0,n){
		lli sum=0;
		REP(j,0,n){
			if(j<=i)sum+=a[0][j];
			if(j>=i)sum+=a[1][j];
		}
		ans = max(ans,sum);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#define _for(i, j, k) for(int (i)=(j); (i)<=(k);(i)++)

int read() {
	int x=0; char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) x=x*10+c-'0', c=getchar();
	return x;
}
int buf[70];
void prt(int n) {
	if (!n) { putchar('0'); return; }
	int index=0;
	while (n) buf[++index]=n%10, n/=10;
	while (index>=1) putchar(buf[index--]+'0');
	return;
}
int main() {
	int n=read(), k=read(), x, cnt=0;
	_for(i, 1, n) {
		x=read();
		cnt+=(int)(x>=k);
	}
	prt(cnt);
	return 0;
}

Measured memory_bytes: 128
quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N = in_1()
  sum(i for i in 1:N if !iszero(mod(i, 3)) && !iszero(mod(i, 5))) |> println
end

isempty(ARGS) && main()


Measured memory_bytes: 166964
#include<bits/stdc++.h>
using namespace std;
 
int main(){
   int MAX=0;
   int a;cin>>a;
   a=0;
   string b;cin>>b;
   for(char c:b){
       if(c=='I')a++;
       else a--;
       MAX=max(MAX,a);
       }
       cout<<MAX<<endl;
    }

Measured memory_bytes: 256
using System;
namespace b
{
  class program
  {
    static void Main()
    {
      var n= Console.ReadLine();
      int ln=n.Length;
      var n1= Convert.ToInt32(n);
      int n2=0;
      for (int i =0;i<ln;i++)
      {
        var an = Convert.ToString(n[i]);
        var a = int.Parse(an);
        n2+=a;
      }
      if (n1%n2==0)
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }
    }
  }
}

Measured memory_bytes: 27396
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

signed main() {
    int N;
    cin >> N;

    int A[N];
    int B[N];
    int C[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    sort(A, A + N);
    sort(C, C + N);

    int ret = 0;

    for (int i = 0; i < N; i++) {
        int b = B[i];
        int a = upper_bound(A, A + N, b - 1) - A;
        int c = (C + N) - lower_bound(C, C + N, b + 1);
        ret += a * c;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N;
vector<vector<P> > G;
Int M;
vector<Int> ans;

void dfs(Int pos, Int pre, Int pcol){
  Int col = 0;
  for(P p:G[pos]){
    while(col == pcol) col++;
    Int to, i; tie(to, i) = p;
    if(to == pre) continue;
    dfs(to, pos, col);
    ans[i] = col;
    col++;
  }
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin>>N;
  G.resize(N);
  for(Int i=0;i<N-1;i++){
    Int a, b;
    cin>>a>>b; a--, b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }

  for(Int i=0;i<N;i++) Max(M, (Int)G[i].size());

  ans.resize(N-1);
  dfs(0, -1, -1);

  cout<<M<<endl;
  for(Int i=0;i<N-1;i++) cout<<ans[i] + 1<<endl;

  return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const int MOD=1e9+7;
struct Point{
    long double x,y;
    int idx;
    Point(){}
    Point(long double x,long double y):x(x),y(y){}
    long double add(long double a,long double b){
        if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
        return a+b;
    }
    Point operator+(const Point& p){return Point(add(x,p.x),add(y,p.y));}
    Point operator-(const Point& p){return Point(add(x,-p.x),add(y,-p.y));}
    Point operator*(const long double& d){return Point(x*d,y*d);}
    bool operator<(const Point& p) const{return abs(x-p.x)>eps?(x<p.x-eps):(y<p.y-eps);}
    bool operator==(const Point& p) const{return abs(x-p.x)<eps&&abs(y-p.y)<eps;}
    long double dot(const Point& p){return add(x*p.x,y*p.y);}
    long double det(const Point& p){return add(x*p.y,-y*p.x);}
};
using P=Point;
struct ConvexHull{
    vector<P> pts,in;
    int n;
    ConvexHull(vector<P> in):in(in){
        pts.resize(2*in.size());
        build();
    } 
    void build(){
        sort(in.begin(),in.end());
        int k=0;
        for(int i=0;i<in.size();i++){
            while(k>1&&(pts[k-1]-pts[k-2]).det(in[i]-pts[k-1])<=0)--k;
            pts[k++]=in[i];
        }
        for(int i=in.size()-2,t=k;i>=0;i--){
            while(k>t&&(pts[k-1]-pts[k-2]).det(in[i]-pts[k-1])<=0)--k;
            pts[k++]=in[i];
        }
        pts.resize(k-1);
        n=k-1;
    }
};
int main(){
    int n;cin>>n;
    vector<P> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i].x>>p[i].y;
        p[i].idx=i;
    }
    ConvexHull ch(p);
    vector<double> ans(n);
    for(int i=0;i<ch.n;i++){
        P a;P b;
        a.x=ch.pts[(i+1)%ch.n].x-ch.pts[i].x;
        b.x=ch.pts[(i-1+ch.n)%ch.n].x-ch.pts[i].x;
        a.y=ch.pts[(i+1)%ch.n].y-ch.pts[i].y;
        b.y=ch.pts[(i-1+ch.n)%ch.n].y-ch.pts[i].y;
        double al=sqrt((a.x*a.x)+(a.y*a.y));
        double bl=sqrt((b.x*b.x)+(b.y*b.y));
        double th=(a.dot(b))/(al*bl);
        th=max(-1.0,min(1.0,th));
        th=acos(th);
        ans[ch.pts[i].idx]=(180.0-(th*180.0/M_PI))/360.0;
    }
    for(int i=0;i<n;i++){
        cout<<fixed<<setprecision(10)<<ans[i]<<endl;
    }
}


Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> pref(n + 1, 0), suf(n + 2, 0), sum(n + 1, 0);
  for (int i = 0; i < n; i++) {
    pref[i + 1] += pref[i];
    sum[i + 1] += sum[i];

    sum[i + 1] += a[i];
    if (a[i] > 0) {
      pref[i + 1] += a[i];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    suf[i + 1] += suf[i + 2];
    if (a[i] > 0) {
      suf[i + 1] += a[i];
    }
  }

  ll ans = 0;
  for (int i = 1; i + k - 1 <= n; i++) {
    ans = max(ans, pref[i - 1] + suf[i + k] + max(0LL, sum[i + k - 1] - sum[i - 1]));
  }

  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

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


int main()
{
  	
 	 int a, b, c,x;
	cin >> a >> b >> c;
  	x = a;
	if (b > x) { x = b; }
	if (c > x) { x = c; }
	cout << a + b + c - x;

	return 0;}



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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
	ll n, a, b; cin >> n >> a >> b;
	if (n == 1)
	{
		if (a == b)
		{
			cout << 1;
		}
		else
		{
			cout << 0;
		}
		return;
	}
	else if (a > b) 
	{
		cout << 0;
		return;
	}
	ll p = (n - 1) * a + b;
	ll t = (n - 1) * b + a;
	cout << abs(p - t) + 1;
}

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int n;

int main()
{
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int a = 0, u = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == "A")
            a++;
        else
            u++;
        if (a < u)
        {
            puts("NO");
            return 0;
        }
    }
    puts((a == u ? "YES" : "NO"));
}


Measured memory_bytes: 3164
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int A[1000000], n;

int main() {
    cin >> n;
    for(int i=0; i<n; i++) {
        scanf("%d", &A[i]);
    }
    
    int q, k, sum=0;
    cin >> q;
    for(int i=0; i<q; i++) {
        scanf("%d", &k);
        if(*lower_bound(A, A+n, k) == k) sum++;
    }
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3524
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

	ll sum=0;

	rep(i, n) {
		ll num;
		cin >> num;
		sum += num;
	}

	if (sum >= h) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

   if(a%b == 0)
    return b;
   else
    return gcd(b,a%b);
 }

 long long numbers[500005];

 int main(){

  string a,b,c;
  cin>>a>>b>>c;

  char n = a[0];
  a.erase(0,1);

  while(1){

     if(n == 'a'){
        if(a.size() == 0){
            cout<<"A"<<endl;
            return 0; }
          n = a[0];
          a.erase(0,1);
     }else if(n == 'b'){
        if(b.size() == 0){
            cout<<"B"<<endl;
            return 0;
        }
        n = b[0];
        b.erase(0,1);
     }
     else if(n == 'c'){
         if(c.size() == 0){
            cout<<"C"<<endl;
            return 0;
         }
         n = c[0];
         c.erase(0,1);
       }
  }


 return 0;
 }

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

// 文字列の最初の位置、最後の位置(0-index)の部分文字列が回文となっているか判定
bool kaibunCheck(string s, int l, int r){
  if(s.size() == 0) return true;
  int n = s.size();
  if(l < 0 || l > n-1 || l > r || r < 0 || r > n-1) return false;
  bool flag = true;
  for(int i = l; i <= r; i++){
    if(s[i] != s[r-i]) flag = false;
  }
  return flag;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  string SS;
  int N = S.size();
  REP(i, N){
    if(S[i] != 'x') SS += S[i]; 
  }
  if(kaibunCheck(SS, 0, SS.size()-1)){
    int left = 0, right = N-1, ans = 0;
    while(left <= right){
      if(S[left] == 'x' && S[right] != 'x'){
        left++; ans++;
      }
      if(S[right] == 'x' && S[left] != 'x'){
        right--; ans++;
      }
      if(S[left] == S[right]){
        left++; right--;
      } 
    }
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 592
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <chrono>

using namespace std;

int main() {
    //ifstream cin("input.in");
    string s, t;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A' || s[i] == 'C') {
            t.push_back(s[i]);
        } else if (i < n - 1 && s[i + 1] == 'C') {
            t.push_back('X');
            i++;
        } else {
            t.push_back('B');
        }
    }
    long long answer = 0;
    int length = 0;
    for (int i = t.size() - 1; i >= 0; i--) {
        if (t[i] == 'A') {
            answer += length;
        } else if (t[i] == 'X') {
            length += 1;
        } else {
            length = 0;
        }
    }
    cout << answer << "\n";
    return 0;
}







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

int main(){
	string s;
	int i=0;
	getline(cin,s);
	while (1){
		if (s[i] == NULL)break;
		if (isupper(s[i])){
			s[i] = tolower(s[i]);
			cout << s[i];
		}
		else if (islower(s[i])){
			s[i] = toupper(s[i]);
			cout << s[i];
		}
		else{
			cout << s[i];
		}
		i++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3216
N=int(input())
A=list(map(int , input().split()))
B=list(map(int , input().split()))
C=list(map(int , input().split()))
ans=0
for i in range(N):
    ans += B[A[i]-1]
    if i > 0 :
        if A[i] - A[i-1] == 1 :
            ans += C[A[i]-2]
print(ans) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

  

int main(){
  int n; cin >> n;
  ll ans=0;
  rep(i,n){
    int k; cin >> k; k--;
    ans += k;
  }

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


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



namespace Test1 {

    class ClassMain {
        public static void Main(String[] args) {
            int w,h;
            while (true) {
                String h_w_line = Console.ReadLine();
                //Console.WriteLine(h_w_line);
                h = int.Parse(h_w_line.Split(' ')[0]);
                w = int.Parse(h_w_line.Split(' ')[1]);
                if (h == 0 || w == 0) { break; }
                char[,] fruitMap = new char[h,w];
                initMap(fruitMap);

                int areaCount = 0;
                while (scanMap(fruitMap)) {
                    areaCount++;
                }

                Console.WriteLine(areaCount);

                
            }
        }

        private static void initMap(char[,] map) {
            for (int i = 0; i < map.GetLength(0); i++) {
                String line = Console.ReadLine();
                char[] char_array = line.ToCharArray();
                for (int j = 0; j < map.GetLength(1); j++) {
                    map[i, j] = char_array[j];
                }
            }
        }

        private static bool scanMap(char[,] map) {
            int w = map.GetLength(1);
            int h = map.GetLength(0);
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    char ch = map[i, j];
                    if (ch == '#' || ch == '*' || ch == '@') {
                        deleteArea(map, i, j);
                        return true;
                    }                
                }
            }
            return false;
        }

        private static void deleteArea(char[,] map, int y, int x) {
            char ch = map[y, x];
            map[y, x] = 'X';
            if (y != 0) { if (map[y - 1, x] == ch) { deleteArea(map, y - 1, x); } }
            if (y != map.GetLength(0)-1) { if (map[y + 1, x] == ch) { deleteArea(map, y+1 , x); } }
            if (x != 0) { if (map[y , x-1] == ch) { deleteArea(map, y, x-1); } }
            if (x != map.GetLength(1) - 1) { if (map[y, x+1] == ch) { deleteArea(map, y , x+1); } }

        }


    }
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
string s;
int n,k,q,aux;
vector<int> p;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>n>>k>>q;
	for(int a = 0; a < n; a++)p.push_back(0);
	for(int a = 0; a < q; a++){
        cin>>aux;
        p[aux - 1] += 1;
	}
	for(int a = 0; a < n; a++){
        if(p[a] + k <= q )cout<<"No\n";
        else cout<<"Yes\n";
	}
}


Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

typedef long long ll;
using namespace std;

const int W = 0;
const int B = 1;
/*
W:0
B:1
*/
int main() {
  string s;
  cin >> s;

  vector<int> vec;
  for (auto c : s) {
    if (c == 'W') {
      vec.push_back(W);
    } else {
      vec.push_back(B);
    }
  }

  int cnt = 0;
  int before = vec[0];
  for (int i = 1; i < vec.size(); i++) {
    if (before == vec[i]) {
      continue;
    } else {
      cnt++;
      before = vec[i];
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1020
def main():
    n = int(input())
    operation = [input().split() for _ in range(n)]
    dictionary = {}
    
    for command, char in operation:
        if command == "insert":
            dictionary[char] = True
        elif command == "find":
            try:
                if dictionary[char]:
                    print("yes")
            except KeyError:
                print("no")
    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 303796
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

struct edge { int to; double cost; };

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

	int n, m, p, a, b;
	while (cin >> n >> m >> p >> a >> b, n) {
		a--; b--;
		vector<double> t(n);
		rep(i, n) cin >> t[i];
		vector<vector<edge>> G(m);
		rep(i, p) {
			int x, y;
			double z;
			cin >> x >> y >> z;
			x--; y--;
			G[x].emplace_back((edge){y, z});
			G[y].emplace_back((edge){x, z});
		}

		const double inf = 1e15;
		vector<vector<double>> d(m, vector<double>(1 << n, inf));
		d[a][0] = 0;
		queue<P> que;
	    que.push(P(a, 0));

	    while (!que.empty()) {
			int v, f;
			tie(v, f) = que.front(); que.pop();
	        for (auto e: G[v]) {
				int nv = e.to;
				double cost = e.cost;
				rep(i, n) {
					if (((f >> i) & 1) == 0) {
						int nf = f | (1 << i);
						if (d[nv][nf] > d[v][f] + cost / t[i]) {
							d[nv][nf] = d[v][f] + cost / t[i];
							que.push(P(nv, nf));
						}
					}
				}
	        }
	    }

		double ans = *min_element(all(d[b]));
		if (ans == inf) {
			// printf("Impossible\n");
            cout << "Impossible" << endl;
		} else {
			// printf("%.3f\n", ans);
            cout << ans << endl;
		}
	}
}

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

void insertionSort(int*, int);
void printArray(int*, int);

int main(void) {
    int n, *a, i = 0;
    scanf("%d", &n);
    a = malloc(sizeof(int) * n);
    while (i < n) {
        scanf("%d", &a[i]);
        i++;
    }
    printArray(a, n);
    insertionSort(a, n);
    return 0;
}

void insertionSort(int *a, int n) {
    int i, j, v;
    for (i = 1; i < n; i++) {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printArray(a, n);
    }
}

void printArray(int *a, int n) {
    int i = 0;
    while (i < n - 1) {
        printf("%d ", a[i]);
        i++;
    }
    printf("%d\n", a[i]);
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  vector<int> a(m);
  vector<int> b(m);
  for(int i = 0; i < m; i++) cin >> a.at(i) >> b.at(i);
  
  vector<int> ansv(n,1);
  for(int i = 0; i < m; i++){
    if(h.at(a.at(i)-1) < h.at(b.at(i)-1)){
      ansv.at(a.at(i)-1) = 0;
    }
    if(h.at(a.at(i)-1) > h.at(b.at(i)-1)){
      ansv.at(b.at(i)-1) = 0;
    }
    if(h.at(a.at(i) - 1) == h.at(b.at(i) - 1)){
      ansv.at(b.at(i)-1) = 0;
      ansv.at(a.at(i)-1) = 0;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += ansv.at(i);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

void op(int **ans,int h,int w){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j)cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
}

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char s[333][333];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
    }
  }
  int ans[333][333]={};
  int cnt=0;
  for(int i=0;i<h;i++){
    /* 
     for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j)cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  cout<<endl;
    */
  int f=0;
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
	f=1;
	cnt++;
	for(int x=0;i-x>=0;x++){
	  if(ans[i-x][j]!=0)break;
	  for(int y=0;j-y>=0;y++){
	    if(ans[i-x][j-y]!=0)break;
	    ans[i-x][j-y]=cnt;
	  }
	}
      }
    }
    if(f){
    for(int x=0;i-x>=0;x++){
      if(ans[i-x][w-1]!=0)break;
      for(int y=0;w-1-y>=0;y++){
	if(ans[i-x][w-1-y]!=0)break;
	ans[i-x][w-1-y]=cnt;
      }
    }
    }
  }
  for(int i=0;i<w;i++){
    for(int j=1;j<h;j++){
      if(ans[j][i]==0)ans[j][i]=ans[j-1][i];
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j)cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 1280
require 'pp'

n, x = gets.chomp!.split(' ').map(&:to_i)
x_n = gets.chomp!.split(' ').map(&:to_i)

points = (x_n + [x]).sort
diffs = []
points.each_cons(2) do |p1, p2|
    diffs << p2 - p1
end

#pp diffs
ans = diffs.pop
while diffs.empty?.!
    ans = ans.gcd(diffs.pop)
end

puts ans


Measured memory_bytes: 11876
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
h=int(0)
w=int(0)
i=int(1)
while i<n:
    if A[i]==A[i-1] and h==0:
        h=A[i]
        i+=1
    elif A[i]==A[i-1] and w==0:
        w=A[i]
        i+=1
    i+=1
print(h*w)

Measured memory_bytes: 14252
N = int(input())


zoroStreak = 0
zoroMaxStreak = 0
for i in range(N):
  d = list(map(int, input().split()))
  if d[0] == d[1]:
    zoroStreak += 1
    zoroMaxStreak = max(zoroMaxStreak, zoroStreak)
  else:
    zoroStreak = 0

if 3 <= zoroMaxStreak:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 62276
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
bool ask(ll x)
{
    cout<<"? "<<x<<endl;
    string ret;
    cin>>ret;
    return ret=="Y";
}
void answer(ll x)
{
    cout<<"! "<<x<<endl;
}
int main()
{
    ll var=1e9;
    ll ans=0;
    for(int i=0;i<10;i++)
    {
        bool ok=0;
        for(int j=4;j<9;j++)
        {
            if(ask((ans*10+j)*var+(var-1)))
            {
                if(j==4)
                {
                    while(j>=(i==0?2:1)&&ask((ans*10+j-1)*var+(var-1)))
                        j--;
                }
                ok=1;
                ans=ans*10+j;
                break;
            }
        }
        if(!ok) ans=ans*10+9;
        var/=10;
    }
    ll tmp=ans;
    while(tmp%10==0)
    {
        tmp/=10;
    }
    if(tmp==1)
    {
        while(ans%10==0&&ask(ans-1))
            ans/=10;
    }
    else{
        while(ans%10==0&&!ask(ans-1))
            ans/=10;
    }
    answer(ans);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	io;
	ll t;
	cin>>t;
	if(t>=30)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int main() {
    long long top=0,ans=0;
    long long n,a[N],b[N];
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i]>>b[i];
    }
    for(int i=n;i>=1;i--) {
        a[i]+=top;
        long long dv=a[i]/b[i];
        if(dv*b[i]!=a[i]) dv++;
        top+=dv*b[i]-a[i];
        ans+=dv*b[i]-a[i];
    }
    cout<<ans;
}


Measured memory_bytes: 1920
#include <iostream>
#include <set>
#include <vector>
#include <deque>

using namespace std;

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> defined(N,0);
  vector<set<int> > route(N);

  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    route[A-1].insert(B-1);
    route[B-1].insert(A-1);
  }

  deque<int> q;
  q.push_back(0);
  while(q.size()!=0){
    int top = q.front();
    q.pop_front();
    for(int s : route[top]){
      if(defined[s]==0){
        defined[s]=top+1;
        q.push_back(s);
      }
    }
  }
  if(find(defined.begin()+1, defined.end(), 0)==defined.end()){
    cout << "Yes" << endl;
    for(int i=1;i<N;i++) {
      cout << defined[i] << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 24764
import numpy as np

def Eratosthenes(n):
	''' n 以下の素数をエラトステネスの篩で生成 '''
	tbl = np.ones(n+1, dtype=bool)
	tbl[0:2] = False
	for i in range(2, int(np.sqrt(n))+1):
		if tbl[i]:
			tbl[2*i::i] = False
	return np.arange(n+1)[tbl]

x = int(input())

prime = Eratosthenes(100003)
for i, p in enumerate(prime):
    if p >= x:
        print(prime[i])
        break


Measured memory_bytes: 15156
s = input()
n = len(s)

MOD = 10**9+7
dp = [ [0]*13 for _ in range(n+1) ]
dp[0][0] = 1
for i in range(n):
    si = s[i]
    if si == '?':
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13]%=MOD

    else:
        sii = int(si)
        for j in range(13):
            dp[i+1][(j*10+sii)%13] += dp[i][j]
            dp[i+1][(j*10+sii)%13]%=MOD


print(dp[n][5])

Measured memory_bytes: 96224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << "Hello world"<<"\n";
    int d,t,s;
    cin >> d >> t >> s;
    long long int mx_d = t*s;
    if(mx_d>=d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3648
n = int(input())
A = list(map(int,input().split()))

answers = [0]*n

answers[n-1] = sum(A)//2-sum(A[0:n-1:2])

for i in range(n-2,-1,-1):
    answers[i] = A[i] - answers[i+1]

print(*[2*a for a in answers])

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; i++)
    {
        int ui, vi;
        cin >> ui >> vi;
        ui--;
        vi--;
        graph.at(ui).push_back(vi);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;

    vector<vector<bool>> reachable(N, vector<bool>(3, false));
    reachable.at(S).at(0) = true;
    queue<tuple<int, int, int>> q;
    q.push(make_tuple(S, 0, 0));
    while (!q.empty())
    {
        int u = get<0>(q.front()), h = get<1>(q.front()), d = get<2>(q.front());
        q.pop();

        if (u == T && h == 0)
        {
            cout << d << endl;
            return 0;
        }

        h++;
        if (h == 3)
        {
            h = 0;
            d++;
        }
        for (auto v : graph.at(u))
        {
            if (reachable.at(v).at(h))
                continue;
            reachable.at(v).at(h) = true;
            q.push(make_tuple(v, h, d));
        }
    }
    cout << -1 << endl;
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2) {
        int count = 0;
        for(int j = 1; j <= i; j++) {
            if(i % j == 0) count++;
        }
        if(count == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int p,q,r;cin>>p>>q>>r;
  int ans=220;
  chmin(ans,p+q);
  chmin(ans,q+r);
  chmin(ans,r+p);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {

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

		double n = sc.nextDouble();
		double d = sc.nextDouble();

		int ans = (int)(Math.ceil(n/(2*d+1)));
		System.out.println(ans);

	}
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define maxn 3030
#define ll long long
using namespace std;

const ll mod=1e9+7;

ll dp[maxn][maxn],times=1,ans;

int a[maxn],n,T,x,y;

void qpow(int k){
	ll base=2;
	while(k){
		if(k&1) times=(times*base)%mod;
		base=base*base%mod;
		k>>=1;
	}
}

int main(){
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dp[i][j]=a[i]>a[j];
	qpow(T);
	while(T--){
		scanf("%d%d",&x,&y);
		for(int i=1;i<=n;i++){
			if(i==x||i==y) continue;
			dp[i][x]=dp[i][y]=(dp[i][x]+dp[i][y])*((mod+1)/2)%mod;
			dp[x][i]=dp[y][i]=(dp[x][i]+dp[y][i])*((mod+1)/2)%mod;
		}
		dp[x][y]=dp[y][x]=(dp[x][y]+dp[y][x])*((mod+1)/2)%mod;
	}
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) ans=(ans+dp[i][j])%mod;
	printf("%lld",ans*times%mod);
	return 0;
}

Measured memory_bytes: 72064
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 100005

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> M;

	priority_queue<int> q1;
	if (M >= N) {
		cout << 0 << '\n';
		return 0;
	}

	for (int i = 1; i <= N; i++) {
		int t;
		cin >> t;
		q1.push(t);
	}

	while (M--) {
		q1.pop();
	}

	ll ans = 0;
	while (!q1.empty()) {
		ans += q1.top();
		q1.pop();
	}

	cout << ans << '\n';






#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 1400