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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    rep2(i,a*10,(b+1)*10){
        A=i*0.08;
        B=i*0.1;
        if(A==a&&B==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 map <ll,ll> mp;
 map <ll,ll> :: iterator it;
 void primeFactors(ll n) 
{ 
    // Prll the number of 2s that divide n 
    mp[2] = 0;
    mp[n] = 0;
    while (n%2 == 0) 
    { 
        mp[2]+=1; 
        n = n/2; 
    } 
    //cout<<n<<endl;
    // n must be odd at this poll.  So we can skip  
    // one element (Note i = i +2) 
    for (ll i = 3; i*i <= n; i = i+2) 
    { 
        // While i divides n, prll i and divide n 
        if(n%i==0)
            mp[i] = 0;
        while (n%i == 0) 
        {  
            //cout<<i<<endl;
             mp[i]+=1;
             n=n/i;
        } 
    } 
    //cout<<"hello"<<endl;
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2 
    if (n > 2) 
        mp[n]+=1; 
} 
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    primeFactors(p);
    ll ans = 1;
    for(it = mp.begin();it!=mp.end();it++)
    {
        
        if(it->second>=n)
        {
            for(ll j=0;j<it->second/n;j++)
            {
            ans *= it->first;
        }
        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split()))

'''
ans = 1000
for i in range(n - 1):
    x = a[i]
    y = a[i + 1]
    if x < y:
        k = ans // x
        ans %= x
        ans += k * y

print(ans)
'''

dp = [0] * (n + 10)
dp[1] = 1000
for i in range(2, n + 1):
    dp[i] = dp[i - 1]
    for j in range(1, i):
        x = dp[j] // a[j]
        y = dp[j] + (a[i] - a[j]) * x
        dp[i] = max(dp[i], y)

ans = dp[n]
print(ans)


Measured memory_bytes: 9204
#include <stdio.h>
 
int main()
{
  	int cnt;
	int M,D,m,d,df,ds;
  	scanf("%d %d\n", &M, &D);
  	cnt = 0;
  	for(m=4;m<=M;m++){ 
  		for(d=22;d<=D;d++){
     		df = d / 10;
      		ds = d % 10;
      		if (df * ds == m && df >=2 && ds >= 2)
             cnt++;
    	}  
  	}
  	printf("%d\n", cnt);
  	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  ll first_pos, K, D;
  cin >> first_pos >> K >> D;
  if (first_pos < 0) first_pos = (-1)*first_pos;
  ll cnt {first_pos/D};
  ll pr_len {first_pos%D};

  ll ans {};
  if (K < cnt) {
    ans = first_pos -K*D;
  } else {
    cnt = K - cnt;
    cnt %= 2;
    if (cnt == 0) {
      ans = pr_len;
    } else if (cnt == 1) {
      ans = D - pr_len;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3588
arr = [0] * 100100
n,k = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    arr[a] += b
for i in range(100010):
    arr[i + 1] += arr[i]
for i,j in enumerate(arr):
    if j >= k:
        print(i)
        exit()


Measured memory_bytes: 9456
MOD = 10**9+7
N = int(input())
C = list(map(int,input().split()))
C.sort(reverse=True)
nu = pow(2,N-1,MOD)
owt = pow(2,MOD-2,MOD)
A = [nu]*N
hoge = (nu*owt)%MOD
for i in range(1,N):
    A[i] = (A[i-1]+hoge)%MOD
ans = 0
for i in range(N):
    ans += A[i]*C[i]
    ans %= MOD
print((ans*pow(2,N,MOD))%MOD)


Measured memory_bytes: 89164
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;



int ans,n,m,k;

char ch[10][10];

set<int>row,col;

void check()
{
    int cnt=0;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            if (ch[i][j]=='#'&&row.find(i)==row.end()&&col.find(j)==col.end())cnt++;
        }
    }
    if (cnt==k)ans++;
}

void f(int cnt)
{
    if (cnt==n+m)
    {
        check();
        return;
    }
    f(cnt+1);
    if (cnt<n)
    {
        row.insert(cnt);
        f(cnt+1);
        row.erase(cnt);
    }
    else
    {
        col.insert(cnt-n);
        f(cnt+1);
        col.erase(cnt-n);
    }
}

int main()
{
    cin >> n >> m >> k;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            cin >> ch[i][j];
        }
    }
    f(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;cin>>n>>m;
  int Max=1;
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      if(i*n<=m){
        Max=max(Max,i);
      }
      long long a=m/i;
      if(a*n<=m){
        Max=max((long long)Max,a);
      }
    }
  }
  cout<<Max<<endl;
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  int black=0, white=0;
  
  for(int i=0; i<N; i++){
    if(S[i]=='.') white++;
    else black++;
  }
  
  int lb=0,rb=black,lw=0,rw=white;
  int result=lb+rw; //全部black
  for(int i=0; i<N; i++){
    //iまでがwhite,i+1からがblackのとき
    if(S[i]=='.'){
      lw++; rw--;
    }else{
      lb++; rb--;
    }
    result=min(result,lb+rw);
  }
  cout << result << endl;
}

