akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;

struct S{
    mint a,b;
};

struct F{
    mint a,b;
};

S op(S x,S y){
    x.a += y.a;
    x.b += y.b;
    return x;
}

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

S mapping(F l,S r){
    return S{r.a*l.a+r.b*l.b,r.b};
}

F composition(F l,F r){
    l.b = l.a*r.b + l.b;
    l.a *= r.a;
    return l;
}

F id(){ return F{1,0};}

int main(){
    int n,q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i,n){
        int x;
        cin >> x;
        a[i].a = x;
        a[i].b = 1;
    }

    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);

    while(q--){
        int t;
        cin >> t;
        if(t==0){
            int l,r,c,d;
            cin >> l >> r >> c >> d;
            seg.apply(l,r,F{c,d});
        }else{
            int l,r;
            cin >> l >> r;
            cout << seg.prod(l,r).a.val() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19348
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC140D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = ReadInt();
            int N = NK[0];
            int K = NK[1];

            string s = Console.ReadLine();

            int first = 0;
            int change = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (s[i] != s[i + 1])
                {
                    change++;
                }
            }
            first = N - change - 1;

            int ans = first + Math.Min(change, K) * 2;
            if (ans >= N) ans = N - 1;

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

int main() {
  string s;
  cin >> s;
  bool a = false,b = false;
  if(s.at(0) == '0'){
    if(s.at(1) != '0')
      a = true;
  }
  else if(s.at(0) == '1' ){
    if(s.at(1) == '0' || s.at(1) == '1' || s.at(1) == '2')
      a = true;
  }
  if(s.at(2) == '0'){
    if(s.at(3) != '0')
      b = true;
  }
  else if(s.at(2) == '1' ){
    if(s.at(3) == '0' || s.at(3) == '1' || s.at(3) == '2')
      b = true;
  }
  if(a && b)
    cout << "AMBIGUOUS" << endl;
  else if(a && !b)
    cout << "MMYY" << endl;
  else if(!a && b)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    map<long long int, int> mp;
    for(int n=0; n<N; n++) {
        long long int A;
        cin >> A;
        
        mp[A]++;
    }
    
    long long int ans=0;
    auto i=mp.end();
    while(i!=mp.begin()) {
        i--;
        if(i->second>=2) {
            if(ans==0) {
                ans = i->first;
            } else {
                ans *= i->first;
                break;
            }
            if(i->second>=4) {
                ans *= i->first;
                break;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
   int k;
   cin >> k;
   string res = "";
   while (k--)
   	res += "ACL";
   cout << res;
   return 0;
}

Measured memory_bytes: 3612
N, A, B = map(int, input().split())

Abs = B - A
if Abs % 2 == 0:
  ans = Abs // 2
else:
  a, b = A-1, N-B
  if a < b:
    ans, B = a+1, B-(a+1)
    ans += (B-1) // 2
  else:
    ans, A = b+1, A+(b+1)
    ans += (N-A) // 2
    
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
map<string,bool>x;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		string s;
		cin>>s;
		if(x[s])
			continue;
		x[s]=1,cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 19148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x, y) x = max(x, y)

int a[3005][3005];
ll dp[3005][3005][4];

int main(){
  ll R, C, k;
  cin >> R >> C >> k;
  rep(i, k){
    int r, c, v;
    cin >> r >> c >> v;
    a[r-1][c-1] = v;
  }
  rep(i, R) rep(j, C){
    for (int k=2; k>=0; k--){
      chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
    }
    rep(k, 4){
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }
  ll ans = 0;
  rep(k, 4) chmax(ans, dp[R-1][C-1][k]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320416
Tsum = 0

catch = input()
catch = catch.split(" ")
T = int(catch[1])

catch = input()
t = catch.split(" ")

t2 = [0]
for i in range(1, len(t)):
    t2.append(int(t[i]) - int(t[i-1]) )

for i in t2:

    if i < T:
        Tsum +=i

    else:
        Tsum +=T

print(Tsum + T)


Measured memory_bytes: 22392
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>

using namespace std;
vector<string> area;

int main() {
	//input
	int h, w;
	cin >> h >> w;

	int h2, w2;
	h2 = h; 
	w2 = w;

	for (int i = 0; i < h; ++i) {
		string tmp;
		cin >> tmp;
		area.push_back(tmp);
	}
	//cout << area.at(0)[0] << endl;

	//横消す
	int i = 0;
	for (i = 0; i < h; ++i) {
		int h_cnt = 0;
		for (int j = 0; j < w; ++j) {
			
			if (area.at(i)[j] == '.') {
				h_cnt++;
			}
		}
		if (h_cnt == w) {
			//消す
			area.erase(area.begin() + i);
			i = -1; //縦のカウンタのリセット
			h--;
		}

	}

	//縦を消す
	//削除条件の確認
	vector<int> tmp;
	for (int i = 0; i < w; ++i) {
		int w_cnt = 0;
		for (int j = 0; j < h; ++j) {
			if (area.at(j)[i] == '.'){
				w_cnt++;
			}
		}
		if (w_cnt == h) {
			tmp.push_back(i);
		}
	}

	//消す
	int i2 = 0;
	vector<int> tmp2;
	tmp2 = tmp;

	int tmpcnt = 0;
	for (int i2 = 0; i2 < h; ++i2) { //縦一列分
		tmpcnt++;
		for (int j = 0; j < tmp2.size(); ++j) {
			area.at(i2).erase(area.at(i2).begin() + tmp2.at(j));
			tmp2.erase(tmp2.begin() + j);
			//要素内を引く1する
			for (int m = 0; m < tmp2.size(); ++m) {
				tmp2.at(m) = tmp2.at(m) - 1;
			}
			j = -1;
		}
		tmp2 = tmp;
		w--;
	} //縦一列分


	for (int i = 0; i < area.size(); ++i) {
		for (int j = 0; j < area.at(i).size(); ++j) {
			cout << area.at(i)[j];
		}
		cout << endl;
	}

	return 0;
}

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

const int maxN = 2000 + 5;
int n;
LL P;
LL f[maxN * 3][maxN];

int main() {
	cin >> n >> P;
	f[0][0] = 1;
	for(int i = 0; i <= n * 3; ++i) {
		for(int j = 0; j <= i / 2 && j <= n; ++j) {
			(f[i + 1][j] += f[i][j]) %= P;
			(f[i + 2][j + 1] += f[i][j] * (i + 1)) %= P;
			(f[i + 3][j + 1] += f[i][j] * (i + 2) % P * (i + 1)) %= P;
		}
	}
	LL ans = 0;
	for(int j = 0; j <= n; ++j) (ans += f[3 * n][j]) %= P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 92928
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    T = np.array(read().split(), np.int32)
    T -= 1
    return D, C, S, T

def print_scores(D, C, S, T):
    x = 0
    last = np.zeros(26, np.int32)
    for d in range(D):
        i = T[d]
        x += S[d, i]
        last[i] = d + 1
        for i in range(26):
            x -= np.sum(C[i] * (d + 1 - last[i]))
        print(x)

D, C, S, T = get_input()
print_scores(D, C, S, T)

Measured memory_bytes: 27572
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
#include <list>

using namespace std;

void print(vector<int> A) {
    for(int i; i<A.size(); i++){
        cout << A[i];
        if (i != A.size() - 1) cout << " ";
    }
    cout << endl;
}

void insertionSort(vector<int> A, int N) {
    int v, j;
    for (int i = 0; i < N; i++) {

        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print(A);
    }
}

int main() {
    int N, a;
    vector<int> A;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
    }
    insertionSort(A, N);
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

string s;
int e, res;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> s;
    FOR(i,0,s.length()-1)
        if (s[i] == 'p') e++;
    FOR(i,0,s.length()-1)
        if (s[i] == 'g') {
            if (e >= 0) e--;
            else {
                e++;
                res++;
            }
        }
    cout << res;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define int long long
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;

int h,w;
string str;
int mem[1005][1005];


signed main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >> h >> w;
  
  iFOR(i,1,h+1){
    cin >> str;
    FOR(j,w){
      if(str[j]=='#'){
        mem[i][j+1] = -1;
      }
    }
  }
  mem[1][1]=1;
  iFOR(i,1,h+1){
    iFOR(j,1,w+1){
      if(mem[i][j] == -1){
        mem[i][j]=0;
      }else{
        mem[i][j]+=((mem[i][j-1]%MOD)+(mem[i-1][j]%MOD))%MOD;
      }
    }
  }
  cout << mem[h][w] fin;
  return 0;
}



Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    int t[26] = {};
    for(int i = 0; i < s.size(); i++) {
        t[s[i] - 'a'] = 1;
    }
    for(int i = 0; i < 26; i++) {
        if(!t[i]) {
            cout << char(i+'a');
            return 0;
        }
    }
    cout << "None";
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int>> x(m);
  for (int i = 0; i < m; i++) cin >> x.at(i).first >> x.at(i).second;
  
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    if (ans.at(x.at(i).first - 1) == -1) {
      ans.at(x.at(i).first - 1) = x.at(i).second;
    }
    else if (ans.at(x.at(i).first - 1) != x.at(i).second) {
      cout << "-1\n";
      return 0;
    }
  }
  
  if (ans.at(0) == 0 && n >= 2) {
    cout << "-1\n";
    return 0;
  }
  
  for (int i = 0; i < n; i++) {
    if (ans.at(i) != -1) cout << ans.at(i);
    else {
      if(i == 0 && n >= 2) cout << 1;
      else cout << 0;
    }
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe

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

count1 :: Int -> Int
count1 i | i `mod` 2 == 0 = 1 + count1 (i `div` 2)
         | otherwise      = 0

solve :: Int -> [Int] -> Int
solve n as =
  sum $ map count1 as

main :: IO ()
main = do
  conts <- B.getContents
  let n : as = bsReadInts conts
      answer = solve n as
  putStrLn (show answer)


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (!x) cout << i, exit(0);
    }
}

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

int main() {
    // freopen("RAW/in", "r", stdin);
    // freopen("RAW/out", "w", stdout);
    int a, b;
    scanf("%d%d", &a, &b);
    int ans = max(max(a+b, a-b), a*b);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int h, w;
  cin >> h >> w;
  map<char, int> mp;
  REP(i, h) {
    string s;
    cin >> s;
    REPe(e, s) { mp[e]++; }
  }
  vecint num;
  for (auto e : mp) {
    if (e.second % 4 != 0) {
      num.push_back(e.second);
    }
  }
  string ans = "Yes";
  if (h % 2 == 0 && w % 2 == 0) {
    if (num.size() != 0) ans = "No";
  } else if (h * w % 2 == 0) {
    int x = (h % 2 == 0) ? h : w;
    int sum = 0;
    REPe(e, num) {
      if (e % 2 != 0) {
        ans = "No";
        break;
      }
      sum += e % 4;
    }
    if (sum > x) ans = "No";
  } else {
    int x = h + w;
    int sum = 0;
    int cnt = 0;
    REPe(e, num) {
      if (e % 2 != 0) {
        cnt++;
        if (cnt > 1) {
          ans = "No";
          break;
        }
      }
      sum += e % 4;
    }
    if (cnt != 1 || sum > x) ans = "No";
  }
  cout << ans << endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[,] dp = new int[n, n + 1];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                for (int j = 0; j < n; j++)
                {
                    dp[i, j + 1] = dp[i, j] + input[j];
                }
            }

            int max = int.MinValue;

            for (int ws = 0; ws < n; ws++)
            {
                for (int wt = ws + 1; wt <= n; wt++)
                {
                    int sum = 0;

                    for (int h = 0; h < n; h++)
                    {
                        sum += dp[h, wt] - dp[h, ws];
                        max = Math.Max(max, sum);
                        sum = Math.Max(sum, 0);
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}

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

using P = pair<int, int>;
long long n, m;
vector<vector<int>> g;
vector<vector<bool>> ch;
queue<P> qu;

long long solve();

int main() {
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  ch.assign(n, vector<bool>(2, 0));
  ch[0][0] = 1;
  qu.push(P(0, 0));
  while (qu.size()) {
    P now = qu.front();
    qu.pop();
    now.second = !now.second;
    for (auto to : g[now.first]) {
      P nxt = now;
      nxt.first = to;
      if (!ch[to][nxt.second]) {
        ch[to][nxt.second] = 1;
        qu.push(nxt);
      }
    }
  }
  if (ch[0][0] && ch[0][1]) return n * (n - 1) / 2 - m;
  long long cnt[2] = {};
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 2; ++j) cnt[j] += ch[i][j];
  return cnt[0] * cnt[1] - m;
}

Measured memory_bytes: 15840
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int k, x;

int main(){
    cin >> k >> x;

    if (500 * k >= x) {
      cout << "Yes";
    } else {
      cout << "No";
    }
    return 0;
}


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

int main() {
  int A, B, C;
  cin >>A>>B>>C;
  int i = abs(A - B);
  int j = abs(B - C);
  int k = abs(C - A);
  
  
  cout << i + j + k - max(i, max(j, k)) << endl;
  
  
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

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

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

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

    // 全部0 の場合は 0 を出力
    bool isallzero = true;
    for (int i = 1; i <= N; i++) {
        if (a[i] == 1) {
            isallzero = false;
            break;
        }
    }
    if (isallzero) {
        cout << 0 << endl;
        return;
    }

    vector<ll> b(N+1);
    for (int i = N; i > 0; i--) {
        if (N / i == 1) {
            b[i] = a[i];
        } else {
            ll sum = 0;
            for (int j = 2; j <= N / i; j++) {
                sum += b[j*i];
            }
            b[i] = a[i] ^ (sum % 2);
        }
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (b[i] == 1) {
            cnt++;
        }
    }

    vector<ll> candidate;
    for (int i = 1; i <= N; i++) {
        if (b[i] == 1) {
            candidate.push_back(i);
        }
    }

    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) {
        if (i == 0) {
            cout << candidate[0];
        } else {
            cout << " " << candidate[i];
        }
    }
    cout << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b;
  cin >> a >> b;
  pr(max(max(a + b, a - b), a * b));
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int temp[n];
  int i,j;
  for(i=0;i<n;i++)
  {
    temp[i]=INT_MAX;
  }
  temp[0]=0;
  temp[1]=abs(arr[0]-arr[1]);
  for(i=2;i<n;i++)
  {
    int t=k;
    int j=i-1;
    while(t--&&j>=0)
    {
      temp[i]=min(temp[i],abs(arr[j]-arr[i])+temp[j]);
      j--;
    }
  }
  cout<<temp[n-1];
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());

  int64_t atackkk = 0;

  if (N <= K) {
      cout << 0 << endl;
  }
  else {
    for (int i = 0; i < N - K; i++) {
      atackkk += H.at(i);
    }
    cout << atackkk << endl;
  }
}

Measured memory_bytes: 1792
N, Q = gets.split.map(&:to_i)
S = gets.chomp.chars
M = ['l'] + S + ['r']
QUERIES = Q.times.map { gets.chomp.split }

def f(x, pos)
  cur = x
  ch = M[cur]

  return true if x == pos

  QUERIES.each do |t, d|
    next if t != ch

    if d == 'L'
      cur -= 1
    else
      cur += 1
    end

    ch = M[cur]

    break if ch == pos
  end

  ch == pos
end

ok = 0
ng = N + 1

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid, 'l')
    ok = mid
  else
    ng = mid
  end
end

left = ng

ok = N + 1
ng = 0

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid, 'r')
    ok = mid
  else
    ng = mid
  end
end

right = ng

puts [right - left + 1, 0].max


Measured memory_bytes: 79132
import math
a,b,h,m=list(map(int, input().split()))

angle=(h/12.0)*2*math.pi+(m/60)/12.0*2*math.pi-(m/60.0)*2*math.pi
c2=a**2+b**2-2*a*b*math.cos(angle)
answer=c2**(0.5)
print(answer)

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

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

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

#define INF 1000000
#define mod 1000000007

int n;
int a[101];
int dp[101][101];

int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,101)rep(j,101)dp[i][j]=INF;
  rep(i,n){
    if(a[0]==i)dp[1][i]=0;
    else dp[1][i]=1;
  }
  repl(i,1,n)rep(j,n){
    rep(k,n){
      if(k==j)continue;
      minch(dp[i+1][k],dp[i][j]+(k==a[i]?0:1));
    }
  }
  int res=INF;
  rep(i,n)minch(res,dp[n][i]);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a;
	int h, m, s;

	do {
		scanf("%d", &a);
	} while (a < 0 || a > 86400);

	if (a == 0)
	{
		printf("0:0:0\n");
	}
	else {
		h = a / 3600;
		m = (a % 3600) / 60;
		s = (a % 60) % 60;
		printf("%d:%d:%d\n", h, m, s);
	}
	return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
  
