akhauriyash/Code-Regression huggingface dataset:
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	string C1, C2;
	cin >>C1>>C2;
	
	// 解法
	if (C1[0]==C2[2] & C1[1]==C2[1] &C1[2]==C2[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

string s;
lli n, dp[MAXN][13];

lli f(lli x, lli rem) {
    if (x == n) return (rem == 5);
    if (dp[x][rem] != -1) return dp[x][rem];

    lli ans = 0;
    if (s[x] == '?') {
        for (int i = 0; i <= 9; ++i) {
            ans = (ans + f(x + 1, (rem * 10 + i) % 13)) % MOD;
        }
    } else {
        ans = (ans + f(x + 1, (rem * 10 + (s[x] - '0')) % 13)) % MOD;
    }
    return dp[x][rem] = ans;
}
void solve() {
    cin >> s;
    n = static_cast<lli>(s.length());
    memset(dp, -1, sizeof(dp));
    cout << f(0, 0) << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 16848
# https://atcoder.jp/contests/agc005/tasks/agc005_a

x = input()
ans = len(x)
stack = []
for i in range(len(x)):
    if x[i] == 'S':
        stack.append(x[i])
    elif x[i] == 'T' and stack:
        ans -= 2
        stack.pop()
print(ans)

Measured memory_bytes: 45792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    static IEnumerable<string> GenerateChain(int start, int count)
    {
        foreach(int i in Enumerable.Range(1, count))
        {
            yield return $"{start} {start + i}";
        }
    }
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int c = int.Parse(inputs[2]);
        System.Console.WriteLine(b + Math.Min(b + a + 1, c));
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int N;
long long x,y;
int main(){
    cin>>N;
    cin>>x>>y;N--;
    while(N--){
        int a,b;
        cin>>a>>b;
        x=a*max((x+a-1)/a,(y+b-1)/b);
        y=b*max((x+a-1)/a,(y+b-1)/b);
    }
    cout<<x+y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a, b);
  if (a < c && c < b) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
int cmp(const void *a,const void *b)
{
	return *(int*)b - *(int*)a;
}
 
int main(void)
{
	int n, k, tmp, result = 0;
	int i;

	scanf("%d %d", &n, &k);

	int a[200000] = {};

	i = 0;
	while (i < n)
	{
		scanf("%d", &tmp);
		a[tmp-1]++;
		i++;
	}
	qsort(a, n, sizeof(int), cmp);
	i = 0;
	while (i < k)
	{
		result += a[i];
		i++;
	}
	result = n - result;
	printf("%d\n", result);

	return 0;
}

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

using namespace std;
#define int long long
#define x first
#define y second

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

mt19937 rand1(time(0));
int randlr(int l, int r) {
    return rand1() % (r - l + 1) + l;
}

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

    int n;
    cin >> n;

    if (n & 1) {
        cout << n / 2;
    }

    else {
        cout << (n - 1) / 2;
    }

    return 0;
}




Measured memory_bytes: 256
S = input()
if int(S[:2]) != 0 and int(S[:2]) <= 12:
  if int(S[2:]) != 0 and int(S[2:]) <= 12: print("AMBIGUOUS")
  else:print("MMYY")
else:
  if int(S[2:]) != 0 and int(S[2:]) <= 12: print("YYMM")
  else:print("NA")

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

using namespace std;

int main()
{
    int n, k, ans = 0; cin >> n >> k;
    char c; cin >> c;
    char cur = c;
    bool flag = 1;
    for (int i = 1; i < n; i ++) {
        cin >> c;
        if (flag) {
            if (c != cur && k > 0) {
                ans ++;
                k--;
                flag = 0;
            }
        }
        else {
            if (c != cur) {
                ans ++;
                flag = 1;
            }
        }
        if (c == cur) ans ++;
        cur = c;
    }
    cout << ans << "\n";
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt[n] = {};
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < n; j++) {
            if (a[j] <= b) {
                cnt[j]++;
                break;
            }
        }
    }
    int idx = -1, ma = -1;
    for (int i = 0; i < n; i++) {
        if (cnt[i] > ma) ma = cnt[i], idx = i + 1;
    }
    cout << idx << endl;
}


