akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n,m = I()
g = [[] for _ in range(n)]
for i in range(m):
    a,b = I()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = deque([0])
d = [-1]*n
d[0] = 0
while q:
    v = q.popleft()
    for i in g[v]:
        if d[i] != -1:
            continue
        d[i] = v
        q.append(i)
if -1 in d:
    print("No")
else:
    print("Yes")
    for i in d[1:]:
        print(i+1)


Measured memory_bytes: 35364
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const ll MOD = 1e9 + 7;
const int MAXN = 100005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
bool dp[85][85][10000]; int H, W, a[85][85], b[85][85];
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    cin >> H >> W;
    int mx=0;
    FOR(i, 1, H) FOR(j, 1, W) cin >> a[i][j];
    FOR(i, 1, H) FOR(j, 1, W) {cin >> b[i][j]; mx+=abs(a[i][j]-b[i][j]);}
    int st=abs(a[1][1] - b[1][1]);
    dp[1][1][st]=true;
    st=abs(b[1][1] - a[1][1]);
    dp[1][1][st]=true;
    int ans=INT_MAX;
    //assert(0 <= mx && mx <= 6400);
    for(int i=1; i<=H; i++) {
        for(int j=1; j<=W; j++) {
            for(int k=0; k<10000; k++){
                if(dp[i][j][k]) {
                    int nxtk = k + abs(a[i+1][j] - b[i+1][j]);
                    dp[i+1][j][nxtk]=true;
                    nxtk = abs(k - abs(a[i+1][j] - b[i+1][j]));
                    dp[i+1][j][nxtk]=true;
                    nxtk = k + abs(a[i][j+1] - b[i][j+1]);
                    dp[i][j+1][nxtk]=true;
                    nxtk = abs(k - abs(a[i][j+1] - b[i][j+1]));
                    dp[i][j+1][nxtk]=true;
                    if(i == H && j == W) ans=min(ans, k);
                }
            }
        }
    }
    FOR(k, 0,6405) if(dp[H][W][k]) ans=min(ans, k);
    printf("%d\n", ans);
}


Measured memory_bytes: 68608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
vector<ll> ok;

void DFS(string S){
    if(S.size()==0){
        for(char c='1';c<='9';c++){
            string S;
            S+=c;
            DFS(S);
        }
        return;
    }
    
    ok.push_back(stoll(S));
    if(S.size()==10){
        return;
    }
    
    for(char c=max(char(S.back()-1),'0');c<=min(char(S.back()+1),'9');c++){
        S+=c;
        DFS(S);
        S.pop_back();
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K;cin>>K;
    string S;
    DFS(S);
    
    sort(all(ok));
    ok.erase(unique(all(ok)),ok.end());
    
    //for(ll a:ok) cout<<a<<endl;
    
    cout<<ok[K-1]<<endl;
}


Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        StringBuffer sb = new StringBuffer();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        double a,b,c;
        for(int i=0;i<n;i++){
            String[] str = (br.readLine()).split(" ");
            a = Math.pow(Integer.parseInt(str[0]),2);
            b = Math.pow(Integer.parseInt(str[1]),2);
            c = Math.pow(Integer.parseInt(str[2]),2);
            if(a+b==c || a+c==b || b+c==a){
                sb.append("YES\n");
            }
            else{
                sb.append("NO\n");
            }
        }
        System.out.print(sb);
    }
}

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

using namespace std;

void disp(vector<string> a, int n){
    for(int i = 0;i < n;i++){
        if(i == n-1) cout << a[i];
        else cout << a[i] << " ";
    }
    cout << endl;
}

void bubble(vector<string> &a, int n){
    string temp;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n-1;j++){
            if(a[j][1]-'0' > a[j+1][1]-'0'){
                temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }

    disp(a, n);
}

void select(vector<string> &a, int n){
    for(int i = 0;i < n;i++){
        int minj = i;
        for(int j = i;j < n;j++){
            if(a[j][1]-'0' < a[minj][1]-'0') minj = j;
        }
        swap(a[i], a[minj]);
    }

    disp(a, n);
}