Measured memory_bytes: 640
import math
import fractions
import collections
import itertools
import pprint
N=int(input())
A=list(map(int,input().split()))
plus=[]
minus=[]
cnt=0
for i in range(N):
    plus.append(A[i]+(i+1))
    minus.append(A[i]-(i+1))
c1=collections.Counter(plus)
c2=collections.Counter(minus)
l2=[]

values=list(c2.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c2.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l2.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#print(l2)
for i in range(len(l2)):
    cnt=cnt+l2[i][1]*c1[-l2[i][0]]
print(cnt)

Measured memory_bytes: 157716
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k,ans=0;
  cin >>n >>k;
  int a[n],b[n+1];
  for(int i=0;i<n+1;i++)b[i]=0;
  for(int i=0;i<n;i++){
    cin >>a[i];
    b[a[i]]++;
  }
  sort(b,b+(n+1));
  reverse(b,b+(n+1));
  for(int i=0;i<k;i++)ans+=b[i];
  cout <<n-ans<<endl;
}

Measured memory_bytes: 1792
s = input()
k = int(input())

if len(set(s)) == 1:
    print(len(s)*k//2)
    exit()

l = head = 0
now = s[0]
for i in range(len(s)):
    if s[i] == now:
      head += 1
    else:
        l = i
        break
        
r = tail = 0
now = s[-1]
for i in range(len(s))[::-1]:
    if s[i] == now:
        tail += 1
    else:
        r = i+1
        break

ans = 0
cnt = 0
now = s[l]
for i in range(l,r):
    if s[i] == now:
        cnt += 1
    else:
        ans += cnt//2
        cnt = 1
        now = s[i]
ans += cnt//2
ans *= k

if s[0] == s[-1]:
    ans += (head+tail)//2*(k-1)
    ans += head//2+tail//2
else:
    ans += (head//2+tail//2)*k
print(ans)

Measured memory_bytes: 9172
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int V; // 頂点数
vector<vector<int>> d; //d[i][j] iからjまでのコスト 最初辺がなければINF 同じ点では0

void warshallFloyd(){
    REP(k, V) REP(i, V) REP(j, V)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
    cin >> V;
    d.resize(V, VI(V, INF));
    REP(i, V){
        d[i][i] = 0;
        int u, k; cin >> u >> k;
        REP(j, k){
            int v, c; cin >> v >> c;
            d[u][v] = c;
        }
    }
    warshallFloyd();
    REP(i, V){
        cout << i << " " << d[0][i] << "\n";
    }
    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  int sum_dis = 0;
  vector<int> balls(N);
  for (int i = 0; i < N; i++) {
    cin >> balls.at(i);
    sum_dis += min(balls.at(i), K - balls.at(i));
  }
  cout << 2 * sum_dis << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numCard = sc.nextInt();
		int numGate = sc.nextInt();
		int count[] = new int[numCard + 10];
		for(int i = 0; i < numCard; i ++) {
			count[i] = 0;
		}
		for(int i = 0; i < numGate; i ++) {
			count[sc.nextInt() - 1] ++;
			count[sc.nextInt()] --;
		}
		for(int i = 1; i < numCard; i ++) {
			count[i] += count[i - 1];
		}
		int ans = 0;
		for(int i = 0; i < numCard; i ++) {
			ans += count[i] == numGate ? 1 : 0;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 66972
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    double ans = 0;
    REP(i, n) {
        double a; cin >> a;
        ans += (1/a);
    }
    ans = 1/ans;
    cout << setprecision(12) <<  ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    vector<ll> a(n), b(n), c(n-1);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n-1)cin >> c[i];
    ll ans = 0;
    rep(i,n){
      int temp = a[i]-1;
      ans += b[temp];  
    }
    rep(i,n-1){
        // if(i == n-2)
        if(a[i]+1 == a[i+1])ans += c[a[i]-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N ,K;
    string S;
    cin >> N >> K >> S;
    for(int i = 0;i < N;i++){
        if(i == K -1){
            if(S[K-1] == 'A')cout << 'a' ;
            if(S[K-1] == 'B')cout << 'b' ;
            if(S[K-1] == 'C')cout << 'c' ;
        }
        else cout << S[i] ;
    }
}

Measured memory_bytes: 256
Imports System

Public Class Program

    Public Shared Sub Main()

        '10円玉
        Dim A As Integer = Integer.Parse(Console.ReadLine)
        '2円玉
        Dim B As Integer = Integer.Parse(Console.ReadLine)
        '1円玉
        Dim C As Integer = Integer.Parse(Console.ReadLine)
        '目標
        Dim X As Integer = Integer.Parse(Console.ReadLine) / 50

        Dim cnt As Integer = 0

        For ia As Integer = 0 To A
            For ib As Integer = 0 To B
                For ic As Integer = 0 To C

                    If ia * 10 + ib * 2 + ic = X Then
                        cnt += 1
                    End If

                Next
            Next
        Next

        Console.WriteLine(cnt)

    End Sub
End Class


Measured memory_bytes: 13140
#include <bits/stdc++.h>
    using namespace std;
    int main(){
      long long int n, k, i, j, d[1005], a[1005], ans[1005], total=0;
      scanf("%lld%lld", &n, &k);
      for(i=1; i<=k; i++){
        scanf("%lld", &d[i]);
        for(j=1; j<=d[i]; j++){
          scanf("%lld", &a[j]);
          ans[a[j]]=1;
        }
      }
      for(i=1; i<=n; i++){
        if(ans[i] != 1) total++;
      }
      printf("%lld", total);
    }

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll dp[60][2];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, p, x;
  cin >> n >> p;
  // ll n, m, k;
  // cin >> n >> m >> k;
  dp[0][0] = 1;
  fi(0, n) {
    cin >> x;
    if(x % 2) {
      dp[i + 1][0] = dp[i][0] + dp[i][1];
      dp[i + 1][1] = dp[i][0] + dp[i][1];
    }
    else {
      dp[i + 1][0] = dp[i][0] * 2;
      dp[i + 1][1] = dp[i][1] * 2;
    }
  }
  ans = dp[n][p];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        int a1a2 = Math.abs(a1 - a2);
        int a1a3 = Math.abs(a1 - a3);
        int a2a3 = Math.abs(a2 - a3);

        if (a1a2 >= a1a3 && a1a2 >= a2a3)
            System.out.println(a1a3 + a2a3);
        else if (a1a3 >= a2a3 && a1a3 >= a1a2) {
            System.out.println(a2a3 + a1a2);
        } else
            System.out.println(a1a2 + a1a3);
    }
}


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

using namespace std;

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

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

string s;
int cnt[26];
bool ok(string s) {
    int n = s.size();
    auto s1 = s.substr(0, n / 2);
    auto s2 = s.substr(n / 2 + n % 2, n / 2);
    reverse(all(s2));
    return s1 == s2;
}
bool ok2(int a[26]) {
    bool f = true;
    rep(i, 26) f &= a[i] % 2 == 0;
    return f;
}
int main() {
    cin >> s;
    if (ok(s)) {
        cout << "0" << endl;
        return 0;
    }
    string s2;
    rep(i, s.size()) if (s[i] != 'x') s2 += s[i];
    if (!ok(s2)) {
        cout << "-1" << endl;
        return 0;
    }
    vector<int> v;
    v.push_back(-1);
    rep(i, s.size()) if (s[i] != 'x') v.push_back(i);
    v.push_back(s.size());

    int N = v.size();
    vector<int> v2;
    rep(i, N - 1) v2.push_back(v[i + 1] - v[i] - 1);
    int M = v2.size();

    int ans = 0;
    rep(i, M / 2) { ans += abs(v2[i] - v2[M - i - 1]); }

    cout << abs(ans) << endl;

    return 0;
}


Measured memory_bytes: 1468
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int b[5]={5,7,5,7,7};
  while(1){
    int n,a[41]={};
    int count=0,ans=0,j=0,c=0;
    string str;
    cin>>n;
    if(n==0)break;
 
    for(int i=0;i<n;i++){
      cin>>str;
      a[i]=str.size();
    }
 
    for(int i=0;i<n;i++){
      c+=a[i];
      count++;
      if(c==b[j]){
    j++;
    c=0;
      }
      else if(c>b[j]){
    i-=count-1;
    j=0;
    c=0;
    count=0;
       }
      if(j>4){
    ans=i-(count-1);
    break;
      }
    }
 
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define ll long long int 
const int mod = 1e9+7;
using namespace std;

int dp[20001];

int main(){
  
  ll n;
  cin>>n;
  
  ll dp[2005] = {0};
	dp[0] = 1;
	
	for(int i = 3 ; i <= n ; i++){
       for(int j = i-3; j >= 0 ; j--){
           (dp[i]+= dp[j])%= mod ;
       }
    }
	
	cout << dp[n] << '\n';
  
  
 return 0; 
}

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

int main() {
  ll N;
  cin >> N;
  
  int x = sqrt(N);
  
  for (int i = x; i >= 1; i--) {
    if (N % i == 0) {
      cout << N / i + i - 2 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input()) 
s = input().split()

cnt1 = 0
cnt2 = 0
for i in range(N):
    if int(s[i]) % 2 == 0:
        cnt1 += 1
    if int(s[i]) % 2 == 0 and (int(s[i]) % 3 == 0 or int(s[i]) % 5 == 0):
        cnt2 += 1

if cnt1 == cnt2:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int K=in(),S=in();
	int num = 0;
	for(int X=0;X<=K;X++){
		for(int Y=0;Y<=K;Y++){
			int Z = S-X-Y;
			if(Z>=0 && Z<=K) num++;
		}
	}
	
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
s = input()
r = ['SS', 'SW', 'WS', 'WW']
flag = [False, False]
for _i in range(4):
    for _j in range(1, N-1):
        if (s[_j] == 'o' and r[_i][_j] == 'S') or (s[_j] == 'x' and r[_i][_j] == 'W'):
            r[_i] += r[_i][_j-1]
        else:
            if r[_i][_j] == 'W':
                if r[_i][_j-1] == 'S':
                    r[_i] += 'W'
                else:
                    r[_i] += 'S'
            if r[_i][_j] == 'S':
                if r[_i][_j-1] == 'W':
                    r[_i] += 'S'
                else:
                    r[_i] += 'W'
    if (s[N-1] == 'o' and r[_i][N-1] == 'S') or (s[N-1] == 'x' and r[_i][N-1] == 'W'):
        if r[_i][N-2] == r[_i][0]:
            flag[0] = True
    else:
        if r[_i][N-2] != r[_i][0]:
            flag[0] = True
    if flag[0]:
            if (s[0] == 'o' and r[_i][0] == 'S') or (s[0] == 'x' and r[_i][0] == 'W'):
                if r[_i][N-1] == r[_i][1]:
                    flag[1] = True
            else:
                if r[_i][N-1] != r[_i][1]:
                    flag[1] = True
    if flag[0] and flag[1]:
        print(r[_i])
        break
    else:
        flag = [False, False]
if not(flag[0]) and not(flag[1]):
    print(-1)

Measured memory_bytes: 3956
#include<stdio.h>
#include<string.h>
#include<string>
#include<queue>
#include<iostream>
using namespace std;
int my_strcmp(char *a,char *b);
int main()
{
    int n,i,j,m,n1,m1;
    char s[1100][1100],t[1100];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=0;i<n;i++)
        {
            scanf("%s",s[i]);
        }
        for(i=0; i<n-1; i++)
        {
            for(j=i+1; j<n; j++)
            {
                if(my_strcmp(s[i],s[j])<0)
                {
                    strcpy(t,s[i]);
                    strcpy(s[i],s[j]);
                    strcpy(s[j],t);
                }
            }
        }
        for(i=0; i<n; i++)
            printf("%s",s[i]);
        printf("\n");
    }
    return 0;
}
int my_strcmp(char *a,char *b)
{
    char a0[310],b0[310];
    int i,len_a,len_b;
    len_a=strlen(a);
    len_b=strlen(b);
    for(i=0;a[i];i++)
    {
        a0[i]=a[i];
        b0[i+len_b]=a[i];
    }
     for(i=0;b[i];i++)
    {
        b0[i]=b[i];
        a0[i+len_a]=b[i];
    }
    a0[len_a+len_b]='\0';
    b0[len_a+len_b]='\0';
    if(strcmp(a0,b0)>0)
    {
        return -1;
    }
    else return 0;

}

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

int main( void )
{
	char tcard[101];
	char hcard[101];
	int i, n, cmp, tpoint = 0, hpoint = 0;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s %s", tcard, hcard);
		
		cmp = strcmp(tcard, hcard);
		
		if(cmp > 0){
			tpoint += 3;
		} else if(cmp < 0){
			hpoint += 3;
		} else {
			tpoint++;
			hpoint++;
		}
	}
	
	printf("%d %d\n", tpoint, hpoint);
	
	return 0;
}

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

using namespace std;

const int MAXN = 1E5;
vector<int> adjList[MAXN + 1];
int dp[MAXN + 1];
bool visited[MAXN + 1];

int dfs(int v)
{
    for (int adj : adjList[v])
    {
        if (visited[adj])
            dp[v] = max(dp[v], 1 + dp[adj]);
        else
            dp[v] = max(dp[v], 1 + dfs(adj));
    }
    visited[v] = true;
    return dp[v];
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        adjList[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
            ans = max(ans, dfs(i));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n, m, l;
	int A[100][100], B[100][100];
	long long int C[100][100];

	for(int i=0; i<100; i++) {
		for(int j=0; j<100; j++) {
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
		}
	}

	cin >> n >> m >> l;

	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			cin >> A[i][j];
		}
	}

	for(int i=0; i<m; i++) {
		for(int j=0; j<l; j++) {
			cin >> B[i][j];
		}
	}

	for(int i=0; i<n; i++) {
		for(int j=0; j<l; j++) {
			for(int k=0; k<m; k++) {
				C[i][j] += A[i][k]*B[k][j];
			}
		}
	}

	for(int i=0; i<n; i++) {
		for(int j=0; j<l; j++) {
			if(j==l-1) {
				cout << C[i][j] << endl;
			}else{
				cout << C[i][j] << " ";
			}
		}
	}

	return 0;
	
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S;
  cin>>S;
  string ans;
  if(S=="ABC"){
    ans="ARC";
  }
  else{
    ans="ABC";
  }
  cout<<ans<<endl;
}
  
  
    


Measured memory_bytes: 3596
#input
N = int(input())
A = list(map(int, input().split()))

#output
# Python program to find
# maximum XOR subset

# Number of bits to
# represent int
INT_BITS = 64

# Function to return
# maximum XOR subset
# in set[]
def maxSubarrayXOR(set,n):

	# Initialize index of
	# chosen elements
	index = 0

	# Traverse through all
	# bits of integer
	# starting from the most
	# significant bit (MSB)
	for i in range(INT_BITS-1,-1,-1):

		# Initialize index of
		# maximum element and
		# the maximum element
		maxInd = index
		maxEle = -9223372036854775808
		for j in range(index,n):

			# If i'th bit of set[j]
			# is set and set[j] is
			# greater than max so far.
			if ( (set[j] & (1 << i)) != 0
					and set[j] > maxEle ):

				maxEle = set[j]
				maxInd = j

		# If there was no
		# element with i'th
		# bit set, move to
		# smaller i
		if (maxEle == -9223372036854775808):
			continue

		# Put maximum element
		# with i'th bit set
		# at index 'index'
		temp = set[index]
		set[index] = set[maxInd]
		set[maxInd] = temp

		# Update maxInd and
		# increment index
		maxInd = index

		# Do XOR of set[maxIndex]
		# with all numbers having
		# i'th bit as set.
		for j in range(n):

			# XOR set[maxInd] those
			# numbers which have the
			# i'th bit set
			if (j != maxInd and
			(set[j] & (1 << i)) != 0):
				set[j] ^= set[maxInd]

		# Increment index of
		# chosen elements
		index += 1

	# Final result is
	# XOR of all elements
	res = 0
	for i in range(n):
		res ^= set[i]
	return res

B = 0
for a in A:
	B ^= a

A2 = [a&(~B) for a in A]
d = maxSubarrayXOR(A2, N)

print(int(d) + int(B^d))

Measured memory_bytes: 83360
using System;
using System.Linq;
using System.Collections.Generic;
public class Test
{
    public static void Main(string[] vs)
    {
        int n, q;
        {
            var p = Console.ReadLine().Split().Select(sp => int.Parse(sp)).ToArray();
            n = p[0];
            q = p[1];
        }
        var s = new char[] {'B'}.Concat(Console.ReadLine());
        var r0 = s.Zip(s.Skip(1), (c1, c2) => c1 == 'A' && c2 == 'C');
        int r1 = 0;
        var r2 = r0.Select(a => { if (a) r1++; return r1; }).ToArray();
        for (int i = 0; i < q; i++)
        {
            var p = Console.ReadLine().Split().Select(sp => int.Parse(sp)).ToArray();
            Console.WriteLine(r2[p[1]-1]- r2[p[0]-1]);
        }
    }
}

Measured memory_bytes: 19772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main() {
    ll n,x,m;cin>>n>>x>>m;
    vi used(m,-1);
    ll ans=0,b;
    rep(i,n){
        if(used[x]!=-1){
            n-=i;b=i-used[x];
            break;
        }
        used[x]=i;
        ans+=x;
        if(i==n-1)dame(ans);
        x=x*x%m;
    }
    used=vi(m,-1);
    ll sum=0;
    rep(i,n){
        if(used[x]!=-1)dame(ans+sum*(n/b));
        if(i<n%b)ans+=x;
        sum+=x;
        used[x]=i;
        x=x*x%m;
    }
    out(ans);
}

Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
    long long A,B,X,C,Y;
    scanf("%lld %lld %lld %lld %lld",&A,&B,&C,&X,&Y);
    int flag=1;
    if(2*C>A+B)
        flag=0;
    long long jiage=0;
    long long jia;
    if(flag==1)
    {
        long long temp;
        temp=min(X,Y);
        jiage=temp*2*C;
        if(X>Y)
        {
            temp=X-Y;
            jia=A;
        }
        else
        {
            temp=Y-X;
            jia=B;
        }
        if(2*C<jia)
            jiage=jiage+temp*2*C;
        else
            jiage=jiage+temp*jia;
    }
    else
    {
        jiage=A*X+Y*B;
    }
    printf("%lld\n",jiage);
    return 0;
}


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