int main()
{
	string s;
  cin>>s;
  int n=s.size();
  ll dp[100001], dp1[100001], dp2[100001], dp0[100001];
  dp[0]=0, dp1[0]=0, dp2[0]=0, dp0[0]=1;
  for(int i=1; i<=n; i++){
    if(s[i-1]=='?'){
      dp0[i]=dp0[i-1]*3;
    }else{
      dp0[i]=dp0[i-1];
    }
    dp0[i]%=MOD;
    if(s[i-1]=='A'){
      dp1[i]=dp1[i-1]+dp0[i-1];
    }else if(s[i-1]=='?'){
      dp1[i]=3*dp1[i-1]+dp0[i-1];
    }else{
      dp1[i]=dp1[i-1];
    }
    dp1[i]%=MOD;
    if(s[i-1]=='B'){
      dp2[i]=dp2[i-1]+dp1[i-1];
    }else if(s[i-1]=='?'){
      dp2[i]=3*dp2[i-1]+dp1[i-1];
    }else{
      dp2[i]=dp2[i-1];
    }
    dp2[i]%=MOD;
    if(s[i-1]=='C'){
      dp[i]=dp[i-1]+dp2[i-1];
    }else if(s[i-1]=='?'){
      dp[i]=3*dp[i-1]+dp2[i-1];
    }else{
      dp[i]=dp[i-1];
    }
    dp[i]%=MOD;
  }
  cout<<dp[n]<<endl;
    return 0;
}

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


