akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

#define INF 1000000009

vector<int> dijkstra(int start, int n, vector<vector<int>>& E){
    using P = pair<int, int>;

    vector<int> d(n, INF);
    vector<int> prev(n, -1);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P (0, start));
    d[start] = 0;

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int dp = p.first;
        int idx = p.second;

        for (int i = 0; i < n; i++){
            if (i == idx) continue;
            int di = dp + E[i][idx];
            if (d[i] > di){
                d[i] = di;
                que.push(P (di, i));
                prev[i] = idx;
            }
        }
    }
    return d;
}

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> E(10, vector<int>(10));
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            cin >> E[i][j];
        }
    }
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    vector<int> d;
    d = dijkstra(1, 10, E);

    int ans = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int aij = a[i][j];
            if (aij < 0) continue;
            ans += d[aij];
        }
    }
    cout << ans << endl;
}


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

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

    vector<int> V(N);
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }

    vector<int> C(N);
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }


    vector<int> diff(N);
    for(int i = 0; i < N; i++){
        diff[i] = V[i] - C[i];
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
        if(diff[i] >0){
            ans += diff[i];
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {
    

    int N = in(); int K = in();
    vector<ll> x;
    
    for(auto i = 0; i<N; i++){
        x.push_back(in());
    }
    
    auto it = lower_bound(x.begin(),x.end(),0);
    
    auto leftlen = distance(x.begin(),it);
    auto rightlen = distance(it,x.end());
    
    
    ll ans = LONG_MAX;
    
    ll temp;
    
    for(auto k = 0; k<=leftlen; k++){
        
        if (K-k>rightlen) continue;
        
        if (k > K) break;
        
        if (k == 0){
            temp =x[leftlen + K-k-1];
            
            if (ans > temp)  ans = temp;
            continue;
        }
        
        if (k == K){
            temp =0 - x[leftlen -k];
            
            if (ans > temp)  ans = temp;
            continue;
        }
        
        temp = 2*(0 - x[leftlen-k]);
        
        temp += x[leftlen + K-k-1];
        
     
        if (ans > temp)  ans = temp;

        temp = 2*x[leftlen + K-k-1];
        temp += (0 - x[leftlen-k]);
        
        
        if (ans > temp)  ans = temp;
    }
    
    cout << ans << endl;
    
    return 0;
}






Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int d, t, s;
	std::cin >> d >> t >> s;
	std::cout << (d <= t * s ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define N 100000
#define Q 50000

main(){  
  int n,q,i,j,k,l,count=0;
  int S[N],T[Q];
  
  scanf("%d",&n);
  scanf("%d",&S[0]);

  for(i=1,l=1;i<n;i++){
    scanf("%d",&k);
    if(k > S[l-1]){
      S[l]=k;
      l++;
    }
  }
  
  scanf("%d",&q);
 
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

    for(j = 0 ; j < q ; j++){
      for(i = 0 ; i < l ; i++){
	if(T[j]==S[i]){
	  count++;
	  break;
	}
      }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int n, m, a[100005];
ll s;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		int x=read();
		a[x]++;
		s+=x; 
	}
	cin>>m;
	for(int i=1;i<=m;i++) {
		int b=read(), c=read();
		s+=a[b]*(c-b);
		a[c]+=a[b];
		a[b]=0;
		printf("%lld\n", s);
	}
}


Measured memory_bytes: 4132
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

hf = pow(2,R-2,R)
n,s = inm()
a = inl()
dp = [[0]*(s+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = pow(2,n,R)
sm = 0
for i in range(1,n+1):
    dp[i] = [x for x in dp[i-1]]
    for j in range(s):
        if dp[i-1][j]>0 and j+a[i-1]<=s:
            dp[i][j+a[i-1]] = (dp[i][j+a[i-1]]+dp[i-1][j]*hf)%R
    #ddprint(i)
    #ddprint(dp[i])
print(dp[n][s])


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

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

  string S;
  cin >> S;
  int N = S.size();
  int64_t dp[N+1][13] = {};
  dp[0][0] = 1;
  for(int i=1;i<=N;i++){
    if(S[i-1] != '?'){
      for(int j=0;j<13;j++){
        int c = S[i-1] - '0';
        dp[i][(j*10+c)%13] += dp[i-1][j];
        dp[i][(j*10+c)%13] %= INF;
      }
    }
    else{
      for(int k=0;k<10;k++){
        for(int j=0;j<13;j++){
          dp[i][(j*10+k)%13] += dp[i-1][j];
          dp[i][(j*10+k)%13] %= INF;
        }
      }
    }
  }
  cout << dp[N][5] << endl;
}


Measured memory_bytes: 10704
package main

import (
	"fmt"
	// "strings"
)

func main() {
	var A1, A2, A3 int

	fmt.Scanf("%d %d %d", &A1, &A2, &A3)
	if A1+A2+A3 >= 22 {
		fmt.Println("bust")
		return
	}

	fmt.Println("win")
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  string s;

  char c = 'x';
  char tmp;
  int ans = 0;
  while(cin >> tmp){
    if(c != tmp){
      ans++;
      c = tmp;
    }
  }

  cout << ans-1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int ans=0;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++){
		int t,x,y;
		cin>>t>>x>>y;
		if((x+y)%2==t%2&&t>=x+y)ans++; 
	}
	if(ans==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int d[20][20];

void warshall_floyd(int n){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int h, w; cin>>h>>w;
    int c[20][20];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin>>c[i][j];
            d[i][j]=c[i][j];
        }
    }

    warshall_floyd(10);

    ll ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int a; cin>>a;
            if(a==1 || a==-1) continue;
            ans+=d[a][1];
        }
    }
    cout << ans << endl;
}

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

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

using namespace std;

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

  if((b-a)%2==0) cout<<(b-a)/2;
  else cout<<min(a-1, n-b) + 1 + (b-a-1)/2;

  return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

def lcm_base(x, y):  
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
c = []
for _ in range(N):
    c.append(int(input()))

print(lcm(*c))

Measured memory_bytes: 67788
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 1000000007
#define infll 2000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define left(i) i<<1
#define right(i) (i<<1)|1
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 1000500001ll
#define mod2 1000300001ll
#define base1 137ll
#define base2 31ll
#define PI acos(-1)
#define sz(a) (int) (a).size()
#define isbit(x,k)  ((x) & (1<<(k))) > 0


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef long double ld;
typedef complex<ld> point;
typedef pair<point, point> line;
typedef pair<ld , point> Circle;
typedef pair<point, int> Point;


int n;

int main() {
    
    scanf("%d",&n);
    if(n < 1200) printf("ABC\n");
    else if(n < 2800) printf("ARC\n");
    else printf("AGC\n");
    
    return 0;
}

/*
 */

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	int a;cin >> a;
	string s; cin >> s;

	if(a >= 3200){
		cout << s; return 0;
	}
	else{
		cout << "red";
	}
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))

