akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

using mint= atcoder::modint998244353;
constexpr int Nmax= 200'000; // '
constexpr int logNmax= 31- __builtin_clz(Nmax);

struct S{
  mint mS_rep;
  int  mS_len;
};

struct F{
  optional<mint> mF_assign;
};

vector<mint> g_aux(logNmax+ 1);
void init(){
  g_aux.at(0)= 1;
  for(int i= 1; i<= logNmax; i++){
    g_aux.at(i)= g_aux.at(i-1)*mint(10).pow(1<<(i-1)) + g_aux.at(i-1);
  }
}

S op(S left, S right){ return S{left.mS_rep*mint(10).pow(right.mS_len) + right.mS_rep, left.mS_len+ right.mS_len}; };

S e(){ return S{0, 0}; };

S mapping(F f, S s){
  if(!f.mF_assign){ return s; }
  else{
    int loglen= 31- __builtin_clz(s.mS_len);
    return S{f.mF_assign.value()* g_aux.at(loglen), s.mS_len};
  }
};

F composition(F f2, F f1){
  if(!f2.mF_assign){ return f1; }
  else             { return f2; }
};

F id(){ return F{nullopt}; };

int main(){
  init();

  int N,Q;
  cin >> N >> Q;

  atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N, S{1,1}));

  int bufL,bufR,bufD;
  for(int q=0; q<Q; q++){
    cin >> bufL >> bufR >> bufD;
    bufL--; // [bufL,bufR] 1-indexed -> [bufL,bufR) 0-indexed
    seg.apply(bufL, bufR, F{bufD});

    cout << seg.all_prod().mS_rep.val() << endl;
  }
}

Measured memory_bytes: 10936
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

char field[1005][1005];

int main(void) {
    queue<pair<int, int>> q;
    int cnt = 0;
    int H, W; cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '#') {
                q.push({i, j});
                cnt++;
            }
        }
    }
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    int ans = 0;
    while (!q.empty()) {
        pair<int, int> crt = q.front();
        q.pop();
        cnt--;
        for (int i = 0; i < 4; i++) {
            int ni = crt.first + dy[i];
            int nj = crt.second + dx[i];
            if (0 <= ni && ni < H && 0 <= nj && nj < W) {
                if (field[ni][nj] == '.') {
                    field[ni][nj] = '#';
                    q.push({ni, nj});
                }
            }
        }
        if (cnt == 0) {
            cnt = q.size();
            ans++;
        }
    }
    cout << ans-1 << endl;
}



Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,st,sr;
    int x=0,i,temp=0;
    cin>>s>>st;
    sr=s+st;
    for (i=0;i<sr.length();i++)
    x=x*10+sr[i]-49+1;
	temp=(int)sqrt(x);
    if(temp*temp==x){
		cout<<"Yes"<<endl;
        return 0;
    }
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,n;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			n=i*j;
			printf("%dx%d=%d",i,j,n);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2036
// AOJ DSL_3_C The Number of Windows
// 2018.5.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() {
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

