akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
#define mod 1000000007

const int MAX = 500001;

struct Query
{
	int l, r, idx;
};

bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
	// initialising bit array
	int bit[n+1];
	memset(bit, 0, sizeof(bit));

	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));

	int ans[q];
	int query_counter = 0;
	for (int i=0; i<n; i++)
	{

		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);

		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
					query(queries[query_counter].r + 1, bit, n)-
					query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}

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

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

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

	Query queries[q];
	for(int i=0;i<q;i++){
        int u,v; cin>>u>>v;
        u--; v--;
        queries[i].l = u;
        queries[i].r = v;
        queries[i].idx = i;
	}

	sort(queries, queries+q, cmp);
	answeringQueries(a, n, queries, q);
	return 0;
}


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

int main() {
  long a, b, c, k;
  cin >> a >> b >> c >> k;

  if (a >= k) {
    cout << k << endl;
  } else if (a + b >= k) {
    cout << a << endl;
  } else {
    long remainder = k - a - b;
    cout << a - min(c, remainder) << endl;
  }
}


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

using namespace std;

typedef long long ll;

string GetName(ll num, ll index){
  string ret;
  for(ll i=0; i<num; i++){
    int temp = index % 26;
    ret += char('a'+ temp);
    index /= 26;
  }
  std::reverse(ret.begin(), ret.end());
  return ret;
}

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

  ll num = 1;
  ll cur = 1;
  while(cur <= N){
    cur += pow(26, num);
    ++num;
  }
  --num;
  cur -= pow(26, num);

  ll target = N - cur;
  string ret = GetName(num, target);
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 4020
#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))


n = input_one_number()
asnyan = input_multiple_number_as_list()

asnyan.sort()

b = 0
flg = True
for a in asnyan:
    if b == a:
        flg = False
    b = a

if flg:
    print("YES")
else:
    print("NO")




Measured memory_bytes: 26808
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();

		int[] M=new int[N];

		for(int i=0;i<N;i++) M[i]=sc.nextInt();

		Arrays.sort(M);

		int gcd=M[0];

		for(int i=1;i<N;i++) {
			gcd=GCD(gcd,M[i]);
		}

		System.out.println(gcd);

		sc.close();
	}

	public static int GCD(int a,int b) {
		if(a<b) {
			int w=a;
			a=b;
			b=w;
		}
		if(b==0) return a;
		return GCD(a%b,b);
	}

}


