akhauriyash/Code-Regression huggingface dataset:
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<assert.h>
#include<ctime>
using namespace std;
#define LL long long
const int maxn = 1e5+10;
const int maxm = 1e5+10;
double pi = acos(-1.0);

//struct edge{
//    int from, to, cost, next;
//}e[maxn*2];
//int head[maxn], tot;
//inline void add(int a, int b, int c) {
//    e[tot].from = a, e[tot].to = b, e[tot].cost = c, e[tot].next = head[a], head[a] = tot++;
//}
//namespace fastIO {
//    #define BUF_SIZE 100000
//    //fread -> read
//    bool IOerror = 0;
//    inline char nc() {
//        static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
//        if(p1 == pend) {
//            p1 = buf;
//            pend = buf + fread(buf, 1, BUF_SIZE, stdin);
//            if(pend == p1) {
//                IOerror = 1;
//                return -1;
//            }
//        }
//        return *p1++;
//    }
//    inline bool blank(char ch) {
//        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
//    }
//    inline void read(int &x) {
//        char ch;
//        while(blank(ch = nc()));
//        if(IOerror)
//            return;
//        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
//    }
//    #undef BUF_SIZE
//};
//using namespace fastIO;
int main(){
    long long q, s, h, d, n;
    while(~scanf("%lld%lld%lld%lld%lld", &q, &s, &h, &d, &n)) {
        q <<= 3;
        s <<= 2;
        h <<= 1;
        if(q <= s && q <= h && q <= d) {
            printf("%lld\n", n*q/2);
        }
        else if(s <= q && s <= h && s <= d) {
            printf("%lld\n", n*s/2);
        }
        else if(h <= q && h <= s && h <= d) {
            printf("%lld\n", n*h/2);
        }
        else  {
            long long ans = n/2*d+(n&1)*(min(q/2,min(s/2,h/2)));
            printf("%lld\n", ans);
        }
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)

int main()
{
    //freopen("in.txt","r", stdin);
    //freopen("out.txt","w", stdout);
    cout<<setprecision(20)<<fixed;
    double r;
    cin>>r;
    cout<<2.0*pi*r<<endl;
    return 0;
}


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

#define F first
#define S second
#define PB push_back

vector<long long> a,b;

main()
{
    int ans=0;
    int n,m;
    long long k;
    scanf("%d %d %lld",&n,&m,&k);
    long long af=0;
    for(int i=0;i<n;i++)
    {
        long long ta;
        scanf("%lld",&ta);
        af+=ta;
        a.PB(af);
    }
    long long bf=0;
    for(int i=0;i<m;i++)
    {
        long long tb;
        scanf("%lld",&tb);
        bf+=tb;
        b.PB(bf);
        if(bf>k)
            continue;
        int cal=i+1;
        vector<long long>::iterator it=upper_bound(a.begin(),a.end(),k-bf);
        cal+=it-a.begin();
        ans=max(ans,cal);
    }
    for(int i=0;i<n;i++)
    {
        af=a[i];
        if(af>k)
            continue;
        int cal=i+1;
        vector<long long>::iterator it=upper_bound(b.begin(),b.end(),k-af);
        cal+=it-b.begin();
        ans=max(ans,cal);
    }
    printf("%d\n",ans);
}


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

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int min(int a,int b){
	if(a<b)return a;
	return b;
}

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,N,K,a,b;
  double cnt,k,p=1,I;
  scanf("%d",&N);
  scanf("%d",&K);
  k=(double)K;
  for(i=N;i>0;i--){
    I=(double)(i);
    if(I>=k){
      cnt+=p;
    }else{
      while(1){
        k=k*0.5;
        p=p*0.5;
        if(k<=I){
          cnt+=p;
          break;
        }
      }
    }
  }
  printf("%.12f\n",(double)cnt/(double)(N));
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A;
    for (int i = 0; i < N; i++) {
      char op = '+';
      if (i > 0) cin >> op;
      ll x;
      cin >> x;
      if (op == '-') x = -x;
      A.push_back(x);
    }
    vector<int> minus;
    for (int i = 0; i < N; i++) {
      if (A[i] < 0) minus.push_back(i);
    }
    vector<ll> sum(N + 1, 0), asum(N + 1, 0);
    for (int i = 0; i < N; i++) {
      sum[i + 1] = sum[i] + A[i];
      asum[i + 1] = asum[i] + abs(A[i]);
    }
    ll res = sum[N];
    for (int i = 0; i + 1 < minus.size(); i++) {
      int a = minus[i], b = minus[i + 1];
      res = max(res, sum[a] - (asum[b] - asum[a]) + (asum[N] - asum[b]));
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3444
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (a % b == 0)
		return b;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int n, k;
	cin >> n >> k;
	cout << n - k + 1;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return(0);
}


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

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;
    vector<int> A(N), B(N), C(N-1);

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

    int prev = A[0];
    int good = B[prev];
    for (int i = 1; i < N; i++) {
        int dish = A[i];
        good += B[dish];
        if (prev+1 == dish) {
            good += C[prev];
        }
        prev = dish;
    }

    cout << good << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')


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

int main() {
        int k,a,b,x; cin >> k >> a >> b;
        x = (a+k-1)/k; //cout << x*k << endl;
        if (x*k >= a && x*k <=b) cout << "OK" << endl;
        else cout << "NG" << endl;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10000000)
N,K=map(int, input().split())

class UnionFindTree:
    def __init__(self, n):
        self.nodes = list(range(n+10))
    def find(self, x):
        if self.nodes[x] == x:
            return x
        parent = self.find(self.nodes[x])
        self.nodes[x] = parent
        return parent
    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        self.nodes[a] = self.nodes[b]
    def is_same(self, a, b):
        return self.find(a) == self.find(b)

uf = UnionFindTree(N)
for i in range(K):
    i,j,k=map(int, input().split())
    uf.unite(i,j)

st = set()
for i in range(1,N+1):
    par = uf.find(i)
    st.add(par)

print(len(st))


Measured memory_bytes: 31476
import sys
from collections import deque


   
def resolve():
    
    input = sys.stdin.readline
    N,K=map(int,input().rstrip().split())
    R,S,P=map(int,input().rstrip().split())
    T=list(input().rstrip())

    ans=0
    flag=[0 for _ in range(N)]
    for i in range(N):
        if T[i]==T[i-K] and i>=K and flag[i-K]==True: #足さない条件、K個前が既に制約で足せなくなっていた時は、今回は足せるようになるのでflag管理
            continue
        if T[i]=="r":
            ans+=P
        if T[i]=="s":
            ans+=R
        if T[i]=="p":
            ans+=S
        flag[i]=True
    print(ans)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2
8 7 6
rsrpr"""
        output = """27"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7 1
100 10 1
ssssppr"""
        output = """211"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr"""
        output = """4996"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 64912
<?php
fscanf(STDIN, "%d %d %d", $N, $M, $C);
$lineB = trim(fgets(STDIN));
$B = explode(" ", $lineB);

for ($i = 0; $i < $N; $i++) {
    $line = trim(fgets(STDIN));
    $A[] = explode(" ", $line);
}

$result = 0;
foreach ($A as $array) {
    $total = 0;
    for ($i = 0; $i < $M; $i++) {
        $total = $total + $array[$i] * $B[$i];
    }
    if ($C + $total > 0) {
        $result++;
    }
}

echo $result;

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

#define all(a) a.begin(),a.end()

typedef long long ll;
typedef std::vector<int>vi;
typedef std::vector<string>vs;
typedef std::vector<double>vd;
typedef std::vector<ll>vll;
typedef vector<vi>vvi;
typedef vector<vvi>vvvi;
typedef vector<vll>vvll;
typedef std::pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vpi>vvpi;
int main(){
	int n,k;
	cin>>n>>k;
	int x[n];
	for(int i=0;i<n;i++)cin>>x[i];
	int ans=1e9; 
	for(int i=0;i<n-k+1;i++){
		if(x[i+k-1]<=0){
			ans=min(ans,-x[i]);
		}else if(x[i]>=0){
			ans=min(ans,x[i+k-1]);
		}else{
			int now=x[i+k-1]-x[i]+min(x[i+k-1],-x[i]);
			ans=min(ans,now);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda AB:(AB[0],AB[1]))
ans=0
count=0
for i in range(N):
    count=M-AB[i][1]
    if count>=0:
        ans+=AB[i][0]*AB[i][1]
        M=M-AB[i][1]
    else:
        ans+=AB[i][0]*M
        break
print(ans)

Measured memory_bytes: 35292
def dfs(i, sum, n, s, k):
    # n 個決め終わったら、今までの和 sum が k と等しいかを返す
    if i == n  - 1:
#         print(sum)
        if eval(sum) == k:
            print(sum+"=7")
        return eval(sum) == k
    # + を使う
    if dfs(i + 1, sum + "-" +  s[i+1],n,s,k):
        return True
    
    # - を使う
    if dfs(i + 1, sum + "+" + s[i+1],n,s,k):
        return True
#     print(sum)
    return False

def main():
    s = input()
    n = len(s)
    k = 7

    if dfs(0, s[0], n, s,k):
        pass
    else:
        pass
if __name__ == '__main__':
    main()

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

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll S;
    in1(S);

    vll dp(S + 1, 0);
    dp[0] = 1;

    repse(i, 0, S)
    {
        repse(j, 3, S)
        {
            if (i - j >= 0)
            {
                dp[i] += dp[i - j];
                dp[i] %= MOD;
            }
        }
    }
    
    outl(dp[S]);

    return 0;
}


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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

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

vector<pair<int, int>> G[55];

int main() {

  rep(i, 5) {
    char x;
    rep(j, 4) {
      cin >> x;
      if(x-'0') {
        G[i * 5 + j].emplace_back(i * 5 + j + 1, 2);
        G[i * 5 + j + 1].emplace_back(i * 5 + j, 0);
      }
    }

    if(i == 4) break;

    rep(j, 5) {
      cin >> x;
      if(x-'0') {
        G[i * 5 + j].emplace_back((i + 1) * 5 + j, 3);
        G[(i + 1) * 5 + j].emplace_back(i * 5 + j, 1);
      }
    }
  }

  string const OP = "LURD";

  int y = 0, x = 0, d = 2;

  while(y != 0 || x != 0 || d != 0) {
    int le = -1, st = -1, ri = -1, dw = -1;
    for(auto && e: G[y * 5 + x]) {
      if(e.second == (d + 3) % 4) le = e.second;
      if(e.second == (d + 1) % 4) ri = e.second;
      if(e.second == d) st = e.second;
      if(e.second == (d + 2) % 4) dw = e.second;
    }
    if(le != -1) d = le;
    else if(st != -1) ;
    else if(ri != -1) d = ri;
    else d = dw;
    y += dy[d], x += dx[d];
    cout << OP[d];
  }
  cout << endl;
    
  return 0;
}

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

int main(){ 
  int n, m;
  cin >> n >> m;
  int sum = 0;
  rep(i,m) {
    int a;
    cin >> a;
    sum += a;
  }
  int res = n - sum;
  if (res < 0) cout << -1 << endl;
  else cout << res << endl;
  return 0;
} 

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N), B(N), C(N-1);
  
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  for(int i=0; i<N-1; i++){
    cin >> C.at(i);
  }
  
  // A[i] は 1~N, 配列は0~N-1でずれる
  int ans=B.at(A.at(0)-1);
  
  for(int i=1; i<N; i++){
    ans += (B.at(A.at(i)-1));
    if(A.at(i) == A.at(i-1) + 1){
      ans += C.at(A.at(i-1)-1);
    }
  }
  cout << ans << endl;
   
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<ll, ll>P;
ll inf = 1e9 + 7;
ll h, w;
char a[55][55];
ll d[55][55];
ll dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
ll bfs() {
	queue<P>que;
	rep(i, h) { rep(j, w)d[i][j] = inf; }
	que.push(P(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == h - 1 && p.second == w - 1)break;
		rep(i, 4) {
			ll nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && h > nx && 0 <= ny && w > ny && d[nx][ny] == inf && a[nx][ny] != '#') {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}
signed main() {
	cin >> h >> w;
	rep(i, h) { rep(j, w)cin >> a[i][j]; }
	ll cnt = 0, ans;
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '#')cnt++;
		}
	}
	ans = bfs();
	if (ans == inf)puts("-1");
	else cout << h * w - cnt - ans - 1 << endl;
	ggr
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define ff first
#define oo 1000000000000000005
#define ss second
#define el "\n"
#define maxS 200005
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    // ll t;cin>>t;while(t--)
    {
        ll p, z, n, k, ans = 0;
        cin>>p>>z>>n>>k;
        
        if(k == p+n+z)
            ans = p-n;
        else if(k > p+z)
            ans = p - (k-p-z);
        else if(k == p+z)
            ans = p;
        else if(k >= p)
            ans = p;
        else
            ans = k;
        
//         if(k >= p)
//             ans += p, k -= p;
//         else
//             ans += p - k;
        
//         if(k >= z)
//             k -= z;
//         else
//             k = -1;
        
//         if(k >= n)
//             ans -= n, k -= n;
//         else
//             ans -= (n - k);
        
        cout<<ans<<el;
    }
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int x = 0;
    int maxx = 0;
    rep(i, N){
        if(S[i]=='I') x++;
        else x--;
        maxx = max(x, maxx);
    }
    cout << maxx << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 1000000009;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int t, d; };

int main()
{
	int n, k;
	while (cin >> n && n)
	{
		cin >> k;
		vector<LL> sums(n);
		rep(i, n)
		{
			cin >> sums[i];
			if (i != 0)
				sums[i] += sums[i - 1];
		}
		LL ans = sums[k - 1];
		for (int i = 0; i + k < n; i++)
		{
			ans = max(ans, sums[i + k - 1] - sums[i - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1788
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
V_C = [0]*N
ans = 0
for i in range(N):
    V_C[i] =V[i]-C[i]
for i in range(N):
    if V_C[i] > 0:
        ans += V_C[i]
print(ans)

Measured memory_bytes: 3064
from sys import stdin
import itertools
def main():
    number = int(input())
    num_list = list(map(int, stdin.readline().split()))
    num_list_sum = sum(num_list)
    total = 0
    for i in range(number):
        num_list_sum -= num_list[i]
        total += num_list[i] * num_list_sum
    print(total % (10**9+7))
if __name__ == '__main__':
    main()

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

int main(void)
{
	char s[100 + 1];
	scanf("%s", s);
	int n = strlen(s); // 文字列の長さを得る s
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
 		// 奇数文字目
 			if (s[i] == 'L') {
 				puts("No");
 				return 0;
 			}
			}else {
 				// 偶数文字目
 				if (s[i] == 'R') {
 					puts("No");
 					return 0;
 			}
 		}
 	}

	puts("Yes");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    string ans = "Yes";
    for(int i = n-1; i > 0; i--){
        if(h.at(i-1)-h.at(i) == 1){
            h.at(i-1)--;
        }else if(h.at(i-1)-h.at(i) > 1){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import itertools

N = int(input())
cities = [tuple(map(int, input().split())) for _ in range(N)]

distance = 0
for c in itertools.combinations(range(N), 2):
    c1, c2 = c
    distance += ((cities[c1][0] - cities[c2][0]) ** 2 + (cities[c1][1] - cities[c2][1]) ** 2) **0.5

answer = 2 * distance / N

print(answer)

Measured memory_bytes: 9408
#include <iostream>
#include<algorithm>
using namespace std;
int n,a,rs;
int aa[1000000];
int main()
{
	cin>>n;rs=0;
	for(int i=0;i<n;i++)scanf("%d",&aa[i]);
	sort(aa,aa+n);
	int t1,tt;t1=-1;
	for(int i=0;i<n;i++)
	{
		if(t1==-1){t1=aa[i];tt=1;}
		else if(i<n-1)
		{
			if(t1==aa[i])tt++;
			else{if(tt%2)rs++;t1=aa[i];tt=1;}
		}
		else 
		{
			if(t1==aa[i]){tt++;if(tt%2)rs++;}
			else{if(tt%2)rs++;rs++;}
		}
	}
	cout<<rs;
}


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


int fibonacci(int n) {
    int fib[50];
    fib[0] = fib[1] = 1;
    
    for (int i = 2; i <= n; i++) {
        fib[i] = fib[i-1] + fib[i-2];
    }

    return fib[n];
}

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

    cout << fibonacci(n) <<endl;

    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#define pii pair<int,int>
#define pb push_back
using namespace std;

/* Union Find*/
class UnionFind {
private:
  vector<int> data;  
public:
  UnionFind(int size) : data(size, -1) { }
  bool unionset(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findset(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int n,m;
vector<int> p;
vector<pii> xy;
int main(){
  cin>>n>>m;

  int t,s;
  for(int i=1;i<=n;i++){
    cin>>t;
    p.pb(t);
  }
  UnionFind uf(n+1);
  for(int i=1;i<=m;i++){
    cin>>t>>s;
    xy.pb(pii(t,s));
    uf.unionset(t,s);
  }
  int res=0;
  for(int i=0;i<n;i++){
    if(uf.findset(p[i],i+1)) res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int array[] = new int[5];
		int index = 0;
		int min = 9999;
		for (int i = 0; i < 5; i++) {
			int don = sc.nextInt();
			array[i] = don;
			int firstDigit = don % 10;
			
			if (min > firstDigit && firstDigit != 0) {
				min = firstDigit;
				index = i;
			}
		}
		int ans = 0;
		
		for (int i = 0; i < 5; i++) {
			if(i != index) {
				if(array[i] % 10 != 0) {
					int temp = array[i] / 10;
					temp = temp +1;
					array[i] = temp * 10;
				
				}
				
				if(array[i] < 10) {
					array[i] = 10;
				}
			}
			ans += array[i];	
		}
		
		System.out.println(ans);

	}
}


Measured memory_bytes: 23508
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@k = gets.to_s.split.map{ |v| v.to_i }
    @a = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
  end

  def show(ans)
    (n-k).times do |i|
      puts a[i] < a[i+k] ? "Yes" : "No"
    end
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 33724
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]

    cost = [10**18] * 10
    cost[1] = 0
    q = [(0, 1)]
    while q:
        c, u = heappop(q)
        if c > cost[u]: continue
        for i in range(10):
            if i == u: continue
            if c + C[i][u] < cost[i]:
                cost[i] = cost[u] + C[i][u]
                heappush(q, (cost[i], i))
    
    d = defaultdict(int)
    for _ in range(H):
        A = list(map(int, input().split()))
        for a in A: d[a] += 1
    ans = 0
    for i in range(10): ans += cost[i] * d[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73884
#include<stdio.h>
int main()
{
    long long int i,N,x,y,z;
    scanf("%lld",&N);
    for(i=1; i<=N; i++)
    {
        scanf("%lld %lld %lld",&x,&y,&z);
        if((x*x+y*y==z*z)||(y*y+z*z==x*x)||(z*z+x*x==y*y))
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 576
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		char[] t = sc.nextLine().toCharArray();

		Map<Character, List<Integer>> s_map = new HashMap<>();
		for (int i = 0; i < s.length; i++) {
			s_map.putIfAbsent(s[i], new ArrayList<>());
			s_map.get(s[i]).add(i);
		}

		for (char ti : t) {
			if (!s_map.containsKey(ti)) {
				System.out.println(-1);
				return;
			}
		}

		int s_idx = 0, t_idx = 0, next_idx;
		long ans = 0;
		List<Integer> idx_list;
		while (true) {
			if (t_idx == t.length) break;
			if (s[s_idx] == t[t_idx]) {
				t_idx++;
				s_idx = (s_idx + 1) % s.length;
				ans++;
			}
			else {
				idx_list = s_map.get(t[t_idx]);
				if (s_idx > idx_list.get(idx_list.size() - 1) || s_idx < idx_list.get(0) || idx_list.size() == 1) {
					next_idx = idx_list.get(0);
				}
				else {
					int idx_list_idx = -Collections.binarySearch(idx_list, s_idx);
					if (idx_list_idx > 0 && idx_list_idx <= idx_list.size()) {
						next_idx = idx_list.get(idx_list_idx - 1);
					}
					else if (idx_list_idx == 0) {
						next_idx = 0;
						System.out.printf("%d,%d", s_idx, t_idx);
						System.out.println(Arrays.toString(idx_list.toArray()));
					}
					else {
						next_idx = 0;
					}
				}

				ans += next_idx > s_idx ? next_idx - s_idx : s.length - s_idx + next_idx;
				s_idx = next_idx;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 35408
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    vector<vector<long long> > coordinate(N, vector<long long>(2,0));
    map<pair<long long, long long>, int> pq;

    for(int i=0; i<N; i++){
        long long x,y;
        cin >> x >> y;
        coordinate[i][0]=x;
        coordinate[i][1]=y;
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i==j)continue;
            long long x,y;
            x=coordinate[i][0];
            y=coordinate[i][1];
            pair<long long, long long> key = make_pair(x-coordinate[j][0], y-coordinate[j][1]);
            auto it = pq.find(key);
            if(it==end(pq)){
                pq[key]=1;
            }else{
                pq[key]++;
            }
        }
    }

    pair<long long, long long> ans=make_pair(0,0);
    int max_=0;
    for(auto i = pq.begin(); i!=pq.end(); i++){
        auto key = i->first;
        int value = i->second;
        if(value>max_){
            max_=value;
            ans=key;
        }
    }

    cout << N-max_ << endl;

}

Measured memory_bytes: 384
N, Y = map(int, input().split())
ans = 0
found = False

Y //= 1000

T = 0
for i in range(Y // 10 + 1):
    for j in range((Y - i * 10) // 5 + 1):
        T += 1
        x = Y - i * 10 - j * 5
        if x < 0:
            break
        if i + j + x == N:
            print(i, j, x)
            found = True
            break
    if found:
        break
if not found:
    print("-1 -1 -1")

Measured memory_bytes: 40556
#include <stdio.h>

int main(void)
{
	int a = 0, b = 0, c = 0;
	
	scanf("%d %d %d", &a,&b,&c);
	
	if (a < b && b < c) {
		printf("Yes");
	} else {
		printf("No");
	}
	
	printf("\n");
	
	return 0;
}




Measured memory_bytes: 2100
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
#define MOD 998244353
vector<int> getting;
long long dp[301][90001] = {};
long long dping[301][90001] = {};
int main() {
	int n;
	cin >> n;
	int sum = 0;
	REP(i, n) {
		int a;
		cin >> a;
		sum += a;
		getting.push_back(a);
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int q = 0; q <= 300 * i; ++q) {
			dp[i + 1][q] += 2LL * dp[i][q];
			dp[i + 1][q + getting[i]] += dp[i][q];
			dp[i + 1][q] %= MOD;
			dp[i + 1][q + getting[i]] %= MOD;
		}
	}
	long long ans = 0;
	for (int i = (sum + 1) / 2; i <= 90000; ++i) {
		ans += dp[n][i];
		ans %= MOD;
	}
	ans *= 3LL;
	ans %= MOD;
	if (sum % 2 == 0) {
		dping[0][0] = 1;
		for (int i = 0; i < n; ++i) {
			for (int q = 0; q <= 300 * i; ++q) {
				dping[i + 1][q] += dping[i][q];
				dping[i + 1][q + getting[i]] += dping[i][q];
				dping[i + 1][q] %= MOD;
				dping[i + 1][q + getting[i]] %= MOD;
			}
		}
		ans -= 3LL * dping[n][sum / 2];
		ans += 3LL * MOD;
		ans %= MOD;
	}
	long long geko = 1;
	REP(i, n) {
		geko *= 3LL;
		geko %= MOD;
	}
	geko -= ans;
	geko += MOD;
	geko %= MOD;
	cout << geko << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    int index = 0;
    rep (i, s.size()) {
        if (s[i] == 'W') {
            int tmp = i - index++;
            ans += tmp;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



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

//#define DEBUG
#define int long long
#define INF 1000000000000000000
#define REP(i,n) for(int i=1;i<=n;i++)
int n,m,k;
int a[20002];
int cs[20002][1002];
int sm[20002];

signed main(){
  cin>>n>>m>>k;
  REP(i,n)cin>>a[i];
  REP(i,n){
    int mx=0;
    int mn=INF;
    REP(j,m){
      if(n<i+j-1)continue;
      mx=max(mx,a[i+j-1]);
      mn=min(mn,a[i+j-1]);
      cs[i][j]=k+j*(mx-mn);
    }
  }
  REP(i,n)sm[i]=INF;
  REP(i,n)REP(j,m){
    if(n<i-1+j)continue;
    sm[i-1+j]=min(sm[i-1+j],sm[i-1]+cs[i][j]);
  }
  #ifdef DEBUG
  REP(i,n){
    REP(j,m)cout<<cs[i][j]<<" ";
    cout<<endl;
  }
  REP(i,n)cout<<sm[i]<<" ";
  cout<<endl;
  #endif
  cout<<sm[n]<<endl;
  return 0;
}

Measured memory_bytes: 159012
S = list(input())

patarn = -1

for i in range(1 << 3):
    summation = int(S[0])
    for j in range(3):
        if (i >> j) % 2 == 1:
            summation += int(S[j+1])
        else:
            summation -= int(S[j+1])
    if summation == 7:
        patarn = i

ans_equ = S[0]

for i in range(3):
    if (patarn >> i) % 2 == 1:
        ans_equ += '+' + S[i+1]
    else:
        ans_equ += '-' + S[i+1]

ans_equ += '=7'
print(ans_equ)


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

int main(){
    long long ans=10000000000000;
    long long n,m,x;
    cin>>n>>m>>x;
    long long c[n+1];
    long long a[n+1][m+1];
    for(long long i=1;i<=n;i++){
        for(long long j=0;j<=m;j++){
            if(j == 0 ){
                cin>>c[i];
            }
            else{
                cin>>a[i][j];
            }
        }
    }
    for(long long i=0;i<= (1<<n)-1 ;i++){
        long long this_ans[m+1] = {0};
        long long temp  =0 ;
        for(long long j=0;j<n;j++){
            if( i & (1<<j) ){
                temp += c[j+1];
                for(long long i=1;i<=m;i++){
                    this_ans[i] += a[j+1][i];
                }
            }
        }
        long long flag=1;
        for(long long i=1;i<=m and flag;i++){
            if(this_ans[i] < x ){
                flag=0;
            }
        }
        if(flag){
            ans = min(ans , temp);
        }
    }
    if(ans == 10000000000000)cout<<-1;
    else cout<<ans;
    cout<<endl;
}


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

char s[102];

int hantei_sub(int a,int b)
{

    while(a<b)
    {
        if(s[a] != s[b])
            return -1;
        
        a++;
        b--;
    }

    return 0;
}

int hantei()
{
    int n = strlen(s);

    if(hantei_sub(1-1,n-1) != 0)
        return -1;

    
    if(hantei_sub(1-1,(n-1)/2 -1) != 0)
        return -1;

    if(hantei_sub((n-1)/2+1,n-1) != 0)
        return -1;

    return 0;
}

int main()
{

    scanf("%s",s);

    if(hantei() == 0)
        printf("Yes\n");
    else  
        printf("No\n");
        
        
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {

	int h, m, s;
	int input;
	
	cin >> input;

	h = input / 3600;
	input -= h * 3600;

	m = input / 60;
	input -= m * 60;

	s = input;

	cout << h << ":" << m << ":" << s << endl;

	return 0;

}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
long long l,r;

int min_n = 2018;
cin >> l >> r;
for(long long i =l;i<r;i++){
  for(long long j=i+1;j<=r;j++){
    
    int cc = (i*j) % 2019;
    min_n = min(min_n,cc);
    if(min_n == 0){cout << 0 << endl; return 0;}
  }
  
}
cout << min_n << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	
	limit := int(math.Floor(math.Sqrt(float64(m))))
	div := []int{}
	for i:=1; i <= limit; i++ {
		if m % i ==0{
			div = append(div,i)
			div = append(div,m/i)
		}
	}

	sort.Sort(sort.IntSlice(div))
	for i := len(div)-1; i >= 0; i -= 1{
		if m/div[i] >= n {
			fmt.Println(div[i])
			return
		}
	}
}


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

 int n;
 

int solve(int a[])
{
  int dp[n];
	dp[0] = 0;
  	dp[1] = dp[0]+abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  } 
  return dp[n-1];
}
  

int main()
{
  cin>>n;
 int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  
  cout<<solve(a)<<endl;
  return 0;
}
  

Measured memory_bytes: 1024
def righttriangle(a, b, c):
	if c * c == a * a + b * b:
		return 'YES'
	else:
		return 'NO'

n = int(raw_input())

for i in range(0, n):
	inpt = map(int, raw_input().split())
	inpt.sort()
	
	print righttriangle(inpt[0], inpt[1], inpt[2])
	

Measured memory_bytes: 6236
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <iomanip>
#define REP(i,n,s) for (int i = (s);i < (int)( n ); i++)
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
using namespace std;

ll i,j;
const int MOD = 1000000000 + 7;

int main(){
    int n;
    string ans = "No";
   
    cin>>n;
    int d[n][2];
    int cnt=0;
    REP(i,n,0){
        cin>>d[i][0]>>d[i][1];
        if(d[i][0]==d[i][1]){
            cnt++;
        }
        else{
            cnt=0;
        }
        if(cnt==3){
            ans="Yes";
        }
    }


    
    cout<<ans<<'\n';
    return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1)/2 << endl;
    

    return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python3
n, k, q = map(int, input().split())
p = [0] * n
for _ in range(q):
    a = int(input()) - 1
    p[a] += 1
for i in range(n):
    ans = (p[i] + k - q > 0)
    print(['No', 'Yes'][ans])


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

int main() {
    int N, K, R, S, P, ans = 0;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    for (int i = 0; i < N; i++) {
        if (i < K || T[i-K] != T[i]) {
            if (T[i] == 'r') ans += P;
            if (T[i] == 's') ans += R;
            if (T[i] == 'p') ans += S;
        } else {
            T[i] = '-';
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
一番小さいの、大きいのをとったときの中央の幅*2とか

100-10000
9901
10-100
9991

1       1000000
 10    10000
   100
   
  1     10
     3      15
       4        20
3-15全部取れる
Aの中央値~Bの中央値まで全部とれるって？
*/

int main(){
  ll N; cin>>N;
  vector<ll>A(N,0),B(N,0);
  for(ll i=0; i<N; i++) cin>>A[i]>>B[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ll n1=N/2;
  ll n2=n1-1;
  ll low,high,ans;
  if(N%2==1){
    low=A[n1];
    high=B[n1];
    ans=high-low+1;
  }
  else{
    low=A[n1]+A[n2];
    high=B[n1]+B[n2];
    ans=high-low+1;
  }  
  cout<<ans<<endl;
}

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

int a[250];
int ans;
int cmp(int a,int b){
	return a>b;
}

int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin >> k;
	cout << "50\n";
	rep (i, 50) {
		ll tmp = k - 51LL * (k / 50LL);
		if (i < k % 50LL) cout << max(0LL, 100LL - tmp) << (i != 49 ? ' ' : '\n');
		else cout << max(0LL, 49 - tmp) << (i != 49 ? ' ' : '\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

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

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

	vector<int> maxi(n,0);
	for(int i = n - 1; i >= 0; i--){
		if(i == n - 1) maxi[i] = a[i];
		else maxi[i] = max(maxi[i + 1], a[i]);
	}

	vector<int> result(n);
	rep(i,n - 1){
		result[i] = maxi[i + 1] - a[i];
	}

	int max_res = *max_element(all(result));
	int ans = 0;
	for_each(all(result), [&](int a){ if(max_res == a) ans++; });
	cout << ans << endl;
}


Measured memory_bytes: 1408
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nq = Console.ReadLine().Split().Select(int.Parse).ToList();
        var s = Console.ReadLine();
        int[] ruiseki = new int[nq[0]];
        for (int i = 0; i < s.Length - 1; i++) ruiseki[i + 1] = ruiseki[i] + (s[i] == 'A' && s[i + 1] == 'C' ? 1 : 0);
        for (int i = 0; i < nq[1]; i++)
        {
            var lr = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToList();
            Console.WriteLine(ruiseki[lr[1]] - ruiseki[lr[0]]);
        }
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T IdentityElement;
    T[] Data;
    Func<T, T, T> Merge;
    int LeafCount;

    public SegmentTree(int size, T identityElement, Func<T, T, T> merge) : this(Enumerable.Repeat(identityElement, size).ToArray(), identityElement, merge) { }

    public SegmentTree(T[] elems, T identityElement, Func<T, T, T> merge)
    {
        Size = elems.Length;
        Merge = merge;
        IdentityElement = identityElement;
        LeafCount = 1;
        while (LeafCount < elems.Length) LeafCount <<= 1;

        Data = new T[LeafCount * 2];
        elems.CopyTo(Data, LeafCount);
        for (int i = LeafCount - 1; i >= 1; i--) Data[i] = Merge(Data[i * 2], Data[i * 2 + 1]);
    }

    public T this[int index]
    {
        get { return Data[LeafCount + index]; }
        set { Update(index, value); }
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Update(int i, T x)
    {
        i += LeafCount;
        Data[i] = x;
        while (0 < (i >>= 1)) Data[i] = Merge(Data[i * 2], Data[i * 2 + 1]);
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x)
    {
        i += LeafCount;
        Data[i] = Merge(Data[i], x);
        while (0 < (i >>= 1)) Data[i] = Merge(Data[i * 2], Data[i * 2 + 1]);
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int l, int r)
    {
        l += LeafCount;
        T lRes = IdentityElement;
        r += LeafCount - 1;
        T rRes = IdentityElement;
        while (l <= r)
        {
            if (l % 2 == 1) lRes = Merge(lRes, Data[l]);
            if (r % 2 == 0) rRes = Merge(Data[r], rRes);
            l = (l + 1) / 2;
            r = (r - 1) / 2;
        }
        return Merge(lRes, rRes);
    }
}

Measured memory_bytes: 16452
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    H, W, K = MI()
    G = np.array(LLS(H))
    # print(G)

    ans = np.zeros((H, W), np.int)
    i = 0
    cnt = 0
    num = 1
    for h in range(H):
        g = G[h]
        if '#' in g:
            cnt += 1
        if cnt == 2:
            # print('tmp', i, h, cnt,)
            l = h-i
            c2 = 0
            for w in range(W):
                gw = G[i:h, w]
                # print(gw)
                if '#' in gw:
                    c2 += 1
                    if c2 == 2:
                        num += 1
                        c2 = 1
                for j in range(l):
                    ans[i+j, w] = num
            num += 1
            i = h
            cnt = 1
            tmp = []
    # print(i, h)
    # print('tmp', i, h, cnt, )
    c2 = 0
    for w in range(W):
        gw = G[i:h+1, w]
        # print(gw)
        if '#' in gw:
            c2 += 1
            if c2 == 2:
                num += 1
                c2 = 1
        for j in range(h+1-i):
            ans[i + j, w] = num
    
    for a in ans:
        print(*a)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 28524
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){

ll a,b;
cin >>a >> b;
if(a==1&&b==2){cout << 3 << endl ;}
else if(a==1&&b==3){cout << 2 << endl ;}
else if(a==2&&b==1){cout << 3 << endl ;}
else if(a==2&&b==3){cout << 1 << endl ;}
else if(a==3&&b==1){cout << 2 << endl ;}
else if(a==3&&b==2){cout << 1 << endl ;}




    return 0 ;
}


Measured memory_bytes: 384