int main(void){

    int n;
    cin >> n;
    vector<string> a(n), b(n);
    for(int i = 0;i < n;i++) cin >> a[i];

    b = a;

    bubble(a, n);
    cout << "Stable" << endl;
    select(b, n);
    bool ok = true;
    for(int i = 0;i < n;i++){
        if(a[i] != b[i]) ok = false;
    }

    if(ok) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int n; cin >> n;
  vi x(n); rep(i, n) cin >> x[i];
  // 同じ要素が並ばないようにする
  vi a; a.pb(x[0]);
  rep(i, n - 1) if(x[i + 1] != x[i]) a.pb(x[i + 1]);
  dump(a);
  
  int ans = 1, now = 1, before;
  int c = 1;
  rep(i, sz(a) - 1){
    if(a[i] > a[i + 1]) now = 0;
    if(a[i] < a[i + 1]) now = 1;
    if(i == 0) before = now;
    dump(i+1,before, now,c);
    if(before != now and c > 1){
      //cout << i + 1 << endl;
      ans++;
      c = 1;
    }else c++;
    before = now;
  }
  dump(c);
  cout << ans << endl;
}

Measured memory_bytes: 2168
process.stdin.resume()
process.stdin.setEncoding("utf8")

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
})

const lines = []

reader.on("line", (line) => {
  lines.push(line)
})

reader.on("close", () => {
  const n = lines[0] - 0
  const A = lines[1].split(" ").map(Number)
  const q = lines[2] - 0
  const ms = lines[3].split(" ").map(Number);

  const solve = (i, m) => {
    if (m === 0) {
      return true
    }

    if (i >= n) {
      return false
    }

    return solve(i + 1, m) || solve(i + 1, m - A[i])
  }

  for (let i = 0; i < q; i++) {
    console.log(solve(0, ms[i]) ? "yes" : "no")
  }
})



Measured memory_bytes: 17284
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <vector>
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <string>

namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;

	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;
using namespace std;

const int K = 10;

int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	vector <int> things[26];
	for (int i = 0; i < s.length(); ++i)
		things[s[i] - 'a'].push_back(i);
	for (char c = 'a'; c <= 'z'; ++c)
	{
		for (int i = 0; i < things[c - 'a'].size(); ++i)
			for (int j = max(i - K, 0); j < i; ++j)
			{
				if (things[c - 'a'][i] - things[c - 'a'][j] <= 2 * (i - j))
				{
					cout << things[c - 'a'][j] + 1 << " " << things[c - 'a'][i] + 1 << endl;
					return 0;
				}
			}
	}
	cout << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 1104
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    String T = sc.nextLine();
    int a = 0, b = 0, count = 0, max = 0, now = 0;
    boolean check = true;
    while((count < K || b < N) && a < N){
      while((count < K || check) && b < N){
        now++;
        if(T.charAt(b) == '0'){
          if(b == N-1){
            count++;
          }else if(T.charAt(b+1) == '1'){
            count++;
          }
        }
        if(count == K && T.charAt(b) == '1'){
          if(b == N-1){
            check = false;
          }else if(T.charAt(b+1) == '0'){
            check = false;
          }
        }
        b++;
        max = now > max ? now : max;
      }
      
      now--;
      if(T.charAt(a) == '0'){
        if(a == N-1){
          count--;
          check = true;
        }else if(T.charAt(a+1) == '1'){
          count--;
          check = true;
        }
      }
      a++;
    }
          
    System.out.println(max);
  }
}

Measured memory_bytes: 26048
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int n,m,tmp;
vector<int> v;
vector<pair<pii,pii>> q;
int answer=0;

