akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

signed main() {
    capi(n);

    int neg = 0;
    vi va;
    rep(i, n) {
        capi(a);
        if (a < 0) ++neg;
        va.push_back(abs(a));
    }

    sort(all(va));
    int ans = 0;
    if (neg % 2 == 1) ans -= va[0];
    else ans += va[0]; 
    rep(i, n - 1) {
        ans += va[i + 1];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3844
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
using namespace std;


int main()
{
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for (int offset = 1; offset < n; offset++) {
		int m = 0;
		for (int i = 0; i+offset < n; i++) {
			
			if (s[i] == s[i + offset]) {
				m++;
				ans = max(ans, min(offset, m));
			}
			else
				m = 0;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

x = int(input())

i = x
while(i > 0):
    if is_prime(i):
        print(i)
        i = -1
    else:
        i+=1
    

Measured memory_bytes: 38512
#include<iostream>
#include<cstring>
using namespace std;
int n,m,sum;
int main()
{
	cin>>n>>m;
	char a[n+2][m+2];
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.')
			{
				sum=0;
				for(int k1=-1;k1<=1;k1++)
				{
					for(int k2=-1;k2<=1;k2++)
					{
						if(a[i+k1][j+k2]=='#') sum++;
					}
				}
				a[i][j]=sum+'0';
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

class A{
	static void Main(){
        var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        Console.WriteLine(ab[0] + ab[1] == 15 ? "+" : (ab[0] * ab[1] == 15 ? "*" : "x"));
    }
}

Measured memory_bytes: 13268
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		if(a >= 30){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35592
R="R"
L="L"

def f(r, l):
    ans_r = (r // 2) + (r % 2) + (l // 2)
    ans_l = (r // 2) + (l // 2) +  (l % 2)
    return (ans_r, ans_l)

S=input()
N=len(S)
ans=[0]*N

r_begin = 0
r_end = -1
l_begin = 0
l_end = 0
for i in range(N):
    if S[i] == R:
        if r_end == -1:
            continue
        else:
            l_end = i - 1
            a = f(r_end - r_begin + 1, l_end - l_begin + 1)
            ans[r_end] = a[0]
            ans[l_begin] = a[1]

            r_begin = i
            r_end = -1
            l_begin = 0
            l_end = 0
    else:
        if r_end == -1:
            r_end = i - 1
            l_begin = i
        else:
            continue
else:
    l_end = N - 1
    a = f(r_end - r_begin + 1, l_end - l_begin + 1)
    ans[r_end] = a[0]
    ans[l_begin] = a[1]

print(*ans)


Measured memory_bytes: 6400
n = int(input())
h = list(map(int, input().split()))
for i in range(n-2, -1, -1):
    if h[i] <= h[i+1]:
        continue
    if h[i] - h[i+1] > 1:
        print('No')
        quit()
    h[i] -= 1
print('Yes')

Measured memory_bytes: 14252
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

const int MAXN = 510000;
const ll MOD = 1e9 + 7;
using namespace std;
int n;
int ff[MAXN];
ll fc[MAXN];
ll fc2[MAXN];
int p[MAXN];
ll pr[MAXN];
ll en[MAXN];

ll get(int x) {
	ll ans = 0;
	for (; x >= 0; x = (x & (x + 1)) - 1)
		ans += ff[x];
	return ans;
}

void add(int x) {
	for (; x <= n; x |= (x + 1))
		ff[x] += 1;
}

int main() {
	scanf("%d", &n);
	fc[0] = 1;
	for (int i = 1; i <= n; ++i)
		fc[i] = (fc[i - 1] * i) % MOD;
	fc2[0] = 0;
	fc2[1] = 1;
	fc2[2] = 1;
	for (int i = 3; i <= n; ++i)
		fc2[i] = fc2[i - 1] * i % MOD;
	for (int i = 0; i < n; ++i)
		scanf("%d", p + i), en[p[i]] = 1;
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
		cnt += en[i];
	for (int i = 1; i <= n; ++i)
		pr[i] = pr[i - 1] + (en[i] == 0 ? 1 : 0);
	cnt = n - cnt;
	ll ans = fc[cnt];
	int now = 0;
	ll sum = 0;
	for (int i = n - 1; i >= 0; --i) {
		ll x = 0;
		if (p[i] == 0) {
			x = fc2[cnt] * now % MOD;
			x = (x + fc[cnt - 1] * sum) % MOD;
			++now;
		}
		else {
			x = fc[cnt] * get(p[i]) % MOD;
			if (cnt >= 1)
				x = (x + now * fc[cnt - 1] % MOD * pr[p[i]]) % MOD;
			add(p[i]);
			sum = sum + (cnt - pr[p[i]]);
			sum %= MOD;
		}
		ans = (ans + x * fc[n - 1 - i]) % MOD;
	}
	cout << ans << "\n";
	return 0;
}




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

#define int long long

using namespace std;

const int MOD = 1e9 + 7;

const int MAXN = 2e6 + 100;

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a%MOD;
		a = a*a%MOD;
		b /= 2;
	}
	return res;
}

int inv(int x)
{
	return qpow(x,MOD-2);
}

int fact[MAXN];

int comb(int n, int k)
{
	return fact[n]*inv(fact[n-k]*fact[k]%MOD)%MOD;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    fact[0] = 1;
    for(int i = 1 ; i < MAXN ; i++)fact[i] = fact[i-1]*i%MOD;

    int K;
    string S;

    cin >> K >> S;

    int N = S.size();

    int tot = qpow(26,K+N);

    for(int i = 0 ; i < N ; i++)
    {
    	tot = (tot + MOD - comb(N+K,i)*qpow(25,N+K-i)%MOD)%MOD;
    }

    cout << tot << '\n';

    return 0;
}

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

int main() {
  int H, W;
  char v[50][50];
  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> v[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (v[i][j] == '#') {
        cout << '#';
        continue;
      }

      int count = 0;
      for (int l = -1; l < 2; l++) {
        for (int m = -1; m < 2; m++) {
          int ni = i + l;
          int nj = j + m;

          if (ni < 0 || H <= ni) {
            continue;
          }

          if (nj < 0 || W <= nj) {
            continue;
          }

          if (v[ni][nj] == '#') {
            count++;
          }
        }
      }

      cout << count;
    }

    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
 long long  int b,c,i;
 cin>>b>>c;
 long long int a[c],s=0;
 for(i=0;i<c;i++)
 {
 cin>>a[i];
 s=s+a[i];	
 }
 if(s>=b)
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
 return 0;
 }


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>s(n),t(m);
  for(i=0;i<n;i++)cin>>s[i];
  for(i=0;i<m;i++)cin>>t[i];
  ll dp[n][m];
  if(s[0]==t[0])dp[0][0]=1;
  else dp[0][0]=0;
  for(i=1;i<n;i++){
    if(s[i]==t[0])dp[i][0]=(dp[i-1][0]+1)%MOD;
    else dp[i][0]=dp[i-1][0];
  }
  for(i=1;i<m;i++){
    if(s[0]==t[i])dp[0][i]=(dp[0][i-1]+1)%MOD;
    else dp[0][i]=dp[0][i-1];
  }

  for(i=1;i<n;i++){
    for(j=1;j<m;j++){
      if(s[i]==t[j])dp[i][j]=(dp[i-1][j]+dp[i][j-1]+1)%MOD;
      else{buf=(dp[i-1][j]+dp[i][j-1])%MOD;
       buf-=dp[i-1][j-1];
       if(buf<0)buf+=MOD;
       else buf%=MOD;
       dp[i][j]=buf;
      }
      //if(s[i]==t[j])dp[i][j]=(dp[i][j]*2-1)%MOD;  
    }
  }
  cout<<(dp[n-1][m-1]+1)%MOD<<endl;



  
  return 0;
}

Measured memory_bytes: 31488
#include<iostream>
using namespace std;
using ll = long long;

ll mod = 1e9 + 7,dp[110][10];
int h, w, k;

int main(){
    cin >> h >> w >> k;
    dp[0][0] = 1, k--;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < (1 << (w - 1)); j++){
            int p[w], jud = 1;
            for (int k = 0; k < w - 2; k++){
                if (j & (1 << k) && j & (1 << (k + 1)))jud = 0;
            }
            if (!jud)continue;
            for (int k = 0; k < w; k++)p[k] = k;
            for (int k = 0; k < w - 1; k++)if (j & (1 << k))swap(p[k], p[k + 1]);
            for (int k = 0; k < w; k++)(dp[i + 1][p[k]] += dp[i][k]) %= mod;
        }
    }
    cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define emb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define N  99999
#define f first 
#define em emplace
#define s second
using lint=long long int;

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 
const int INF=1e9+5;
   
void solve(){
 
        cini(n);
        vector<int> v(n,INF);
        cinai(b,n);
        v[0]=0;
        for(int i=0;i<n;i++){
            for(int j:{i+1,i+2}){
              if(j<n)
                v[j]=min(v[j],abs(b[i]-b[j])+v[i]);
            }
        }

        cout<<v[n-1]<<endl;
  }

 
 
int main()
{ 
  fast;
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("hex.txt","w",stdout);
  #endif
*/
  solve();
 }

Measured memory_bytes: 1024
object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)
  val positions = io.StdIn.readLine().split(' ').map(_.toInt)


  def calcMinDist(n: Int, k: Int, xs: Seq[Int]): Int = {
    import scala.math._
    // 左右に行ったり来たりせず、折り返しは最大一回までにするのが最短経路になる。   
    // N本のうち連続するK本のろうそくを選ぶ方法は、"N - K + 1"通りなので、
    // 全てのパターンに対して経路を計算して、最小値を探す。
    // 経路の一番左の座標をxl, 一番右の座標をxrとすると、
    // 左 -> 右の順に訪れる場合は: |xl| + |xr - xl|
    // 右 -> 左の順に訪れる場合は: |xr| + |xr - xl|
    // が最小値となる。
    List.range(0, n-k+1).foldLeft(Int.MaxValue){(acc, l) =>
        val r = l + k - 1
        min(acc, abs(xs(r) - xs(l)) + min(abs(xs(l)), abs(xs(r))))
      }
  }

  println(calcMinDist(n, k, positions))
}




Measured memory_bytes: 42344
#include <stdio.h>

int main()
{
  int n=0,m=0;
  int len=0;
  int a[1000000];
  
  scanf("%d",&n);
  scanf("%d",&m);
  
  for(int i=0; i<m; i++)
  {
    scanf("%d",&a[i]);
  };
  
  for(int i=0;i<m;i++)
  {
   len += a[i];
  };
  
  if(n<len)
  {
  printf("-1");
  }else{
  printf("%d",n-len);
  };
  return 0;
};
        


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

int main(){

  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  int sum=0;
  for(int i=1;i<=N;i++){
    if(i>K)
      sum+=Y;
    else
      sum+=X;
    }
    cout<<sum<<endl;
  }

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

int main() {
	int n; cin >> n;
	vector<vector<int>>f(100, vector<int>(10)), p(100, vector<int>(11));
	for (int i = 0; i < n; i++)for (int j = 0; j < 10; j++) {
		int tmp; cin >> tmp;
		f[i][j] = tmp;
	}
	for (int i = 0; i < n; i++)for (int j = 0; j < 11; j++) {
		int tmp; cin >> tmp;
		p[i][j] = tmp;
	}

	int ans = -(1 << 30);
	for (int bit = 1; bit < (1 << 10); bit++) {
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int tmp = 0;
			for (int j = 0; j < 10; j++)if ((bit >> j & 1) && f[i][j])tmp++;
			cnt += p[i][tmp];
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S;
    int h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-(h*3600+m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2096
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll x1, y1, x2, y2, x3, y3;
    // x1 = 0; y1 = 0;
    // x2 = 1e9; y2 = 0;
    // x3 = 0, y3 = 1e9;
    // x1 = 0; y1 = 0;
    // x2 = 1e9; y2 = 5e8;
    // x3 = 1, y3 = 1e9;
    // x1 = 0; y1 = 0;
    // x2 = 1e9; y2 = 7;
    // x3 = 1, y3 = 1e9;
    int a = 1, b = 7;
    int c = 1;
    // a < 1e9 - c
    auto calc = [&](){ 
        x1 = 0; y1 = 0;
        x2 = 1e9; y2 = a;
        x3 = b, y3 = 1e9 - c;
        ll other = abs(x1 - x3) * (y3 - y1) + (x2 - x1) * (y2 - x1) + (y3 - y2) * (x2 - x3);
        ll sq = 2 * (x2 - min(x1, x3)) * (y3 - y1);
        printde(sq, other);
        return sq - other;
    };
    printde(calc());
    ll s; cin >> s;
    ll s2 = 1e18L - s;
    printde(s, s2);
    ll sl = s2 / (int)1e9, sr = s2 % (int)1e9;
    printde(sl, sr);
    c = sl;
    b = sr;
    a = sr == 0 ? 0 : 1;
    printde(calc());
    cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << '\n';
}


Measured memory_bytes: 888
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	D = defaultdict(int)
	N = int(input())
	for i in range(N):
		S = input()
		D[S] += 1

	ans = len(D)
	print(ans)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 128724
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let l = get!(usize);
    let mut vec = Vec::new();
    for i in (0..21).rev() {
        if (l>>i)%2 == 1 {
            vec.push(i);
        }
    }
    let n = vec[0]+1;
    println!("{} {}", n, 2*(n-1)+vec.len()-1);
    for i in 0..n-1 {
        println!("{} {} {}", i+1,i+2,1<<i);
        println!("{} {} {}", i+1,i+2,0);
    }
    let mut current = 1<<(n-1);
    for i in vec.into_iter().skip(1) {
        println!("{} {} {}", i+1, n, current);
        current |= 1<<i;
    }
}


Measured memory_bytes: 8572
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] < v[i2];});
  return idx;
}


struct S
{
	int x;
	S() {}
	S(int x) : x(x) {}
	static S I() {
		return S(0);
	}
	void merge(S& a, S& b) {
		x = std::max(a.x, b.x);
	}
};

struct SegmentTree
{
	const int n;
	std::vector<S> data;
	SegmentTree(int n, std::vector<int>& a) : n(n), data(2*n) {
		for(int i=0;i<n;i++) {
			data[n+i] = S(a[i]);
		}
		for(int i=n-1;i>0;i--) {
			data[i].merge(data[i<<1], data[i<<1|1]);
		}
	}
	void set(int i, S v) {
		data[n+i] = v;
		i+=n;
		while(i>0) {
			i>>=1;
			data[i].merge(data[i<<1], data[i<<1|1]);
		}
	}
	S get(int l, int r) {
		// 0-Indexed, [l, r)
		l+=n; r+=n;
		S sum = S::I();
		while(l<r) {
			if(l&1) sum.merge(sum,data[l++]);
			if(r&1) sum.merge(sum,data[--r]);
			l>>=1; r>>=1;
		}
		return sum;
	}
};


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> h(n);
	rep(i,n) std::cin >> h[i];
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	auto idx = sort_indexes(h);
	std::vector<int> dp_seg(n,0);
	SegmentTree seg(n,dp_seg);
	rep(i,n) {
		seg.set(idx[i],S(seg.get(0,idx[i]).x+a[idx[i]]));
	}
	print(seg.get(0,n).x);

	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b) {
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N,a[201],i=0,modd=0,ans=0;
   cin >> N;
   for(i = 0 ; i < N ; i++)
   {
       cin >> a[i];
   }
   

    for(i = 0 ; i < N ; i++)
    {
        modd = modd + a[i] % 2;
        a[i] = a[i] / 2 ;
    }
   
   while(modd==0)
   {
        for(i = 0 ; i < N ; i++)
        {
            modd = modd +a[i] % 2;
            a[i] = a[i] / 2 ;
        }
    ++ans;
   }
   cout << ans <<"\n";
   return 0;
}

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

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

            if(a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17992
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
//using ll=long long;
const int MX = 2200000;
#define MAX 100000
#define INFTY 1<<30
#define WHITE 0
#define GRAY 1
#define BLACK 2

// 重み付き有向グラフの隣接リスト
vector<pair<int,int> > adj[MAX];

void dijkstra(int n,int start){
    priority_queue<pair<int,int> > pq;
    // weight[v]に始点sからvまでの最短コストを保存する.v,weight
    int weight[MAX];
    // 訪問状態を記録
    int color[MAX];
    // 1.初期化
    for(int i = 1;i <= n;++i){
        weight[i] = INFTY;
        color[i] = WHITE;
    }
    
    // 始点
    weight[start] = 0;
    color[start] = GRAY;
    pq.push(make_pair(0,start));
    // 2
    while(!pq.empty()){
        // 2.1最小である頂点の決定
        pair<int,int> first = pq.top();
        pq.pop();
        // 頂点
        int u = first.second;
        color[u] = BLACK;
        
        // 最短値を取りだして、最短でなければ飛ばす
        if(weight[u] < first.first * -1) continue;
        // uに隣接する頂点vが存在する限り最短店を更新する
        for(int i = 0;i < adj[u].size();++i){
            int v = adj[u][i].first;
            if(color[v] == BLACK)continue;
            // 2.2最短点の更新
            if(weight[v] > weight[u] + adj[u][i].second){
                weight[v] = weight[u] + adj[u][i].second;
                // priority_queueはデフォルトで大きい値を優先するので-にする
                pq.push(make_pair(weight[v] * -1, v));
                color[v] = GRAY;
            }
        }
    }
    
    // 出力までする.ノードの番号とスタート地点からのコスト
    for(int i = 1;i <= n;++i){
        if(weight[i]==INFTY) cout << "INF" << endl;
        else cout << weight[i] << endl;
    }
}

int main(){
    int w,e,r;cin >> w >> e >>r;r++;
    for (int i = 0; i < e; ++i)
    {
        int u,v,d;cin >> u >> v >> d;
        u++;v++;
        adj[u].push_back(make_pair(v,d));
    }

    dijkstra(w,r);
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int x, y;
    cin >> x >> y;
    vector<int> group = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if(group.at(x - 1) == group.at(y - 1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
P = 10 ** 9 + 7


def combination(n, r):
    if r == 0:
        return 1
    x = 1
    y = 1
    for i in range(n - r + 1, n + 1):
        x = (x * i % P)
    for i in range(1, r + 1):
        y = (y * i % P)
    y_inv = _power(y, P - 2)
    return (x * y_inv) % P


def _power(x, n):
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = (ans * x) % P
        x = (x * x) % P
        n = n >> 1
    return ans


for i in range(1, K + 1):
    if i - 1 <= N - K:
        print((combination(K - 1, i - 1) * combination(N - K + 1, i)) % P)
    else:
        print(0)


Measured memory_bytes: 74456
#include <stdio.h>

int main(void) {
  int a, b, divisor, dividend, remainder, result;
  while (scanf("%d %d", &a, &b) != EOF) {
    if (a > b) {
      dividend = a;
      divisor = b;
    }
    else {
      dividend = b;
      divisor = a;
    }	
    while (dividend % divisor != 0) {
      remainder = dividend % divisor;
      dividend = divisor;
      divisor = remainder;
    }
    result = divisor;
    printf("%d\n", result);
  }
  return(0);
}

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int a, b, k;

	cin >> a >> b >> k;

	int cnt = 0, ans;
	vector<int>list;

	for (int i = 1; i <=b; i++) {
		if (a%i == 0 && b%i == 0) {
			list.push_back(i);
			//cout << "i->" << i << endl;
			
		}
	}

	cout << list[list.size() - k] << endl;



	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 310;
const long long INF = 1LL<<50;

long long G[MAX][MAX];
using pll = pair<long long, long long>;

int main() {
    int N, M; long long L;
    cin >> N >> M >> L;
    
    for (int i = 0; i < MAX; ++i) {
        for (int j = 0; j < MAX; ++j) G[i][j] = INF;
        G[i][i] = 0;
    }
    for (int i = 0; i < M; ++i) {
        int a, b; long long c;
        cin >> a >> b >> c; --a, --b;
        G[a][b] = G[b][a] = c;
    }

    vector<vector<pll> > dist(N, vector<pll>(N, {INF, INF}));
    for (int s = 0; s < N; ++s) {
        dist[s][s] = {0, 0};
        priority_queue<pair<pll, int>,
                       vector<pair<pll, int> >,
                       greater<pair<pll, int> > > que;
        que.push(make_pair(pll(0, 0), s));
        while (!que.empty()) {
            auto p = que.top();
            que.pop();
            
            long long v = p.second;
            long long kaisuu = p.first.first;
            long long used = p.first.second;
            
            if (p.first > dist[s][v]) continue;
            for (int nv = 0; nv < N; ++nv) {
                if (nv == v) continue;
                if (G[v][nv] > L) continue;
                long long nused = used + G[v][nv];
                pll np = {0, 0};
                if (nused > L) np = {kaisuu + 1, G[v][nv]};
                else np = {kaisuu, nused};

                if (chmin(dist[s][nv], np)) que.push(make_pair(np, nv));
            }
        }
    }

    int Q; cin >> Q;
    while (Q--) {
        int a, b; cin >> a >> b; --a, --b;
        
        long long res = dist[a][b].first;
        if (res >= INF) cout << -1 << endl;
        else cout << res << endl;
    }
}

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

int main() {

    int N, i, j, count;

    cin >> N;
    count = N;

    vector<int> H(N);

    for(i=0;i<N;++i){

        cin >> H[i];
    }

    for(i=1;i<N;++i){

        for(j=0;j<i;++j){

            if(H[i] < H[j]){
                count--;
                break;
            }
        }

    }

    cout << count << endl;

}

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

int main() {
int a;
  string s;
  cin >> a >> s;
  if(a <3200)
    cout << "red" << endl;
  else
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
const int MAX_N = 60;
using namespace std;

typedef long long ll;
struct point {
  ll x, y, z;
};
typedef pair<point, point> P;

int main(void) {
  int N, K;
  vector<ll> x, y, z;
  cin >> N >> K;

  point p1, p2;
  vector<P> pair_points;
  for (int i = 0; i < N; i++) {
    cin >> p1.x >> p1.y >> p1.z
        >> p2.x >> p2.y >> p2.z;
    pair_points.push_back(P(p1, p2));

    x.push_back(p1.x);
    x.push_back(p2.x);
    y.push_back(p1.y);
    y.push_back(p2.y);
    z.push_back(p1.z);
    z.push_back(p2.z);
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  sort(z.begin(), z.end());
  map<ll, int> zipped_x, zipped_y, zipped_z;
  for (int i = 0; i < x.size(); i++) {
    zipped_x[x[i]] = i;
  }
  for (int i = 0; i < y.size(); i++) {
    zipped_y[y[i]] = i;
  }
  for (int i = 0; i < z.size(); i++) {
    zipped_z[z[i]] = i;
  }


  int ocean[MAX_N*2][MAX_N*2][MAX_N*2];
  for (int i = 0; i < MAX_N*2; i++) {
    for (int j = 0; j < MAX_N*2; j++) {
      for (int k = 0; k < MAX_N*2; k++) {
        ocean[i][j][k] = 0;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = zipped_x[pair_points[i].first.x]; j < zipped_x[pair_points[i].second.x]; j++) {
      for (int k = zipped_y[pair_points[i].first.y]; k < zipped_y[pair_points[i].second.y]; k++) {
        for (int l = zipped_z[pair_points[i].first.z]; l < zipped_z[pair_points[i].second.z]; l++) {
          ocean[j][k][l]++;
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < x.size()-1; i++) {
    for (int j = 0; j < y.size()-1; j++) {
      for (int k = 0; k < z.size()-1; k++) {
        if (ocean[i][j][k] >= K) {
          ans += (x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);
        }
      }
    }
  }

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

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  
  if(s.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	ABCD := nextInt()
	var A, B, C, D int
	A, ABCD = ABCD/1000, ABCD%1000
	B, ABCD = ABCD/100, ABCD%100
	C, ABCD = ABCD/10, ABCD%10
	D = ABCD

	fmt.Printf("%s\n", ABC079C(A, B, C, D))
}

// ABC079C ...
func ABC079C(A, B, C, D int) string {
	results := make([]int, 16)
	resStr := make([]string, 16)
	results[0], resStr[0] = A, strconv.Itoa(A)
	rest := []int{A, B, C, D}

	for d := 0; d < len(rest)-1; d++ {
		dl := int(math.Pow(2, float64(d))) - 1
		for j := 0; j <= dl; j++ {
			i, n := dl+j, rest[d+1]
			results[2*i+1], resStr[2*i+1] = results[i]+n, resStr[i]+"+"+strconv.Itoa(n)
			results[2*i+2], resStr[2*i+2] = results[i]-n, resStr[i]+"-"+strconv.Itoa(n)
		}
	}

	for i := 7; i < len(results); i++ {
		if results[i] == 7 {
			return resStr[i] + "=7"
		}
	}

	return "something wrong"
}


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

int main(){

    int n;
    int ans=0;
    cin>>n;
    vector<int> p(n);

    for(int i=0;i<n;i++) cin>>p[i];

    for(int i=1;i<n-1;i++){
        if(p[i]==p[i-1]+p[i]+p[i+1]-min({p[i-1],p[i],p[i+1]})-max({p[i-1],p[i],p[i+1]})) ans++;
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
// #define ll long long
const int MX = 1e6;
//const ll inf = 1e13;
// const int mod = 1e9+7;
using ll = long long;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
 }
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<mint> fac(MX);
vector<mint> ifac(MX);
mint comp(ll a, ll b) {
    return fac[a]/fac[b]/fac[a-b];
}
signed main() {
    int n,k;
    cin >> n >> k;
    fac[0]=1;
    FOR(i,1,MX) {
        fac[i]=fac[i-1]*i;
    }
    mint ans = 1;
    FOR(i,1,min(k+1,n)) {
        ans += comp(n,i)*comp(n-1,i);
    }
    cout << ans.x << endl;

    return 0;
}



Measured memory_bytes: 18692
N = int(input())
pre = None
is_inc = None
ans = 1
for num in list(map(int, input().split())):
    if pre is None:
        pre = num
        continue

    if is_inc is None and num > pre:
        is_inc = True
    elif is_inc is None and num < pre:
        is_inc = False
    elif (is_inc and num < pre) or (not is_inc and num > pre):
        ans += 1
        is_inc = None

    pre = num

print(ans)


Measured memory_bytes: 62832
#include <bits/stdc++.h>
#define REP0(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define ARRSET(name, i) memset(name, i, sizeof(name))
#define Cn2(i) ((i)*((i)-1)>>1)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
const ll INF = 9.22e18;
ll n;
ll arr[100005];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    REP1(i, n) {
        cin >> arr[i];
    }
    sort(arr+1, arr+1+n);
    ll cnt = 0;
    ll a, b = 1;
    while (b <= n) {
        a = b;
        while (b < n && arr[a] == arr[b+1]) b++;
        b++;
        cnt += (b-a)%2;
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn solve(n: i32, d: Vec<i32>) -> i32 {
    let uniq: HashSet<i32> = d.into_iter().collect();
    uniq.len() as i32
}

fn main() {
    input!{
        n: i32,
        d: [i32; n]
    }
    println!("{}", solve(n, d))
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;

int g[300][300];
int gg[300][300];

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> g[i][j];
      gg[i][j] = 1.01e9;
    }
    gg[i][i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int mn = 2e9;
      for (int k = 0; k < n; k++) {
        mn = min(mn, g[i][k] + g[k][j]);
      }
      if (mn != g[i][j]) {
        puts("-1");
        return 0;
      }
    }
  }

  vector<tuple<int, int, int>> es;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      es.emplace_back(g[i][j], i, j);
    }
  }

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

  long long ans = 0;
  for (auto e : es) {
    int w, u, v;
    tie(w, u, v) = e;

    if (gg[u][v] != w) {
      gg[u][v] = w;
      gg[v][u] = w;

      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          gg[i][j] = min(gg[i][j], gg[i][u] + gg[u][v] + gg[v][j]);
          gg[i][j] = min(gg[i][j], gg[i][v] + gg[v][u] + gg[u][j]);
        }
      }
      ans += w;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    cout<<(n-2)*180<<endl;
    return 0;
}


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


void solve(long long N, std::vector<long long> p){
    ll i=0, cnt = 0;
    while(i< N){
        if(p[i]== i+1) {
            cnt ++;
            i+=2;
        }
        else{
            i++;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    map<int,ll> cnt;
    ll ans = 0;
    RREP(i, n) {
        ans += cnt[a[i] + i];
        cnt[i - a[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 26668
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    
    while t:
        if n>K:
            t=False
            print('-1')
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Measured memory_bytes: 63136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s, t; cin >> s >> t;
    s += t[t.size()-1];
    if (s==t) Yes();
    else No();
}


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

int main(void){
  int n;
  string s;
  cin >> n >> s;
  int n_b = 0;
  int n_all_b = 0;
  for( int i=0; i<n; ++i){
    if( s[i] == '#') n_all_b++;
  }
  int  ans = n - n_all_b;
  for( int i=0; i<n; ++i){
    if( s[i] == '#') n_b++;
    ans = min(n_b + ( (n - (i+1)) - (n_all_b - n_b) ), ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int abs(long long a) {
    if (a < 0) {
        a = -(a);
    }
    return a;
}

int chmin(long long *a, long long b) {
    if (*a > b) {
        *a = b;
        return 1;
    }
    return 0;
}

const long long INF = 1LL << 60;

// https://qiita.com/drken/items/dc53c683d6de8aeacf5a
// に沿って実装
int main() {

    int num;
    scanf("%d", &num);

    long long scaffolds[num];
    for (int i = 0; i < num; i++) {
        scanf("%lld", &scaffolds[i]);
    }

    long long costs[num];
    for (int i = 0; i < num; i++) {
        costs[i] = INF;
    }

    costs[0] = 0;
    costs[1] = abs(scaffolds[1] - scaffolds[0]);
    for (int i = 2; i < num; i++) {
        chmin(&costs[i], costs[i-1] + abs(scaffolds[i] - scaffolds[i-1]));
        chmin(&costs[i], costs[i-2] + abs(scaffolds[i] - scaffolds[i-2]));
    }

    printf("%lld\n", costs[num-1]);

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>



int main()
{
	double num ;


	while( scanf( "%lf" ,&num ) )
	{
		if( num < 0 )
		{
			return 0 ;
		}



		num *= ( 1 << 4 ) ;


		int n = num ;


		if( n >= ( 1 << 12 ) || num - ( double )n != 0 )
		{
			puts( "NA" ) ;
		}

		else
		{
			int i ;
			for( i = 12 ; i > 0 ; --i )
			{
				if( i == 4 )
				{
					printf( "." ) ;
				}


				printf( "%d" ,n >> i - 1 & 1 ) ;
			}


			puts( "" ) ;
		}
	}
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n) cin >> s.at(i);
  
  int ans=0;
  rep(i,n) {
    for(int j = i+1; j < n; j++) {
      if(s.at(i) > s.at(j)){
        int a = s.at(i);
        s.at(i) = s.at(j);
        s.at(j) = a;
      }
    }
  }
  rep(i,n) {
    ans = s.at(i) - ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

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

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }

  for (int i = 0; i < N-1; i++) {
    if(vec.at(i) == vec.at(i+1)){
      ans++;
      i++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var startPoint = new List<Vector2>();

            for (int i = 0; i < nm[0]; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                startPoint.Add(new Vector2(ab[0], ab[1]));
            }

            var destinationPoint = new List<Vector2>();

            for (int i = 0; i < nm[1]; i++)
            {
                var cd = Console.ReadLine().Split().Select(int.Parse).ToArray();
                destinationPoint.Add(new Vector2(cd[0], cd[1]));
            }

            foreach(var item in startPoint)
            {
                float dist = float.MaxValue;
                int nearestPointIndex =0;
                
                int index = 0;
                foreach(var dest in destinationPoint)
                {
                    var currentDist = ManhattanDist(item,dest);
                    
                    if(dist>currentDist)
                    {
                        dist = currentDist;
                        nearestPointIndex = index;
                    }
                    index++;
                }

                Console.WriteLine(nearestPointIndex+1);
            }



        }


        static float ManhattanDist(Vector2 a, Vector2 b)
        {
            return (Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y));
        }
    }
}


Measured memory_bytes: 13396
N, M = map(int, input().split())
S = []
for i in range(M):
  k, *s = list(map(int, input().split()))
  S.append(s)

P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  if all([
    sum([i & 2 ** (n-1) > 0 for n in S[m]]) % 2 == P[m] for m in range(M)
  ]):
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int y, m, d;
	char c;
	cin >> y >> c >> m >> d;
	if (m <= 4) {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  ll n,k;
  cin>>n>>k;
  ll a=1,b=k;
  ll cnt=1;
  while(1){
    if(a<=n&&n<b){
      cout<<cnt<<endl;
      return(0);
    }
    a*=k;
    b*=k;
    cnt++;
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1e9 + 7;

int memo[2001];
int go(int sum) {
   if (sum == 0)
      return 1;
   int& res = memo[sum];
   if (res < 0) {
      res = 0;
      for (int a = 3; a <= sum; ++a) {
         res += go(sum - a);
         if (res >= MOD)
            res -= MOD;
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int S;
   cin >> S;

   memset(memo, -1, sizeof(memo));
   int res = go(S);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3644