Measured memory_bytes: 3092
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    cinv(a,n)
    cinv(b,m)
    vll pre_a(n+3),pre_b(m+3);
    pre_a[0]=0;
    pre_b[0]=0;
    FOR(i,1,n+1)
    {
    	pre_a[i]=pre_a[i-1]+a[i-1];
    }
    
    FOR(i,1,m+1)
    {
    	pre_b[i]=pre_b[i-1]+b[i-1];
    }
    
    ll ind=0;
    REV(i,n,0)//start with max index in a and decrease
    {
    	FOR(j,ind,m+1)//increase index of B
    	{
    		if(pre_a[i]+pre_b[j]<=k)
    		{
    			ans=max(ans,i+j);
    		}
    		else{ind=j;break;}
    	}
    	if(ans==n+m){break;}
    }
    
    cout<<ans;
    return 0;
}



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

int main(){
	int x;
  	cin >> x;
  	
  	if(x >= 30) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
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");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
 int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c;
  cin>>c;
  vector<int> d(c),e(c);
  rep(i,c)
    cin>>d[i]>>e[i];
  vector<int> f(100010);
  int k=0;
   rep(i,a){
  f[b[i]]++;
    k+=b[i];
  }
  rep(i,c){
    f[e[i]]+=f[d[i]];
 
    k+=(e[i]-d[i])*f[d[i]];
     f[d[i]]=0;
    out(k);
    }
    
}

Measured memory_bytes: 6508
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=3005;
const int mod=1e9+7;