using namespace std;

int main(){
  int k, s;
  cin>>k>>s;
  int cnt=0;

  for(int i=0; i<=k; i++){
    for(int j=0; j<=k; j++){
      if(s-i-j<=k and s-i-j>=0){
        cnt+=1;
      }
    }
  }

  cout<<cnt<<endl;
}


Measured memory_bytes: 3620
def grade(m, f, r):
	if m == -1 or f == -1: return "F"
	if m + f >= 80: return "A"
	if m + f >= 65: return "B"
	if m + f >= 50 : return "C"
	if m + f < 30: return "F"
	if r >= 50: return "C"
	return "D"

while True:
	m,f,r = map(int, input().split())
	if m == -1 and f == -1 and r == -1: 
		break
	print(grade(m,f,r))


Measured memory_bytes: 5600
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
#include <algorithm>
#include <math.h>
using namespace std;


int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char c[6][6];
    char c2[6][6];
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(i,pow(2,h)-1){
        rep(j,pow(2,w)-1){
            //cout << i << j << endl;
            int b2=0;
            rep(i2,h) rep(j2,w) c2[i2][j2]=c[i2][j2];
            rep(a,h){
               if((i >> a) & 0x01){
                    rep(j2,w) c2[a][j2] = 'r';
                }
            }
            rep(b,w){
                if(((j >> b) & 0x01) == 1){
                    rep(i2,w) c2[i2][b] = 'r';
                }
            }
            rep(i2,h) rep(j2,w) {
                if(c2[i2][j2] == '#') b2++;
            }
            if(b2 == k) ans++;

            /*rep(i2,h){
                rep(j2,w)
                {
                    cout << c2[i2][j2];
                }
                cout << endl;
            }
            cout << i << j<< endl;*/
        }
    }
    if(k ==0) ans++;
    if(h == 1 && w == 1){
        if(c[0][0] == '#'){
            if(k == 0 || k == 1) ans = 1;
            else ans = 0;
        }else{
           if(k == 0) ans = 0;
           else ans = 0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 4056
n = gets.to_i
min = last = gets.to_i
max = 0
profits = []
(n-1).times{
  current = gets.to_i
  if (current <= last)
    profits<<(current-last)
    min = current if (current < min)
    max = 0
  end
  max = current if (current > last)
  profits<<(max-min) if (max != 0)
  last = current
}
puts profits.uniq.max

Measured memory_bytes: 24332
def func(n):
    s = str(n)
    L = len(s)
    for i in reversed(range(L-1)):
        x = int(s[i])
        y = int(s[i+1])
        if abs(x-y) > 1:
            buf = 10**(L-(i+1)-1)
            if x > y:
                return int(s[:i] + str(x) + str(x-1)) * buf
            else:
                return (int(s[:i+1]) + 1)*(buf*10)
    return -1

def main():
    k = int(input())
    target = 1
    while k > 0:
        buf = func(target)
        if buf == -1:
            k -= 1
            if k == 0:
                break
            target += 1
        else:
            target = buf
#        print(target)
    print(target)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            puts("OK");
            return 0;
        }
    }

    puts("NG");
    return 0;
}

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