int min_cost(int a[], int n)
{
	int cost[n];
	cost[n-1] = 0;
	cost[n-2] =abs(a[n-2]-a[n-1]);
	for(int i=n-3;i>=0;i--)
		cost[i] = min(abs(a[i]-a[i+1])+cost[i+1],abs(a[i+2]-a[i])+cost[i+2]);
	return cost[0];
}

int main()
{
	int n;cin>>n;int a[n];for(int i=0;i<n;i++)	cin>>a[i];
	cout<<min_cost(a,n)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int solve() {
    int A[3];
    for (int& i : A) cin >> i;
    sort(A, A + 3);
    int t1 = (A[2] - A[0]) / 2, t2 = (A[2] - A[1]) / 2;
    A[0] += 2 * t1;
    A[1] += 2 * t2;
    if (A[0] == A[1] && A[1] == A[2]) return t1 + t2;
    sort(A, A + 3);
    return t1 + t2 + (A[0] == A[1] ? 1 : 2);
}
int main() {
    cout << solve() << endl;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    multiset<ll> tops;
    rep(i, n) {
        ll a;
        cin >> a;
        a = -a;
        auto it = tops.upper_bound(a);
        if (it == tops.end()) {
            tops.insert(a);
        } else {
            tops.erase(it);
            tops.insert(a);
        }
    }

    cout << tops.size() << endl;

}





Measured memory_bytes: 4992
#include<stdio.h>
int m[101][101];
int s[101];
int n[101];
int p,k=0;

void search(x){
  int i;

  s[x]=++k;
  for(i=1;i<=p;i++){
    if(m[x][i]==0) continue;
    if(s[i]>0) continue;

    search(i);
  }
  n[x]=++k;
}

int main(void){
  int u,k,v;
  int i,j;

  scanf("%d",&p);
  for(i=0;i<p;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      m[u][v]=1;
    }
  }
  for(i=1;i<=p;i++){
    if(s[i]==0) search(i);
  }
  for(i=1;i<=p;i++){
    printf("%d %d %d\n",i,s[i],n[i]);
  }
  return 0;
}

    



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