void f(int now)
{
    v.push_back(now);
    if(v.size()==n){
        int nowanswer=0;
        for(int i=0; i<q.size(); i++){
            if(v[q[i].ff.ss-1]-v[q[i].ff.ff-1]==q[i].ss.ff) nowanswer+=q[i].ss.ss;
        }
        answer=max(answer,nowanswer);
    }
    else for(int i=now; i<=m; i++) f(i);
    v.pop_back();
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    cin>>n>>m>>tmp;
    q.resize(tmp);
    for(int i=0; i<tmp; i++){
        cin>>q[i].ff.ff>>q[i].ff.ss>>q[i].ss.ff>>q[i].ss.ss;
    }

    for(int i=1; i<=m; i++) f(i);
    cout<<answer;

    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        Console.WriteLine(Math.Max(input[0],Math.Max(input[1],input[2]))==(double)input.Sum()/2?"Yes":"No");

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main(void)
{

	int N, min= 200010,P[200010],sum=0;

	scanf("%d", &N);

	for (int i = 0;i < N;i++) {
		scanf("%d", &P[i]);
		if (min >= P[i]) {
			min = P[i];
			sum++;
		}

	}
	printf("%d", sum);
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;

int main(){
  int k;
  cin >> k;
  rep(i, k){
    cout << "ACL";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

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;

int Sum(int n){
  
  int goukei = 0;
  
  goukei = (1 + n) * n / 2;
  
  return goukei;
  
}

int main() {
  
  int a,b,h,ans;
  cin >> a >> b;
  
  int n = b - a;
  
  h = Sum(n-1);
  
  ans = h - a;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <vector>
using namespace std;
int N, M;
vector<double> As;
// long long opt[2][100005];
int main(){
    scanf("%d%d", &N, &M);
    for (int i = 1; i<= N; ++i){
        int A;
        scanf("%d",&A);
        As.push_back(double(A));
    }

    make_heap(As.begin(), As.end()); 

    while(M>0){
        double top = As.front() ;
        pop_heap(As.begin(), As.end()); 
        As.pop_back(); 

        As.push_back(top/2); 
      
        // using push_heap() to reorder elements 
        push_heap(As.begin(), As.end());
        M--;
    }

    long long result = 0;
    for(int i = 0; i < As.size();++i)
        result += int(As[i]);

    // for(int i = 0; i <= M; ++i){
    //     opt[0][i] = 0;
    // }

    // for (int i = 1; i<= N; ++i){
    //     for(int j = 0; j <= M; ++j){
    //         opt[i%2][j] = opt[(i-1)%2][0] + As[i];
    //         for(int k = 0; k <= M; ++k){
    //             long long tmp = opt[(i-1)%2][k] + int(As[i]/pow(2,j-k));
    //             if (tmp >= opt[i%2][j])
    //                 break;
    //             opt[i%2][j] = tmp;
    //         }
    //     }
    // }

    printf("%lld\n",result);

}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int N,M; cin >>N >>M;
  int X; cin >>X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M, 0));
  rep(i, N){
    cin >>C[i];
    rep(j, M) cin >>A[i][j];
  }
  int res = INT_MAX;
  vector<int> com(M, 0); // アルゴリズムiの理解度
  for (int S=1; S<(1<<N); S++){
    // Sは参考書の集合
    com.assign(M, 0);
    int cost = 0;
    for (int i=0; i<N; i++){
      if (S & (1<<i)){
        cost += C[i];
        rep(j, M) com[j] += A[i][j];
      }
    }
    bool ok = true;
    rep(j, M) if (com[j] < X) ok = false;
    if (ok) chmin(res, cost);
  }
  res = res == INT_MAX ? -1 : res;
  cout <<res <<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 

using namespace std;

int main() {
    int N;
    int count = 0;
    cin >> N;
    int A[N];

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

    while (true) {
        bool flag = false;
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 != 0) flag = true;
        }

        if (flag) break;

        for (int i = 0; i < N; i++) {
            A[i] /= 2;
        }
        count++;
    }


    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
const int mod = 1e9+7;
#define rep(a,b) for(int a=0;a<b;++a)
signed main(){
  int h,w;
  cin>>h>>w;
  vector<vector<bool>> v(h,vector<bool>(w,false));
  rep(i,h){
    string s;
    cin>>s;
    rep(j,w)v[i][j]=(s[j]=='#'?1:0);
  }
  vector<vector<int>> dist(h,vector<int>(w,h+w+10));
  dist[0][0]=v[0][0];
  for(int i=1;i<w;++i)dist[0][i]=dist[0][i-1]+(!v[0][i-1]&&v[0][i]);
  for(int i=1;i<h;++i)for(int j=0;j<w;++j){
    dist[i][j]=min(j?dist[i][j-1]+(!v[i][j-1]&&v[i][j]):h+w+10,dist[i-1][j]+(!v[i-1][j]&&v[i][j]));
  }
  cout<<dist[h-1][w-1];
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool used[200000];
int ans[101][101],idx,s1,s2;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0},n;
vector<int>v[20000];
int main(){
  cin>>n;
  r(i,n*n*2-2*n){
    cin>>s1>>s2;
    v[s1].push_back(s2);
    v[s2].push_back(s1);
  }
  r(i,n*n+1)if(v[i].size()==2)idx=i;
  ans[0][0]=idx;
  used[idx]=1;
  r(i,n)r(j,n)if(!ans[i][j]){
    vector<int>p;
    r(k,4){
      int y=i+dy[k];
      int x=j+dx[k];
      if(y<0||x<0||y>=n||x>=n)continue;
      p.push_back(ans[y][x]);
    }
    r(k,n*n+1)if(v[k].size()==p.size()){
      if(!used[k]){
	int f=0;
	r(l,p.size())if(p[l]){
	  r(q,v[k].size()){
	    if(v[k][q]==p[l])break;
	    if(q==v[k].size()-1)f++;
	  }
	}
	if(!f){
	  ans[i][j]=k;
	  used[k]=1;
	  goto L;
	}
      }
    }L:;
  }
  r(i,n){
    r(j,n){
      if(j)cout<<' ';
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3968
n = int(input())
p = list(map(int, input().split()))
counter = 0

for i in range(1, n - 1, 1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i+1] < p[i] and p[i] < p[i-1]):
        counter += 1
    
print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
bool isprime(int n){
	if(n < 2)return false;
	for(int i=2;i*i<=n;i++)if(n%i==0)return false;
	return true;
}
int main(){
	int n;
	vector<int> prime;
	bool e[30001] = {0};
	rep(i,30001){
		if(isprime(i)) prime.push_back(i) , e[i] = 1;
		else e[i] = 0;
	}
	int M = prime.size();
	while(cin >> n , n){
		int ret = 0;
		rep(i,M){
			for(int j=i;j<M;j++){
				if(prime[i]+prime[j] >= n) break;
				if(n-prime[i]-prime[j] < prime[j])break;
				if(e[ n-prime[i]-prime[j] ] && prime[i] + prime[j] > n-prime[i]-prime[j])ret++;
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 964
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

ll solve(int n, vector<int> const & a, vector<int> const & b) {
    vector<pair<int, int> > c;
    REP (i, n) {
        c.emplace_back(a[i], i);
        c.emplace_back(b[i], i);
    }
    sort(ALL(c));

    ll answer = LLONG_MAX;
    chmin(answer, accumulate(ALL(a), 0ll));
    chmin(answer, accumulate(ALL(b), 0ll));

    bool found = false;
    ll acc = 0;
    vector<bool> used(n);
    REP (k, n) {
        acc += c[k].first;
        int i = c[k].second;
        if (used[i]) {
            found = true;
        } else {
            used[i] = true;
        }
    }

    if (found) {
        chmin(answer, acc);
    } else {
        REP (k, n) {
            int i = c[k].second;
            int j = (c[n].second == i ? n + 1 : n);
            ll delta = - c[k].first + c[j].first;
            chmin(answer, acc + delta);
        }
    }

    return answer;
}

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    REP (i, n) cin >> a[i] >> b[i];
    cout << solve(n, a, b) << endl;
    return 0;
}


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

int main(){
    char n[3];
    bool flag = false;
    cin >> n;
    for(int i = 0; i < 3; i++){
        if(n[i] == '7'){
            std::cout << "Yes" << std::endl;
            flag = true;
            break;
        }
    }
    if(flag == false){
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
long g(long a,long b){return b?g(b,a%b):a;}
long l(long a,long b){return a/g(a,b)*b;}
long i,n,t,r;
main()
{
	for(r=1,cin>>n;i++<n;cin>>t,r=l(r,t));
	cout<<r;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;
const long T = 1000000000;

int main(){
	long n=1l;
	long k, s;
	cin >> n >> k >> s;
	if (s == T) {
		for (int i = 0; i < k; ++i) {
			if (i == k-1 && n - k == 0) {
				cout << s;
			} else {
				cout << s << " ";
			}
		}
		for (int i = 0; i < n - k; ++i) {
			if (i == n - k - 1) {
				cout << s - 1;
			} else {
				cout << s - 1 << " ";			
			}
		}
		return 0;
	}

	for (int i = 0; i < k; ++i) {
		if (i == k-1 && n - k == 0) {
			cout << s;
		} else {
			cout << s << " ";
		}
	}
	for (int i = 0; i < n - k; ++i) {
		if (i == n - k - 1) {
			cout << T;
		} else {
			cout << T << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int n;
double x,ans;
string s;
int main() {
	cin >> n;
	ans = 0;
	for(int i=0; i<n; i++) {
		cin >> x >> s;
		if(s == "JPY") ans += x;
		else ans += x*380000;
	}
	printf("%.10f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  vector<int> a(9,0);
  vector<bool> c(9,false);
  rep(i,9) cin >> a.at(i);
  int n;
  cin >> n;
  vector<int> b(n,0);
  rep(i,n) {
    cin >> b.at(i);
    rep(j,9) {
      if(b.at(i) == a.at(j)) c.at(j) = true;
    }
  }

  if(c.at(0) && c.at(1) && c.at(2)) cout << "Yes" << endl;
  else if(c.at(3) && c.at(4) && c.at(5)) cout << "Yes" << endl;
  else if(c.at(6) && c.at(7) && c.at(8)) cout << "Yes" << endl;
  else if(c.at(0) && c.at(3) && c.at(6)) cout << "Yes" << endl;
  else if(c.at(1) && c.at(4) && c.at(7)) cout << "Yes" << endl;
  else if(c.at(2) && c.at(5) && c.at(8)) cout << "Yes" << endl;
  else if(c.at(0) && c.at(4) && c.at(8)) cout << "Yes" << endl;
  else if(c.at(2) && c.at(4) && c.at(6)) cout << "Yes" << endl;
  else cout << "No" << endl;



  return 0;
}


Measured memory_bytes: 256
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = I()
b = I()

ans = 6
print(ans - a - b)

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

int main(){
  
  double a, b, x, i, S, deg, h;
  cin >> a >> b >> x;
  
  S = pow(a, 2) * b;
  if (x >= S / 2){
    
    h = 2 * (S - x) / pow(a, 2);
    deg = atan(h/a);
    deg = 180 * deg / 3.1415926535;
  }else{
    
    h = 2 * x / (a * b);
    deg = atan(b/h);
    deg = 180 * deg / 3.1415926535;
  }
  printf("%.8f", deg);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    int n = scan.nextInt();
    int[] ar = new int[n];
    for (int i = 1; i < n; i++) {
      ar[scan.nextInt() - 1]++;
    }

    for (int i = 0; i < n; i++) {
      System.out.println(ar[i]);
    }
  }
}

Measured memory_bytes: 58080
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;

fn read_vec<T: FromStr>(s: String) -> Result<Vec<T>, T::Err> {
    s.split(' ').map(|x| x.parse()).collect()
}

fn main() {
    const M: i64 = 1000_000_000 + 7;
    let mut lines = BufReader::new(io::stdin()).lines().map(|l| l.unwrap());
    let nk: Vec<usize> = read_vec(lines.next().unwrap()).unwrap();
    let k = nk[1];
    let mut v: Vec<i64> = read_vec(lines.next().unwrap()).unwrap();
    let mut P: Vec<_> = v.iter().filter(|&&x| x > 0).collect();
    let mut N: Vec<_> = v.iter().filter(|&&x| x < 0).collect();
    P.sort_unstable();
    N.sort_unstable();
    // 正の数にできるか否か
    let can_positive = if P.len() >= k {
        true // Pが十分あればok
    } else if P.len() == 0 {
        k & 1 == 0 && k <= N.len() // Pがゼロ個なら、kが偶数で、Nはkより多い必要がある
    } else {
        // Pが1つ以上あって、kより少ない時
        (k - P.len() + 1) & !1 <= N.len() // Pが一つ以上あれば、k-Pを2の倍数に切り上げた数より、Nが多い必要がある
    };
    if !can_positive {
        if v.contains(&0) {
            // ゼロにできる時
            println!("0");
        } else {
            // 負の数になる時
            v.sort_unstable_by_key(|x| {
                let y = x >> 31;
                (x ^ y) - y
            });
            let ans = v
                .iter()
                .take(k) // 小さい方から集めて
                .fold(1, |acc, x| acc * (x % M) % M);
            println!("{}", (ans + M) % M);
        }
        return;
    }
    let mut ans = 1;
    let mut k = k;
    if k & 1 == 1 {
        ans *= P.pop().unwrap();
        k -= 1;
    }
    let mut P = P.rchunks_exact(2).map(|x| x[0] * x[1]).peekable();
    let mut N = N.chunks_exact(2).map(|x| x[0] * x[1]).peekable();
    while k > 0 {
        // pnどっちからとるか。 両方空っぽはありえない
        ans *= if P.peek().map_or(false, |p| N.peek().map_or(true, |n| p > n)) {
            P.next()
        } else {
            N.next()
        }
        .unwrap()
            % M;
        ans %= M;
        k -= 2;
    }
    println!("{}", (ans + M) % M);
}

Measured memory_bytes: 6152
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)3e2 + 5;

int arr[MAXN][MAXN];

bool del[MAXN];

int ptr[MAXN];

int cnt[MAXN];

int n, m;

bool check(int lim) {
    for (int i = 1; i <= n; ++i) {
        ptr[i] = 1;
    }

    for (int i = 1; i <= m; ++i) {
        del[i] = 0;
    }

    while (1) {
        for (int i = 1; i <= m; ++i) {
            cnt[i] = 0;
        }

        for (int i = 1; i <= n; ++i) {
            ++cnt[arr[i][ptr[i]]];
        }

        bool found = 0;

        for (int i = 1; i <= m; ++i) {
            if (cnt[i] > lim) {
                del[i] = 1;
                found = 1;
            }
        }

        if (!found) {
            break;
        }

        for (int i = 1; i <= n; ++i) {
            while (ptr[i] <= m && del[arr[i][ptr[i]]]) {
                ++ptr[i];
            }

            if (ptr[i] > m) {
                return 0;
            }
        }
    }

    return 1;
}

void solve() {
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%d", &arr[i][j]);
        }
    }

    int l = 1, r = n, ans = 0;

    while (l <= r) {
        int mid = (l + r) >> 1;

        if (check(mid)) {
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
        }
    }

    printf("%d\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int S,h,m,s;
  cin>>S;
  h=S/3600;
  m=S%3600/60;
  s=S%3600-m*60;
  cout<<h<<':'<<m<<':'<<s<<endl;
 }

Measured memory_bytes: 1160
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int n,k,count = 0;
  long long sum =0;
  cin >> n >> k;
  vector<long long> a(n);
  rep(i,n) cin >> a.at(i);

  if(n <= k){
    cout << 0;
    return 0;
  }

  //昇順にソート
  sort(a.begin(),a.end());
  rep(i,n-k) sum = sum += a.at(i);
  cout << sum;



}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long

const int N = 100010;

int a[N], n, A, B;

int main(){
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; ++ i){
		ans += std::min(1ll * (a[i + 1] - a[i]) * A, 1ll * B);
	}
	printf("%lld\n", ans), 0;
	return 0;
}

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

const int MAX_N=101010;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll C(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}

int main(){
  prepare();
  int N; cin>>N;
  int A[N+1];
  map<int,int> mp;
  int r=-1;
  rep(i,N+1){
    cin>>A[i];
    if(mp[A[i]]) r=i;
    mp[A[i]]++;
  }
  int l=-1;
  rep(i,N+1) if(A[i]==A[r]){
    l=i;
    break;
  }
  cout<<N<<endl;
  for(int i=2;i<=N;i++){
    ll tmp=(C(N+1,i)-C(N-(r-l),i-1))%MOD;
    if(tmp<0) tmp+=MOD;
    cout<<tmp<<endl;;
  }
  cout<<1<<endl;
  return 0;
}


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

int main() {
 int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
}
         
 

Measured memory_bytes: 256
S = input()
tmp = []
count = 1
for i, x in enumerate(S):
    if x == 'B':
        tmp.append([i, count])
        count += 1

tmp.sort(key=lambda x: x[1], reverse=True)
ans = 0
for i in range(len(tmp)):
    x = tmp[i][0]
    ans += len(S)-1-i - x
print(ans)


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

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n;
  cin >> n;
  int cnt[n + 1];
  memset(cnt, 0, sizeof cnt);
  for (int x = 1; x * x <= n; x++) {
    for (int y = 1; x * x + y * y + x * y <= n; y++) {
      for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= n; z++) {
        ++cnt[x * x + y * y + z * z + x * y + y * z + z * x];
      }
    }
  } 
  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3580
read A
read B
read C
read X

count=0

for (( a = 0; a <= A; a++ )); do
    for (( b = 0; b <= B; b++ )); do
        for (( c = 0; c <= C; c++ )); do
            (( a * 500 + b * 100 + c * 50 == X )) && (( ++count ))
        done
    done
done

echo ${count}


Measured memory_bytes: 376
# include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	int k;
	cin >> k >> s;
	if(s.size() <= k){
		cout << s << '\n';
	}else{
		s = s.substr(0, k);
		cout << s << "...\n";
	}
}

Measured memory_bytes: 3652
n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [-1] * (n * 18)
for i in range(n * 9):
    dp[i] = 0
lis = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(n):
    cnt = -float("inf")
    for j in a:
        cnt = max(cnt, dp[i + 1 - lis[j]] * 10 + j)
    dp[i + 1] = cnt
print(dp[n])

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

using namespace std;

int main() {
    /*int A,B,C,D,seconds,minutes;
    cin >> A >> B >> C >> D;
    seconds = A + B + C + D;
    minutes = seconds / 60;
    seconds = seconds - minutes *60;
    cout << minutes << endl << seconds << endl;*/
    
    /*int AB,BC,CA,answer;
    cin >> AB >> BC >> CA;
    answer = AB * BC / 2;
    cout << answer << endl;*/
    
    /*int X,Y,sum;
    cin >> X >> Y;
    sum = X + Y/2;
    cout << sum << endl;*/
    
    /*int A,B,s;
    cin >> A >> B;
    s=(A-1)*(B-1);
    cout << s << endl;*/
    
    /*int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    int answer;
    if(A < 0){
        answer=-A*C+D+B*E;
    }
    else if(A>0){
        answer=(B-A)*E;
    }
    cout << answer << endl;*/
    
    /*int AJ,AS,AR,AE,BJ,BS,BR,BE,A,B;
    cin >> AJ >> AS >> AR >> AE >> BJ >> BS >> BR >> BE;
    A = AJ + AS + AR + AE;
    B = BJ + BS + BR + BE;
    if(A>B){
         cout << A << endl;
     }
    else if(A<B){
        cout << B << endl;
    }
    else{
        cout << A << endl;
    }*/
    
   /* int A,B,C,D,E,F,t,s;
    cin >> A >> B >> C >> D >> E >> F;
    if(A<B){
        t=A;
    }
    else if(A>B){
        t=B;
    }
    if(t>C){
        t=C;
    }
    if(t>D){
        t=D;
    }
    int ans1;
    ans1=A+B+C+D-t;
    
    if(E<F){
        s=F;
    }
    if(E>F){
        s=E;
    }
    int answer;
    answer=ans1+s;
    
    cout << answer << endl;*/
    
    /*t Pa,Pb,Pc,Ja,Jb,t,j,sum;
    cin >> Pa >> Pb >> Pc >> Ja >> Jb;
    
    if(Pa>Pb){
        t=Pb;
    }
    else if (Pa<Pb){
        t=Pa;
    }
    if(t>Pc){
        t=Pc;
    }
    j=min(Ja,Jb);
    sum=t+j-50;
    cout << sum << endl;*/
    
   /*int A,B,C;
   cin >> A >> B >> C;
   int i =0;
   int coin = 0;
   while(coin<C){
       i = i+1;
       coin = coin + A;
       if(i%7==0){
           coin = coin +B;
       }
   }
    cout << i << endl;*/
    
  int   A,B,K;
  cin >> A >> B >> K;
  
  int i = 0;
  int j = 0;
  int x = A+B;
  while(i<K){
      x=x-1;
      if(A%x==0&&B%x==0){
          i++;
      }
      
  }
  cout << x << endl;
    
    
    
    
    
    
    
    
    
    return 0;
}

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

using namespace std;

const int N = 105;

int n, a[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);

    double sum = a[1];
    for (int i = 2; i <= n; i++) sum = (sum + a[i]) / 2.0;
    cout << fixed << setprecision(9) << sum;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramD
    {
        static void Main()
        {
            var s = Line;
            var odd = Enumerable.Repeat(0, s.Length).ToArray();
            var even = Enumerable.Repeat(1, s.Length).ToArray();

            for (int i = s.Length - 1; i >= 1 ; i--)
            {
                if (s[i] == 'L')
                {
                    odd[i - 1] += even[i];
                    even[i - 1] += odd[i];
                    even[i] = 0;
                    odd[i] = 0;
                }
            }

            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] == 'R' && s[i + 1] == 'R')
                {
                    odd[i + 1] += even[i];
                    even[i + 1] += odd[i];
                    even[i] = 0;
                    odd[i] = 0;
                }
            }

            for (int i = 0; i < s.Length - 1; i++)
            {
                even[i + 1] += odd[i];
            }

            System.Console.WriteLine(string.Join(" ", even));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 17760
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=2000005;
const int MOD=200003;
const double Pi=acos(-1);
struct Complex
{
	double x,y;
	Complex(double xx=0,double yy=0)
	{
		x=xx,y=yy;
		return;
	}
	Complex operator+(Complex const &b)const
	{
		return (Complex){x+b.x,y+b.y};
	}
	Complex operator-(Complex const &b)const
	{
		return (Complex){x-b.x,y-b.y};
	}
	Complex operator*(Complex const &b)const
	{
		return (Complex){x*b.x-y*b.y,x*b.y+y*b.x};
	}
};
Complex W[N<<1];
void dft(vector<Complex> &f,int len)
{
	if(len==1) return;
	vector<Complex> fl,fr;
	fl.resize(len/2),fr.resize(len/2);
	for(int k=0;k<len/2;k++)
		fl[k]=f[k*2],fr[k]=f[k*2+1];
	dft(fl,len/2);
	dft(fr,len/2);
	Complex w=W[len],buf=(Complex){1,0};
	for(int k=0;k<len/2;k++)
	{
		f[k]=fl[k]+buf*fr[k];
		f[k+len/2]=fl[k]-buf*fr[k];
		buf=buf*w;
	}
	return;
}
void idft(vector<Complex> &f,int len)
{
	if(len==1) return;
	vector<Complex> fl,fr;
	fl.resize(len/2),fr.resize(len/2);
	for(int k=0;k<len/2;k++)
		fl[k]=f[k*2],fr[k]=f[k*2+1];
	idft(fl,len/2);
	idft(fr,len/2);
	Complex w=(Complex){W[len].x,-W[len].y},buf=(Complex){1,0};
	for(int k=0;k<len/2;k++)
	{
		f[k]=fl[k]+buf*fr[k];
		f[k+len/2]=fl[k]-buf*fr[k];
		buf=buf*w;
	}
	return;
}
typedef vector<long long> poly;
poly fft(const poly &F,const poly &G)
{
	vector<Complex> f,g;
	int n=F.size()-1,m=G.size()-1;
	f.resize(n+1),g.resize(m+1);
	for(int i=0;i<=n;i++)
		f[i].x=F[i];
	for(int i=0;i<=m;i++)
		g[i].x=G[i];
	for(m+=n,n=1;n<=m;n<<=1);
	for(int i=1;i<=n;i++)
		W[i]=(Complex){cos(2*Pi/i),sin(2*Pi/i)};
	f.resize(n);
	g.resize(n);
	dft(f,n);
	dft(g,n);
	for(int i=0;i<n;i++)
		f[i]=f[i]*g[i];
	idft(f,n);
	poly res;
	res.resize(m+1);
	for(int i=0;i<=m;i++)
		res[i]=(long long)(f[i].x/n+0.5);
	return res;
}
const int G=2;
int n;
int a[N];
long long powG[N],logG[N];
void init()
{
	powG[0]=1;
	logG[1]=0;
	for(int i=1;i<=MOD-2;i++)
	{
		powG[i]=powG[i-1]*G%MOD;
		logG[powG[i]]=i;
	}
	return;
}
int cnt[N];
int main()
{
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]) cnt[logG[a[i]]]++;
	}
	poly f;
	f.resize(MOD-1);
	for(int i=0;i<=MOD-2;i++)
		f[i]=cnt[i];
	f=fft(f,f);
	long long ans=0;
	for(int i=0;i<f.size();i++)
		ans+=f[i]*powG[i%(MOD-1)];
	for(int i=0;i<=MOD-2;i++)
		ans-=cnt[i]*(powG[i]*powG[i]%MOD);
	printf("%lld",ans/2);
	return 0;
}


Measured memory_bytes: 105276
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int h,w,ans[100][100]={};
    string s[100];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
        cout<<(ans[i][0]=-(s[i][0]=='.'))<<' ';
        for(int j=1;j<w;j++)
            cout<<(ans[i][j]=(ans[i][j-1]+(ans[i][j-1]>=0))*(s[i][j]=='.'))<<(j+1==w?'\n':' ');
    }
}



Measured memory_bytes: 3304
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//222
	int a,b,k;
	cin>>a>>b>>k;
	set<int> s;
	REP(i,a,min(b,a+k-1))s.insert(i);
	REP(j,max(a,b-k+1),b)s.insert(j);
	for(int i:s)cout<<i<<"\n";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int N, K, p[200005];
long long int s[200005];

int main(void) {

	cin >> N >> K;

	for (int i = 1; i <= N; i++) { cin >> p[i]; }

	for (int i = 1; i <= N; i++) {
		s[i] = p[i] + s[i - 1];
	}

	long long int ans = 0;

	for (int i = K; i <= N; i++) {
		ans = max(ans, s[i] - s[i - K]);
	}

	cout << setprecision(12) << 0.5*(1.0*ans+1.0*K) << endl;

	return 0;
}

Measured memory_bytes: 2560
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int ans[10][10];

int firstDigit(int n) 
{  
    while (n >= 10)  
        n /= 10; 
    return n; 
} 

int lastDigit(int n) 
{ 
    return (n % 10); 
}

void solve()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		ans[firstDigit(i)][lastDigit(i)]++;
	}
	int cnt = 0;
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			int p = ans[i][j];
			int q = ans[j][i];
			cnt += p * q;
		}
	}
	cout << cnt << endl;
}

 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256