if N >= M:
	print(0)
else:
	Xl = []
	for i in range(M - 1):
		Xl.append(X[i + 1] - X[i])
	Xl = sorted(Xl)
	ans = 0
	for i in range(M - N):
		ans += Xl[i]

	print(ans)

Measured memory_bytes: 13968
N = int(input())						# 5

s = "0 " + input()
a = [int(i) for i in s.split()]	# 1 2 3 4 5 ...


ans = 0
bSkip = False

for i in range(N+1):
	if i==0: continue;
	if bSkip:
		bSkip = False
		continue;
#	print(i, a[i])
	
	if i==a[i]:
		ans += 1
		if(i<N):
			if(i+1)==a[i+1]:
				bSkip = True

print(ans)


Measured memory_bytes: 14648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int re i=a;i<b;++i)
#define drep(i,a,b) for(int re i=a;i>b;--i)
#define re register
#define ll long long
using namespace std;

inline
ll getint(){
	static ll num;
	static bool f;
	static char c;
	num=0;f=0;
	while(c=getchar(),!isdigit(c))if(c=='-')break;
	if(c=='-')f=1,c=getchar();
	while(isdigit(c))num=(num<<1)+(num<<3)+c-'0',c=getchar();
	return f?-num:num;
}

inline
void outint(ll a){
	if(a>9)outint(a/10);
	putchar(a%10+'0');
}

