akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long M = (long long)1e9+7;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) {
    if(a>=0)
        return a;
    return -a;
}
template<typename T> inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {
    return modpow(b, Mod - 2, Mod );
}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T gcd(T a, T b) {
    if(b==0)
        return a;
    return gcd(b, a%b);
}

template <typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (; isdigit(ch); ch = getchar())
        n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}
template<typename T, typename U> inline void Int(T &a, U &b) {
    Int(a);
    Int(b);
}
template<typename T, typename U, typename W> inline void Int(T &a, U &b, W &c) {
    Int(a,b);
    Int(c);
}
template<typename T, typename U, typename W,typename X> inline void Int(T &a, U &b, W &c, X &d) {
    Int(a,b,c);
    Int(d);
}
vector<int> Unique(vector<int> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb			push_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int res[N] ;

int main() {
    int n = Int , m = Int , v = Int ;
    (v <= (n + m) ) ? puts("Yes"):puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
typedef long long ll;

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

	if (a + b == 15)
		cout << "+" << endl;
	else if (a * b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;


	//cin >> N;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
struct St {
    int a;
    int b;
 
    bool operator<( const St& right ) const {
        return a == right.a ? a < right.a : a < right.a;
    }
};
 
int main()
{
    int N;
    long long int K;
    cin >> N >> K;
 
    vector<St> st(N);
    for( int i = 0; i < N; ++i ){
        cin >> st[i].a >> st[i].b;
    }
 
    sort(st.begin(), st.end());
 
    long long int cnt = 0;
    for( int i = 0; i < N; ++i ){
        cnt += st[i].b;
        if( K <= cnt ){
            cout << st[i].a << endl;
            break;
        }
    }
 
    return 0;
}

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

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
int main(){
    cin>>n;
    vector<int> height(n);
    rep(i,n)cin>>height.at(i);
    int count=0;
    int maxcount=0;
    int index=0;
    while(index<(n-1)){
        if(height[index]>=height[index+1]){
            count++;
        }
        else{
            count=0;
        }
        if(count>maxcount)maxcount=count;
        index++;
    }
    cout<<maxcount<<endl;
    return 0;
}




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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

std::string s;
int main() {
    std::cin >> s;
    int l = s.length();
    bool a = l % 2 == 0;
    bool b = s[0] == s[l-1];

    if( (!a&&b) || (a&&!b) ) {
        std::cout << "Second" << std::endl;
    } else {
        std::cout << "First" << std::endl;
    }
}

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

using namespace std;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> S(A);
    for (auto& s : S) {
        cin >> s;
    }
    vector<long long> T(B);
    for (auto& t : T) {
        cin >> t;
    }
    vector<long long> X(Q);
    for (auto& x: X) {
        cin >> x;
    }
    for (int i = 0; i < Q; i++) {
        auto x = X.at(i);
        long long left_s = 1e12;
        long long right_s = 1e12;
        auto lb_s = lower_bound(S.begin(), S.end(), x);
        if (lb_s != S.begin()) {
            left_s = x - *(lb_s - 1);
        }
        if (lb_s != S.end()) {
            right_s = *lb_s - x;
        }
        long long left_t = 1e12;
        long long right_t = 1e12;
        auto lb_t = lower_bound(T.begin(), T.end(), x);
        if (lb_t != T.begin()) {
            left_t = x - *(lb_t - 1);
        }
        if (lb_t != T.end()) {
            right_t = *lb_t - x;
        }
        vector<long long> v(4);
        v.at(0) = max(left_s, left_t);
        v.at(1) = max(right_s, right_t);
        v.at(2) = left_s + right_t + min(left_s, right_t);
        v.at(3) = right_s + left_t + min(right_s, left_t);
        cout << *min_element(v.begin(), v.end()) << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX],n;
//入力部分↓
  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  int maxv = R[1] - R[0];
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv,R[i] - minv);
    minv = min(minv,R[i]);
  }

  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3868
#include<stdio.h>

int main(void) {

	int a = 0;	scanf("%d", &a);	//printf("%d", a);
	char op[2];	scanf("%s", op);	//printf("%s", op);
	int b = 0;	scanf("%d", &b);	//printf("%d", b);

	
	while (op[0] != '?') {

		if (op[0] == '+') {
			printf("%d\n", a + b);
		}
		else if (op[0] == '-') {
			printf("%d\n", a - b);
		}
		else if (op[0] == '*') {
			printf("%d\n", a * b);
		}
		else if (op[0] == '/') {
			printf("%d\n", a / b);
		}

		scanf("%d %s %d", &a, op, &b);
	}
	
	return 0;
}


Measured memory_bytes: 2052
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import Counter
from itertools import product

n = ni()
a = na()

even = Counter(a[::2])
odd = Counter(a[1::2])

even[-1] = 0
odd[-2] = 0

e = even.most_common(2)
o = odd.most_common(2)

ans = n
for (k1, v1), (k2, v2) in product(e, o):
    if k1 == k2:
        continue
    x = (n - v1 - v2)
    if ans > x:
        ans = x

print(ans)

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

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

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

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

	if(n%2==0){
		lint ans=0;
		rep(i,n){
			if     (i< n/2-1) ans-=2*a[i];
			else if(i==n/2-1) ans-=a[i];
			else if(i==n/2  ) ans+=a[i];
			else              ans+=2*a[i];
		}
		printf("%lld\n",ans);
	}
	else{
		lint ans1=0;
		rep(i,n){
			if     (i<n/2-1) ans1-=2*a[i];
			else if(i<n/2+1) ans1-=a[i];
			else             ans1+=2*a[i];
		}
		lint ans2=0;
		rep(i,n){
			if     (i<n/2  ) ans2-=2*a[i];
			else if(i<n/2+2) ans2+=a[i];
			else             ans2+=2*a[i];
		}
		printf("%lld\n",max(ans1,ans2));
	}

	return 0;
}