using namespace std;

int main()
{
    int a,b,n,m,z;
    cin>>a>>b;
    n=a+b;
    m=a-b;
    z=a*b;
    if(n>=m&&n>=z)
        cout<<n;
    else if (m>=n&&m>=z)
        cout<<m;
    else
        cout<<z;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

if $0 == __FILE__
  N = gets.to_i
  points = []
  points << [0, 0, 0] # 初期位置
  N.times.each{ points << gets.split(' ').map(&:to_i) }

  (0...N).each do |i|
    t1 = points[i][0]
    x1 = points[i][1]
    y1 = points[i][2]
    t2 = points[i+1][0]
    x2 = points[i+1][1]
    y2 = points[i+1][2]

    t = t2 - t1
    x = (x2 - x1).abs
    y = (y2 - y1).abs

    if t >= (x + y) and (x + y - t) % 2 == 0
    else
      puts 'No'
      exit
    end
  end

  puts 'Yes'
end


Measured memory_bytes: 9468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (;;) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=50005,M=1000005;
int mk[M][6];
pair<pii,int>e[N];
int ufs[(N<<1)+(N<<2)],rt[6];
int UFS(int v){return ufs[v]?ufs[v]=UFS(ufs[v]):v;}
inline void mg(int v,int u){if((v=UFS(v))!=(u=UFS(u)))ufs[u]=v;}
inline int mygcd(int a,int b){return b?mygcd(b,a%b):a;}
inline void mark(int z,int g,int id){
	//printf("mark z=%d g=%d id=%d\n",z,g,id);
	mk[rt[id]=(z%=g)][id]=1;
	for(int i=(z<<2)%g;i!=z;i=(i<<2)%g)mk[i][id]=1;
	//printf("---\n");
}
int main(){
    //freopen("f.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,m,q,md,i,j,k,z=1000000000,g,g3,t,v,u,w;
    scanf("%d%d%d%d",&n,&m,&q,&md);g=md;
    rep(i,1,m){
		scanf("%d%d%d",&e[i].fi.fi,&e[i].fi.se,&e[i].se);
		cmin(z,e[i].se);
	}
	rep(i,1,m)g=mygcd(g,e[i].se-z);g3=g+(g<<1);
	//printf("g=%d 3g=%d\n",g,g3);
	if(md%g3){
		z%=g;
		mark(z   ,g,0);
		mark(z<<1,g,1);
		t=2;
	}else{
		z%=g3;
		mark( z           ,g3,0);
		mark( z    + g    ,g3,1);
		mark( z    +(g<<1),g3,2);
		mark((z<<1)       ,g3,3);
		mark((z<<1)+ g    ,g3,4);
		mark((z<<1)+(g<<1),g3,5);
		t=6;g=g3;
	}
	//REP(k,0,t)printf("%d ",rt[k]);puts("RT");
	rep(i,1,m){
		v=e[i].fi.fi;
		u=e[i].fi.se;
		w=e[i].se-z ;
		REP(j,0,t)REP(k,0,t)if(mk[((rt[j]<<1)+w)%g][k])mg(v*t+j,u*t+k);
	}
	while(q--){
		scanf("%d%d%d",&u,&v,&w);
		w=(w+z)%g;
		REP(k,0,t)if(UFS(v*t)==UFS(u*t+k)&&mk[w][k])break;
		if(k==t)puts("NO");else puts("YES");
	}
    return 0;
}

Measured memory_bytes: 25344
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		System.out.println(n % sumOfDigits(n) == 0 ? "Yes" : "No");
	}

	private static int sumOfDigits(int n) {
		int sum = 0;
		while (n > 0) {
			sum += n % 10;
			n = n / 10;
		}
		return sum;
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;
vec bit(400010,0);
ll sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    while(i <= N){
        bit[i] += x;
        i += i & -i;
    }
}
int main() {
    cin>>N;
    vector<P> dot(N,P(0,0));
    vec yv(N);
    rep(i,N){
        cin>>A>>B;
        dot[i] = {A,B};
        yv[i] = B;
    }
    sort(dot.begin(),dot.end());
    sort(yv.begin(),yv.end());
    mat data(4,vec(N,0));//右上から反時計回りの領域
    rep(i,N){
        ll I = lower_bound(yv.begin(),yv.end(),dot[i].se) - yv.begin();
        //cout<<I<<endl;
        data[2][i] = (I == 0) ? 0 : sum(I);
        data[1][i] = (I == N-1) ? 0 : sum(N) - sum(I);
        add(I+1,1);
    }
    rep(i,400010) bit[i] = 0;
    for(ll i = N-1; i >= 0; --i){
        ll I = lower_bound(yv.begin(),yv.end(),dot[i].se) - yv.begin();
        //cout<<I<<endl;
        data[3][i] = (I == 0) ? 0 : sum(I);
        data[0][i] = (I == N-1) ? 0 : sum(N) - sum(I);
        add(I+1,1);
    }
    /*rep(i,N){
        rep(j,4) cout<<data[j][i]<<' ';
        cout<<endl;
    }*/
    vec b2(N+10,0);
    b2[0] = 1;
    reps(i,1,N+10) (b2[i] += (b2[i-1] << 1))%=MOD;
    ll ans = 0;
    rep(i,N){
        (ans += b2[N-1]<<1)%=MOD;
        ll temp = 0;
        rep(j,4){
            temp = data[j][i] + data[(j+1)%4][i];
            ((ans += MOD) -= b2[temp])%=MOD;
            (ans += b2[data[j][i]])%=MOD;
        }
        (ans += MOD-1)%=MOD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
N = int(input())
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
    a[i] = int(st[i])
    A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
    b[i] = int(st[i])
    B += b[i]
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")


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


void testcase(){
    int n, K;
    cin >> n >> K;
    vector<int> input(n);
    for(int i = 0; i < n; i++) cin >> input[i];

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int k = i + 1; k <= min(i + K , n - 1); k++){
            dp[k] = min(dp[k], dp[i] + abs(input[i] - input[k]));
        }
    }
    cout << dp[n - 1];
}

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