long long ll() {
	long long n = 0; int c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF   0x10101010101010LL
#define MAX_N 100005
long long s[MAX_N];

int main()
{
	int N, Q, i, j;
	long long base, x, ans;

	N = in(), Q = in();
	base = (long long)N*(N+1) >> 1;

	for (i = 1; i <= N; i++) s[i] = s[i-1] + in();
	s[++N] = INF;		// caution: N -> N+1

	while (Q--) {
		x = ll();
		j = 1; while (s[j] <= x) j++;
		ans = 0, i = 0;
		while (j < N) {
			while (s[j]-s[i] >  x) i++, ans += N-j;
			while (s[j]-s[i] <= x) j++;
		}
		printf("%lld\n", base-ans);
	}
	return 0;
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
#define foi for(int i=0; i<n; i++)
#define foj for(int j=0; j<n; j++)
#define ll long long int
#define vi vector<int>
#define maxn 200005
#define mod 1000000007
using namespace std;

int cnt[30];
char c;
int main() {
    int n;
    cin >> n;
    foi {
        cin >> c;
        cnt[c-'a']++;
    }
    ll ans=1;
    for (int i=0; i<28; i++) {
        ans=ans*(cnt[i]+1)%mod;
    }
    ans--;
    if (ans<0) ans+=mod;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
void solve()
{
    ll N;cin>>N;
    ll i=1;
    while(1)
    {
        if((i*360)%N ==0){cout<<(i*360)/N<<"\n";return;}
        i++;
    }
    cout<<"-1\n";
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    solve(); exit(0);
}/*Solved By:- Ritik Agarwal*/

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

ll int A, B;
ll int K;
set<ll int> s;

int main(){
    scanf("%lld%lld%d", &A, &B, &K);

    ll int m = (A == B) ? 1 : B - A;

    REP(i, min(m, K)){
        s.insert(A+i);
        s.insert(B-i);
    }

    for(auto itr=s.begin();itr!=s.end();++itr){
        printf("%lld\n", *itr);
    }

	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace _0632
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[,] Area = new char[x[0], x[1]];
            for (int i = 0; i < x[0]; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < x[1]; j++)
                {
                    Area[i, j] = s[j];
                }
            }
            int a = 0;
            for (int i = 0; i < x[0]; i++)
            {
                for (int j = 0; j < x[1]; j++)
                {
                    bool b = true;
                    if (i + x[2] <= x[0])
                    {
                        for (int k = 0; k < x[2]; k++)
                        {
                            if (Area[i + k, j] != '.')
                            {
                                b = false;
                            }
                        }
                        if (b)
                        {
                            a++;
                        }
                    }
                    b = true;
                    if (j + x[2] <= x[1])
                    {
                        for (int k = 0; k < x[2]; k++)
                        {
                            if (Area[i, j + k] != '.')
                            {
                                b = false;
                            }
                        }
                        if (b)
                        {
                            a++;
                        }
                    }
                }
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 9452
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        for(int n = 0; n < 3000; n++) {
            int x = s.nextInt();
            int y = s.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            else {
                if(x > y) {
                    int m;
                    m = x;
                    x = y;
                    y = m;
                }
            }
            System.out.println(x + " " + y);
        }
    }
}


Measured memory_bytes: 35952
#include<bits/stdc++.h>
using namespace std;
bool A[200],B[200];
int N;
void change(bool *C,int &c,int &fld){
    for(int i=fld+1;i<2*N;i++){
        if(C[i]){
            C[i]=false;
            c--;
            fld=i;
            return;
        }
    }
    fld=-1;
}
void solve(){
    int a,b,fld=-1;
    a=b=N;
    for(int i=0;i<N;i++){
        int x;
        scanf("%d",&x);
        A[--x]=true;
        B[x]=false;
    }

    for(int i=0;a&&b;i++){
        if(i%2)change(B,b,fld);
        else change(A,a,fld);
    }
    printf("%d\n%d\n",b,a);
}

int main(){
    while(scanf("%d",&N),N){
        fill_n(A,2*N,false);
        fill_n(B,2*N,true);
        solve();
    }
    return 0;
}

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

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

pair<int, int> rotate(pair<int, int> p) {
    return { -p.second, p.first };
}

int main() {
    int n;
    while (cin >> n && n) {
        set<int> ans;
        vector<pair<int, int>> v[n+1];
        rep(i, n+1) {
            int m; cin >> m;
            rep(j, m) {
                pair<int, int> p;
                cin >> p.first >> p.second;
                v[i].push_back(p);
            }
        }

        for (int i = 1; i < n+1; ++i) {
            if (v[0].size() != v[i].size()) continue;
            bool ok = false;
            for (int r = 0; r < 4; ++r) {
                bool f = true;
                double dx = -1, dy = -1;
                for (int j = 0; j < v[i].size(); ++j) {

                    double x = v[0][j].first - v[i][j].first;
                    double y = v[0][j].second - v[i][j].second;

                    if (dx == -1 && dy == -1) { dx = x; dy = y; }

                    if (v[0][j] != v[i][j]) {
                        if (dx != x || dy != y) {
                            f = false;
                        }
                    }

                    v[i][j] = rotate(v[i][j]);
                }
                if (f) {
                    ok = true;
                    cout << i << endl;
                    break;
                }
            }

            if (!ok) {
                for (int r = 0; r < 4; ++r) {
                    bool f = true;
                    int dx = -1, dy = -1;
                    for (int j = v[i].size()-1; j >= 0; --j) {

                        double x = v[0][v[i].size()-j-1].first - v[i][j].first;
                        double y = v[0][v[i].size()-j-1].second - v[i][j].second;

                        if (dx == -1 && dy == -1) { dx = x; dy = y; }

                        if (v[0][v[i].size()-j-1] != v[i][j]) {
                            if (dx != x || dy != y){
                                f = false;
                            }
                        }

                        v[i][j] = rotate(v[i][j]);
                    }
                    if (f) {
                        ok = true;
                        cout << i << endl;
                        break;
                    }
                }
            }
        }

        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define M 100005
int a[M],b[M],cnt;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);cnt=unique(b+1,b+n+1)-b-1;
	for(int i=1;i<=n;++i)a[i]=lower_bound(b+1,b+cnt+1,a[i])-b;
	int ans=0;
	for(int i=1;i<=n;++i){
		int pr=1e9,j;
		for(j=i;j<=n;++j){
			if(a[j]>pr)break;
			pr=a[j];
		}ans=max(ans,j-i);
		i=j-1;
	}
	printf("%d",ans-1);
}

Measured memory_bytes: 1024
#include <ctype.h>
#include <stdio.h>
#include <string.h>

void
lowercase(char *s)
{
	int i;
	for (i = 0; s[i] != '\0'; i++)
	{
		s[i] = tolower(s[i]);
	}
}

int
main()
{
	char w[10] = {0};
	char t[1000] = {0};
	scanf("%s", w);
	lowercase(w);

	int n_matches = 0;
	for (;;)
	{
		scanf("%s", t);

		if (strcmp(t, "END_OF_TEXT") == 0)
			break;

		lowercase(t);
		if (strcmp(t, w) == 0)
			n_matches++;
	}

	printf("%d\n", n_matches);

	return 0;
}

Measured memory_bytes: 548
#include<stdio.h>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int A[N];
  for (int i=0 ; i<N ; i++) {
    scanf("%d", &A[i]);
  }
  sort(A, A+N);
  int res=0;
  int num=0;
  int cnt=0;
  for (int i=0 ; i<N ; i++) {
    if (A[i] != num) {
      if (cnt % 2 != 0) res++;
      num = A[i];
      cnt = 1;
    } else {
      cnt++;
    }
    
    if (i==N-1) {
      if (cnt % 2 != 0) res++;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string s;
  cin >> s;

  set<char> ss;
  for (int i = 0; i != s.size(); ++i) {
    ss.insert(s[i]);
  }
  if (ss.size() == 26) {
    cout << "None" << endl;
  } else {
    for (char chr = 'a'; chr <= 'z'; ++chr) {
      if (ss.count(chr) == 0) {
        cout << chr << endl;
        break;
      }
    }
  }
  return 0;
}


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

using namespace std;
#define ll long long
const int N=100005;
int n;
int ar[N];
int mem[N];

int solve(int ind){
    if(ind==n-1){
        return 0;
    }
    if(ind>=n){
        return 1e9;
    }
    if(mem[ind]!=-1){
        return mem[ind];
    }
    int ch1=solve(ind+1)+abs(ar[ind]-ar[ind+1]);
    int ch2=solve(ind+2)+abs(ar[ind]-ar[ind+2]);
    return mem[ind]=min(ch1,ch2);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 4224
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	s, t := readString(), readString()

	ans := math.MaxInt64
	for i := 0; i <= len(s)-len(t); i++ {
		cnt := 0
		for j := range t {
			if s[i+j] != t[j] {
				cnt++
			}
		}
		ans = min(ans, cnt)
	}

	fmt.Println(ans)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;

int N, A[200005], B[200005];
vector<int> V;
map<int, int> mp;
int mx;

signed main()
{
    cin >> N;
    for(int i = 0; i < N ;i++){
        cin >> A[i];
        mp[A[i]]++;
        mx = max(mx, A[i] * 2);
    }
    sort(A, A + N);
    int tmp = 1ll;
    while(tmp <= mx){
        V.pb(tmp);
        tmp *= 2ll;
    }
    /*for(int i = 0; i < V.size(); i++){
        printf("%lld\n", V[i]);
    }*/
    int k = 0;
    for(int i = 0; i < N; i++){
        while(V[k] <= A[i]){
            k++;
        }
        B[i] = V[k] - A[i];
    }
    int ans = 0ll;
    for(int i = N - 1; i >= 0; i--){
        if(mp[A[i]] <= 0)continue;
        mp[A[i]]--;
        ans += (int)(mp[B[i]] > 0);
        mp[B[i]]--;
    }
    cout << ans << endl;
    /*for(int i = N - 1; i >= 0; i--){
        printf("A[%lld] : %lld B[%lld] : %lld\n", i, A[i], i, B[i]);
    }*/

    return 0;
}

/*

7
3
13
15
1
31
33
1

*/


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    int m = INT_MAX;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (m > p) {
            ans++;
            m = p;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void judge(double max,double min,int f){
  double h;

  if(scanf("%lf",&h)!=EOF){
    if(max<h){
      max=h;
    }
    if((min>h)||(f==0)){
      min=h;
    }
    judge(max,min,1);
  }
  else{
    printf("%f\n",max-min);
  }
}

int main(){
  judge(0,0,0);
  return 0;
}

Measured memory_bytes: 648
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx, y = ty - sy;
    for (int i = 0; i < x; ++i) {
        cout << "R";
    }
    for (int i = 0; i < y; ++i) {
        cout << "U";
    }
    for (int i = 0; i < x; ++i) {
        cout << "L";
    }
    for (int i = 0; i < y; ++i) {
        cout << "D";
    }
    cout << "D";
    for (int i = 0; i < x + 1; ++i) {
        cout << "R";
    }
    for (int i = 0; i < y + 1; ++i) {
        cout << "U";
    }
    cout << "LU";
    for (int i = 0; i < x + 1; ++i) {
        cout << "L";
    }
    for (int i = 0; i < y + 1; ++i) {
        cout << "D";
    }
    cout << "R" << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
var v:array[1..25]of integer;
    n,a,b,c,ans,i,j  :integer;
begin
  readln(n);
  for i:=1 to n do read(v[i]);
  for i:=1 to n do begin
    read(a);
    inc(v[i],-a)
  end;
  ans:=0;
  for i:=1 to n do
    if v[i]>0 then inc(ans,v[i]);
  write(ans)
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ft first
#define se second
#define mk make_pair
using namespace std;
vector<pii>ans;
int n;
ll a[105];

int gt()
{
    ll ma=a[1],pos=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]>ma)
        {
            pos=i;
            ma=a[i];
        }
    }
    return pos;
}

int gt1()
{
    ll mi=a[1],pos=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]<mi)
        {
            mi=a[i];
            pos=i;
        }
    }
    return pos;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        //scanf("%d",&a[i]);
        cin>>a[i];
    }
    
    int p=gt(),p1=gt1();
    if(abs(a[p])>abs(a[p1]))
    {
        for(int i=2;i<=n;i++)
       {
           int p=gt();

            while(a[i]<a[i-1])
           {
            ans.pb(mk(p,i));
            a[i]+=a[p];
           }

        }
    }
    else
    {
        for(int i=n-1;i>=1;i--)
        {
            int p=gt1();
            while(a[i]>a[i+1])
            {
                ans.pb(mk(p,i));
                a[i]+=a[p];
            }
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
    {
        printf("%d %d\n",ans[i].ft,ans[i].se);
    }
}


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

using namespace std;

const int INF = 1e9 + 9;

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

    int n;
    cin >> n;

    vector<int> h(n);
    vector<int> dp(n, INF);

    for (int &x : h)
        cin >> x;

    dp[0] = 0;

    for (int i = 0; i < n; i++)
        for (int j : {i + 1, i + 2})
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {

    public static void main(String[] args) {
	
	Scanner stdin = new Scanner(System.in);
	final long[] sum = new long[4001];
	final ArrayList<Integer> exist = new ArrayList<Integer>();
	final ArrayList<Integer> noList = new ArrayList<Integer>();
	
	while ( true )  {
	    Arrays.fill(sum, 0);
	    noList.clear();
	    exist.clear();
	    
	    final int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }
	    for (int i = 0; i < n; i++) {
		final int cn = stdin.nextInt();
		final long su = stdin.nextLong();
		final long sn = stdin.nextLong();
		if (!exist.contains(cn)) {
		    exist.add(cn);
		}
		if (sum[cn] < 1000000L) {
		    sum[cn] += su * sn;
		}
		if (sum[cn] >= 1000000L) {
		    noList.add(cn);
		}
	    }
	    
	    if (noList.isEmpty()) {
		System.out.println("NA");
	    } else {
		for ( Integer i : exist ) {
		    if ( noList.contains(i) ) {
			System.out.println(i);
		    }
		}
	    }
	}	
    }
}

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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int a[5];
	rep(i,5)
		cin>>a[i];
	rep(i,5){
		if(!a[i])
			cout<<i+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot;
int fa[N],cnt[N],n;
int a[N],sub[N],subfa[N];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs1(int x){
	for (int i=head[x];i;i=e[i].next)
		if (fa[x]!=e[i].to){
			fa[e[i].to]=x;
			dfs1(e[i].to);
			if (a[x]>a[e[i].to]&&!sub[e[i].to])
				cnt[x]++;
		}
	sub[x]=(cnt[x]!=0);
}
void dfs2(int x){
	if (x!=1){
		if (a[fa[x]]<a[x]&&!subfa[x])
			cnt[x]++;
	}
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa[x]){
			int tmp=cnt[x];
			if (a[e[i].to]<a[x]&&!sub[e[i].to])
				tmp--;
			subfa[e[i].to]=(tmp!=0);
			dfs2(e[i].to);
		}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs1(1);
	dfs2(1);
	for (int i=1;i<=n;i++)
		if (cnt[i]) printf("%d ",i);
} 