char c;
int ans=0; 
int main(){
	for(int i=1;i<=4;++i)scanf("%c",&c),ans+=c=='-'?-1:1;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] dataline = Console.ReadLine().Split(' ');
            int a = int.Parse(dataline[0]);
            int b = int.Parse(dataline[1]);
            int c = int.Parse(dataline[2]);
            bool flag = false;

            for (int i = 0; i <= b; i++)
            {
                if ((i * a) % b == c)
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

using namespace std;

struct S {
  int d[2];
  vector<int> to;
};

vector<S> V;

void dfs(int v, int prev, int t, int d) {
  V[v].d[t] = d++;
  for (auto to : V[v].to)
    if (to != prev) dfs(to, v, t, d);
};

int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  V.resize(N);
  for (int i = N - 1; i--;) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V[a].to.push_back(b);
    V[b].to.push_back(a);
  }
  dfs(u, -1, 0, 0);
  dfs(v, -1, 1, 0);
  int ans = 0;
  for (auto& v : V)
    if (v.d[1] > v.d[0]) ans = max(ans, v.d[1]);
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 11648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_170
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] xy = ReadInts();
            int x = xy[0];
            int y = xy[1];

            for(int i = 0; i <= x; i++)
            {
                int cnt = i * 2 + (x - i) * 4;
                if (cnt == y)
                {
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27540
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);

    if((a==b && a!=c)||(a==c && a != b)||(b==c && a!=b)) Console.WriteLine("Yes");
    else Console.WriteLine("No");
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D,i,j,sum;scanf("%d",&D);
  pair<int,vector<int>> ans;
  pair<int,int> k;
  int c[26],l[26],up[26],down[26];
  fill(l,l+26,-1);
  for(i=0;i<26;i++) scanf("%d",&c[i]);
  for(i=0;i<D;i++){
    for(j=0;j<26;j++){
      scanf("%d",&up[j]);
      down[j] = (i-l[j])*c[j];
    }
    sum = accumulate(down,down+26,0);
    ans = make_pair(-1000000000,vector<int>());
    for(j=0;j<26;j++){
      if(up[j]-sum+down[j] > ans.first){
        ans.first = up[j]-sum+down[j];
        ans.second = vector<int>({j});
      }
      else if(up[j]-sum+down[j] == ans.first){
        ans.second.push_back(j);
      }
    }
    k = make_pair(-1,-1);
    for(j=0;j<ans.second.size();j++){
      if(c[ans.second[j]] > k.first){
        k.first = c[ans.second[j]];
        k.second = ans.second[j];
      }
    }
    l[k.second] = i;
    printf("%d\n",k.second+1);
  }
}

Measured memory_bytes: 3752
program main
 implicit none
 integer*16 a,b,c,d,t1,t2,gcd,lcm,p,q,ans
 read(*,*) a,b,c,d
 t1 = c
 t2 = d
 do while( t2 /= 0 )
     gcd = t1
     t1 = t2
     t2 = mod(gcd, t2)
 end do
 gcd = abs(t1)
 lcm = c*d / gcd
 p = b / c + b / d - b / lcm
 q = (a-1) / c + (a-1) / d - (a-1) / lcm
 ans = b - (a-1) - (p - q)
 write(*,*) ans
end program main

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),sorted_A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        sorted_A.at(i) = A.at(i);
    }
    sort(sorted_A.begin(),sorted_A.end());
    reverse(sorted_A.begin(),sorted_A.end());
    int A_1 = sorted_A.at(0);
    int A_2 = sorted_A.at(1);

    for(int x:A){
        if(x == A_1) cout << A_2 << endl;
        else cout << A_1 << endl;
    }
}

Measured memory_bytes: 3200
C = [[]for i in range(3)]
for i in range(3):
    C[i].extend(list(map(int, input().split())))
flag = True

for i in range(2):
    if (C[1][i+1] - C[1][i] == C[2][i+1] - C[2][i]) and (C[1][i+1] - C[1][i] == C[0][i+1] - C[0][i]):
        continue
    else:
        flag = False
        break
