akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

#define SIZE 200000


using namespace std;

int main() {
   long long int X,a,b,c;

   cin >> X;

// resultat = 360/pgcd(360,X)
  a = 360;
  b = X;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }

   cout << 360/a << endl;

  return 0;

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vc<bool> ch(8,false);
    int cnt = 0;
    rep(i,n){
        int x; cin >> x;
        if(x >= 3200) cnt++;
        else ch[x/400] = true;
    }
    int ans = accumulate(all(ch), 0);
    cout << max(ans, 1) << " " << ans+cnt << endl;
    return 0;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  unordered_map<string, ll> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++m[s];
  }

  ll res = 0;

  for (auto& a : m) {
    res += a.second * (a.second - 1) / 2;
  }

  cout << res << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 10356
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M,Q;
ll ans;
ll A[50];
ll B[50];
ll C[50];
ll D[50];
ll a[50];
 
 
int main(){
    cin >> N >> M >> Q;
    for (int i=0;i<Q;i++){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
    }
    int cntt = 0;
    for(int i= 0;i<N;i++){
        a[i] = 1;
    }
    while(a[0]<=M){
        ll anss=0;
        for(int i=0;i<Q;i++){
            if(a[B[i]-1]-a[A[i]-1]==C[i])
                anss += D[i];
        }
        if(anss>ans){
            ans = anss;
        }
        if(a[N-cntt-1]<M){
            a[N-cntt -1] += 1;
        }else{
            int cnttt = cntt;
            if(a[0]==M){
                break;
            }
            while(a[N-cnttt -1] == M){
                cnttt++;
            }
            a[N-cnttt-1] += 1;
            for(int i=0;i<cnttt;i++){
                a[N-i-1] = a[N-cnttt-1];
            }
        }
        
    
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  auto x = N * (N - 1) / 2;

  cout << x << endl;

  return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A')  return 1;
    else if (ch == 'C')  return 2;
    else if (ch == 'G')  return 3;
    else if (ch == 'T')  return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
    long long key, h;
    key = getKey(str);
    for (long long i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)  return 1;
        else if (strlen(H[h]) == 0)  return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, h;
    key = getKey(str);
    for (long long i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)  return 1;  //已存在
        else if(strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    char str[L];
    char com[9];
    int n = 0;
    for (int i = 0; i < M; i++)  H[i][0] = '\0';
    scanf("%d", &n);
    for (long long i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        if (com[0] == 'i') {
            insert(str);
        }
        else if (com[0] == 'f') {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16964
#include<stdio.h>
#include<math.h>

/* 値を入れ替える関数 */
void swap(int* x, int* y) {
	int temp;    // 値を一時保存する変数

	temp = *x;
	*x = *y;
	*y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition(int array[], int left, int right) {
	int i, j, pivot;
	i = left;
	j = right + 1;
	pivot = left;   // 先頭要素をpivotとする

	do {
		do { i++; } while (array[i] < array[pivot]);
		do { j--; } while (array[pivot] < array[j]);
		// pivotより小さいものを左へ、大きいものを右へ
		if (i < j) { swap(&array[i], &array[j]); }
	} while (i < j);

	swap(&array[pivot], &array[j]);   //pivotを更新

	return j;
}

/* クイックソート */
void quick_sort(int array[], int left, int right) {
	int pivot;

	if (left < right) {
		pivot = partition(array, left, right);
		quick_sort(array, left, pivot - 1);   // pivotを境に再帰的にクイックソート
		quick_sort(array, pivot + 1, right);
	}
}

int main() {
	int n, k;
	int p[1000];
	int total = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &(p[i]));
	}
	quick_sort(p, 0, n-1);
	for (int j = 0; j < k; j++) {
		total += p[j];
	}
	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int A = 0, B = 0, C = 0, D = 0;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  if(D < A || C > B) puts("0");
  else if (A <= C && D <= B) printf("%d\n", D-C);
  else if (C <= A && B <= D) printf("%d\n", B-A);
  else printf("%d\n", min(B,D)-max(A,C));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>

using namespace std;


int main() {
	int n;
	cin >> n;
	map<int, long long> appear;
	map<long long, long long> ansers;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		appear[a[i]] += 1;
	}
	for (int i = 0; i < n; i++) {
		long long count = 0;

		if (ansers.count(appear[a[i]]) == 0) {
			appear[a[i]] -= 1;

			for (auto itr = appear.begin(); itr != appear.end(); itr++) {
				long long tmp = itr->second;
				count += tmp * (tmp - 1) / 2;
			}
			appear[a[i]] += 1;
			ansers[appear[a[i]]] = count;

		}
		else {
			count = ansers[appear[a[i]]];
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(20)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    long T[N + 2], A[N + 2];
    T[0] = 0;
    A[N + 1] = 0;
    cins(T + 1, T + N + 1);
    cins(A + 1, A + N + 1);
    long ans = 1;
    for(int i = 1; i <= N; i++){
        if(T[i - 1] < T[i] && A[i] > A[i + 1]){
            if(T[i] != A[i]){
                ans = 0;
            }
        }else if(T[i - 1] < T[i]){
            if(A[i] < T[i]){
                ans = 0;
            }
        }else if(A[i] > A[i + 1]){
            if(T[i] < A[i]){
                ans = 0;
            }
        }else{
            ans = ans * min(T[i], A[i]) % mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int num[70],num2[70];
int dp[70][2][2][2];
long long dfs(int x,int limit,int limit2,bool key,int flg) {
	if(~dp[x][limit][limit2][flg]&&key)return dp[x][limit][limit2][flg];
	if(x==0)return 1;
	int res=0,up=limit?num[x]:1,up2=limit2?num[x]:1,down=flg?num2[x]:0;
	if(down==0)res=(res+dfs(x-1,limit&&up==0,limit2&&up2==0,key,flg))%mo;
	if(up2){
		if(key&&!down)res=(res+dfs(x-1,limit&&up==0,limit2,key,flg&&down==0))%mo;
		if(up)res=(res+dfs(x-1,limit,limit2,1,flg&&down))%mo;
	}
	if(key)dp[x][limit][limit2][flg]=res;
	return res;
}
long long Solve(long long x,long long y) {
	int len=0,l2=0;
	while(x) {
		num[++len]=x&1;
		x>>=1;
	}
	while(y){
		num2[++l2]=y&1;
		y>>=1;
	}
	return dfs(len,1,1,0,1);
}
int main() {
	memset(dp,-1,sizeof(dp));
	long long l,r;
	scanf("%lld%lld",&l,&r);
	printf("%lld\n",Solve(r,l));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, m, h[100100], i, j, ans=0;
    vector<long long> con[100100];
    bool judge;
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        con[a].push_back(b);
        con[b].push_back(a);
    }
    for(i=0;i<n;i++){
        judge=true;
        for(auto x : con[i]){
            if(h[x]>=h[i]){
                judge=false;
                break;
            }
        }
        if(judge){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;
typedef long long LL;

#define MAXN 200001
#define MOD 1000000007

int N;
int A[MAXN];
int B[MAXN][21];

int main(int argc, char** argv) {
#ifdef OJ	
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int b = 0; b < 21; b++) {
            B[i][b] = B[i-1][b];
            if (A[i] & (1<<b))
                B[i][b]++;
        }
    }

    LL ans = 0;
    for (int i = 1; i <= N; i++) {
        int l = i;
        int r = N+1;
        while(r-l > 1) {
            int m = (r+l) / 2;
            int ok = 1;
            for (int b = 0; b < 21; b++) {
                if (B[m][b] - B[i-1][b] > 1)
                    ok = 0;
            }

            if (ok) {
                l = m;
            } else {
                r = m;
            }
        }

        ans += r-i;
    }

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

Measured memory_bytes: 17408
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let m = it.next().unwrap().parse::<usize>().unwrap();
    let a = (0..n).map(|_| it.next().unwrap()).collect::<Vec<_>>();
    let b = (0..m).map(|_| it.next().unwrap()).collect::<Vec<_>>();
    let mut valid = false;
    for i in 0..n-m+1 {
        for j in 0..n-m+1 {
            let mut eq = true;
            for k in 0..m {
                if &a[i+k][j..j+m] != b[k] { eq = false; }
            }
            if eq { valid = true; }
        }
    }
    println!("{}", if valid { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S;
    cin >> S;
    if(S.substr(0,1)=="S"){
        cout << "Cloudy" << endl;
    }else if(S.substr(0,1)=="C"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }

    

}

Measured memory_bytes: 3500
# -*- coding: utf-8 -*-

import math

a, b, x = map(int, input().split())

V = a**2 * b
V_2 = V / a

x_2 = x / a

if x_2 > V_2/2:
    c = 2*x/a**2 - b
    theta = math.atan2(a,(b-c))
    deg = math.degrees(theta)
else:
    c = 2*x/(a*b)
    theta = math.atan2(c,b)
    deg = math.degrees(theta)

print("{}".format(90.0-deg))


Measured memory_bytes: 3060
//ITP1_4_C

using System;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        int[] ans = new int[100];
        int count = 0;

        while (true)
        {
            string[] sarray = (Console.ReadLine().Split(' '));          //??????????????????sarray???????????????

            int a = int.Parse(sarray[0]);
            int b = int.Parse(sarray[2]);
            string op = sarray[1];

            if (op == "?")
                break;

            switch (op)
            {
                case "+":
                    ans[count++] = a + b;
                    break;

                case "-":
                    ans[count++] = a - b;
                    break;

                case "*":
                    ans[count++] = a * b;
                    break;

                case "/":
                    ans[count++] = a / b;
                    break;

                default:
                    break;
            }
        }

        for (int i = 0; i < count; i++)
            Console.WriteLine(ans[i]);
    }
}

Measured memory_bytes: 9168
#include <stdio.h>
int main()
{
   int a,b,d,r;
   double f;
   
   scanf("%d %d",&a,&b);
   d=a/b;
   r=a%b;
   f=(double)a/b;
   printf("%d %d %.5lf\n",d,r,f);
   
   return 0;
}


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

int selectionSort(int a[], int n) {
  int count = 0;
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    swap(a[i], a[minj]);
    if (i != minj) count++;
  }
  return count;
}

void printArray(int a[], int n) {
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int main() {
  int n, a[100];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sw = selectionSort(a, n);
  printArray(a, n);
  cout << sw << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll X;
  cin >> X;
  cout <<  1000 *(X/500) + 5 * ((X % 500)/5) << endl;
 return 0;
}

Measured memory_bytes: 256
n=int(input())
from collections import defaultdict
data=defaultdict(int)
ans=1
mod=10**9+7
for i in range(1,1+n):
    target=i
    now=1
    while target>1:
        now+=1
        while target>1:
            if target%now==0:
                data[now]+=1
                target//=now
            elif target%now!=0:
                break
for x in data.keys():
    ans=(ans*(data[x]+1))%mod
print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long a,b,c,d=0,e=0,w,x,y,z;
    cin>>a>>b>>c;
    y=c;
    y/=a;
    y*=a;
    if(y>=b){cout<<"OK";}
    else{cout<<"NG";}
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double num = i;
        double p = 1.0 / n;
        while(num < k){
            num *= 2;
            p *= 1.0/2.0;
        }
        ans += p;
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n;
	cin >> n;
	ll a[N];
	rep(i, n) cin >> a[i];

	int count_minus = 0;
	ll max_minus = -INFL;
	ll min_plus = INFL;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] >= 0) {
			min_plus = min(a[i], min_plus);
		}
		else {
			count_minus++;
			max_minus = max(a[i], max_minus);
		}
		ans += abs(a[i]);
	}

	if(count_minus % 2 == 1) {
		ans -= 2 * min(min_plus, -max_minus);
	}
	cout << ans << endl;
}


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

int main()
{ 
  int64_t n ;
  cin >> n ;
  int64_t answer = 0 ;
  for(int i = 1 ; ; i++)
  {
    if(i * i > n)
    {
      answer = (i - 1) * (i - 1) ;
      break;
    }
  }

  cout << answer << endl ;
}


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

int gcd(int x,int y) {
if (x % y == 0) {
  return y;
}
else {
return gcd(y,x % y);
}
}

int main () {
int K;
cin >> K;
int i,j,k,sum = 0;
for (i = 0;i < K;i++) {
for (j = 0;j < K;j++) {
for (k = 0;k < K;k++) {
gcd(gcd((j+1),(k+1)),(i+1));
sum += gcd(gcd((j+1),(k+1)),(i+1));
}
}
}
cout << sum << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>

int memo[20][20];
int x, y;

int calc(std::vector<std::vector<int> > &v, int x, int y){

	int res = 0;
	if (memo[x][y] != -1)return memo[x][y];
	if ((x > v.size() - 1) || (x == v.size() - 1 && v[x][y] != 1))return 1;

	if (v[x][y] == 2)res += calc(v, x + 2, y);

	if (v[x][y] == 0){
		if (v[x + 1][y] == 0 || v[x + 1][y] == 2)res += calc(v, x + 1, y);

		if (y < v[x].size() - 1 && v[x + 1][y + 1] == 0)res += calc(v, x + 1, y + 1);

		if (y > 0 && v[x + 1][y - 1] == 0)res += calc(v, x + 1, y - 1);
	}

	return memo[x][y] = res;
}


int main(){

	while (std::cin >> x >> y){

		if (x == 0 && y == 0)break;

		int res = 0;
		std::vector<std::vector<int> >v(y, std::vector<int>(x));

		for (int i = 0; i < 20; i++){
			for (int j = 0; j < 20; j++){
				memo[i][j] = -1;
			}
		}

		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				std::cin >> v[i][j];
			}
		}

		for (int i = 0; i < v[0].size(); i++)res += calc(v, 0, i);

		std::cout << res << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>

using namespace std;

int main(){
    string s;
    string t;
    cin >> s >> t;

    int count = 0;

    for (int i = 0; i < 3; i++){
        if (s[i] - t[i] == 0){count += 1;}
    }

    cout << count << endl;
}

Measured memory_bytes: 888
n = int(input())
a = list(map(int, input().split()))
kau = [0]*n
index = []
if a[0] < a[1]:
    kau[0] = 1
elif a[0] == a[1]:
    for j in range(1, n):
        if a[0] < a[j]:
            kau[0] = 1
            break
        if a[0] > a[j]:
            break
    
for i in range(1, n-1):
    if a[i-1] > a[i]:
        for j in range(i+1, n):
            if a[i] < a[j]:
                kau[i] = 1
                break
            if a[i] > a[j]:
                break
for i, j in enumerate(kau):
    if j == 1:
        index.append(i)
index.append(n)

ans = 1000
for i in range(len(index)-1):
    kabu = ans//a[index[i]]
    ans -= a[index[i]]*kabu
    ans += max(a[index[i]+1:index[i+1]])*kabu
print(ans)

Measured memory_bytes: 9156
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

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

    ll n;
    cin >> n;

    ll ar[n] , mn = INT_MAX , mx = INT_MIN;
    for(ll i=0 ; i<n ; i++) {
    	cin >> ar[i];
    	mn = min(mn , ar[i]);
    	mx = max(mx , ar[i]);
    	//sum+=ar[i];
    }

    ll ans=  INT_MAX;

    for(ll i=0 ; i<=105 ; i++) {

    	ll sum=0;

    	for(ll j=0 ; j<n ; j++) {
    		sum+=((i - ar[j])*(i - ar[j]));
    	}
    	ans = min(sum , ans);
    }

    cout << ans;


    // ll cord1 = (mx + mn)/2 , cord2 = cord1+1;
    // ll sum1=0 , sum2=0;
    // //cout << cord << endl;
    // for(ll i=0 ; i<n ; i++) {
    // 	sum1=sum1 + ((ar[i] - cord1)*(ar[i] - cord1));
    // 	sum2+= ((ar[i] - cord2)*(ar[i] - cord2));
    // 	//cout << sum << " ";
    // }
    // cout << min(sum1 ,  sum2);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(long p){
	int i =0;
	for (int j=0;j<k;j++){
		llong s=0;
		while(s+T[i]<=p){
			s +=T[i];
			i++;
			if (i==n) return n;
		}
	}
	return i;
}


int solve(){
	llong left =0;
	llong right = 100000 * 10000;
	llong mid;
	while(right - left >1 ){
		mid =(left+right)/2;
		int v=check(mid);
		if(v>=n)right=mid;
		else left=mid;
	}
	return right;
}


main(){
	cin >> n >> k;
	for (int i =0; i<n;i++){
	cin >> T[i];
	}
	llong ans=solve();
	cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,m,n) for(int i = m; i < n; i++)
#define rep2(i,m,n) for(int i = m; i <= n; i++)
#define rep3(i,m,n) for(int i = 0; m <= n; i++)


int main(void) {
 int n;
 cin >> n;
  typedef map<int, int> INTMAP;
  INTMAP myMap;
  rep2(i,1,n){
    int k;
    cin >> k;
    myMap.insert(INTMAP::value_type(k, i));
  }
  INTMAP::const_iterator it;
  for (it = myMap.begin(); it != myMap.end(); it++){
    cout << (*it).second << endl;
  }

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  ll n; cin >> n;
  vector<ll> a(5); rep(i, 5) cin >> a[i];

  ll mina = *min_element(ALL(a));
  cout << ((n+mina-1)/mina)+4 << endl;
}

Measured memory_bytes: 256
import heapq
INFTY = 10**4
N,X,Y = map(int,input().split())
G = {1:[2],N:[N-1]}
for i in range(2,N):
    G[i] = [i-1,i+1]
G[X].append(Y)
G[Y].append(X)
dist = [[INFTY for _ in range(N+1)] for _ in range(N+1)]
for s in range(1,N):
    hist = [0 for _ in range(N+1)]
    heap = [(0,s)]
    dist[s][s] = 0
    hist[s] = 1
    while heap:
        d,x = heapq.heappop(heap)
        if d>dist[s][x]:continue
        hist[x] = 1
        for y in G[x]:
            if hist[y]==0 and dist[s][y]>d+1:
                dist[s][y] = d+1
                heapq.heappush(heap,(d+1,y))
C = {k:0 for k in range(1,N)}
for i in range(1,N):
    for j in range(i+1,N+1):
        C[dist[i][j]] += 1
for k in range(1,N):
    print(C[k])

Measured memory_bytes: 95580
N=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=sum(a)

for i in range(N):
    a[i]-=b[i]

    if  a[i]<=0:
        a[i+1]+=a[i]
        if a[i+1]<=0:
            a[i+1]=0
        a[i]=0

print(c-sum(a))

Measured memory_bytes: 18624
#include <stdio.h>
#define rep(i,l,r,d) for(int i=(l);i<(r);i+=(d))
int main(void){
    int a, b, ANS=0;
    scanf("%d %d", &a, &b);
    rep(i, 1, b-a, 1){
        ANS += i;
    }
    printf("%d\n", ANS-a);
    return 0;
}


Measured memory_bytes: 128
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: [Int] -> Int -> Int -> Int
calc [] s c
  | s == 1 = -1
  | otherwise = c
calc (a : as) s c
  | a == s = calc as (s + 1) c
  | otherwise = calc as s (c + 1)

main = do
  n <- getInt
  as <- getIntList
  print $ calc as 1 0


Measured memory_bytes: 4348
//#include "bits/stdc++.h"
//using namespace std;
#include <stdio.h>
#include <assert.h>

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

bool calc(int depth, char *abcd, char ope) {

}

char ope[2] = {'+', '-'};



int main() {
  char abcd[4+1]; scanf("%4s", abcd);

  char p[8][4];
  int idx{0};
  for (int i{0}; i < 2; ++i) {
    for (int j{0}; j < 2; ++j) {
      for (int k{0}; k < 2; ++k) {
          p[idx][1] = ope[i];
          p[idx][2] = ope[j];
          p[idx][3] = ope[k];
          ++idx;
      }
    }
  }

  for (int i{0}; i < 8; ++i) {
    int ans = abcd[0] & 0xF;
    for (int j{1}; j < 4; ++j) {
      switch (p[i][j]) {
        case '+': ans += abcd[j] & 0xF; break;
        case '-': ans -= abcd[j] & 0xF; break;
      }
    }
    if (ans == 7) {
      printf("%c", abcd[0]);
      for (int j{1}; j < 4; ++j) {
        printf("%c", p[i][j]);
        printf("%c", abcd[j]);
      }
      printf("=7\n");
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 128
def main():
    from queue import deque

    K = int(input())
    q = deque()
    for i in range(1, 10):
        q.append(i)
    for i in range(K - 1):
        s = q.popleft()
        for j in range(-1, 2):
            add = (s % 10) + j
            if add >= 0 and add <= 9:
                q.append(s * 10 + add)
    print(q[0])


main()


Measured memory_bytes: 19812
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b,c = list(map(int,input().split(" ")))
a,b,c = list(input().split())
#string = input()

if a[-1] == b[0] and b[-1] == c[0]:
  print("YES")
else:
  print("NO")

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  ll ai = 0;
  for (int i = 0; i <= b; i++) {
    ai = (ai + a) % b;
    if (ai == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    map<char, ll> mp;
    string s;
    cin >> s;
    rep(i, n) mp[s[i]]++;
    ll ans = 1;
    for (auto & tmp : mp) {
        ans *= (tmp.second + 1);
        ans %= mod;
    }
    cout << (ans - 1 + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
int main(){
    int m,n,i,j,k;
        long int K;
        int a,b,c,d;
        char tmp;
        int **I,**O,**J;
        int tmp1,tmp2,tmp3;
        
        
        I=(int **)malloc(sizeof(int *)*1024);
        for(i=0;i<1024;i++){
            I[i]=(int *)malloc(sizeof(int)*1024);
        }
        O=(int **)malloc(sizeof(int *)*1024);
        for(i=0;i<1024;i++){
            O[i]=(int *)malloc(sizeof(int)*1024);
        }
        J=(int **)malloc(sizeof(int *)*1024);
        for(i=0;i<1024;i++){
            J[i]=(int *)malloc(sizeof(int)*1024);
        }
        scanf("%d %d\n%ld\n",&m,&n,&K);
        //for(i=0;i<m;i++){
        //      gets(map[i]);
                //printf("%s\n",&map[i]);
        //}
        //printf("%c\n",map[0][3]);
        for(i=1;i<=m;i++){
                for(j=1;j<=n;j++){
            scanf("%c",&tmp);
            if(tmp=='\n') scanf("%c",&tmp);
            if(i==1&&j==1){
                
            }
            else if(i==1){
                J[i][j]=J[i][j-1];
                O[i][j]=O[i][j-1];
                I[i][j]=I[i][j-1];
            }
            else if(j==1){
                J[i][j]=J[i-1][j];
                O[i][j]=O[i-1][1];
                I[i][j]=I[i-1][1];
            }
            else{
                                J[i][j]=J[i-1][j]+J[i][j-1]-J[i-1][j-1];
                                O[i][j]=O[i-1][j]+O[i][j-1]-O[i-1][j-1];
                                I[i][j]=I[i-1][j]+I[i][j-1]-I[i-1][j-1];
            }
                                if(tmp=='J'){
                                        //printf("j\n");
                                        J[i][j]+=1;
                    //printf("%d:%d J%d\n",i,j,J[i][j]);
                                }
                                else if(tmp=='O'){
                                        O[i][j]+=1;
                    //printf("%d:%d O%d\n",i,j,O[i][j]);
                                }
                                else if(tmp=='I'){
                                        I[i][j]+=1;
                    //printf("%d:%d I%d\n",i,j,I[i][j]);
                                }
                }
        }
    scanf("%c",&tmp);
        for(i=0;i<K;i++){
                scanf("%d %d %d %d\n",&a,&b,&c,&d);
                tmp1 = J[c][d]-J[c][b-1]-J[a-1][d]+J[a-1][b-1];
                printf("%d ",tmp1);
                tmp2 = O[c][d]-O[c][b-1]-O[a-1][d]+O[a-1][b-1];
                printf("%d ",tmp2);
                //tmp3 = (c-a+1)*(d-b+1)-tmp1-tmp2;
                tmp3 = I[c][d]-I[c][b-1]-I[a-1][d]+I[a-1][b-1];
                printf("%d\n",tmp3);
        }
        return 0;
}

Measured memory_bytes: 13372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1e9+7;
int main()
{
	ll n,val,i,j,k,c,s=0;
	string ss;
	cin>>n;
	s=s+(n/500)*1000;
	n=n%500;
	s=s+(n/5)*5;
	cout<<s;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s,t; cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        s[i] = 'x';
    }
    cout << s << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

static unordered_map<int64_t, int64_t> memo;
int64_t solve(int64_t n, int64_t a, int64_t b, int64_t c, int64_t d)
{
	if (n == 0) return 0;
	if (n == 1) return d;

	auto it = memo.find(n);
	if (it != memo.end()) {
		return it->second;
	}

	int64_t ans = INT64_MAX;
	if (n <= INT64_MAX / d) {
		ans = n * d;
	}

	if (n % 2 == 0) {
		ans = min(ans, solve(n/2, a, b, c, d) + a);
	}
	else {
		ans = min(ans, solve((n + 1) / 2, a, b, c, d) + a + d);
		ans = min(ans, solve((n - 1) / 2, a, b, c, d) + a + d);
	}
	if (n % 3 == 0) {
		ans = min(ans, solve(n / 3, a, b, c, d) + b);
	}
	else {
		int64_t r = n % 3;
		ans = min(ans, solve((n - r) / 3, a, b, c, d) + b + r * d);
		ans = min(ans, solve((n + 3 - r) / 3, a, b, c, d) + b + (3 - r) * d);
	}
	if (n % 5 == 0) {
		ans = min(ans, solve(n / 5, a, b, c, d) + c);
	}
	else {
		int64_t r = n % 5;
		ans = min(ans, solve((n - r) / 5, a, b, c, d) + c + r * d);
		ans = min(ans, solve((n + 5 - r) / 5, a, b, c, d) + c + (5 - r) * d);
	}

	memo.insert({ n, ans });

	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int repeat; cin >> repeat;
	REP(repeat) {
		memo.clear();
		int64_t n, a, b, c, d; cin >> n >> a >> b >> c >> d;

		int64_t ans = solve(n, a, b, c, d);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4136
#include<iostream>
#include<algorithm>
#include<complex>
using namespace std;
int n;
long long sum[200010],a;
int main(){
	cin>>n>>sum[0];
	for(int i=1;i<n;i++){
		cin>>a;
		sum[i]=sum[i-1]+a;
	}
	long long ans=1145141145141919;
	for(int i=0;i<n-1;i++){
		ans=min(ans,abs(sum[i]-(sum[n-1]-sum[i])));
	}cout<<ans<<endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

#define bp __builtin_popcountll
#define bf __builtin_ffsll

void solve( ll a, ll b, ll v, ll n )
{
	if( bp( v ) + 1 == n ) { cout << b << " "; return; }
	ll x = bf( a ^ b ) - 1;
	v |= 1 << x;
	ll c, cn;
	REP( i, n ) if( !( v & ( 1 << i ) ) )
	{
		c = a ^ ( 1 << i );
		cn = c ^ ( 1 << x );
	}
	solve( a, c, v, n );
	cout << cn << " ";
	solve( cn, b, v, n );
}

int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if( bp(a^b) % 2 == 0 )
	{
		cout << "NO" << endl;
		return 0;
	}
	
	cout << "YES" << endl;
	cout << a << " ";
	solve( a, b, 0, n );
	return 0;
}

Measured memory_bytes: 1024
import * as fs from 'fs';

namespace AtCoder.abc099 {
    class ProgramA {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            const n: number = parseInt(this.args[0], 10);
            if (n<1000){
                console.log('ABC');
            } else {
                console.log('ABD');
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const func = new ProgramA(args)
    func.main();
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  if (A % K == 0 || B % K == 0 || A / K < B / K) {
    cout << "OK";
  } else {
    cout << "NG";
  }
  return 0;  
}

Measured memory_bytes: 3632
sx,sy,tx,ty=map(int,input().split())
R_go='R'*(tx-sx)
L_go='L'*(tx-sx)
U_go='U'*(ty-sy)
D_go='D'*(ty-sy)

cycle1=R_go+U_go+L_go+D_go
cycle2_1="D"+R_go+"R"+"U"+U_go+"L"
cycle2_2="U"+L_go+"L"+"D"+D_go+"R"
print(cycle1+cycle2_1+cycle2_2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<LL> line(N);
	foreach(i, line)cin>>i;
	LL ans = 0;
	LL sum = 0;
	foreach(i, line)sum += max(0LL, i);
	vector<LL> imos(N+1, 0);
	vector<LL> imos2(N+1, 0);
	REP(i, N)imos[i+1]=imos[i] + min(0LL, line[i]);
	REP(i, N)imos2[i+1]=imos2[i] + max(0LL, line[i]);
	for(int i=K;i<=N;++i){
		chmax(ans, sum + imos[i] - imos[i-K]);
		chmax(ans, sum - imos2[i] + imos2[i-K]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    vector<int>V={0,400,800,1200,1600,2000,2400,2800,3200,5000};
    vector<int>Color={0,0,0,0,0,0,0,0,0};
    int n;cin>>n;
    int x;
    rep(i,n){
        cin>>x;
        rep(j,9){
            if(V[j]<=x&&x<V[j+1]){Color[j]++;}
        }
    }
    int count=Color[8];int ans=0;
    rep(i,8){
        if(Color[i]!=0)ans++;
    }
    if(ans==0)cout<<1<<' '<<count<<endl;
    else cout<<ans<<' '<<count+ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    int k;
    cin>>k;
    int n = 0;
    FOR(i,1,k+1){
        if(i%2==0){
            n++;
        }
    }
    cout << n * (k - n) << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author yousack
 */
public class Main {
    static Scanner in = new Scanner(System.in);
        
    public static void main(String[] args) {
        while (true) {
            int W = in.nextInt();
            int H = in.nextInt();

            if (W == 0 && H == 0) {
                break;
            } else {
                char[][] field = new char[H][W];
                int r = 0, c = 0;

                for (int i = 0; i < H; i++) {
                    field[i] = in.next().toCharArray();
                    for (int j = 0; j < W; j++) {
                        if (field[i][j] == '@') {
                            field[i][j] = '.';
                            r = i;
                            c = j;
                        }
                    }
                }
                
                dfs(field, r, c);
            }
        }
    }
    
    public static void dfs(char[][] f, int r, int c) {
        Queue<int[]> queue = new LinkedList<int[]>();
        queue.add(new int[]{r, c});
        int counter = 0;
        int[][] dirArray = new int[][]{{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
        
        while (!queue.isEmpty()) {
            int[] curPos = queue.poll();
            int curR = curPos[0], curC = curPos[1];
            if (f[curR][curC] == '.') {
                counter++;
                f[curR][curC] = '@';
                for (int[] next : dirArray) {
                    if (ok(curR + next[0], curC + next[1], f.length, f[0].length)) {
                        queue.add(new int[]{curR + next[0], curC + next[1]});
                    }
                }
            }
        }

        System.out.println(counter);
    }
    
    public static boolean ok(int posR, int posC, int boundR, int boundC) {
        return 0 <= posR && posR < boundR && 0 <= posC && posC < boundC;         
    }
}

Measured memory_bytes: 32292
#include <iostream>

using namespace std;


int main(int argc, const char *argv[])
{
    int N, a;
    int arr[9] = {};
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> a;
        arr[min(a / 400, 8)]++;
    }

    int ans = 0;
    for (int i = 0; i < 8; ++i)
    {
        if(arr[i] > 0){
            ans++;
        }
    }
    cout << max(ans, 1) << ' ' << ans + arr[8] << endl;
    return 0;
}


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

bool dp[100010] ; 
int a[1001] ; 

int main() {
	int n , k ; 
	scanf("%d %d" , &n , &k) ; 
	for (int i =0 ; i<n ; ++i)
		scanf("%d" , &a[i]) ; 
		
	for (int i =0 ; i<=k ; ++i){
		for(int j =0 ; j<n ; ++j) {
			if (i >= a[j] && !dp[i-a[j]])
				dp[i] = 1 ; 
		}
	}
	if (dp[k])
		puts("First");
	else 
		puts("Second") ; 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/**************************contemporary declaration & definitions**************************/

/**************************define functions**************************/

/**************************main function below**************************/
int main(void) {

	int N; cin >> N;
	string S; cin >> S;

	vector<ll> C('z' - 'a' + 1, 1);
	for (int i = 0; i < S.size(); i++) {
		C[S[i] - 'a']++;
	}
	ll ans = 1;
	for (int i = 0; i < 'z' - 'a'+1; i++) {
		ans *= C[i];
		ans %= mod;
	}
	if (ans == 0) {
		cout << 1000000006 << endl;
	}
	else {
		cout << ans - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 512
a = input()
iff3 = a[2]
iff4 = a[3]
iff5 = a[4]
iff6 = a[5]
if iff3 == iff4 :
    if iff5 == iff6 :
        print("Yes")
    else :
        print("No")
else :
    print("No")

Measured memory_bytes: 9052