Measured memory_bytes: 512
/*
                       ::
                      :;J7, :,                        ::;7:
                      ,ivYi, ,                       ;LLLFS:
                      :iv7Yi                       :7ri;j5PL
                     ,:ivYLvr                    ,ivrrirrY2X,
                     :;r@Wwz.7r:                :ivu@kexianli.
                    :iL7::,:::iiirii:ii;::::,,irvF7rvvLujL7ur
                   ri::,:,::i:iiiiiii:i:irrv177JX7rYXqZEkvv17
                ;i:, , ::::iirrririi:i:::iiir2XXvii;L8OGJr71i
              :,, ,,:   ,::ir@mingyi.irii:i:::j1jri7ZBOS7ivv,
                 ,::,    ::rv77iiiriii:iii:i::,rvLq@huhao.Li
             ,,      ,, ,:ir7ir::,:::i;ir:::i:i::rSGGYri712:
           :::  ,v7r:: ::rrv77:, ,, ,:i7rrii:::::, ir7ri7Lri
          ,     2OBBOi,iiir;r::        ,irriiii::,, ,iv7Luur:
        ,,     i78MBBi,:,:::,:,  :7FSL: ,iriii:::i::,,:rLqXv::
        :      iuMMP: :,:::,:ii;2GY7OBB0viiii:i:iii:i:::iJqL;::
       ,     ::::i   ,,,,, ::LuBBu BBBBBErii:i:i:i:i:i:i:r77ii
      ,       :       , ,,:::rruBZ1MBBqi, :,,,:::,::::::iiriri:
     ,               ,,,,::::i:  @arqiao.       ,:,, ,:::ii;i7:
    :,       rjujLYLi   ,,:::::,:::::::::,,   ,:i,:,,,,,::i:iii
    ::      BBBBBBBBB0,    ,,::: , ,:::::: ,      ,,,, ,,:::::::
    i,  ,  ,8BMMBBBBBBi     ,,:,,     ,,, , ,   , , , :,::ii::i::
    :      iZMOMOMBBM2::::::::::,,,,     ,,,,,,:,,,::::i:irr:i:::,
    i   ,,:;u0MBMOG1L:::i::::::  ,,,::,   ,,, ::::::i:i:iirii:i:i:
    :    ,iuUuuXUkFu7i:iii:i:::, :,:,: ::::::::i:i:::::iirr7iiri::
    :     :rk@Yizero.i:::::, ,:ii:::::::i:::::i::,::::iirrriiiri::,
     :      5BMBBBBBBSr:,::rv2kuii:::iii::,:i:,, , ,,:,:i@petermu.,
          , :r50EZ8MBBBBGOBBBZP7::::i::,:::::,: :,:,::i;rrririiii::
              :jujYY7LS0ujJL7r::,::i::,::::::::::::::iirirrrrrrr:ii:
           ,:  :@kevensun.:,:,,,::::i:i:::::,,::::::iir;ii;7v77;ii;i,
           ,,,     ,,:,::::::i:iiiii:i::::,, ::::iiiir@xingjief.r;7:i,
        , , ,,,:,,::::::::iiiiiiiiii:,:,:::::::::iiir;ri7vL77rrirri::
         :,, , ::::::::i:::i:::i:i::,,,,,:,::i:i:::iir;@Secbone.ii:::
		 
-->
*/