using namespace std;

void fill(vector<vector<int>>& res, const vector<int>& S, int level){
    if(S.size() <= 1) return;
    vector<vector<int>> v(2);
    for(int i=0;i<S.size();i++){
        v[i%2].push_back(S[i]);
    }
    for(auto& a : v[0]){
        for(auto& b : v[1]){
            res[a][b] = res[b][a] = level;
        }
    }
    for(auto s : v) fill(res, s, level+1);
}

vector<vector<int>> solve(int N){
    vector<int> S(N);
    for(int i=0;i<N;i++) S[i] = i;
    vector<vector<int>> res(N, vector<int>(N, 0));
    fill(res, S, 1);
    return res;
}

int main(){
    int N;
    while(cin >> N){
        auto res = solve(N);
        for(int i=0;i<N-1;i++){
            for(int j=i+1;j<N-1;j++){
                cout << res[i][j] << " ";
            }
            cout << res[i].back() << endl;
        }
    }
}

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


int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if(b<a)
    {
        puts("0");
        exit(0);
    }
    if(n==1)
    {
        if(a==b) puts("1");
        else puts("0");
        exit(0);
    }
    long long ans=1LL*(n-1)*b+a-1LL*(n-1)*a-b+1;
    cout<<ans<<endl;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin>>n>>m;//n=prefecture m=city
    vector<vector<P > > v(n);
    REP(i,m){
        int p, y;//
        cin >> p >> y;
        P temp;
        p--;
        temp.first = y; temp.second = i;
        v[p].push_back(temp);
        //v[i].push_back(P(p,y));
    }
    vector<P> ans(m);

    REP(i,n){
        sort(all(v[i]));
        // v[i][j] := i個目の県の中でｊ番目に速く誕生した市の誕生した年と市の番号
        REP(j,v[i].size()){
            ans[v[i][j].second] = P(i + 1,j + 1);
        }
    }   

    REP(i,m){
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    
}