#ifdef AKP
    freopen("in.txt","r", stdin);
#endif

    int t = 1;
    //cin >> t;
    while(t--){
        testcase();
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<iostream>

using namespace std;
#define MOD 1000000007
int n, m;
vector<int> g[200005];
map<pair<int,int>, bool> check;
int visited[200005], id = 1;
map<int, int> cnt;

void dfs(int s)
{
  //cout << id << ": " << s << endl;
  visited[s] = id;
  for(int i = 0; i < g[s].size(); i++)
  {
    int u = g[s][i];
    if(!visited[u]){
      dfs(u);
    }
  }
}
int main()
{
  cin >> n >> m;
  for(int i = 0; i < m; i++)
  {
    int u, v;
    cin >> u >> v;
    pair<int,int> p1 = {u,v}, p2= {v,u};
    if(!check[p1] && !check[p2]){
      g[u].push_back(v);
      g[v].push_back(u);
      check[p1] = check[p2] = 1;
    }
  }
  for(int i = 1; i <= n; i++)
  {
    if(!visited[i]) {
      dfs(i);
      id++;
    }
  }
  
  for(int i = 1; i <= n; i++)
    cnt[visited[i]]++;
  int mx = (int) - 1e9;
  for(auto x:cnt)
  {
    mx = max(mx, x.second);
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 39908
pd = list(map(str,input()))
# print(pd)
if(len(pd) == 1):
    pd[0] ="D"
else:
    if(pd[0] == "?"):
            pd[0] = "D"
    for i in range(1,len(pd)):
        if(pd[i]=="?"):
            pd[i] = "D"
print("".join(pd))

Measured memory_bytes: 10904
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)


let n = readIntArray()
Array.groupBy (fun x -> x) n 
|> Array.where (fun x -> snd(x).Length = 1)
|> Array.head
|> fun x -> fst x
|> printfn "%d"

Measured memory_bytes: 12892
#include <stdio.h>

int main(void) 
{
	int i ;
	int counter=0;	
	char eitango[100]={0}; 
	char shouryaku[10]={0};
	scanf("%s",eitango);

	for (i=0 ; eitango[i] != '\0' ; i++)
	{
		if (eitango[i] != '\0')
		counter++;	
	}
	
	sprintf (shouryaku,"%c%d%c",eitango[0],counter-2,eitango[i-1]);
	printf ("%s\n",shouryaku);

	return 0;
}

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

#define pb push_back
#define ll long long
#define mp make_pair
#define F first
#define S second
using namespace std;
void data() {
	#ifdef NURS
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}
const int N = 1e5 + 100;
const int mod = 1e9 + 7;
int dp[N];
int main()
{
	data();
	int n, k;
	cin >> n >> k;
	int a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 2; i <= n; i++)
	{
		dp[i] = 1e9;
	}
	for (int i = 2; i <= n; i++)
	{
		for (int j = max(i - k, 1); j <= i - 1; j++)
		{
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}	
	}
	cout << dp[n];
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 20000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,a[MN+5];
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[read()]+=i;
	for(int i=1;i<=n;++i) printf("%d%c",i*20000,i==n?'\n':' ');
	for(int i=1;i<=n;++i) printf("%d ",a[i]+(n-i)*20000);
	return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 128;

vector <int> adj[MAX];
int d[MAX];

void solve(void){
	ENJYU;
	int N;
	cin >> N;
	rep(N, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, i) {
			int v;
			cin >> v;
			v--;
			adj[u].pb(v);
		}
	}
	memset(d, -1, sizeof(d));
	queue <int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		int n = q.front();
		q.pop();
		for (int nv : adj[n]) {
			if (d[nv] >= 0) {
				//d[nv] = min(d[nv], d[n] + 1);
				continue;
			}
			d[nv] = d[n] + 1;
			q.push(nv);
		}
	}

	rep(N, i) cout << i+1 << ' ' << d[i] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3136
use std::io::*;

fn check(mut x: u64) -> bool {
    let mut san = false;
    let mut go = false;
    let mut siti = false;
    while x > 0 {
        match x % 10 {
            7 => siti = true,
            5 => go = true,
            3 => san = true,
            _ => continue,
        }
        x /= 10;
    }
    san && go && siti
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: u64 = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(3);
    q.push_back(5);
    q.push_back(7);
    while let Some(x) = q.pop_front() {
        if x > n {
            break;
        }
        if check(x) {
            ans += 1;
        }
        q.push_back(x * 10 + 3);
        q.push_back(x * 10 + 5);
        q.push_back(x * 10 + 7);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();
			if (h == 0 && w == 0) {
				break;
			} else if (3 <= h && h <= 300 && 3 <= w && w <= 300) {
				for (int i = 0; i < w; i++) {
					System.out.print("#");
				}
				System.out.println("");
				for (int j = 0; j < h - 2; j++) {
					System.out.print("#");
					for (int k = 0; k < w - 2; k++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for (int l = 0; l < w; l++) {
					System.out.print("#");
				}
				System.out.println("");
			}
System.out.println("");

		}

	}

}

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

int vec_fnd(vector<int> vec, int n) {
    bool a = 0;
    for (int i=0; i < vec.size(); i++) {
        if (vec.at(i) == n) {
            a = 1;
            break;
        }
    }
    return a;
}

int main() {
    int x, y;
    cin >> x >> y;
    vector<int> A(7);
    A = { 1, 3, 5, 7, 8, 10, 12 };
    vector<int> B(4);
    B = { 4, 6, 9, 11 };

    if ((vec_fnd(A, x) && vec_fnd(A, y)) || (vec_fnd(B, x) && vec_fnd(B, y))) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;
// RunLengthEncoding O(n)
std::vector<std::pair<char,int>> runLength(const std::string &s){
    std::vector<std::pair<char,int>> ret(0);
    int n = s.size();
    char prev = s[0];
    int length = 1;
    for(int i=1; i<n; i++){
        if(s[i]==prev){
            length++; 
        }
        else{
            ret.push_back(std::make_pair(prev,length));
            length = 1;
            prev = s[i];
        }
    }
    ret.push_back(std::make_pair(prev, length));
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s; 

    auto RL = runLength(s);


    cout << RL.size() << endl;
    return 0;
}

Measured memory_bytes: 1480
N = int(input())
S = input()

right_white = S.count(".")
left_black = 0

ans = right_white + left_black
for i in range(N):
    if S[i] == ".":
        right_white -= 1
    else:
        left_black += 1
    ans = min(ans, right_white + left_black)

print(ans)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  string s;
  cin >> s;
  REP(i,s.size()-1){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  
  cout << "Good" << endl;
}


Measured memory_bytes: 256