#include<bits/stdc++.h>

using namespace std;

int main() {
	string s;
	cin>>s;
	bool flag=0;
	if (s[0]=='A')
		flag=1;
	for (int i=1;i<s.length();i++) {
		if (s[i]>='A'&&s[i]<='Z'&&s[i]!='C') {
			flag=0;
			break;
		}
	}
	int r=0;
	for (int i=2;i<s.length()-1;i++) {
		if (s[i]=='C') {
			r++;
			if (r==2) {
				flag=0;
				break;
			}
		}
	}
	if (r==0) {
		flag=0;
	}
	if (s[1]=='C'||s[s.length()-1]=='C')
		flag=0;
	if (flag) {
		cout<<"AC"<<endl;
	}
	else {
		cout<<"WA"<<endl;
	}
//	system("pause");
}

Measured memory_bytes: 256
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)
M = max(a)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, M+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Measured memory_bytes: 32112
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	string S;
	cin >> S;

	string ans = "AC";
	if (S[0]!='A') ans = "WA";
	int cnt = 0;
	for (int i=2; i<S.size()-1; i++) {
		if (S[i]=='C') {
			S[i] = 'c';
			cnt++;
		}
	}
	if (cnt!=1) ans = "WA";
	for (int i=1; i<S.size(); i++) {
		if (isupper(S[i])) ans = "WA";
	}
	cout << ans << endl;
}

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