Measured memory_bytes: 7808
#include<iostream>
using namespace std;
 
int main(){
   char a, b, c, d;
   cin >> a >> b >> c >> d;
   if (a == b && c == d && a != c){
     cout << "Yes" << endl;}
   else if (a == c && b == d && a != b){
     cout << "Yes" << endl;}
   else if (a == d && b == c && a != b){
     cout << "Yes" << endl;}
   else {
     cout << "No" << endl;}
  return 0;
   }

Measured memory_bytes: 256
N,T = map(int,input().split())

item=[list(map(int,input().split())) for _ in range(N)]
item = sorted(item,key=lambda x:x[0])

dp=[[0]*(T+1) for _ in range(N+1)]

for i,(a,b) in  enumerate(item,1):
    for t in reversed(range(T)):
        dist=min(T,t+a)
        dp[i][dist] = max(dp[i-1][t]+b,dp[i][dist])
        dp[i][t]=max(dp[i-1][t],dp[i-1][t])
ans=0
for l in dp:
    ans=max(ans,max(l))
print(ans)


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

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

    vector<vector<int>> sent(s.size()+1, vector<int>(t.size()+1,0));

    for(int i = 0; i < s.size(); ++i)
    {
        for(int j = 0; j < t.size(); ++j)
        {
            if(s[i] == t[j])
            {
                if(sent.at(i).at(j)+1 > sent.at(i+1).at(j+1)) sent.at(i+1).at(j+1) = sent.at(i).at(j) + 1;
            }
            if(sent.at(i).at(j+1) > sent.at(i+1).at(j+1)) sent.at(i+1).at(j+1) = sent.at(i).at(j+1);
            if(sent.at(i+1).at(j) > sent.at(i+1).at(j+1)) sent.at(i+1).at(j+1) = sent.at(i+1).at(j);
        }
    }

    string ans = "";
    int ll = sent.at(s.size()).at(t.size());
    int ss = s.size();
    int tt = t.size();
    while(ll > 0)
    {
        if(sent.at(ss).at(tt-1) == ll) --tt;
        else if(sent.at(ss-1).at(tt) == ll) --ss;
        else
        {
            ans = s[ss-1] + ans;
            --tt;
            --ss;
            --ll;
        }
        
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
    //abc103c
    ll n;
    cin>>n;
    vl a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
ll ans=0;
rep(i,n)ans+=a[i];
cout<<ans;
}

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

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
streak = N
neg_max = N
for i in range(N):
    if A[i] <= 0:
        streak += 1
    else:
        neg_max = min(neg_max, streak)
        streak = 0