Measured memory_bytes: 1024
import math

A, B = [int(i) for i in input().split()]

aa = math.ceil(A / 0.08)
bb = math.ceil(B / 0.1)


if aa > bb:
    if int(aa * 0.08) != A or int(aa * 0.1) != B:
        print('-1')
    else:
        print(aa)
else:
    if int(bb * 0.08) != A or int(bb * 0.1) != B:
        print('-1')
    else:
        print(bb)
        

Measured memory_bytes: 3060
from collections import deque
import sys
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
graph = [[] for j in range(N)]
q = deque([])
depth_array = [-1 for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def bfs(graph, q, depth_array):
    # 終了条件
    if len(q) == 0:
        return depth_array

    cur_room = q.popleft()

    # キューに追加
    for r in graph[cur_room]:
        if depth_array[r] == -1: #未訪問なら
            q.append(r)
            depth_array[r] = depth_array[cur_room] + 1

    return bfs(graph, q, depth_array)
    
# init
q.append(0)
depth_array[0] = 0
depth_array = bfs(graph, q, depth_array)

mark_array = [-1 for i in range(N)]
#print(depth_array)

for room, depth in enumerate(depth_array):
    for node in graph[room]:
        if depth_array[node] + 1 == depth_array[room]:
            mark_array[room] = node

if -1 in mark_array[1:]:
    print("No")
else:
    print("Yes")
    for m in mark_array[1:]:
        print(m+1)

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


int main(){
  int a,b;
  cin>>a>>b;
  
  int cnt=0,sum=1;
  while(sum<b){
    cnt++;
    sum+=a-1;
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;
using ullong = unsigned llong;
using Graph = std::vector<std::vector<int>>;
using Edge = std::pair<int,int>;

std::vector<bool> used;
std::vector<int> match;

using P = pair<int,int>;

P red[100],blue[100];

bool dfs(const Graph &g,int v){
  used[v] = true;
  for(const auto &u:g[v]){
    int w = match[u];
    if(w<0||!used[w]&&dfs(g,w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(const Graph &g,int n,std::vector<Edge> &edges){
  int res = 0;
  match.resize(g.size());
  used.resize(g.size());
  std::fill(match.begin(),match.end(),-1);
  for(int v = 0; v < g.size();++v){
    std::fill(used.begin(),used.end(),false);
    if(dfs(g,v)){
      res++;
    }
  }

  for(int i=0;i<n;++i){
    if(match[i]>=0) edges.emplace_back(i,match[i]);
  }
  return res;
}


int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> red[i].first >> red[i].second;
  }
  for(int i=0;i<N;++i){
    cin >> blue[i].first >> blue[i].second;
  }

  Graph g(2*N);
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(red[i].first < blue[j].first&&red[i].second < blue[j].second){
        g[i].push_back(j+N);
      }
    }
  }

  g.emplace_back();
  g.emplace_back();
  for(int i=0;i<N;++i){
    g[2*N].push_back(i);
    g[N+i].push_back(2*N+1);
  }

  vector<Edge> edges;
  bipartite_matching(g,N,edges);
  int pairs = 0;
  for(auto e:edges){
    if(e.first!=2*N&&e.first!=2*N+1&&e.second!=2*N&&e.second!=2*N+1){
      pairs++;
    }
  }
  cout << pairs << endl;

  return 0;
}

Measured memory_bytes: 256
N=input()
scores=[]
while True:
    try:
        scores.append(int(input()))
    except:
        break


scores=sorted(scores)

res=sum(scores)
res_tmp=res
i=0
while True:

    if res_tmp%10!=0:
        res=res_tmp
        break
    if i==len(scores)-1:
        res=0
        break
    res_tmp=res-scores[i]
    i+=1

print(res)

Measured memory_bytes: 3064
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n=int(input())
m=math.ceil(pow(n,0.5))
for i in range(m):
    if n%(m-i)==0:
        p=m-i
        break
q=n//p
ans=int(max(p,q))
print(len(str(ans)))

Measured memory_bytes: 65640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A!=C){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	int cnt[3] = {};
	for(int i = 0; i < s.length(); i++){
		cnt[s[i] - 'a']++;
	}
	int sub = max(cnt[0], max(cnt[1], cnt[2])) - min(cnt[0], min(cnt[1], cnt[2]));
	if(sub <= 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int arr[6];
  for(int i=1;i<6;++i) cin>>arr[i];
  for(int i=1;i<6;++i) {
    if(arr[i]==0){cout<<i;break;}}
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
using namespace std;

int check[27];

int main()
{
    string a, b, c;
    int n, res = 0;

    cin >> n >> a >> b >> c;

    for (int i = 0; i < n; i++)
    {
        check[a[i] - 'a']++;
        check[b[i] - 'a']++;
        check[c[i] - 'a']++;
        int m = 0;
        for (int j = 0; j < 27; j++)
        {
            m = max(m, check[j]);
            check[j] = 0;
        }

        if (m == 3)
        {
            res += 0;
        }
        else if (m == 2)
        {
            res += 1;
        }
        else if (m == 1)
        {
            res += 2;
        }
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 256
# Atcoder 2019/10/19
"""
# A
A, B = map(int, input().split())

ans = A - 2 * B

if ans >= 0:
    print(ans)
else:
    print(0)
"""

# B
import sys
n = int(input())
d = list(map(int, sys.stdin.readline().strip().split()))

ans = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        ans += d[i] * d[j]

print(ans)




Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int h,w,i,j;
    for(;;){
        scanf("%d %d\n",&h,&w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            if(i%2==0){
                for(j=0;j<w;j++){
                    if(j%2==0){
                        printf("#");
                    }else{
                        printf(".");;
                    }
                }
            }else{
                for(j=0;j<w;j++){
                    if(j%2==0){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, count = 0;
    cin >> n;

    rep(i, n + 1)
    {
        if (((int)log10(i) + 1) % 2 == 1)
        {
            count++;
        }
    }

    OP(count)
    return 0;
}

Measured memory_bytes: 640
/* You can't hack me! */
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef set<ll> sll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define sc scanf
#define pr printf
#define in(x) sc("%lld", &(x))
#define id(x) sc("%Lf", &(x))
#define os(x) cout<<x<<' ';
#define on(x) cout<<x<<"\n";
#define nl cout<<"\n";
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;
const ll MaxN=2000010;
const long double pi=3.14159265358979323846264338327950288419716939937510;

ll gcd(ll a, ll b)
{
    ll m=min(a, b), M=max(a, b);
    if(m==0) return M;
    return gcd(m, M%m);
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t=1;
    //cin>>(t);
    //in(t);
    fo(q, t)
    {
        ll type, n;
        cin>>n;
        if(n%10==3) type=3;
        else if(n%10==0 || n%10==1 ||n%10==6 ||n%10==8) type=2;
        else type=1;
        std::vector<string> v(3);
        v[0]="hon", v[1]="pon", v[2]="bon";
        on(v[type-1]);
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3844
#!/usr/bin/env python3
from math import isinf


def main():
    V, E, r = map(int, input().split())
    vertices = [float('inf')] * V
    vertices[r] = 0
    edges = []
    for i in range(E):
        s, t, d = map(int, input().split())
        edges.append((s, t, d))

    for i in range(V - 1):
        for s, t, d in edges:
            if vertices[t] > vertices[s] + d:
                vertices[t] = vertices[s] + d

    for s, t, d in edges:
        if vertices[t] > vertices[s] + d:
            print("NEGATIVE CYCLE")
            return

    for v in vertices:
        print('INF' if isinf(v) else v)

main()

Measured memory_bytes: 7144
N,K=map(int,input().split())
L=list(map(int,input().split()))

for i in range(N):
  if L[i]==1:
    base=i//(K-1)+(N-i-1)//(K-1)
    modulo=i%(K-1)+(N-i-1)%(K-1)

if modulo==0:
  print(base)
elif 1<= modulo < K:
  print(base+1)
else:
  print(base+2)

Measured memory_bytes: 13880
H,W=map(int, input().split())
c=[list(map(int,input().split())) for i in range(10)]
A=[list(map(int,input().split())) for i in range(H)]
def dfs(n,tcost,depth):
    for i in range(10):
        if cost[i]>tcost+c[i][n]:
            cost[i]=tcost+c[i][n]
            if depth<10:
                dfs(i,cost[i],depth+1)
cost=[10**4]*11
cost[1]=0
cost[-1]=0
dfs(1,0,0)
ans=0
for h in range(H):
    for w in range(W):
        ans+=cost[A[h][w]]
print(ans)

Measured memory_bytes: 3444
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long k = sc.nextLong();
        System.out.println(k % 2 == 0 ? a - b : b - a);
    }
}

Measured memory_bytes: 21844
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
// why
int n,k;
struct node{int x,y;}edge[1000010];
int main(){
    n=gi();k=gi();
    int tot=(n-2)*(n-1)/2,m=n-1;
    for(int i=1;i<=m;i++)edge[i].x=n,edge[i].y=i;
    if(k>tot)return puts("-1"),0;int now=2,Q=1;
    n--;
    while(tot!=k){
        tot--;
        edge[++m]=(node){now,(now+Q-1)%n+1};
        now++;now=(now-1)%n+1;
        if(now==2)Q++;
    }
    printf("%d\n",m);
    for(int i=1;i<=m;i++)
        printf("%d %d\n",edge[i].x,edge[i].y);
    return 0;
}


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

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long>v;
    long long sum = 0;
    for(long long i = 0; i < n; ++i){
        long long tmp; cin >> tmp;
        sum += tmp;
        v.push_back(tmp);
    }
    if(sum % 10 != 0)cout << sum;
    else{
        sort(v.begin(), v.end());
        for(auto a:v){
            if((sum - a) % 10 != 0){
                cout << sum - a;
                return 0;
            }
        }
        cout << 0;
    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}


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


Measured memory_bytes: 384
//============================================================================
// Name        : ProjG.cpp
// Author      : Yong Kiat
// Version     :
// Copyright   : By Algotae.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

const int mxN = 100, mxK = 1e5;
int n, k, a[mxN];
bool dp[mxK+1];

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

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

    for (int i = 0; i <= k; i++) {
    	for (int j = 0; j < n; j++) {
    		// when i - a[j] == 0, then when there are i rocks, player 1 will win
    		// if after i - a[j], player 1 will win, it means that player 1 will not win when there are i rocks
    		if (i - a[j] >= 0 && !dp[i-a[j]]) {
    			dp[i] = 1;
    		}
    	}
    }

    cout << (dp[k] ? "First" : "Second");
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n,ans=0;
    cin>>n;
    vl a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n){
        ans += min(b[i], a[i] + a[i+1]);
        a[i+1] -= min(b[i], a[i] + a[i+1]) - min(b[i], a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(n)]
ans=10**8
for i in ct:
    if i[1]<=t:
        ans=min(ans,i[0])
if ans==10**8:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3001],b[3001],i=1;
	for(a[0]=1,b[0]=1;a[i-1]!=0||b[i-1]!=0;i++) cin>>a[i]>>b[i];
	i--;
	for(int j=1;j<i;j++) cout<<min(a[j],b[j])<<" "<<max(a[j],b[j])<<endl;
	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string x,y;
    cin >>x>>y;
    
    if (x>y)cout << ">" << endl;
    else if (x<y)cout << "<" << endl;
    else cout << "=" << endl;
        
    return 0;
}



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

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

    ll acc = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == 0) continue;

        a[i] += acc;
        if (a[i] < b[i])
            acc += b[i] - a[i];
        else {
            if (a[i] % b[i] != 0) acc += b[i] - a[i] % b[i];
        }
    }

    cout << acc << endl;
    return 0;
}


Measured memory_bytes: 1920
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000000000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE
    //TakeInput
    #endif
    ll n,m,i;
    cin>>n>>m;
    ll a[n];
    ll sum=0;
    in(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    in(i,n-m){
        sum+=a[i];
    }
    cout<<sum;

}








 




Measured memory_bytes: 1792
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int c = scanner.nextInt();
        Show[] shows = new Show[n];
        for (int i = 0; i < shows.length; i++) {
            shows[i] = new Show(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
        }
        Arrays.sort(shows);
        int recs = 1;
        int[] recChannel = new int[c + 1];
        Arrays.fill(recChannel, -1);
        recChannel[recs] = 0;
        for (int i = 1; i < shows.length; i++) {
            boolean free = false;
            for (int j = 1; j < recChannel.length; j++) {
                if (recChannel[j] == -1)break;
                else  if(!(shows[i].s <= shows[recChannel[j]].t && shows[i].c != shows[recChannel[j]].c)){
                    free = true;
                    recChannel[j] = i;
                    break;
                }
            }
            if (!free){
                recs++;
                recChannel[recs] = i;
            }
        }
        System.out.println(recs);
    }
}

class Show implements Comparable<Show>{
    int s, t, c;

    Show(int s, int t, int c) {
        this.s = s;
        this.t = t;
        this.c = c;
    }

    @Override
    public int compareTo(Show o) {
        if (s - o.s == 0) return t - o.t;
        return s - o.s;
    }
}

Measured memory_bytes: 95176
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  llong N;
  cin >> N;
  for(llong i=0; i<100000; ++i){
    if(i * i > N){
      cout << (i-1) * (i-1) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3644
a, b, c, d = map(int, input().split())

if a >= c:
    if a - c <= d:
        print('Yes')
    elif a >= b >= c and a - b <= d and b - c <= d:
        print('Yes')
    else:
        print('No')

else:
    if c - a <= d:
        print('Yes')
    elif a <= b <= c and b - a <= d and c - b <= d:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 9068
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

int main()
{
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> a.at(i);
	}

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

	int m = a.back();
	int c = 0;
	for (;;)
	{
		if (a.at(0) == m && a.at(1) == m && a.at(2) == m)
		{
			break;
		}

		if (a.at(0) < m)
		{
			if (a.at(1) == m)
			{
				a.at(0) += 2;
			}
			else
			{
				a.at(0)++;
				a.at(1)++;
			}
		}

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

		m = a.back();

		c++;
	}

	cout << c << endl;
}

Measured memory_bytes: 256
n=1<<18;N,m;L[1<<18],p;first[1<<18],next[1<<18];i;
long dat[1<<20],lazy[1<<20],A[1<<18],x;
long update(a,b,k,l,r){
	return a<=l&r<=b?dat[k]+(lazy[k]+=x):l<b&a<r?(dat[k]=fmax(
		update(a,b,2*k+1,l,(l+r)/2),
		update(a,b,2*k+2,(l+r)/2,r)
	))+lazy[k]:dat[k]+lazy[k];
}
main(j){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+j,&p,A+j);first[p]=j++)next[j]=first[p];
	for(;i++<N;){
		update(i,i+1,0,0,n);
		for(p=first[i];p!=0;p=next[p])x=A[p],x=update(L[p],i+1,0,0,n);
	}
	printf("%ld",x);
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/


Measured memory_bytes: 12800
#include<stdio.h>
int main()
{
    int A,B,C,K;
    scanf("%d %d %d %d",&A,&B,&C,&K);
    if(K<=A)
        printf("%d",K);
    else if(K<A+B)
        printf("%d",A);
    else
        printf("%d",2*A+B-K);

    return 0;
}


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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

long double ar[Max];

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
	}
	int len = n;
	for(int i = 1; i < n; i++) {
		sort(ar + 1, ar + len + 1, greater<long double>());
		/*for(int j = 1; j <= len; j++) {
			cout << ar[j] << " ";
		} cout << endl;*/
		len--;
		ar[len] = (ar[len] + ar[len + 1]) / 2.0;
	}
	cout << ar[1] << endl;
	return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }
    let mut v = vec![vec!['.'; w + 3]; h + 2];
    for i in 0..h {
        for j in 0..w {
            v[i + 1][j + 1] = s[i][j];
        }
    }
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            if v[i][j] == '#' && {
                v[i][j + 1] == '.' && v[i][j - 1] == '.' && v[i + 1][j] == '.' && v[i - 1][j] == '.'
            } {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
import itertools

A = [None] * 5
for i in range(5):
    A[i] = int(input())

ans = 10000

for a in itertools.permutations(A):
    total = 0
    for t in a:
        while total % 10 != 0:
            total += 1
        total += t
    ans = min(ans, total)

print(ans)


Measured memory_bytes: 3060
import numpy as np

def multi_input():
    return map(int, input().split())

A, B, M = multi_input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
C = [list(map(int, input().split())) for i in range(M)]

mn = np.inf
for x, y, c in C:
    mn = min(mn, a[x-1]+b[y-1]-c)
mn = min(mn, min(a)+min(b)) 
print(mn)

Measured memory_bytes: 47428
from math import pi, sin, cos, sqrt


A, B, H, M = map(int, input().split())

h = 2 * pi * (H / 12 + M / 720)
m = 2 * pi * (M / 60)
ax, ay = A * cos(h), A * sin(h)
bx, by = B * cos(m), B * sin(m)
print(sqrt((ax - bx) ** 2 + (ay - by) ** 2))



Measured memory_bytes: 9508
#include <iostream>//头文件
#include <cstdio>
#include <cctype>//isdigit要用到<cctype>
#define int long long//注意用long long，宏定义成int，方便
using namespace std;//命名空间
inline int read() { //快读
    int s = 0, v = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') v = -1; c = getchar();}
    while (isdigit(c)) s = s * 10 + c - '0', c = getchar();
    return s * v;
}
inline void write(int x) { //快写
    if (x < 0) x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n = read(), x = read(), a[100005], ans;//定义+读入
signed main(void) { //主函数
    for (int i = 1; i <= n; ++i) {
        a[i] = read();//读入
    }
    for (int i = 1; i <= n; ++i) {
        if (a[i] + a[i - 1] > x) ans += a[i] + a[i - 1] - x, a[i] -= a[i] + a[i - 1] - x;//贪心，啃掉a[i]
    }
    write(ans);//输出答案
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//define
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D=0;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N>>M;
  int a[N],j=N-1;
  rep(0,N)cin>>a[i];
  while(j>=1){
    j-=(M-1);
    count+=1;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 640
#![allow(unused_imports)]

macro_rules! input {
    ($($name:ident : $t:tt),*,) => {
        input!($($name: $t),*)
    };
    ($($name:ident : $t:tt),*) => {
        let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
        $(
            let $name = unsafe { _read_value!(_scanned, $t) };
        )*
    };
}

macro_rules! _read_value {
    ($scanned:expr, ($($t:tt),*)) => {
        ($(_read_value!($scanned, $t)),*)
    };
    ($scanned:expr, 1based) => {
        _read_value!($scanned, usize) - 1
    };
    ($scanned:expr, [u8]) => {
        _read_value!($scanned, String).into_bytes()
    };
    ($scanned:expr, [$t:tt; $n:expr]) => {
        (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
    };
    ($scanned:expr, $t:ty) => {
        $scanned.next::<$t>()
    };
}

mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        n: usize,
        x: u32,
        ls: [u32; n],
    }
    let mut r = 1;
    let mut d = 0;
    for l in ls {
        d += l;
        if d <= x {
            r += 1;
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 4352
var s:string;
i:integer;
c,f:boolean;
begin
c:=false;
f:=false;
read(s);
for i:=1 to length(s) do
begin
if s[i]='C' then c:=true;
if s[i]='F' then f:=true;
if not(c) then f:=false;
end;
if c and f then writeln('Yes') else writeln('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int ans = 0;
  for(int i = 0;i < n-2;i++){
    for(int j = i + 1;j<n-1;j++){
      int sum = l[i] + l[j];
      int mm = lower_bound(l.begin(),l.end(),sum) - l.begin();
      int nn = j + 1;
      ans += max((int)0,mm-nn);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin >> a >> b;
    if(b < 10)
        a *= 10;
    if(b>=10&&b < 100)
        a *= 100;
    if(b == 100)
        a *= 1000;
    a += b;
    //cout << a << endl;
    for(int i = 1; i < 500; ++i) {
        if(i * i == a) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

int main()
{
    deque<int> data;
    int N; 
    cin >> N;
    
    for(int i = 0; i < N; ++i)
    {
        int Command; cin >> Command;
        
        if(Command == 0)
        {
            int d; cin >> d;
            int val; cin >> val;
            
            if(d==0) data.push_front(val);
            else data.push_back(val);
            
        }
        else if(Command == 1)
        {
            int p; cin >> p;
            cout << data[p] << endl;
        }
        else 
        {
            int d; cin >> d;
            
            if(d==0) data.pop_front();
            else data.pop_back();
            
        }
        
    }
    
    return 0;
    
}


Measured memory_bytes: 4572
s = list(str(input()))
s.reverse()
S = []

c = ''
for i in range(len(s)):
    c += s[i]
    if S:
        if c != S[-1]:
            S.append(c)
            c = ''
    else:
        S.append(c)
        c = ''
#print(S)
print(len(S))


Measured memory_bytes: 62832
#include<stdio.h>
#define MAX 100001
 
 struct P{
          char name[10];
          int time;
          };

 struct P q[MAX];
 int head,tail;

 int init(){
        return head=tail=0;
        }

 int empty(){
        return head==tail;
        }

 int full(){
        return head==(tail+1)%MAX;
        }

 void enqueue(struct P x){
        if(full())return;

        q[tail]=x;
        tail=(tail+1)%MAX;
        }

 struct P dequeue(){
        if(empty())return;

        struct P x=q[head];
        head=(head+1)%MAX;
        return x;
        }

 int main(){
      int n,lim,ttt,sum=0,i;
      init();
      scanf("%d%d",&n,&lim);
      for(i=0;i<n;i++){
                scanf("%s %d",&q[i].name,&q[i].time);
                }
      head=0;tail=n;
      while(head != tail){
                     struct P c=dequeue();
                     ttt=(c.time<lim)?c.time:lim;
                     c.time-=ttt;
                     sum+=ttt;
                     if(c.time>0)enqueue(c);
                     else {printf("%s %d\n",c.name,sum);}
                     }
      return 0;
      }




      


Measured memory_bytes: 3268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=1e5+10;
int a,b,n,cnt; 
ll h,w,ans[10],all;
P res[N*9];
bool ok(int x,int y)
{
	return x>1&&x<h&&y>1&&y<w;
}
map<P,int>num;
int main()
{
	scanf("%lld%lld%d",&h,&w,&n);
	ans[0]=(h-2)*(w-2);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&a,&b);
		num[P(a,b)]=1;
		for(int j=-1;j<=1;++j)
		{
			for(int k=-1;k<=1;++k)
			{
				if(ok(a+j,b+k))
					res[cnt++]=P(a+j,b+k);
			}
		}
	}
	if(cnt)
	{
		sort(res,res+cnt);
		cnt=unique(res,res+cnt)-res;
		for(int i=0;i<cnt;++i)
		{
			a=res[i].first,b=res[i].second;
			int now=0;
			for(int j=-1;j<=1;++j)
			{
				for(int k=-1;k<=1;++k)
				{
					if(num.count(P(a+j,b+k)))
						now++;
				 } 
			}
			ans[now]++,ans[0]--; 
		}
	}
	for(int i=0;i<=9;++i)
	printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 13568
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define int long long
#define N 1e6+100
ll n,p;
int a[100100],prime[1001000],tot=0; 

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}
bool isprime[1001000];
void init()
{
    memset(isprime,1,sizeof(isprime));
    isprime[0]=isprime[1]=0;
    int i;
    for (i=2;i<=N;i++)
    {
        if (isprime[i]) prime[++tot]=i;
        int j;
        for (j=1;j<=tot && i*prime[j]<=N;j++)
        {
            isprime[i*prime[j]]=0;
            if (i%prime[j]==0) break;
        }
    }
}

signed main()
{
	cin >> n >> p;ll ans=1;int i;
	if (n==1) {cout << p;return 0;}
	init();
	for (i=1;i<=tot;i++)
	{
		if (prime[i]>p) break;
		//cout << prime[i] << " ";
		if (p%prime[i]) continue;
		ll tmp=0;
		while (p%prime[i]==0) {p/=prime[i];tmp++;}
		if (tmp/n>=1) 
		{
			int j;tmp/=n;//cout << prime[i] << " " << tmp << endl;
			for (j=1;j<=tmp;j++) ans=ans*prime[i];
		}
	}
	cout << ans;
}


Measured memory_bytes: 1920