void solve(){
  
  string s,t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<s.size();i++){
      if(s[i]!=t[i]){
         cnt++;
      }
  }

   cout<<cnt<<endl;
}

int main(){
   
   solve();

}      

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

int main() {
  
  int A, B;
  cin >> A >> B;
  int p = 0;
  int N = A;
  
  for (int i = 0; i < B - A + 1; i++) { 
    
    int a, b, c, d, e;
    a = N % 10;
    b = N / 10 % 10;
    c = N / 100 % 10;
    d = N / 1000 % 10;
    e = N / 10000 % 10;
    
    if (a == e && b == d) {
      p += 1;
    }
    
    N += 1;
  } 
  cout << p << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<double>> a(n, vector<double>(3));
  for (auto &r : a) {
    for (auto &e : r) {
      cin >> e;
    }
  }
  vector<vector<double>> d(n, vector<double>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 3; k++) {
        d[i][j] += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
      }
    }
  }
  vector<int> v(n);
  fill(rbegin(v), rbegin(v) + m, 1);
  double r = 0;
  do {
    double t = 0;
    for (int i = 0; i < n; i++) {
      if (v[i]) {
        for (int j = i + 1; j < n; j++) {
          if (v[j]) {
            t += d[i][j];
          }
        }
      }
    }
    r = max(r, t);
  } while (next_permutation(begin(v), end(v)));
  cout << fixed << setprecision(6) << r << endl;
}