Anp = np.array(A)
positive_sum = Anp[Anp>0].sum()
answer = - 10 ** 15
if neg_max >= K:
    answer = positive_sum
else:
    neg_sum = 0
    pos_sum = 0
    for i in range(K):
        if A[i] < 0:
            neg_sum += A[i]
        else:
            pos_sum += A[i]
    for i in range(N-K+1):
        temp = positive_sum + neg_sum
        temp2 = positive_sum - pos_sum
        answer = max(answer, temp, temp2)
        if i + K >= N:
            break
        if A[i] > 0:
            pos_sum -= A[i]
        else:
            neg_sum -= A[i]
        if A[i+K] > 0:
            pos_sum += A[i+K]
        else:
            neg_sum += A[i+K]

print(answer)
# 54

Measured memory_bytes: 23188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int X;
  cin >> X;
  X -= 200;
  cout << 9 - X / 200 << endl;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 2e5 + 5;

int n , a[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n , d;
        cin >> n >> d;
        d = 2 * d + 1;
        cout << ( n + d - 1 ) / d << endl;
        return 0;
}










Measured memory_bytes: 256
N=int(input())
table=list(map(int,input().split()))
num=0
I=True
while I:
    for i in range(N):
        if table[i]%2==1:
            I=False
            break
        else:
            table[i]//=2
    if I==False:
        break
    num+=1