for i in range(2):
    if not flag:
        break
    if (C[i+1][1] - C[i][1] == C[i+1][2] - C[i][2]) and (C[i+1][1] - C[i][1] == C[i+1][0] - C[i][0]):
        continue
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  ll ans = A * B;
  ans = max(A-B, ans);
  ans = max(A+B, ans);
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int N,H,p,a[7][7][7],cnt[7][7];
bool is(int x,int y,int z){
	return 0<=x&&x<N&&0<=y&&y<N&&0<=z&&z<N;
}
bool win(int i){
	rep(xx,N) rep(yy,N) rep(zz,N){
		for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++) for(int dz=-1;dz<=1;dz++){
			if(dx==0&&dy==0&&dz==0) continue;
			bool ok=true;
			rep(t,H){
				if(!is(xx+dx*t,yy+dy*t,zz+dz*t)||a[xx+dx*t][yy+dy*t][zz+dz*t]!=i%2){
					ok=false;
					break;
				}
			}
			if(ok) return true;
		}
	}
	return false;
}
int main(){
	while(true){
		cin>>N>>H>>p;
		if(N==0) break;
		rep(i,N) rep(j,N) rep(k,N) a[i][j][k]=-1;
		rep(i,N) rep(j,N) cnt[i][j]=0;
		rep(i,p){
			int x,y;
			cin>>x>>y;
			x--,y--;
			a[x][y][cnt[x][y]++]=i%2;
			if(win(i)){
				cout<<((i+1)%2?"Black ":"White ")<<i+1<<endl;
				rep(j,p-i-1) cin>>x>>y;
				break;
			}
			if(i==p-1) puts("Draw");
		}
	}
}

Measured memory_bytes: 1164
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		int a,b,c,d;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();

		if ((b-a<=d && a-b<=d && c-b<=d && b-c<=d) || (c-a<=d && a-c<=d)){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
		
		return;
	}
}

Measured memory_bytes: 21844
<?php
//$S = trim(fgets(STDIN));
list($a1,$a2,$a3) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));

if ($a1+$a2+$a3 >= 22) {
 printf("bust\n");
}
else {
 printf("win\n");
}


Measured memory_bytes: 4728
N, M = map(int, input().split(" "))
lines = []
for i in range(M):
    line = list(map(int, input().split(" ")))
    lines.append(set(line[1:]))

P = list(map(int, input().split(" ")))
ans = 0
for i in range(1 << N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1) == 1:
            on.add(j+1)

    flag = True
    for k, switches in enumerate(lines):
        if len(on & switches) % 2 == P[k]:
            pass
        else:
            flag = False
            break
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	if(a>b)return gcd(b,a);
	if(b%a)return gcd(a,b-a);
	else return a;
}
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				sum+=gcd(gcd(i,j),k);
	cout<<sum;
	return 0;
}


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

using namespace std;

int main(){

 int n,ani=0;
  cin>>n;

  for(int i=1;i<=n;i++)
{
    int res=0;
    for(int j=1;j<=i;j+=2)
    {
        if(i%j == 0)
            res++;
    }

    if(res == 8)
        ani++;
  }

  cout<<ani<<endl;

return 0;
}


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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int N = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

inline ll read()
{
	ll x = 0; int f = 1, c = getchar(); 
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; 
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); 
	return x * f; 
}

int n; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	n = read(); 
	int cnt = 0; 
	rep(i, n)
	{
		int x = read(); 
		if (x != i) cnt++; 
		if (cnt > 2)
		{
			puts("NO"); 
			return 0; 
		}
	}
	
	puts("YES"); 
	
	return 0; 
}


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

ll findLCD(ll X, ll Y) {
    ll g;
    ll A = max(X, Y);
    ll B = min(X, Y);
    ll iniA = A;
    ll iniB = B;

    if (A == B) g = A;
    else {
        if (A%B == 0) g = B;
        else {
            while (true) {
                g = A%B;
                A = B;
                B = g;
                if (A%B == 0) break;
            }
        }
    }
    ll a = iniA/g;
    ll b = iniB/g; 
    ll ans = a*b*g;
    return ans;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll whole = B-A+1;
    ll ac = A/C;
    ll bc = B/C;
    ll canC = bc-ac;
    if (A % C == 0) canC ++;

    ll ad = A/D;
    ll bd = B/D; 
    ll canD = bd-ad;
    if (A % D == 0) canD ++;

    ll LCD = findLCD(C, D);
    ll acd = A/LCD;
    ll bcd = B/LCD;
    ll canboth = bcd-acd;
    if (A % LCD == 0) canboth++;

    ll ans = whole-(canC+canD-canboth);
    // cout << canC << endl;
    // cout << canD << endl;
    // cout << canboth << endl;
    // cout << whole << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 2e5 + 7;

vector <int> g[N];
int who[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue <int> q;
    vector <bool> used(n + 1, false);
    who[1] = 1;
    q.push(1);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : g[v]) {
            if (!who[to]) {
                who[to] = v;
                q.push(to);
            }
        } 
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; i++) cout << who[i] << '\n';
    return 0;
}

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