Measured memory_bytes: 3296
#include<stdio.h>

int main(void) {

	int a,x,y;

	scanf("%d", &a);

	if (a == 1) {

		printf("Hello World");

		return 0;

	}
	else {

		scanf("%d", &x);

		scanf("%d", &y);

		printf("%d", x + y);

	}





	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
using namespace std;


int main(){
    
    int n;
    cin >> n;
    vector<int> v(n+1);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        v[i] = p;
    }

    for (int i = 1; i < n-1; i++)
    {
        if((v[i]>v[i-1]&&v[i]<v[i+1]) || v[i]<v[i-1]&&v[i]>v[i+1]){
            ans ++;
        }
    }
    
    
    cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())


int main()
{
  LL n, a, b;
  cin >> n >> a >> b;
  LL times;
  times = (n) / (a + b);
  LL res = times * a + min(n % (a + b), a);
  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt(),W=sc.nextInt();
		String[][] map = new String[H][W];
		boolean[] getH = new boolean[H];
		boolean[] getW = new boolean[W];
 
 		for(int i=0;i<H;i++) {
 			map[i]=sc.next().split("");
			for(int j=0;j<W;j++) {
				if(map[i][j].equals("#")) {
					getH[i]=true;
					getW[j]=true;
				}
			}
		}
 
 		for(int i=0;i<H;i++) {
 			if(getH[i]) {
 				for(int j=0;j<W;j++) {
 					if(getW[j]) {
 						System.out.print(map[i][j]);
 					}
 				}
 				System.out.println();
 			}
 		}
	}
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll w, h, n; cin >> w >> h >> n;
    ll xmin=0, ymin=0, xmax=w, ymax=h;

    ll x, y, a;
    rep(i, n){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                xmin = max(xmin, x);
                break;
            case 2:
                xmax = min(xmax, x);
                break;
            case 3:
                ymin = max(ymin, y);
                break;
            case 4:
                ymax = min(ymax, y);
                break;
        }
    }

    x = max(xmax-xmin, (ll)0);
    y = max(ymax-ymin, (ll)0);

    cout << x*y << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;
