akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {

	S := oneStr()

	if S[2] == S[3] {
		if S[4] == S[5] {
			fmt.Print("Yes")
			return
		}
	}

	fmt.Print("No")
}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
N=int(input())
alist=list(map(int,input().split()))
#print(alist)

answer=0
while max(alist)>=N:
  s=sum([a//N for a in alist])
  for i in range(N):
    dec=(alist[i]//N)*N    
    asc=s-(alist[i]//N)
    alist[i]-=dec-asc
  answer+=s
  
print(answer)

Measured memory_bytes: 3060
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B) = nextIntList()
    val S = next()
    val a = S.take(A)
    val b = S.takeLast(B)
    if (S[A] == '-' && a.all { it.isDigit() } && b.all { it.isDigit() }) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 37872
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

bool check(ll m){
    int a=0,b=0,c=0;
    while(m>0){
        if(m%10==3)a=1;
        if(m%10==5)b=1;
        if(m%10==7)c=1;
        m/=10;
    }
    if(a+b+c==3)return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    stack<ll> s;
    s.push(0);
    int ans = 0;
    while(!s.empty()){
        if(s.top()>n){
            s.pop();
            continue;
        }
        ll a = s.top();
        s.pop();
        s.push(10*a+3);
        s.push(10*a+5);
        s.push(10*a+7);
        if(check(a))ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

void dfs(int r,vector<vector<int>> &g, map<P,P> &edge,int c,int k,int n,vector<int> &used){
	used[r]=1;
	int color = 1;
	if(color==c)color++;
	for(auto x:g[r]){
		if(used[x]>0)continue;
		int min_ = min(r,x);
		int max_ = max(r,x);
		edge[P(min_,max_)].second = color;
		dfs(x,g,edge,color,k,n,used);
		color++;
		if(color==c)color++;
	}
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int>> g(n,vector<int>());
	map<P,P> edge;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);

		if(a>b){
			int tmp=a;
			a=b;
			b=tmp;
		}
		edge.insert(make_pair(P(a,b),P(i,0)));
	}

	vector<int> deg(n);
	rep(i,n)deg[i] = g[i].size();
	int color = *max_element(all(deg));
	int r=-1;
	rep(i,n)if(deg[i]==g[i].size()){
		r=i;
		break;
	}
	vector<int> used(n,0);
	dfs(r,g,edge,0,color,n,used);
	
	vector<P> ans;
	for(auto x:edge){
		ans.push_back(x.second);
	}

	sort(all(ans));

	cout<<color<<endl;
	rep(i,n-1){
		cout<<ans[i].second<<endl;
	}


	return 0;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


int main() {
  string N;
  cin >> N;
  ll K;
  cin >> K;
  ll dp[111][5][2]={};
  ll i, j, k;
  
  
  dp[0][0][1]=1;
  for(i=0; i<N.size(); i++) {
    for(j=0; j<=K; j++) {
      
      //i桁まで一致
      for(k=1; k<N[i]-'0'; k++)
        dp[i+1][j+1][0]+=dp[i][j][1];
      
      if(N[i]-'0'>0) {
        dp[i+1][j+1][1]+=dp[i][j][1];
        dp[i+1][j][0]+=dp[i][j][1];
      }else {
        dp[i+1][j][1]+=dp[i][j][1];
      }
      
      //不一致
      for(k=1; k<10; k++)
        dp[i+1][j+1][0]+=dp[i][j][0];
      
      dp[i+1][j][0]+=dp[i][j][0];
      
    }
  }
  
  
  pt(dp[N.size()][K][1]+dp[N.size()][K][0]);
  
  
}




















Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

Node *treeMinimum(Node *x)
{
  while (x->left != NIL)
  {
    x = x->left;
  }
  return x;
}

Node *find(Node *u, int key)
{
  while (u != NIL && key != u->key)
  {
    if (key < u->key)
    {
      u = u->left;
    }
    else
    {
      u = u->right;
    }
  }

  return u;
}

Node *treeSuccessor(Node *x)
{
  if (x->right != NIL)
  {
    return treeMinimum(x->right);
  }
  Node *y = x->parent;
  while (y != NIL && y->right)
  {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z)
{
  Node *target;
  Node *child;

  if (z->left == NIL || z->right == NIL)
  {
    target = z;
  }
  else
  {
    target = treeSuccessor(z);
  }

  if (target->left != NIL)
  {
    child = target->left;
  }
  else
  {
    child = target->right;
  }

  if (child != NIL)
  {
    child->parent = target->parent;
  }

  if (target->parent == NIL)
  {
    root = child;
  }
  else
  {
    if (target == target->parent->left)
    {
      target->parent->left = child;
    }
    else
    {
      target->parent->right = child;
    }
  }

  if (target != z)
  {
    z->key = target->key;
  }

  free(target);
}

void insert(int key)
{
  Node *y = NIL;
  Node *x = root;

  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL)
  {
    y = x;
    if (z->key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }
  // この時点でyはzの親か初期値のNIL
  z->parent = y;
  if (y == NIL)
  {
    // 親がNILなのはroot
    root = z;
  }
  else
  {
    // 親の子へ設定
    if (z->key < y->key)
    {
      y->left = z;
    }
    else
    {
      y->right = z;
    }
  }
}

void inorder(Node *u)
{
  if (u == NIL)
  {
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if (u == NIL)
  {
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n;
  int x;
  string command;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    cin >> command;
    if (command[0] == 'f')
    {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL)
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
    else if (command == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if (command == "print")
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (command == "delete")
    {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 21960
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>
#include <cstring>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

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

	int result = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k <= N; k++) {
				int tmpGDC = gcd(i, j);
				tmpGDC = gcd(tmpGDC, k);
				result += tmpGDC;
			}
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize
    }
    println!("{}", if a + b < c && 4 * a * b < (c - a - b).pow(2) {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
A = list(map(int, input().split()))
num = dict()
for i in range(M):
    B, C = map(int, input().split())
    if C in num.keys():
        num[C] += B
    else:
        num[C] = B
for i in range(N):
    if A[i] in num.keys():
        num[A[i]] += 1
    else:
        num[A[i]] = 1
dct = sorted(num.items(), reverse = True)
count = N
ans = 0
for i in range(len(dct)):
    b, c = dct[i]
    if c <= count:
        ans += b * c
    else:
        ans += b * count
    count -= c
    if count <= 0:
        break
print(ans)



Measured memory_bytes: 40736
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


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

    int ans = 0;
    for(int i = 1; i<N; i++){
        for(int j = 1; j*j <= N-i; j++){
            if((N-i)%j == 0){
                ans += 2;
                if(j*j == N-i)ans--;
            }
        }
    }

    cout << ans << endl;

}



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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int a,b,c,d;

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

  cin>>a>>b>>c>>d;
  cout<<a*b-((a/c)*(b/d)*(c*d))<<endl;

  return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int X, Y;
	while ( cin >> X >> Y && X && Y )
	{
		vector < vector <int> > map( Y, vector <int>(X, 0) );
		vector < vector <int> > dp( Y, vector <int>(X, 0) );
		for ( int i = 0; i < Y; i++ )
		{
			for ( int j = 0; j < X; j++ )
			{
				cin >> map[i][j];
			}
		}

		for ( int i = 0; i < X; i++ )
		{
			if ( map[0][i] == 0 )
				dp[0][i] = 1;
		}

		for ( int i = 0; i < Y-1; i++ )
		{
			for ( int j = 0; j < X; j++ )
			{
				if ( map[i][j] == 2 )
				{
					if ( i+2 < Y )
					{
						if ( map[i+2][j] != 1 )
							dp[i+2][j] += dp[i][j];
					}
					else
					{
						dp[Y-1][j] += dp[i][j];
					}
				}
				if ( map[i][j] == 0 )
				{
					if ( i+1 < Y )
					{
						if ( map[i+1][j] == 2 )
						{
							dp[i+1][j] += dp[i][j];
						}
					}
				}
				for ( int k = -1; k < 2; k++ )
				{
					if ( j+k<0 || j+k>=X )
						continue;

					if ( map[i][j] == 0 && map[i+1][j+k] == 0 )
					{
						dp[i+1][j+k] += dp[i][j];
					}
				}
			}
		}

		int answer = 0;
		for ( int i = 0; i < X; i++ )
		{
			answer += dp[Y-1][i];
		}

		cout << answer << endl;

	}
	return 0;
}

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

int main()
{
	int n;
	for (cin >> n; n; n--) {
		int a, b, c;
		cin >> a >> b;
		if (a < b) {
			int tmp = b;
			b = a;
			a = tmp;
		}
		cin >> c;
		if (a < c) {
			int tmp = c;
			c = a;
			a = tmp;
		}
		cout << (pow(a, 2) == pow(b, 2) + pow(c, 2) ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vint p(n);rep(i,n)cin>>p[i];
    sort(p.begin(),p.end());
    int ans = p[n-1]/2;
    rep(i,n-1)ans += p[i];
    cout<<ans<<endl; return 0; 
}


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

struct potential_Unionfind{
    vector<int> parents;
    vector<int> weights;
    int m;
    potential_Unionfind(int n):parents(n,-1){
        m = n;
        weights.resize(n);
    }

    int find(int x){
        if(parents[x] < 0) return x;
        else{
            int p = find(parents[x]);
            weights[x] += weights[parents[x]];
            return parents[x] = p;
        }
    }

    //weight[y] - weights[x] = wとなるようにuniteする。
    bool unite(int x,int y,int w){
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if(x == y) return false;//もうすでに繋がれている頂点ならfalseを返す
        if(parents[x] > parents[y]) {swap(x,y); w = -w;}
        parents[x] += parents[y];
        parents[y] = x;
        weights[y] = w;
        return true;
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }

    //weightsは各頂点から根までの距離
    int weight(int x){
        find(x);
        return weights[x];
    }

    int diff(int x,int y){
        return weight(y) - weight(x);
    }


};

int main(){
    int n,m;
    cin >> n >> m;
    potential_Unionfind uf(n);
    rep(i,m){
        int a,b,w;
        cin >> a >> b >> w;
        --a;--b;
        if(!uf.unite(a,b,w)){
            if(uf.diff(a,b) != w){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;

}


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

int main(void){
    int N, number, max_sum = 20;
    std::cin >> N;
    std::vector<std::vector<unsigned long long> > dp(N, std::vector<unsigned long long>(max_sum + 1, 0));
    std::cin >> number;
    dp[0][number] = 1;
    for(int i = 1; i <= N - 2; ++i){
        std::cin >> number;
        for(int j = 0; j <= max_sum; ++j){
                if(j + number <= max_sum)
                    dp[i][j + number] += dp[i - 1][j];
                if(0 <= j - number)
                    dp[i][j - number] += dp[i - 1][j];
        }
    }
    std::cin >> number;
    std::cout << dp[N - 2][number] << std::endl;
}

Measured memory_bytes: 1224
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <functional>
#include <random> 
#include <tuple>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793

#define DEBUG 1

int main(void) {
    string s;
#if DEBUG
    cin >> s;

#else 

    int n = 500000;

    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> r(0, 1);

    for (int i = 0; i < n; ++i) 
        if (r(mt) == 0) s.push_back('<');
        else s.push_back('<');


#endif
    
    vector<int> a(s.length() + 1, 0);

    for (int i = 0; i < s.length(); ++i) {
        int j = i + 1;
        while (s[i] == s[j]) {
            //cout << s[i] << " " << s[j] << " " << j << endl;
            ++j;
        }
        ull dis = j - i;
        
        if (s[i] == '<') {
            if (dis > a[j]) a[j] = dis;
            a[i] = 0;
            for (int k = i + 1; k < j; ++k) {
                a[k] = a[k - 1] + 1;
            }
        }
        else {
            if (dis > a[i]) a[i] = dis;
            a[j] = 0;
            for (int k = j - 1; k > i; --k) {
                a[k] = a[k + 1] + 1;
            }
        }
        if (j != i + 1) i = j - 1;     
    }

    //for (int& aa : a) cout << aa << ", ";
      //cout << endl;

    cout << accumulate(a.begin(), a.end(), 0LL) << endl;


    return 0;
}

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

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

    vector< vector<int> > X(N, vector<int>(D)); // 2重ネストした vector
    for (int i=0; i<N; ++i)
        for (int j=0; j<D; ++j)
            cin >> X[i][j];

    int ans = 0;
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            int norm = 0;
            for (int k=0; k<D; ++k) {
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for (int k=0; k<=norm; ++k) {
                if (k*k == norm) {
                    flag = true;
                }
            }
            if (flag) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n;
	long double ansinv=0,ans;
	cin>>n;
	vector <long double> a(n);
	rep(i,n)cin>>a[i];
	vector <long double> ainv(n);
	rep(j,n)ainv[j]=1/a[j];
	rep(k,n)ansinv+=ainv[k];
	ans=1/ansinv;
	
	cout<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> A(N + 1);
	vector<ll> B(N);
	rep(i, N+1) {
		cin >> A.at(i);
	}
	rep(i, N) {
		cin >> B.at(i);
	}
	ll an = 0;
	rep(i, N) {
		if (A.at(i) >= B.at(i)) {
			an += B.at(i);
			A.at(i) -= B.at(i);
			B.at(i) = 0;
		}
		else {
			an += A.at(i);
			B.at(i) -= A.at(i);
			A.at(i) = 0;
		}
		if (A.at(i + 1) >= B.at(i)) {
			an += B.at(i);
			A.at(i + 1) -= B.at(i);
			B.at(i) = 0;
		}
		else {
			an += A.at(i + 1);
			B.at(i) -= A.at(i + 1);
			A.at(i + 1) = 0;
		}
	}
	cout << an << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#define MAX_SIZE 100

int row_sum(int i, int c, int matrix[][MAX_SIZE]);
int colum_sum(int i, int r, int matrix[][MAX_SIZE]);

int main()
{
    int r, c;
    scanf("%d %d", &r, &c);

    int matrix[MAX_SIZE][MAX_SIZE];

    for(int i = 0; i < r; i++)
    {
        for(int j = 0; j < c; j++)
        {
            scanf("%d", &matrix[i][j]);
        }
    }

    for(int i = 0; i <=r; i++)
    {
        if(i == r)
        {
            int sum = 0;
            for(int j = 0; j <=c; j++)
            {
                if(j) printf(" ");
                if(j == c){
                    printf("%d\n", sum);
                }
                else{
                    printf("%d", colum_sum(j, r, matrix));
                    sum += colum_sum(j, r, matrix);
                }
            }
        }
        else{
            for(int j = 0; j <=c; j++)
            {
                if(j) printf(" ");
                if(j == c){
                    printf("%d\n", row_sum(i, c, matrix));
                }
                else
                {
                    printf("%d", matrix[i][j]);
                }
            }
        }


        
    }
}

int row_sum(int i, int c, int matrix[][MAX_SIZE])
{
    int sum = 0;
    for(int j = 0; j < c; j++)
    {
        sum += matrix[i][j];
    }

    return sum;
}

int colum_sum(int i, int r, int matrix[][MAX_SIZE])
{
    int sum = 0;
    for(int j = 0; j < r; j++)
    {
        sum += matrix[j][i];
    }

    return sum;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int n,a[N];
ll res;
map<ll,ll> H;
set<int> kaka;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n;
	fo(i,0,n-1) { cin>>a[i]; kaka.insert(a[i]); H[a[i]]++; }
	for (int u:kaka) {
		res+=((H[u]*(H[u]-1))/2);
	}
	fo(i,0,n-1) cout<<1+res-H[a[i]]<<endl;
	return 0;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{

    //freopen("inputfile.txt","r",stdin);
    IOS;
   string s;cin>>s;
   int count = 0;
   for(int i=0;i<s.size();)
   {

       if(s[i]=='R'){
        int ans = 0;
       while(s[i]=='R')
       {
           ans++;
           i++;
       }
       count = max(count,ans);
       }
       else i++;
   }
   cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include<cstring>
#include<bits/stdc++.h> 
#define ll long long
#define fo(a,b,c) for(a=b;a<c;a++)
using namespace std;

int main(){
	char a;
	cin >> a;
	if(a<91){
		cout << "A" ;
	}
	else{
		cout << "a";
	}
	return 0;
}

Measured memory_bytes: 3596
A, B, C = map(int, input().split())
max_v = max(A,B,C)
temp = (max_v - A) + (max_v - B) + (max_v - C)
ans = 0

if temp % 2 == 0:
    ans = temp/2
else:
    ans = (temp+1)/2 + 1
    
print(int(ans))

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	var us []float64
	for i := 0; i < n; i++ {
		var u float64
		fmt.Scan(&u)
		us = append(us, u)
	}

	sort.Float64s(us)

	result := (us[0] + us[1]) / 2
	for i := 2; i < n; i++ {
		result = (result + us[i]) / 2
	}

	fmt.Print(result)

}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  long long odd=0,even=0,odd_num=0,even_num=0;
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    if(i%2==0){
      if(even_num+a[i]>0)
        even_num+=(long long)a[i];
      else{
        even+=1-(long long)(even_num+a[i]);
        even_num=1;
      }
      if(odd_num+a[i]<0)
        odd_num+=(long long)a[i];
      else{
        odd+=1+(long long)(odd_num+a[i]);
        odd_num=-1;
      }
    }
    else{
      if(even_num+a[i]<0)
        even_num+=(long long)a[i];
      else{
        even+=1+(long long)(even_num+a[i]);
        even_num=-1;
      }
      if(odd_num+a[i]>0)
        odd_num+=(long long)a[i];
      else{
        odd+=1-(long long)(odd_num+a[i]);
        odd_num=1;
      }
    }
  }
  printf("%lld\n",even<odd?even:odd);
  return 0;
}

Measured memory_bytes: 2068
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
n,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
s = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
ans = 0
for i in range(n-1):
    ans+=min(b,(s[i+1]-s[i])*a)
print(ans)

Measured memory_bytes: 24128
#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
    while (1)
    {
        int n, a[10010], cnt=1, p_v, ans=0;
        vector<pair<int, int>> vec;
        cin>>n;
        if (n==0) break;
        for (int i=n-1; i>=0; i--) cin>>a[i];
        p_v=a[0];
        for (int i=1; i<n; i++)
        {
            if (a[i]!=p_v)
            {
                vec.push_back({p_v, cnt});
                cnt=1;
                p_v=a[i];
            }
            else cnt++;
        }
        vec.push_back({p_v, cnt});
        for (auto u=vec.begin(); u!=vec.end(); u++)
        {
            auto v=vec.begin();
            u++;
            cnt=0;
            if (u==vec.end()) break;
            if (u->second!=3) u--;
            else
            {
                u--;
                stack<pair<int, int>> stk;
                for (; v<=u; v++)
                {
                    stk.push({v->first, v->second});
                }
                v=u;
                cnt=4;
                u++;
                if (v->second==1)
                {
                    stk.pop();
                    if (!stk.empty() && stk.top().first==u->first) { cnt+=stk.top().second; stk.pop(); }
                }
                else stk.top().second-=1;
                u--;
                v++; v++;
                for (; v!=vec.end() && !stk.empty(); v++)
                {
                    if (stk.top().first==v->first && stk.top().second+v->second>=4)
                    {
                        cnt+=stk.top().second+v->second;
                        stk.pop();
                    }
                    else { v=vec.end(); v--; }
                }
            }
            ans=max(ans, cnt);
        }
        for (auto u=vec.begin(); u!=vec.end(); u++)
        {
            auto v=vec.begin();
            if (u==vec.begin()) u++;
            u--;
            cnt=0;
            if (u->second!=3) u++;
            else
            {
                stack<pair<int, int>> stk;
                for (; v<u; v++)
                {
                    stk.push({v->first, v->second});
                }
                cnt=4;
                v=u;
                v++;
                if (v->second==1)
                {
                    v++;
                    if (v->first==u->first) { cnt+=v->second; v++; }
                }
                else v->second-=1;
                u++;
                for (; v!=vec.end() && !stk.empty(); v++)
                {
                    if (stk.top().first==v->first && stk.top().second+v->second>=4)
                    {
                        cnt+=stk.top().second+v->second;
                        stk.pop();
                    }
                    else { v=vec.end(); v--; }
                }
            }
            ans=max(ans, cnt);
        }
        cout<<n-ans<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3304
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print("3")
elif A == 1 and B == 3:
  print("2")
elif A == 2 and B == 1:
  print("3")
elif A ==3 and B == 1:
  print("2")
elif A == 3 and B == 2:
  print("1")
else:
  print("1")

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

int main() {
    string s, t;

    cin >> s >> t;

    int m = s.size();
    int n = t.size();

    int dp[m][n][5];
    /*
     * dp[i][j][0] = value
     * dp[i][j][1] = previousI
     * dp[i][j][2] = previousJ
     * d[i][j][3] = currentI
     * dp[i][j][4] = currentJ
     */
    int max = 0;
    int startX = -1;
    int startY = -1;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j][0] = 0;
            dp[i][j][1] = -1;
            dp[i][j][2] = -1;
            dp[i][j][3] = -1;
            dp[i][j][4] = -1;

            if (s[i] == t[j]) {
                if (i > 0 && j > 0) {
                    dp[i][j][0] = dp[i - 1][j - 1][0] + 1;
                    dp[i][j][1] = dp[i - 1][j - 1][3];
                    dp[i][j][2] = dp[i - 1][j - 1][4];
                }
                else {
                    dp[i][j][0] = 1;
                }

                dp[i][j][3] = i;
                dp[i][j][4] = j;
            }
            else {
                if (i > 0 && dp[i - 1][j][0] > 0) {
                    dp[i][j][0] = dp[i - 1][j][0];
                    dp[i][j][1] = dp[i - 1][j][1];
                    dp[i][j][2] = dp[i - 1][j][2];
                    dp[i][j][3] = dp[i - 1][j][3];
                    dp[i][j][4] = dp[i - 1][j][4];
                }

                if (j > 0 && dp[i][j - 1][0] > dp[i][j][0]) {
                    dp[i][j][0] = dp[i][j - 1][0];
                    dp[i][j][1] = dp[i][j - 1][1];
                    dp[i][j][2] = dp[i][j - 1][2];
                    dp[i][j][3] = dp[i][j - 1][3];
                    dp[i][j][4] = dp[i][j - 1][4];
                }
            }

            if (dp[i][j][0] > max) {
                max = dp[i][j][0];
                startX = i;
                startY = j;
            }
        }
    }

    string ans = "";

    while (startX != -1 && startY != -1) {
        ans = s[dp[startX][startY][3]] + ans;

        int x = dp[startX][startY][1];
        int y = dp[startX][startY][2];

        startX = x;
        startY = y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 176000
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
 
///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////
 
int main(){
    string s;
    cin>>s;
    bool a=false,b=false,c=true,key2=false;
    rep(i,s.size()){
        if(s[i]>='A' && s[i]<='Z'){
            if(i==0 && s[i]=='A'){
                a = true;
            }else if((i>1 && i<=s.size()-2) && s[i]=='C' && !key2){
                key2 = true;
                b = true;
            }else if((key2 || i<=1)&& s[i]=='C'){
                b = false;
                key2 = true;
            }else{
                c = false;
            }
        }else{
 
        }
    }
    if(a&&b&&c){
        cout<<"AC"<<endl;
    }else{
        cout<<"WA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin>>S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;







int main()
{
    ll n,w;
    cin>>n>>w;
    ll W[n+1],val[n+1];
    ll sum=0;
    for(ll i=1; i<=n; i++)
    {
        cin>>W[i]>>val[i];
        sum+=val[i];

    }

    ll dp[n+1][sum+1];
    for(ll i=0; i<=n; i++)
    {
        for(ll j=0; j<=sum; j++)
        {
            if(j==0)
                dp[i][j]=0;
            else
                dp[i][j]=1e18;
        }
    }

    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=sum; j++)
        {
            if(j>=val[i])
            {
                dp[i][j]=min(dp[i-1][j-val[i]]+W[i],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }


//    for(ll i=1; i<=n; i++)
//    {
//        for(ll j=1; j<=sum; j++)
//        {
//            cout<<dp[n][j]<<ss;
//        }
//        cout<<nn;
//    }
    ll ans=0;
    for(ll i=1; i<=sum; i++)
    {
        if(dp[n][i]==1e18)
            continue;
        //cout<<0;
        if(dp[n][i]<=w)
            ans=max(ans,i);
    }

    cout<<ans<<nn;

    //cout<<dp[n][100]<<nn;









}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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

static const int MAX_N = 100000;
int A[MAX_N][3];
int DP[MAX_N][3];

int main()
{
  int N;

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

  for (int i = 0; i < 3; ++i)
  {
    DP[N-1][i] = A[N-1][i];
  }

  for (int i = N - 2; i >= 0; --i)
  {
    for (int j = 0; j < 3; ++j)
    {
      int maxv = 0;
      for (int k = 0; k < 3; ++k)
      {
        if (k == j) continue;
        maxv = max(maxv, DP[i + 1][k]);
      }
      DP[i][j] = A[i][j] + maxv;
    }
  }

  int ans = 0;
  for (int i = 0; i < 3; ++i)
  {
    ans = max(ans, DP[0][i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
#n = int(input())
d, t, s = map(int, sys.stdin.readline().split())
#n = input()
#a = list(map(int, sys.stdin.readline().split()))


x = d / s

if x <= t:
    print("Yes")
else:
    print("No")







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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 100050;

int n, a[maxn], s1, s2, shit;

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n) if(a[i]%4==0) ++ s1; else ++ s2;
	fo(i,1,n) if(a[i]%2==0&&(a[i]%4!=0)) ++ shit;
	if(s1+s1+1==n) {puts("Yes"); return 0;} 
	if(shit>=2) s2 -= shit;
	if(s2-s1>1) {puts("No"); return 0;}
	if(s1 >= s2) puts("Yes");
	else puts("No");
	return 0;
}

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

int a[200000],reva[200001];


int main() {
	int n; cin >> n;
	for(int i=0;i<n;++i) cin>>a[i],reva[a[i]]=i;
	long long ans=0;
	set<int> lst,rst;
	lst.insert(1);
	rst.insert(n);
	for(int i=1;i<=n;++i) {
		auto lit=lst.lower_bound(-reva[i]);
		auto rit=rst.lower_bound(reva[i]);
		ans+=1LL*(reva[i]+*lit)*(*rit-reva[i])*i;
		lst.insert(-reva[i]); rst.insert(reva[i]);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stack>
using namespace std;


//维护四个dp动态规划

int main()
{
    int a,b;
    cin>>a>>b;
    int n1=0,n2=0,n3=0;

     n1=a*2-1;

        n2=b*2-1;
    n3=a+b;
    cout<<max(max(n1,n2),n3);
    return 0;
}


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

vector<int> G[200010];

int main()
{

int N,M;
cin >> N >> M;

rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
}

vector<int> dist(N, -1);
queue<int> que;

dist[0] = 0;
que.push(0);

while (!que.empty()) {
    int v = que.front(); 
    que.pop();

    for (int nv : G[v]) {
        if (dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        que.push(nv);
    }
}

if(dist[N - 1] == 2) puts("POSSIBLE");
else puts("IMPOSSIBLE");

return 0;
}

Measured memory_bytes: 13168
fn solve(a: usize, b: usize) -> usize {
    let mut acc = 1;
    let mut c = 0;
    loop {
        if acc * a > b {
            break;
        }
        c += acc;
        acc *= a;
    }

    let r = b - acc;
    let s = r / (a - 1) + if r % (a - 1) > 0 { 1 } else { 0 };

    s + c
}

#[test]
fn solve_test() {
    assert_eq!(solve(4, 10), 3);
    assert_eq!(solve(8, 9), 2);
    assert_eq!(solve(8, 8), 1);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (a, b) = parse_line!(usize, usize);
    println!("{}", solve(a, b));
}


Measured memory_bytes: 4352
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define pb push_back
# define cauto const auto
# define int long long
using namespace std;
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class Type> void Print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void Print(vector<vector<Type>> &df) { for (auto& vec : df) { Print(vec); } }

static const int dx[4] = {1, 0, -1, 0};
static const int dy[4] = {0, 1, 0, -1};
static const vector<pair<int, int>> dydx = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int W, H;

bool read()
{
    cin >> W >> H;
    return not (W == 0 and H == 0);
}

bool read(vector<vector<int>>& G)
{
    rep (y, 2*H - 1)
    {
        rep (x, IsEven(y) ? W - 1 : W)
        {
            Cin(int, v);
            if (v == 0) // 壁なし
            {
                int now = y/2*W + x;
                int nxt = now + 1*IsEven(y) + W*IsOdd(y);
                G[now].pb(nxt);
                G[nxt].pb(now);
            }
        }
    }
    return true;
}

signed main()
{
    while (read())
    {
        vector<vector<int>> G(H*W);
        read(G);
        const int entry = 0;
        const int exit = H*W - 1;

        queue<int> que;
        vector<int> d(W*H, -1);
        que.push(entry);
        d[entry] = 0;
        while (not que.empty())
        {
            int now = que.front(); que.pop();
            if (now == exit) break;
            for (cauto& nxt : G[now])
            {
                if (d[nxt] > 0) continue;
                d[nxt] = d[now] + 1;
                que.push(nxt);
            }
        }
        Print(d[exit] + 1);
    }

    return 0;
}



Measured memory_bytes: 3096
n=input()
nl=len(n)
m=input()
ml=len(m)
if nl>ml:
  print('GREATER')
elif nl<ml:
  print('LESS')
else:
  for i in range(nl):
    if int(n[i])>int(m[i]):
      print('GREATER')
      break
    elif int(n[i])<int(m[i]):
      print('LESS')
      break
    if i==nl-1:
      print('EQUAL')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

int main(){
    string x;
    int ans = 0;
    getline(cin,x);
    while ( x != "0" ) {
        for ( int i=0; i<x.length();i++ ){
            //cout << int(x[i]-'0') << endl;
            ans+= int(x[i]-'0');
        }
        cout << ans << endl;
        ans = 0;
        getline(cin,x);
    }
    return 0;
}



Measured memory_bytes: 3180
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))

Measured memory_bytes: 23240
using System;
using System.Collections.Generic;

namespace ABC123_A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			List<int> list = new List<int>();
			for(int i = 0; i < 6; i++)
				list.Add(int.Parse(Console.ReadLine()));

			for (int i = 0; i < 4; i++)
			{
				for (int j = i + 1; j < 5; j++)
				{
					if ((Math.Abs(list[i] - list[j])) > list[5])
					{
						Console.WriteLine(":(");
						return;
					}
				}
			}
			
			Console.WriteLine("Yay!");
			
			
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int n;

void solve1(vector<int> x, vector<int> y, int p){
    ld ans = 0;
    forn(i, n) ans += pow(abs(x[i] - y[i]), p);
    ans = powl(ans, 1.0/p);
    cout << setprecision(10) << ans << endl;
}

void solve2(vector<int> x, vector<int> y){
    int ans = 0;
    forn(i, n) ans = max(ans, abs(x[i] - y[i]));
    cout << setprecision(10) << ans << endl;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    forn(i, n) cin >> x[i];
    forn(i, n) cin >> y[i];
    solve1(x, y, 1);
    solve1(x, y, 2);
    solve1(x, y, 3);
    solve2(x, y);

}


Measured memory_bytes: 3604
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, k: usize, a:[usize; n]};
    let a: Vec<usize> = a;

    for i in 0..n - k {
        if a[i] < a[i + k] {
            println!("Yes")
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 5596
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = iil()
ans = 0
for i in range(n):
    for j in range(i+1,n):
#        print(i,j)
        ans += D[i]*D[j] 
print(ans)

Measured memory_bytes: 3316