Measured memory_bytes: 50268
import java.util.Scanner;

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

        int n = in.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            if(p[i] == i + 1) {
                ans++;
                i++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50960
#include<iostream>
#include<string.h>


using namespace std;
 
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  bool agreed = false;
  for(int i=a;i<= b;++i){
  if(i % k == 0){
  	agreed = true;
  }
  }
  if(agreed){
  	cout<<"OK"<<endl;

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

Measured memory_bytes: 3116
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
#define ss second
#define ff first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    while(T --> 0)
    {
        cin>>n;
        int sum=0;
        for(i=1;i<=n;i++)
        {
            if((i%3)!=0 and (i%5)!=0)
                sum+=i;
        }
        cout<<sum;
    }
    return 0;
}

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

typedef long long llong;

llong minq(llong minv, llong target){
  return (minv > target) ? target : minv;
}

int main(){
  llong L, R;
  cin >> L >> R;
  int minv = 2020;
  for(llong i = L;i < R;i++){
    for(llong j = i + 1;j <= R;j++){
      minv = minq(minv, (i * j) % 2019);
      if(minv == 0)break;
    }
    if(minv == 0)break;
  }
  cout << minv;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vnit;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

int extgcd(int a,int b,int &x,int &y){
    int g=a;x=1;y=0;
    if(b!=0)g=extgcd(b,a%b,y,x),y-=(a/b)*x;
    return g;
}

signed main(){
    int a,b,d;
    while(cin>>a>>b>>d,a||b||d){
        int x,y;
        int g=extgcd(a,b,x,y);
        x*=d/g;
        y*=d/g;

        x=abs(x);
        y=abs(y);

        for(int i=0;i<=x+y;i++){
            int tmp=abs(a*i-d);
            if(tmp%b)continue;
            int j=tmp/b;
            if(x+y>i+j||(x+y==i+j&&a*x+b*y>a*i+b*j))x=i,y=j;
        }
        for(int j=0;j<=x+y;j++){
            int tmp=abs(b*j-d);
            if(tmp%a)continue;
            int i=tmp/a;
            if(x+y>i+j||(x+y==i+j&&a*x+b*y>a*i+b*j))x=i,y=j;
        }
        cout<<x<<" "<<y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3056
k,n = map(int, input().split())
ls = list(map(int, input().split()))
a = []
for i in range(n-1):
    a.append(ls[i+1] - ls[i])
a.append(k-ls[n-1]+ls[0])
a.sort(reverse=True)
print(k-a[0])


Measured memory_bytes: 26572
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = long.Parse(Console.ReadLine());
            //var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //var N = NK[0];
            //var K = NK[1];
            //var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var S = Console.ReadLine();
            var flag = false;
            long ans = 0;
            long count = 0;
            for (int i = 0; i < 3; i++)
            {
                if (flag && S[i] == 'R')
                {
                    count++;
                    ans = Max(ans, count);
                }
                else if(S[i] == 'R')
                {
                    count++;
                    ans = Max(ans, count);
                    flag = true;
                }
                else
                {
                    flag = false;
                    count = 0;
                }
            }
            
            Console.WriteLine(ans);
           
        }


    }
}


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

while k!=0:
    B=[0 for _ in range(n+1)]
    for i,j in enumerate(A):
        B[max(0,i-j)] +=1
        B[min(n,i+j+1)] -=1
    for i in range(1,n):
        B[i] +=B[i-1]
    A=B[:n]
    k -=1
    if sum(A)==n**2:break
print(*A)

Measured memory_bytes: 219352
#include<bits/stdc++.h>
using namespace std;
const int N=18;
const int mod=1000000007;
int n,m,a[N],fac[1<<N],ifc[1<<N],dp[N][1<<N],cnt[1<<N],siz,ans;
int qpw(int x,int n){
    int ret=1; for(;n;n>>=1,x=1ll*x*x%mod)
    if(n&1) ret=1ll*ret*x%mod; return ret;
}
int P(int n,int m){return n<m?0:1ll*fac[n]*ifc[n-m]%mod;}
int main(){
    scanf("%d%d",&n,&m),dp[0][0]=fac[0]=1,siz=1<<n;
    for(int i=0;i<m;i++) scanf("%d",&a[m-i]);
    for(int i=1;i<=siz;i++)fac[i]=1ll*fac[i-1]*i%mod;
    ifc[siz]=qpw(fac[siz],mod-2);
    for(int i=siz;i>=1;i--)ifc[i-1]=1ll*ifc[i]*i%mod;
    for(int s=0;s<siz;s++) for(int t=1;t<=s;t<<=1) if(s&t) cnt[s]+=t;
    for(int i=1;i<=m;i++) for(int s=0;s<siz;s++){
        (dp[i][s]+=dp[i-1][s])%=mod;
        for(int t=1;t<=siz;t<<=1) if(!(s&t))
            (dp[i][s|t]+=1ll*dp[i-1][s]*P(siz-a[i]-cnt[s],t-1)%mod*t%mod)%=mod;
    }
    for(int s=0;s<siz;s++){
        long long k=1;
        for(int t=s;t;t>>=1) if(t&1) k=-k;
        (ans+=k*dp[m][s]*fac[siz-cnt[s]-1]%mod)%=mod;
    }
    printf("%d\n",(1ll*ans*siz%mod+mod)%mod);
}


Measured memory_bytes: 19200
/*
              *******
When winter comes,You'll hear no lions roar,
no stags grazing the fields,
no roses growing in the meadows,
no snakes in the sand.
The krakens will freeze where they swim.
The flayed men will rot and wither.
No trouts swimming in the river and no falcons flying in the air.
Not even the dragons breath will warm you in your halls.
Only the wolfs howl in the night.
            WINTER IS COMING
*/
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%lld",&x)
#define p(x) printf("%lld\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define inf 2e18
#define prec(x) fixed<<setprecision(15)<<x
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mem(x,y) memset(x,y,sizeof(x))
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

bool cmp(pii a, pii b) {
    if(a.F==b.F) {
        return a.S>b.S;
    }
    return a.F>b.F;
}

int main() {
    fast_io;
    int n,m; cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    vector< pll >vec;
    for(int i=0;i<m;i++) {
        ll b,c; cin>>b>>c;
        vec.pb(mp(c,b));
    }
    sort(all(vec), cmp);
    int ptr=0;
    for(int idx=0;idx<n;idx++) {
        if(a[idx]>=vec[ptr].F) break;
        a[idx]=vec[ptr].F;
        vec[ptr].S--;
        if(vec[ptr].S==0) ptr++;
        if(ptr==m) break;
    }
    ll ans=0;
    for(int i=0;i<n;i++) {
        ans+=a[i];
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3188
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const A = input[1].map(Number);

  A.sort((a, b) => a - b);

  return A[N - 1] - A[0];
};

console.log(main(read()));


Measured memory_bytes: 29572
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;

  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

N,M = Line[0],Line[1]

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

if (N-sum(Line)) < 0 :
    print("-1")
else:
    print(N-sum(Line)) 
    

Measured memory_bytes: 9808
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
signed main(){
    int n;
    cin>>n;
    int h[114514];
    for(int i=0;i<n;i++)cin>>h[i];
    h[0]--;
    bool ans=true;
    for(int i=1;i<n;i++){
        if(h[i]<h[i-1])ans=false;
        else if(h[i]>h[i-1])h[i]--;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
    int A,B,C,k;
    cin>>A>>B>>C>>k;
    int ans=0;
    while(A>=B){ B*=2;ans++;}
    while(B>=C){ C*=2;ans++;}
    if(ans<=k) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3572
from fractions import gcd
N=int(input())
A=list(map(int,input().split(' ')))
L = 1
def lcm(x,y):
    return x//gcd(x,y)*y
for a in A:
    L = lcm(L,a)
ans=0
for a in A: ans+=L//a
print(ans%(10**9+7))

Measured memory_bytes: 6112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll t[n], a[n];
	for (int i = 0 ; i < n ; i++) cin >> t[i] >> a[i];
	ll x = t[0], y = a[0], b, c;
	for (int i = 1 ; i < n ; i++) {
			b = x;
			c = y;
			x = t[i] * max((x - 1) / t[i] + 1, (y - 1) / a[i] + 1);
			y = a[i] * max((b - 1) / t[i] + 1, (c - 1) / a[i] + 1);
	}
	cout << x + y; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e9
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  loop(i, 1, n - 1) {
    vector<pair<int, int>> vp;
    vp.push_back(make_pair(p[i - 1], i - 1));
    vp.push_back(make_pair(p[i], i));
    vp.push_back(make_pair(p[i + 1], i + 1));
    sort(all(vp));
    if (vp[1].second == i) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
using namespace std;
signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int grid[103][103];
	int a[10004];
	int h, w, n;
	cin >> h >> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int i = 0;
	int j = 0;
	int tmp = 0;
	int flag = 0;
	while (1) {
		if (i >= h)break;
		grid[i][j] = tmp;
		a[tmp] -= 1;
		if (a[tmp] == 0)tmp += 1;
		if (j == 0 && flag == 1) {
			i += 1; flag = 0;
		}
		else {
			if (j == (w - 1) && flag == 0) {
				i += 1; flag = 1;
			}
			else if (flag==0) {
				j += 1;
			}
			else if (flag == 1) {
				j -= 1;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << grid[i][j]+1 << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;


int main() {
    string s,t,k;
    cin >> s;
    cin >> t;
    t.erase(--t.end());
    if(s==t){
        cout << "Yes"  << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);

    rep(i,n) cin >> h[i];

    sort(all(h));

    int ans = 1002003004;

    rep(i,n-k+1){
        ans = min(ans,h[i+k-1] - h[i]);
    }

    dunk(ans);
}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc051_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int K, S;
  cin >> K >> S;
  
  ll ans = 0;
  rep(i, min(K, S) + 1) {
    rep(j, min(K, S) + 1) {
      int rest = S - (i + j);
      if (rest >= 0 && rest <= K) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
ll pre[N], pre1[N];
ll a[N];

void solve() {
	int n, k;
    sc(n, k);
    fr(i, 1, n) {
        sc(a[i]);
        pre[i] = pre[i - 1] + a[i];
        pre1[i] = pre1[i - 1] + max(0LL, a[i]);
    }
    ll ans = 0;
    fr(i, k, n) {
        ll val = max(0LL, pre[i] - pre[i - k]) + pre1[n] - pre1[i] + pre1[i - k];
        ans = max(ans, val);
    }
    cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5940
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int t = 0;
    int x = 0;
    int y = 0;
    for(int i=0; i<n; ++i){
        int t2, x2, y2;
        cin >> t2 >> x2 >> y2;

        int dt = t2 - t;
        int dist = abs(x2 - x) + abs(y2 -y);
        if(dt < dist || dt % 2 != dist % 2){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	while(1){
		int n ; cin >> n ; if(!n) break;
		int* a=new int[n];
		for(int i=0;i<n;i++) cin >> a[i];
		int MAX=a[0];
		for(int i=0;i<n;i++){
			int temp=0;
			for(int j=i;j<n;j++){
				temp+=a[j];
				if(temp>MAX) MAX=temp;
			};
		};
		cout << MAX << '\n' ;
		delete[] a;
	};
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(){
  int n,m,l=1;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    if(l*2>l+m)l+=m;
    else l*=2;
  }
  printf("%d\n", l);
  return 0;
}


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

using namespace std;

int main()
{
	int A, B;
	int ans1, ans2;

	cin >> A >> B;

	ans1 = A * 12.5;
	ans2 = B * 10;

	for(int i = ans2;; i++){
		if(int(i * 0.08) == A && int(i * 0.1) == B){
			cout << i << endl;
			return 0;
		}else if(A < int(i * 0.08))
			break;
	}

	cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された

    if(n%2 == 0) return false;

    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }

    return true;
}

int main()
{
    int X;
    cin>>X;
    while(1){
        if(is_prime(X)){
            cout<<X<<endl;
            break;
        }
        X++;
    }

    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

vector<vector<int>> g(100000);
int k;
vector<bool> isVisited(100001);
map<pair<int,int>, int> m_id;
void dfs(int now, int now_color){
    int next_color = 1; // 次に使う色
    isVisited[now] = true;
    // 分岐
    rep(i,g[now].size()){
        int next = g[now][i];
        if(isVisited[next]) continue;
        if(next_color == now_color) next_color++;
        // 辺の色を記録
        m_id[make_pair(now,next)] = next_color;
        m_id[make_pair(next,now)] = next_color;
        k = max(k, next_color);
        dfs(next, next_color);
        next_color++;
    }
}

int main(){
    // 入力
    int n; cin >> n;
    int a,b;
    vector<pair<int,int>> kanako(n); // kanakoは僕の元カノの名前です……
    rep(i,n-1){
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
        kanako[i] = make_pair(a, b);
    }

    dfs(0,0);

    // 出力
    cout << k << "\n";
    rep(i,n-1) cout << m_id[kanako[i]] << "\n";
}

Measured memory_bytes: 20480
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn = 100000;

int n, k, q;
ll dist[maxn];
bool used[maxn];
vector<pair<int, int>> p;
vector<vector<pair<ll, ll>>> v(maxn);  //行先とコスト

int main() {

	cin >> n;
	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		v[a].push_back(pair<ll, ll>(b, c));
		v[b].push_back(pair<ll, ll>(a, c));
	}

	cin >> q >> k;

	rep(i, q) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p.push_back(pair<int, int>(a, b));
	}

	fill(used, used + n, false);
	fill(dist, dist + n, INF);
	dist[k - 1] = 0; used[k - 1] = true;

	queue<int> que;
	que.push(k - 1);

	while (que.size()) {
		int t = que.front(); que.pop();
		for (int i = 0; i < v[t].size(); i++) {
			if (!used[v[t][i].first]) {
				dist[v[t][i].first] = dist[t] + v[t][i].second;
				used[v[t][i].first] = true;
				que.push(v[t][i].first);
			}
		}
	}

	rep(i, p.size()) {
		cout << dist[p[i].first] + dist[p[i].second] << endl;
	}

	return 0;
}


Measured memory_bytes: 12660
n,m,k = map(int,input().split())
nlist = list(map(int,input().split()))
mlist = list(map(int,input().split()))
result = 0

# mlistが読める残り時間。ncount(nが読める冊数)が増えるたびに減少していく
mrest = k

# mlistが読める冊数。最初はの最大冊数だが、ncount(nが読める冊数)が増えるたびに減少していく
mcount = m

# mcount分読むのにかかる時間。最初は最大冊数分持っているか、mcountが減るたびに減少していく
mtime = sum(mlist)

# ncount分読むのにかかる時間。ncountが増えるたびに増加していく
ntime = 0

# ncount(nが読める冊数)を1ずつ増やしていく
for ncount in range(len(nlist) + 1):
  # ncountが1以上の場合は、1冊読んだので、mrestをその時間分減らす
  if ncount > 0:
    mrest -= nlist[ncount - 1]
    ntime += nlist[ncount - 1]
  # もしntimeが最大時間を超えてしまったら終了する
  if ntime > k:
    break;
  # mlistが読める残り時間も冊数もあれば、mlistから本を取っていく
  # もしmlistが読める残り時間が最大時間を超えていたら後ろから諦めていく
  while mcount > 0 and mtime > mrest:
    mcount -= 1
    mtime -= mlist[mcount]
  # このループで読める冊数はncount+mcount。ループごとの最大値が答え
  result = max(result, ncount + mcount)
  # nlistの本を全部読み終わっていたら処理を終了する
  if ncount == n:
    break;
print(result)


Measured memory_bytes: 40416
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n,k;
    cin >> n >> k;

    int sum = 0;
    for(int i = 0;;i++){
        sum += pow(k,i) * (k - 1);
        if(sum >= n) {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i=0; i<k; i++){
            int d = scanner.nextInt();
            for(int j=0; j<d; j++){
                map.put(scanner.nextInt(), 0);
            }
        }
        scanner.close();
        System.out.print(n-map.size());
    }
 
}

Measured memory_bytes: 37520
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    b %= m;
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclidalgo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) {
        return a;
    } else {
        return euclidalgo(b,a % b);
    }
}
bool coprime(ll int a, ll int b) {
    if (euclidalgo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int power(ll int x, ll int y, ll int p) { // x ^ y % p
    ll int res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y /= 2; 
        x = (x * x) % p; 
    } 
    return res; 
}
ll int modInverse(ll int n, ll int p) {
    return power(n, p - 2, p); 
}
ll int nCrModPFermat(ll int n, ll int r, ll int p) {
    if (r == 0) return 1; 
    ll int fac[n + 1]; 
    fac[0] = 1; 
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p; 
    }
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // implementation
    ll int n;
    cin >> n;
    ll int hp = 0;
    while (n >= 500) {
    	hp += 1000;
    	n -= 500;
	}
	while (n >= 5) {
		hp += 5;
		n -= 5;
	}
	cout << hp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    float ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=pow(pow(x[i]-x[j], 2)+pow(y[i]-y[j], 2), 0.5)*2/n;
        }
    }
    cout << fixed <<setprecision(10) << ans <<endl;
    return 0;
}



Measured memory_bytes: 384
a = str(input())
kouho = 9999999999999999

for i in range(len(a) - 2):
    if abs(int(a[i]) * 100 + int(a[i+1]) * 10 + int(a[i+2]) - 753) < abs(kouho - 753):
        kouho = int(a[i]) * 100 + int(a[i+1]) * 10 + int(a[i+2])

print(abs(kouho - 753))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ri register
//#define int long long
#define E (n+1)
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int K,dis[N],book[N];
int head[N],maxE;
struct Edge{ int nxt,to,rdis; }e[N];
inline void Add(int u,int v,int w) { e[++maxE].nxt=head[u]; head[u]=maxE; e[maxE].to=v; e[maxE].rdis=w; }
struct Node
{
    int x,w;
    inline bool operator < (const Node &a) const { return w>a.w; }
};
signed main()
{
    K=read();
    memset(head,-1,sizeof(head));
    for(ri int i=0;i<K;i++)
    {
        Add(i,(i+1)%K,1), Add(i,i*10%K,0);
    }
    priority_queue<Node> Q;
    Q.push((Node){1,1});
    memset(dis,0x3f,sizeof(dis)), dis[1]=1;
    while(!Q.empty())
    {
        Node now=Q.top(); Q.pop();
        int x=now.x;
        if(book[x]) continue;
        book[x]=1;
        for(ri int i=head[x];i!=-1;i=e[i].nxt)
        {
            int v=e[i].to;
            if(dis[v]>dis[x]+e[i].rdis)
            dis[v]=dis[x]+e[i].rdis, 
            Q.push((Node){v,dis[v]});
        }
    }
    printf("%d\n",dis[0]);
    return 0;
}

Measured memory_bytes: 14416
#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(){
  ll n,m;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  string x;
  rep(i,n){
    cin>>s[i]>>t[i];
  }
  for(int i=1; i<n; i++){
    t[i] += t[i-1];
  }
  cin >> x;
  
  int mus=0;
  rep(i,n){
    if(x==s[i]){mus=i;}
  }


  cout << t[n-1]-t[mus] << endl; 
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    string S;
    cin >> S;
    string ans = !(S=="AAA" or S=="BBB") ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


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

using namespace std;

struct StronglyConnectedComponents
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  StronglyConnectedComponents(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

int main()
{
  int N, M, S, P[100], T[100], K[100];
  bool mine[100];
  int deq[10001], deqv[10001];

  while(scanf("%d %d %d", &N, &M, &S), N) {
    for(int i = 0; i < N; i++) {
      scanf("%d %d %d", &P[i], &T[i], &K[i]);
    }
    StronglyConnectedComponents g(N);
    memset(mine, false, sizeof(mine));
    for(int i = 0; i < M; i++) {
      int x, y;
      scanf("%d %d", &x, &y);
      g.add_edge(--x, --y);
      if(x == y) mine[x] = true;
    }

    vector< vector< int > > dag;
    g.build(dag);
    vector< vector< int > > component(dag.size());
    for(int i = 0; i < N; i++) component[g[i]].push_back(i);

    vector< vector< int > > dp(dag.size(), vector< int >(S + 1, 0));
    int ret = 0;

    for(int i = 0; i < dag.size(); i++) {
      if(component[i].size() == 1 && !mine[component[i][0]]) {
        int now = component[i][0];
        for(int k = S; k >= T[now]; k--) {
          dp[i][k] = max(dp[i][k], dp[i][k - T[now]] + P[now]);
        }
      } else {
        for(int j : component[i]) {
          for(int k = 0; k < T[j]; k++) {
            int s = 0, t = 0;
            for(int l = 0; l * T[j] + k <= S; l++) {
              int val = dp[i][l * T[j] + k] - l * P[j];
              while(s < t && deqv[t - 1] <= val) --t;
              deq[t] = l;
              deqv[t++] = val;
              dp[i][l * T[j] + k] = deqv[s] + l * P[j];
              if(deq[s] == l - K[j]) ++s;
            }
          }
        }
      }
      for(int k = 0; k <= S; k++) {
        ret = max(ret, dp[i][k]);
        for(int j : dag[i]) dp[j][k] = max(dp[j][k], dp[i][k]);
      }
    }

    printf("%d\n", ret);
  }
}

Measured memory_bytes: 6984
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int a,b;
  cin>>a>>b;

  int aa,bb;
  rep(i,1251){
    aa=floor(i*0.08);
    bb=floor(i*0.1);

    if(aa==a && bb==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char d[10];
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		char f;
		cin>>f;
		d[f-'0']=1;
	}
	for(int i=n;i<100000;i++)
	{
		string s;
		stringstream ss;
		ss<<i;
		s=ss.str();
		for(int j=0;j<s.size();j++)
			if(d[s[j]-'0']==1)
				goto E;
		cout<<i<<endl;
		break;
		E:;
	}
	return 0;
}

Measured memory_bytes: 256
import collections
H, W = map(int, input().split())

a = ''.join(input() for _ in range(H))
c = collections.Counter(a)

if H % 2 == 0 and W % 2 == 0:
    if all(v % 4 == 0 for v in c.values()):
        print('Yes')
    else:
        print('No')

elif H % 2 == 1 and W % 2 == 1:
    d = (H-1)//2+(W-1)//2
    if sum(v % 2 for v in c.values()) <= 1 and sum(1 if v % 4 >= 2 else 0 for v in c.values()) <= d:
        print('Yes')
    else:
        print('No')

else:
    if H % 2 == 0:
        d = H//2
    else:
        d = W//2

    if sum(v % 2 for v in c.values()) >= 1:
        print('No')
        exit()

    if sum(1 if v % 4 == 2 else 0 for v in c.values()) <= d:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3700
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch[1000001];
    int sum;
    cin>>ch;
    for(int i=0;i<strlen(ch);i++)
    {
        if(ch[i]=='x')
        {
            sum++;
        }
    }                                           
    if(sum>=8)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  int t, n, k, x, ans,a;

  while(1) {
    vector<int> point;
    cin >> n;

    if(n == 0){
      break;
    }

    for(int i = 0; i < n; ++i) {
      cin >> x;
      point.push_back(x);
    }

    sort(point.begin(),point.end());
    reverse(point.begin(),point.end());

    t = point[0];

    for(int i = 1; i < n; ++i) {
      k = point[i];
      if(i == 1){
        ans = t - k;
      }
      else {
        a = t - k;
        if(ans > a){
          ans = a;
        }
      }
      t = k;
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows:
 
 
  c
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)


int main()
{
        io;
        //////////////////////////////////
        cs1{
            ll i,j,k,l,s=0,p=0,q=0;
            string st;
            cin>>st;
            for(i=0;i<st.size();i++){
                s=s+(st[i]-'0');
            }
            if(s%9==0) cout<<"Yes" nl;
            else cout<<"No" nl;
        }
        //////////////////////////////////
       
}

Measured memory_bytes: 3784
#include <stdio.h>

int main (void)
{
  int N,k1000,A;
  
  scanf("%d",&N);
  
  k1000 = N/1000*1000; //1000の位
  A = N - k1000; //1000の位を外した値(100の位以下の数字だけ)
  
  if(A == 0){
    printf("%d\n",A);
  }
  else{
    printf("%d\n",1000 - A);
  }
  
  return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
 
#define MAX 100005
#define NIL -1
 
typedef struct{
  int p,l,r;
}Node;
 
Node T[MAX];
int n,D[MAX];
 
void print(int);
int rec(int,int);
 
int main(){
  int i,j,d,v,c,l,r;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = T[i].l = T[i].r = NIL;
 
  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
 
  for(i=0;i<n;i++)
    if(T[i].p == NIL)r = i;
 
  rec(r,0);
  for(i=0;i<n;i++)
    print(i);
 
  return 0;
}
 
void print(int u){
  int i,c;
 
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
 
  if(T[u].p == NIL)printf("root, [");
  else if(T[u].l == NIL)printf("leaf, [");
  else printf("internal node, [");
 
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
 
int rec(int u,int p){
 
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r,p);
  if(T[u].l != NIL)rec(T[u].l,p+1);
}


Measured memory_bytes: 6484
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N;
    cin >> N;
    cout << N / 2 + N % 2 << endl;
    return 0;
}

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

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

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

int main(){
      int n;cin >> n;
      int k;cin >> k;
      int ans = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            if(t >= k)ans++;
      }
      cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pi;
typedef pair<Pi,ll> P;
P a[300000];
P b[300000];
bool used[300000];
ll num[300000];
ll max(ll a,ll b){return a>b?a:b;}
int main(){
    ll n;
    ll i,j;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        ll x,y;
        scanf("%lld %lld",&x,&y);
        a[i]=P(Pi(y,x),i);
        b[i]=P(Pi(x,y),i);
    }
    sort(a,a+n);
    sort(b,b+n);
    for(i=0;i<n;i++)num[b[i].second]=i;
    ll l=0,r=n;
	ll mid;
    bool pos;
    ll m;
    ll ans=0;
    for(i=0;i<20;i++){
        mid=(l+r)/2;
        memset(used,true,n);
        pos=false;
        ll s=0;
        for(j=0;j<mid;j++)s+=b[j].first.first;
        m=mid-1;
        if(s<=mid*a[0].first.first)pos=true;
        for(j=1;j<=n-mid;j++){
            used[a[j-1].second]=false;
            if(num[a[j-1].second]<=m){
                m++;
                while(m<n&&!used[b[m].second])m++;
                if(m==n)break;
                s+=b[m].first.first-a[j-1].first.second;
            }
            if(s<=mid*a[j].first.first){
                pos=true;
                break;
            }
        }
        if(pos){
            ans=max(ans,mid);
            l=mid+1;
        }
        else r=mid;
    }
    printf("%lld\n",ans);
    return 0;  
}

Measured memory_bytes: 17732
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> war;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        war.push_back(make_pair(a,b));
    }
    sort(war.begin(),war.end());
    int l,r;
    int ans=1;
    l = war[0].first;
    r = war[0].second;
    for(int i=1;i<war.size();i++){
        if(war[i].first >= r){
            ans++;
            l = war[i].first;
            r = war[i].second;
        }
        else{
            if(war[i].second < r){
                r = war[i].second;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3884