int dp[N][N];
signed main(){
    FastIO;
    string a,b,ans;
    cin>>a>>b;
    rep(i,0,a.size()-1){
        rep(j,0,b.size()-1){
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            if(a[i]==b[j]) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
        }
    }
    int maxi=dp[a.size()][b.size()];
    repb(i,a.size()-1,0){
        repb(j,b.size()-1,0){
            if(a[i]==b[j] and dp[i+1][j+1]==maxi){
                ans+=a[i];
                maxi--;
                i--;
            }
        }
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
package main
import (
  "fmt"
  "os"
  "bufio"
//  "strings"
  "strconv"
//  "sort"
)

// var rdr = bufio.NewReaderSize(os.Open("input.txt"), 1000000)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func read_line() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func main() {
    // as := make([] int, 5)
    // for i, word := range strings.Split(read_line(), " ") {
    //     as[i], _ = strconv.Atoi(word)
    // }

    strconv.Atoi(read_line())
    S := read_line()

    res := 0
    var prev_c rune
    for _, c := range(S) {
        if prev_c != c {
            res += 1
        }
        prev_c = c
    }

    fmt.Println(res)
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{
  char a,b;
  string str1,str2;
  cin>>a>>b;
  if (a>b) {
    for(int i=0;i<a-48;i++){
      cout<<b;
    }
  }
  else{
    for(int i=0;i<b-48;i++){
      cout<<a;
    }
  }
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
  	int n;
  	std::string s;
  	
  	std::cin >> n;
  	std::cin >> s;
  
  	if (n%2) {
      std::cout << "No" << std::endl;
      return 0;
    }
  
    std::cout << (s.substr(0, n/2) == s.substr(n/2, n/2) ? "Yes" : "No") << std::endl;
  
  	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
	int n;
	scanf("%d", &n);
	int a[MAX];
	rep(i, 0, n) scanf("%d", &a[i]);

	qsort(a, n, sizeof(int), acs);
	int maxx, maxn = a[n-1];
	double mid = (double)maxn / 2.0;
	rep(i, 0, n-1) {
		if (a[i] <= mid && mid < a[i+1]) {
			double fd = mid - (double)a[i];
			double bd = (double)a[i + 1] - mid;
			if (fd > bd) maxx = a[i+1];
			else maxx = a[i];
		}
	}
	printf("%d %d\n", maxn, maxx);
  return 0;
}


Measured memory_bytes: 892
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [0]
res, p = 0, 0
for i in range(N+1):
  pp = B[i]+p
  res += min(A[i], pp)
  p = max(min(pp-A[i], B[i]), 0)
print(res)


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

int N, K;

int main(){
  
  cin >> N >> K;
  long long mul = N / K;
  long long hmul = (N + K/2) / K;
  
  long long ans = mul * mul * mul;
  if(K % 2 == 0){
    ans += hmul * hmul * hmul;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int collatz(int n) {
    if (n % 2 == 0)
        return n / 2;
    else
        return 3 * n + 1;
}

int main() {
    fastIO;

    int n;
    cin >> n;

    map<int, int> mp;
    int idx = 1;

    while (true) {
        if (mp.find(n) != mp.end()) {
            cout << idx << endl;
            return 0;
        } else {
            mp[n] = idx++;
        }
        n = collatz(n);
    }
}


Measured memory_bytes: 3668
l,r = map(int,input().split())
if r-l>=2019:
  print(0)
  exit()
l = l%2019
r = r%2019
ans = 2018
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = min(ans,i*j%2019)
print(ans)

Measured memory_bytes: 3060
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = 0
b = 0
for i in range(k):
    a += p[i]
    b += p[i]
for i in range(n - k):
    a += p[i + k]
    a -= p[i]
    if b < a:
        b = a
    
print((b + k) / 2)
    

Measured memory_bytes: 25060
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    
    if(x < a){
      System.out.println(0);
    }
    else if(x >= a){
      System.out.println(10);
    }
  }
}

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

int main() {
    int n,k,i,ans=0;
    cin >> n >> k;
    while(n!=0 || k!=0){
        int a,sum[1000000],S;
        sum[0]=0;
    
        for(i=0;i<n;++i){
            cin >> a;
            sum[i+1] = sum[i] + a;
        }
    
        for(i=0;i<n-k;++i){
            S=sum[i+k]-sum[i];
            ans = max(ans,S);
        }
    
        cout << ans << endl;
        cin >> n >> k;
    }
}



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

using namespace std;

int main(void) {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector< pair<int,int> > A(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i].first;
    }
    for(int i=0; i<N+2; i++) {
        A[i].second = i;
    }

    sort(A.begin(), A.end());

    int ans = numeric_limits<int>::max();
    for(int i=2; i<N+2; i++) {
        int q = Q;
        vector<int> tmp;
        int Y = A[i].first;
        for(int j=0; j<N+2; j++) {
            if(A[j].first < Y) {
                tmp.emplace_back(A[j].second);
            }
        }
        sort(tmp.begin(), tmp.end());
        vector<int> diff(tmp.size());
        for(int j=1; j<diff.size(); j++) {
            diff[j] = tmp[j] - tmp[j-1] - 1;
        }
        for(int j=tmp.size(); j<N+2; j++) {
            auto itr = upper_bound(tmp.begin(), tmp.end(), A[j].second);
            int dist = distance(tmp.begin(), itr);
            if(diff[dist] >= K) {
                --diff[dist];
                --q;
            }
            if(q == 0) {
                int X = A[j].first;
                ans = min(ans, X-Y);
                break;
            }
        }
    }

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


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

int main() {
	int N, flag = 0;
	scanf("%d", &N);
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (N == i*j)
			{
				printf("Yes");
				flag = 1;
				break;
			}
		}
		if (flag==1)
		{
			break;
		}
	}
	if (flag == 0)
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,i,j,c=0,ans=0;
	cin>>n;
	f(i,1,n+1){
		c=0;
		if(i%2==0){
			continue;
		}
		f(j,1,i+1){
			if(i%j==0){
				c++;
			}
		}
		if(c==8){
			ans++;
		}
	}
	cout<<ans<<endl;
} 
	

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int n,a[100005],dp[100005];
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   // int n,ans=inf;
   // cin>>n;
   // vector<int>a(n);
   // for(int i=0;i<n;i++)
   // {
   // 	cin>>a[i];
   // }
   cin>>n;
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   	dp[i]=inf;
   }
   multiset<int>s;
   for(int i=n-1;i>=0;i--)
   {
   	auto it = s.lower_bound(a[i]+1);
   	if(it==s.end())
   	{
   		s.insert(a[i]);
   	}
   	else
   	{
   		int p=*it;
   		s.erase(it);
   		s.insert(a[i]);
   	}
   }
   cout<<s.size()<<endl;
}		

Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    vvi x(n),y(n);
    rep(i,n){
        cin>>a[i];
        x[i]=vi(a[i]);
        y[i]=vi(a[i]);
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ans=0;
    rep(mask,1<<n){
        bool f=true;
        rep(i,n){
            if(!((mask>>i)&1))continue;
            rep(j,a[i]){
                int t=(mask>>x[i][j])&1;
                if(t!=y[i][j])f=false;
            }
        }
        if(f)ans=max(ans,(int)__builtin_popcount(mask));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	int R;

	cin >> R;

	if (R < 1200)cout << "ABC" << endl;
	else if (R < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
def check(string):
    return string == string[::-1]
S = input()
N = len(S)
# print(S[:(N-1)//2], S[(N+3)//2-1:])
if check(S) and check(S[:(N-1)//2]) and check(S[(N+3)//2-1:]):
    print("Yes")
else:
    print("No")


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

int main() {
    lint n; cin >> n;
    vector<lint> a(n);
    rep(i,n) cin >> a[i];
    lint ans = 0;
    for (int i=1; i<n; i++) {
        if (a[i-1] > a[i]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
}

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

int main() {
  
  int K, N; cin >> K >> N;
  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  
  int ans = data.at(N-1) - data.at(0);
  for(int i=0; i<N-1; i++){
    int d = (data.at(i) + K) - data.at(i+1);
    if(d < ans){
      ans = d;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,K;

int main(){
    cin>>N>>K;
    out(N-K+1);
}


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

int main(){
  int n,time,sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    sum+=i;
    if(sum>=n){
      time = i;
      break;
    }
  }
  cout<<time<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int mod=1000000007;
char g[1000][1000];
long long  a[1001][1001];
int main(){
	int h,w;
  	scanf("%d%d",&h,&w);
  	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
        	cin>>g[i][j];
        }
    }
    a[h-1][w-1]=1;
  	for(int i=h-1;i>=0;i--){
    	for(int j=w-1;j>=0;j--){
        	if(g[i][j]=='.') a[i][j]+=a[i+1][j]+a[i][j+1];
        	if(a[i][j]>=mod) a[i][j]-=mod;
        }
    }
  	cout<<a[0][0];
  	
}

Measured memory_bytes: 9088
unittest
{
	assert( [ "4 2", "2 5 2 5" ].parse.expand.solve == 12 );
	assert( [ "8 4", "9 1 8 2 7 5 6 4" ].parse.expand.solve == 32 );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// 部分列の美しさを全列挙
	auto cs = new long[ as.length.signed * ( as.length.signed + 1 ) / 2 ];
	auto ci = 0L;
	auto cm = 0L;
	foreach( i; 0L .. as.length )
	{
		auto t = 0L;
		foreach( a; as[ i .. $ ] )
		{
			t += a;
			cs[ ci ] = t;
			ci++;
			cm = max( cm, t );
		}
	}
	
	// 美しさのうち、できるだけ上位bitを立てられるものを選ぶ
	auto ans = 0L;
	for( auto b = 1L << cm.bsr; 0 < b; b >>= 1 )
	{
		// 最上位bitが立っているものを集める
		auto fs = new long[ cs.length ];
		auto fi = 0L;
		foreach( i, c; cs )
		{
			if( ( c & b ) == 0 ) continue;
			fs[ fi ] = c;
			fi++;
		}
		// 最上位bitが立っているものがk個以上なら、それらの中から選ぶ
		if( k <= fi )
		{
			cs = fs[ 0 .. fi ];
			ans |= b;
		}
	}
	return ans;
}


Measured memory_bytes: 11260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll n, a, b; cin >> n >> a >> b; a -= b;
    V<> h(n);
    REP(i,n) cin >> h[i];

    auto f = [&] (ll m){
        V<> u = h;
        ll k = 0;
        ll res = 0;
        REP(i,n) u[i] -= (__builtin_mul_overflow(b, m, &res) ? INF : b * m);
        REP(i,n) if(u[i] > 0){
            k += Roundup_div(u[i],a);
            if(k > m) return false;
        }
        return k <= m;
    };
  
    ll ok = INF, ng = 0;
    while(ok - ng > 1){
        ll mid = (ok+ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';
}

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

int main() {
  int A;
  int B;
  cin >> A >> B;

  if (A == B) {
    cout << A+B << endl;
  }
  else if (A > B) {
    cout << 2*A-1 << endl;
  }
  else if (B > A) {
    cout << 2*B-1 << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  string S = v[0];
  for(int i = 1; i < n; i++){
    S += v[i];
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int count=0,i=0,j=s.size()-1;
	while(i<=j){
	    if(s[i]==s[j]){
	        i++;
	        j--;
	    }
	    else{
	        i++;
	        j--;
	        count++;
	    }
	    }
	    cout<<count<<"\n";

  return 0;  
}

Measured memory_bytes: 256
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

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

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        d1 = random.randint(0,D-1)
        d2 = random.randint(0,D-1)
        if d1 == d2:
            continue
        tmp_d1 = ans[d1]
        tmp_d2 = ans[d2]
        ans[d1] = tmp_d2
        ans[d2] = tmp_d1
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp_d1
            ans[d2] = tmp_d2
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9644
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 998244353;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}

string generate_bstring(ll n)
{
string str;
for(ll i=0;i<n;i++)
{
ll a = rand()%2;
if(a==0)
str += '0';
else
str += '1';
}
	
return str;	
}



void Test(ll n,ll* a)
{
    

}

void solve()
{
	ll n;
	cin>>n;
	string ans;
	ll d=0;
	while(1)
	{
	if(n-pow(26,d+1)>0)
	{
	n -= pow(26,d+1);
	d++;
	}
	else
	{
	break;	
	}	
	}
	// d - cover
	// d+1 ;
	d++;
	// d terms
	ll a[d+3];
	//cout<<"n: "<<" "<<n<<" d:"<<d<<endl;
	n--;
	for(ll i=d;i>=1;i--)
	{
	a[i] = n%26;
	n = n/26;		
	}
	//for(ll i=1;i<=d;i++)
	{
	//cout<<a[i]<<" ";	
	}
	//cout<<endl;
	for(ll i=1;i<=d;i++)
	{
		ll z = a[i];
		z = z+ (ll)'a' ;
		ans += (char)z;	
	}
	
	
	cout<<ans<<endl;
   // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}



signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	}
}


Measured memory_bytes: 4068
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>

using namespace std;

typedef pair<int, int> pii;

int n, m, k;
int amat[5000][5000];
int vtx[5000];
vector< vector<int> > adj(5000);
vector<int> mal;

int solve(){
	
	for(int i=0; i<n; ++i){
		vtx[i] = INT_MAX;
	}
	
	//dijkstra
	for(int s=0; s<k; ++s){
		
		int vtx_tmp[5000];
		
		for(int i=0; i<n; ++i){
			vtx_tmp[i] = INT_MAX;
		}
		
		priority_queue<pii, vector<pii>, greater<pii> > qu;
		qu.push(make_pair(0, mal[s]));
		vtx_tmp[mal[s]]=0;
		
		while(!qu.empty()){

			int now = qu.top().second, nxt;
			qu.pop();

			for(int i=0; i<adj[now].size(); ++i){
				
				nxt = adj[now][i];
					
				if( vtx_tmp[nxt] > vtx_tmp[now] + amat[now][nxt]){
				
					vtx_tmp[nxt] = vtx_tmp[now] + amat[now][nxt];
					qu.push( make_pair(vtx_tmp[nxt], nxt) );
				}

			}
		}

		for(int i=0; i<n; ++i){
			vtx[i] = min(vtx[i], vtx_tmp[i]);
		}
	}

	int ma = -1;

	for(int p=0; p<n; ++p){
		for(int i=0; i<adj[p].size(); ++i){
			
			int q = adj[p][i];
			int gap = ( amat[p][q] + abs(vtx[p]-vtx[q]) +1 )/2;
			// +1 in the denominator is for rounding off to the nearest whole number
			
			ma = max(ma, min(vtx[p], vtx[q]) + gap);
		}
	}

	return ma;
}

int main(){

	cin >> n >> m >> k;

	for(int i=0; i<m; ++i){
		
		int a, b, l;
		cin >> a >> b >> l;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
		amat[a][b] = amat[b][a] = l;
	}

	for(int i=0; i<k; ++i){
		int s;
		cin>>s;
		mal.push_back(--s);
	}

	cout << solve() << endl;

	return 0;
}

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

typedef long long ll;

string s;
ll sum;

void calc(int ind, ll now1, ll now2) {
  int n = s.size();
  if (n == ind) {
    sum += now1 + now2;
    return;
  }

  calc(ind + 1, s.at(ind) - '0', now1 + now2);
  calc(ind + 1, now1 * 10 + (s.at(ind) - '0'), now2);
}


int main() {
  cin >> s;
  calc(0, 0, 0);
  cout << sum / 2ll << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	else if(a==c) cout<<b<<endl;
	else cout<<a<<endl;
	return 0;
}

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

int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	int n, ans=0;
	string s;
	cin>>n>>s;

	int lhs=0, rhs=n-1;
	while(lhs<rhs) {
		if(s[lhs]=='R') ++lhs;
		else if(s[rhs]=='W') --rhs;
		else ++ans,++lhs,--rhs;
	}
	cout<<ans<<"\n";
	return 0;
}



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

using namespace std;

int main(void){

    int n;
    vector<int> a, b;
    long long int sum = 0;

    cin >> n;

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

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

    for(int i = 0;i < n;i++){
        if(a[i] <= b[i]){
            sum += a[i];
            b[i] -= a[i];
            a[i] = 0;

            if(a[i+1] <= b[i]){
                sum += a[i+1];
                b[i] -= a[i+1];
                a[i+1] = 0;
            }else{
                sum += b[i];
                a[i+1] -= b[i];
                
            }
        }else{
            sum += b[i];
            b[i] = 0;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

string s, t;
void run(){
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = m, cnt;
    for(int i = 0; i + m <= n; i++){
        cnt = 0;
        for(int j = i, k = 0; k < m; j++, k++)
            cnt += s[j] != t[k];
        ans = min(ans, cnt);
    }
    DEBUG(ans);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

typedef bitset<13000> bs;

int main(){
    int H,W; cin >> H >> W;
    vector<vector<int>> A(H,vector<int>(W)),B(H,vector<int>(W)),C(H,vector<int>(W,0));
    rep(i,H) rep(j,W) cin >> A[i][j];
    rep(i,H) rep(j,W) cin >> B[i][j];
    rep(i,H) rep(j,W) C[i][j]=abs(A[i][j]-B[i][j]);
    bs dp[H][W];
    rep(i,H) rep(j,W) dp[i][j]=bs(0);
    dp[0][0].set(0);
    rep(i,H){
        rep(j,W){
            bs tmp=dp[i][j],pre=dp[i][j];
            tmp>>=C[i][j];
            dp[i][j]<<=C[i][j];
            dp[i][j]|=tmp;
            rep(k,6500) if (k-C[i][j]<0&&pre.test(k)) dp[i][j].set(C[i][j]-k);
            if (i+1<H) dp[i+1][j]|=dp[i][j];
            if (j+1<W) dp[i][j+1]|=dp[i][j];
        }
    }
    int ans=INF;
    rep(i,13000){
        if (dp[H-1][W-1].test(i)){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10496
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
typedef struct pp{
  char name[100];
  int t;
}P;
  
P Q[LEN+1];
int head, tail, n;
  
void enqueue(P x){
     Q[tail] = x;
     if(tail == LEN - 1){
       tail = 0;
     } else {
       tail++;
     }
}     
  
P dequeue(){
     P tmp = Q[head];
     if(head == LEN - 1){
       head = 0;
     } else {
       head++;
     }
return tmp;
}
  
  
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
   
  tail = n+1;
  head = 1;
  
  while(tail != head){    
    if(Q[head].t > q){
      elaps += q;
      Q[head].t -= q; 
      enqueue(dequeue());
  
    } else {
      elaps += Q[head].t;
      dequeue();
      printf("%s %d\n", Q[head-1].name, elaps);
    }
  }
    
  return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x = x2 - x1, y = y2 - y1;
  cout << x2 - y << " " << y2 + x << " "
       << x1 - y << " " << y1 + x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int n;
Int w[1100], s[1100], v[1100];
Int dp[1100][22000];

int main(){
    cin >> n;
    for(int i = 0;i < n;i++)cin >> w[i] >> s[i] >> v[i];
    vector<int> blocks;
    for(int i = 0;i < n;i++)blocks.push_back(i);
    sort(blocks.begin(), blocks.end(), [&](int x, int y){return s[x] + w[x] < s[y] + w[y];});

    for(int i = 1;i <= n;i++){
        int ind = blocks[i-1];
        for(int j = 0;j < 22000;j++){
            dp[i][j] = dp[i-1][j];
            if(j - w[ind] <= s[ind] && j-w[ind] >= 0){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[ind]] + v[ind]);
            }
        }
    }
    Int ans = 0;
    for(int j = 0;j < 22000;j++){
        ans = max(ans, dp[n][j]);        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 174208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  ll n,k;
  cin>>n>>k;
  vector<ll>v1(n);
  for(ll i=0;i<n;i++){
    cin>>v1[i];
  }
  for(ll j=0;j<n-k;j++){
    if(v1[j]<v1[j+k]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int H, W, N;
    cin >> H >> W >> N;

    int ans;

    int big = max(H, W);
    int small = min(H, W);

    ans = (N + big - 1) / big;
    if (ans > small) {
        ans = small;
        ans += (N - ans * big + small - 1) / small;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  unordered_set<int> s{a, b, c};
  cout << (s.size() == 2 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3672