int main() {
	int date[5],k,i;
	date[1] = 1;
	date[2] = 0;
	date[3] = 0;
	string b, c,a;
	while (cin >>a) {
		b = a[0];
		c = a[2];
		if (b == "A") {
			k = date[1];
			i = 1;
		}
		if (b == "B") {
			k = date[2];
			i = 2;
		}
		if (b == "C") {
			k = date[3];
			i = 3;
		}
		if (c == "A") {
			date[i] = date[1];
			date[1] = k;
		}
		if (c == "B") {
			date[i] = date[2];
			date[2] = k;
		}
		if (c == "C") {
			date[i] = date[3];
			date[3] = k;
		}
	}
	if (date[1] == 1) {
		cout << "A" << endl;
	}
	if (date[2] == 1) {
		cout << "B" << endl;
	}
	if (date[3] == 1) {
		cout << "C" << endl;
	}
}


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

using namespace std;

vector<bool> sieve(int x) {
  vector<bool> V(x+1,1);
  V[0] = V[1] = 0;
  for (int i = 2; i <= x; ++i) 
    if(V[i] && (long long)(x) >= (long long)(i) * (long long)(i))
      for(long long j = i * i; j <= x; j += i) V[j] = 0;
  return V;
}

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

  int x; 
  cin >> x;
  
  int N = 100000+7;

  vector<bool> res = sieve(N);

  for (int i = 0; i < N; ++i) {
    if (res[i] && i >= x) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int a, b, c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3616
#import <stdio.h>
#import <stdlib.h>

typedef int Int;

Int compareInt(const void *a, const void *b) {
    return *(Int*)a - *(Int*)b;
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        Int N, K;
        scanf("%d %d", &N, &K);
        Int *numbers = (int *)malloc(N * sizeof(Int));
        
        Int n;
        Int i = 0;
        while (scanf("%d", &n) != EOF) {
            numbers[i] = n;
            i++;
        }
        
        qsort(numbers, N, sizeof(Int), compareInt);
        
        Int min = numbers[N-1];
        for (Int i=0; i<=N-K; i++) {
            Int diff = numbers[i+K-1] - numbers[i];
            min = (min<diff) ? min : diff;
        }
        printf("%d\n", min);
    }
    return 0;
}


Measured memory_bytes: 3040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i] - 1;
        }

        System.out.println(ans);
    }
}

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

int main(){
  string S;
  cin >> S;
  
  if(S == "SUN"){cout << 7 << endl;}
  if(S == "MON"){cout << 6 << endl;}
  if(S == "TUE"){cout << 5 << endl;}
  if(S == "WED"){cout << 4 << endl;}
  if(S == "THU"){cout << 3 << endl;}
  if(S == "FRI"){cout << 2 << endl;}
  if(S == "SAT"){cout << 1 << endl;}
  
}

Measured memory_bytes: 256
#include <stdio.h>
    #include <string.h>
    #include <math.h>

    int main(void)
    {
        int n;
        int i,x;

        scanf("%d",&n);

        for(i=1;i<=n;i++){
            x = i;
            if((x % 3 == 0)){
                printf(" %d",i);
            }else{
                do{
                    if(x % 10 == 3){
                        printf(" %d",i);
                        x = 0;
                    }else{
                        x /= 10;
                    }
                }while(x);
            }
        }
        printf("\n");
        return 0;
    }



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int64_t N;