print(num)


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

#define MAXN 200010
typedef long long LL;


int main()
{
	//freopen("in.txt", "r", stdin);
	
	int k;
	string s;
	cin >> s >> k;
	vector<string> l;
	
	for (int i = 0; i < s.size(); ++i)
	{
		string tmp; tmp += s[i];
		for (int j = 1; j <= 5; ++j)
		{
			l.push_back(tmp);
			if (i + j >= s.size()) break;
			tmp += s[i + j];
		}
	}
	sort(l.begin(), l.end());
	l.erase(unique(l.begin(), l.end()), l.end());
	cout << l[k - 1] << endl;
	 
	
	
	return 0;
}
 

Measured memory_bytes: 1660
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        aa: [u64;n],
    }
    let res = aa.into_iter().fold(0, |a, x| gcd(a,x));
    println!("{}", res);
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n;
    string s;
    cin >> n >> s;

    ll dp[n + 1][10] = {};
    repm(i, n - 1, 0)
    {
        rep(j, 0, 10)
        {
            dp[i][j] = dp[i + 1][j] + (s[i] - '0' == j);
        }
    }
    /*rep(i, 0, n)
    {
        rep(j, 0, 10) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    vector<vector<bool>> pass(10, vector<bool>(10));
    ll ans = 0;
    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            if (pass[s[i] - '0'][s[j] - '0'])
                continue;
            pass[s[i] - '0'][s[j] - '0'] = true;
            ll cnt = 0;
            rep(k, 0, 10)
            {
                cnt += (dp[j + 1][k] > 0);
            }
            ans += cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688