int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                if (L[i] + L[j] <= L[k] || L[j] + L[k] <= L[i] ||
                    L[k] + L[i] <= L[j])
                    continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 16;
const ll Inf = 1e18;

int a[N][N];
ll Sum[1 << N];
ll Dp[1 << N];

void max_self(ll& x, ll y)
{
    if(x < y)   x = y;
}

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

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            scanf("%d", &a[i][j]);

    for(int Mask = 0; Mask < (1 << n); Mask++)
        for(int i = 0; i < n; i++)
            if(Mask & (1 << i))
                for(int j = i + 1; j < n; j++)
                    if(Mask & (1 << j))
                        Sum[Mask] += a[i][j];

    Dp[(1 << n) - 1] = 0;

    for(int Mask = (1 << n) - 2; ~Mask; --Mask)
    {
        Dp[Mask] = -Inf;

        int Not = ((1 << n) - 1) ^ Mask;

        for(int Sub = Not; Sub; Sub = (Sub - 1) & Not)
        {
            max_self( Dp[Mask], Sum[Sub] + Dp[Mask | Sub]);
        }
    }

    cout << Dp[0] << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i,n) cin >> a.at(i);
	rep(i,m) cin >> b.at(i);
	bool ans=false;
	rep(i,n-m+1){
		rep(j,n-m+1){
			bool same=true;
			rep(k,m){
				if(a.at(i+k).substr(j,m)!=b.at(k)) same=false;
			}
			if(same) ans=true;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    char str[1001],p[1001],cmd[10];
    int a,b,q,i,j;
    
    scanf("%s",str);
    scanf("%d",&q);
    
    for(i=0;i<q;i++)
    {
        char ans[1001]={};
        scanf("%s",cmd);
        
        if(strcmp(cmd,"print")==0)
        {
            scanf("%d %d",&a,&b);
            for(j=0;j<(b-a+1);j++)
            {
                ans[j]=str[j+a];
                ans[b-a+1]='\0';
            }
            printf("%s\n",ans);
        }
        else if(strcmp(cmd,"reverse")==0)
        {
            scanf("%d %d",&a,&b);
            strcpy(ans,str);
            char tmp[1001]={};
            for(j=0;j<(b-a+1);j++)
            {
                tmp[j]=str[b-j];
                ans[j+a]=tmp[j];
            }
            strcpy(str,ans);
        }
        else if(strcmp(cmd,"replace")==0)
        {
            scanf("%d %d %s",&a,&b,p);
            strcpy(ans,str);
            for(j=0;j<(b-a+1);j++)
            {
                ans[j+a]=p[j];
            }
            strcpy(str,ans);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2104
n = int(input())
h = list(map(int,input().split()))
h.reverse()
jud = 1
for i in range(n-1):
    if h[i] - h[i+1] == -1:
        h[i+1] -= 1
    elif h[i] - h[i+1] < -1:
        jud = 0
if jud == 1:
    print("Yes")
else:
    print("No")

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

int main(){

  string str[10] = {
    ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"
  };

  int n;
  cin >> n;
  while( n-- ){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '0') continue;
      int j = 0;
      while( s[i+j] != '0' ) j++;
      cout << str[ (int)s[i+j-1]-'1' ][ (j-1)%str[ (int)s[i]-'1' ].size()];
      i += j;
    }
    cout << endl;
  }
	return 0 ;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

int a[1001], b[1001];
signed main(){
	int n, q;
	scanf("%lld", &n);
	rrep(i,n)scanf("%lld", &a[i]);
	scanf("%lld", &q);
	
	int f = 0;
	rep(i,q){
		int x, y, z;
		scanf("%lld%lld%lld", &x, &y, &z);
		if(f)continue;
		if(x == 1){
			b[y] += z;
			if(a[y] < b[y]){
				printf("%lld\n", y);
				f = 1;
			}
		}else{
			b[y] -= z;
			if(b[y] < 0){
				printf("%lld\n", y);
				f = 1;
			}
		}
	}
	if(f == 0)printf("0\n");
	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
int main(){
    int n,t;
    cin>>n;
    for(int i=1;i<n;i++) cin>>t,a[t]++;
    
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4364
#include<bits/stdc++.h>
#define se second
#define fi first
#define re register
using namespace std;
const int N = 55;
int n,a,b,ans;
inline int read(){
    int f = 0,x = 0;char ch;
    do{ch = getchar();f |= (ch == '-');}while(!isdigit(ch));
    do{x = (x << 3) + (x << 1) + (ch ^ 48);ch = getchar();}while(isdigit(ch));
    return f ? -x : x;
}
int main(){
    n = read(),a = read(),b = read();
    for(re int i = 1;i <= n;++i){
        stringstream sio;
        string s;
        int sum = 0;
        sio << i;
        sio >> s;
        for(re int j = 0;j < s.size();++j)sum = sum + s[j] - '0';
        if(sum >= a && sum <= b)ans += i;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, K, mx(0); std::cin >> N >> K;
    std::vector<int> A(N);
    for(int i(0); i < N; ++i){
        std::cin >> A[i];
        chmax(mx, A[i]);
    }
    
    int ng(0), ok(mx);
    while(ok > ng + 1){
        int mid((ng + ok) / 2), cnt(0);
        for(int i(0); i < N; ++i){
            cnt += (A[i] - 1) / mid;
        }
        if(cnt <= K) ok = mid;
        else ng = mid;
    }
    std::cout << ok << std::endl;
    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> Z_algorithm(const string &s){
    vector<int> res(s.size());
    res.front() = s.size();
    for (int i = 1, j = 0; i < s.size(); ) {
        while(i + j < s.size() && s[j] == s[i+j]) ++j;
        res[i] = j;
        if(j == 0) { ++i; continue;}
        int k = 1;
        while(i+k < s.size() && k + res[k] < j) res[i+k] = res[k], ++k;
        i += k; j -= k;
    }
    return res;
}



int main() {
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    for (auto &&i : A) scanf("%d", &i);
    for (auto &&k : B) scanf("%d", &k);
    vector<int> ok(n), val(n);
    for (int i = 0; i < 30; ++i) {
        string s, t, u;
        for (int j = 0; j < n; ++j) {
            if(A[j] & (1 << i)) s += '1';
            else s += '0';
            if(B[j] & (1 << i)) t += '1', u += '0';
            else t += '0', u += '1';
        }
        s += t;
        s += t;
        auto Z = Z_algorithm(s);
        for (int j = 0; j < n; ++j) {
            if(Z[j+n] >= n && ok[j] == i) ok[j] = i+1;
            s.pop_back(); s.pop_back();
        }
        s += u;
        s += u;
        Z = Z_algorithm(s);
        for (int j = 0; j < n; ++j) {
            if(Z[j+n] >= n && ok[j] == i) ok[j] = i+1, val[j] ^= (1 << i);
        }
    }
    for (int i = n; i > 0; --i) {
        if(ok[i%n] == 30){
            printf("%d %d\n", n-i, val[i%n]);
        }
    }
    return 0;
}

Measured memory_bytes: 10004
N,K = map(int,input().split())
h = [0]*N
hmax = 0
hmin = 0
H = [0]*(N-K+1)
for i in range(N):
  h[i] = int(input())
h.sort()
for i in range(N-K+1):
  hmin = h[i]
  hmax = h[i+K-1]
  H[i] = hmax-hmin
print(min(H))

Measured memory_bytes: 16908
#include<iostream>
using namespace std;
 
int main()
{
  int N,h,count=0;
 
  cin >> N;
 
  int A[N];
 
  for(int i=1;i<=N;i++)
    {
      cin >> A[i];
    }
 
  int mini;
  for(int i=1;i<=N;i++)
    {
      mini=i;
      for(int j=i;j<=N;j++)
    {
      if(A[j]<A[mini])
        {
          mini=j;
        }
    }
      if(A[i] != A[mini])count++;
      h = A[i];
      A[i] = A[mini];
      A[mini] = h;  
    }
 
  for(int i=1;i<=N;i++)
    {
      cout << A[i];
      if(i != N)cout << " ";
    }
  cout  << endl << count << endl;
 
  return 0;
}


Measured memory_bytes: 3112
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
import Debug.Trace

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve _ as@(a:as') = subproc sum0 as as as' 0 0 a sum0
  where sum0 = sum as

subproc mindiff [_] _ _ _ _ _ _ = mindiff
subproc mindiff (a:as) ps qs s1 s2 s3 s4 =
  subproc newmindiff as ps' qs' s1' s2' s3' s4'
  where
    s2' = s2 + a
    (s1', ps') = newdiv s1 s2' ps
    s4' = s4 - a
    (s3', qs') = newdiv (s3 - a) s4' qs
    a_min = minimum [s1', s2'-s1', s3', s4'-s3']
    a_max = maximum [s1', s2'-s1', s3', s4'-s3']
    newmindiff = min mindiff (a_max - a_min)

newdiv sLeft sAll xs = (u, v)
  where
    sums = takeWhile (\s -> 2*s <= sAll - 2*sLeft)
           $ tail $ scanl' (+) 0 xs
    n1 = length sums
    sL | null sums = sLeft
       | otherwise = sLeft + last sums
    x' : xs' = drop n1 xs
    sR = sAll - (sL + x')
    (u, v) = if sL < sR then (sL + x', xs') else (sL, x' : xs')

tmain cont =
  let n : as = bsReadInts cont
  in solve n as

main = putStrLn . show . tmain =<< B.getContents


Measured memory_bytes: 30972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Panasonic2020
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long h = long.Parse(input[0]);
            long w = long.Parse(input[1]);

            long answer;
            if (h == 1 || w == 1)
            {
                answer = 1;
            } else
            {
                long product = h * w;
                answer = product / 2 + product % 2;
            }

            Console.WriteLine(answer);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int n = input<int>();
    vector<int> p(n, 0);
    input(p);

    int res = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (p[i - 1] > p[i + 1])
        {
            if (p[i] >= p[i + 1] && p[i] < p[i - 1])
            {
                res++;
            }
        }
        else if (p[i - 1] == p[i + 1])
        {
            if (p[i] < p[i - 1])
            {
                res++;
            }
        }
        else
        {
            if (p[i] >= p[i - 1] && p[i] < p[i + 1])
            {
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n;
    cin>>n;
    if(n >= 30) cout << "Yes";
    else cout <<"No";
    return 0;
}

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

int main()
{
    int num;
    cin >> num;
    deque<int> v;
    int current;
    for(int i=0;i<num;i++){
        cin >> current;
        if(i%2==num%2){
            v.push_back(current);
        }else{
            v.push_front(current);
        }
    }
    for(int i=0;i<num-1;i++){
        cout << v[i] << " ";
    }
    cout << v[num-1] << endl;
    return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] L = new long[N+1];
		L[0] = 2;
		L[1] = 1;

		for(int i=2;i<=N;i++){
			L[i] =	L[i-1]+L[i-2];
		}
		System.out.println(L[N]);
	}



}


Measured memory_bytes: 21844
import numpy as np
N, Q=map(int,input().split())
S=input()
L =[list(map(int,input().split()))for i in range(Q)]
c = [0]*(N)  #ACのチェック
s = [0]*(N)  #ACの累積和
ans = [0]*Q 

for i in range(N-1):
  if S[i] == "A" and S[i+1] == "C":
    c[i+1] = 1
s = np.cumsum(c)
for i in range(Q):
  ans[i] = s[L[i][1]-1]-s[L[i][0]-1]

for i in ans:
  print(i)


Measured memory_bytes: 40368
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, s = 0;
  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);
  }

  for (int i = 0; i < N; i++)
  {
    s += B[A[i] - 1];
    if ((i != 0) && (A[i] - A[i - 1] == 1))
    {
      s += C[A[i - 1] - 1];
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  long n, c, k;

  cin >> n >> c >> k;

  long t[n];

  fillLong(t, n);
  sort(t, t+n);

  long bus = 0;
  long next = 0;

  while (next < n) {
    bus++;
    long j = next;
    while (j < next + c && j < n && t[j] <= t[next]+k) j++;
    next = j;
  }

  cout << bus << endl;

  return 0;
}


Measured memory_bytes: 1024