int main()
{
    cin>>N;
    int64_t t=N;
    string ans="";
    while(t>0){
        --t;
        int64_t rem=t%26;
        ans.pb(char(rem+'a'));
        t/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define rep2(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define repr2(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a[4],tmp;cin>>tmp;
  //各桁をa配列に格納
  repr(i,3){
    a[i]=tmp%10;
    tmp/=10;
  }
  int res;
  char op[4];
  for(int i=0;i<( 1 << 4 );i++){
    //今回の結果
    res=0;
    for(int j=0;j<4;j++){
      if( i & ( 1 << j ) ){
        res+=a[j];
        op[j]='+';
      }else{
        res-=a[j];
        op[j]='-';
      }
    }
    if(res==7){
      rep(i,4){
        if(i!=3){
          cout<<a[i]<<op[i+1];
        }else{
          cout<<a[i];
        }
      }
      cout<<"=7"<<'\n';
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
	char ch;
	
	while(1){
	    scanf("%c", &ch);

        if (islower(ch)) ch = toupper(ch);
        else if (isupper(ch)) ch = tolower(ch);
	    
	    printf("%c", ch);
	    if ( ch == '\n' ) break;
	}	
    return 0;
}


Measured memory_bytes: 2616
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N, M, Q;
ll a[110], b[110], c[110], d[110];
ll A[10000010][11] = {};

ll X[110] = {};

ll ai = 0;

ll n = 0;

ll ans = -1;

void Amaker(ll e, ll M, ll n) {
    //aはn回めのループの最初のインデックス
    //Nはループの回数
    //nは今何回目繰り返したかを数える
    //n回再帰的に繰り返す
    for (ll i = e; i < M; i++) {
        //X[]は各ループのインデックスを覚えておく
        X[n] = i;
        //cout << "X[" + to_string(n) + "]:" + to_string(i + 1) << endl;
        if (N - 1 == n) {
            //やりたい処理
            //X[n]がn + 1回めのインデックスを表す
            REP(j, N) {
                A[ai][j] = X[j] + 1;
                //cout << X[j] + 1 << " ";
            }
            //cout << endl;
            ai++;
        }
        else {
            Amaker(i, M, n + 1);
        }
        //if (L - 1 == i) n--;
    }
}

int main() {
    cin >> N >> M >> Q;
    REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    //まず全てのA配列の可能性を書き出す
    //Amaker(0, 3);
    //cout << endl;
    //REP(i, ai) {
    //    REP(j, 3) {
    //        cout << A[i][j] << " ";
    //    }
    //    cout << endl;
    //}

    Amaker(0, M, 0);

    //REP(i, 4) {
    //    Amaker(0, i + 1);
    //    cout << endl;
    //}

    ll tmp;

    REP(i, ai) {
        //ai番目の数列に対して
        tmp = 0;
        REP(j, Q) {
            //Q個あてはめていくつ点が取れるかみる
            if (A[i][b[j] - 1] - A[i][a[j] - 1] == c[j]) tmp += d[j];
            //cout << to_string(A[i][b[j] - 1]) + " " + to_string(A[i][a[j] - 1]) << endl;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

}

/*
10 10 2
1 10 9 1
2 10 9 2
*/


Measured memory_bytes: 11564
// https://atcoder.jp/contests/abc161/tasks/abc161_e

use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        _: usize, k: usize, c: usize,
        ss: String,
    }
    let ss: Vec<char> = ss.chars().collect();
    let mut heads = Vec::new();
    for (i, _) in ss.iter().enumerate().filter(|(_, &x)| x == 'o') {
        if heads.len() >= k {
            break;
        }
        match heads.last() {
            None => {
                heads.push(i);
            }
            Some(&last) => {
                if last + c < i {
                    heads.push(i);
                }
            }
        }
    }
    let mut tails = Vec::new();
    for (i, _) in ss.iter().enumerate().rev().filter(|(_, &x)| x == 'o') {
        if tails.len() >= k {
            break;
        }
        match tails.last() {
            None => {
                tails.push(i);
            }
            Some(&last) => {
                if last - c > i {
                    tails.push(i);
                }
            }
        }
    }
    tails.reverse();
    for (h, _) in heads.iter().zip(tails.iter()).filter(|(h, t)| h == t) {
        println!("{}", h + 1);
    }
}


Measured memory_bytes: 6416
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




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

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

	priority_queue<int> ap;
	priority_queue<int> an;
	for (int i = 0; i < n; i++) {
		if (a[i] > 0) {
			ap.push(a[i]);
		}else{
			an.push(-a[i]);
		}
	}


	if ((ap.empty() && k % 2 != 0) || k == n) {
		ll ans = 1;
		for (int i = 0; i < k; i++) {
			ans = (ans * (MOD + a[n - 1 - i])) % MOD;
		}
		cout << ans << endl;
		return 0;
	}


	ll ans = 1;
	if (k % 2 != 0) {
		ans = ap.top();
		ap.pop();
		k--;
	}
	k /= 2;

	priority_queue<ll> pq;
	while (!ap.empty()) {
		ll num = ap.top();
		ap.pop();
		if (ap.empty()) {
			break;
		}
		num *= ap.top();
		ap.pop();

		pq.push(num);
	}

	while (!an.empty()) {
		ll num = an.top();
		an.pop();
		if (an.empty()) {
			break;
		}
		num *= an.top();
		an.pop();

		pq.push(num);
	}
	for (int i = 0; i < k; i++) {
		ll num = pq.top() % MOD;
		pq.pop();

		ans = (ans * num) % MOD;
	}

	cout << ans << endl;


}


Measured memory_bytes: 6312