akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  char C;
  cin >> C;

  printf("%c\n", ++C);

  return 0;
}


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

using lli = long long int;

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;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
#define MAX_N 100000

lli n;
vector<vector<pair<lli, lli>>> node(MAX_N);
vector<bool> seen(MAX_N);
vector<lli> res(MAX_N);

void dfs(lli k, int c){
    if(seen[k]) return;
    res[k] = c;
    seen[k] = true;
    for(auto i : node[k]){
        if(i.second%2 == 0) dfs(i.first, c);
        else dfs(i.first, 1-c);
    }

    return;
}

int main(void){
    cin >> n;
    rep(i, n-1){
        lli u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        node[u].push_back(make_pair(v, w));
        node[v].push_back(make_pair(u, w));
    }
    dfs(0LL, 0);
    rep(i, n){
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
vector<ll> v,A,B;
int N,M;
int main(){
  cin>>N>>M;
  vector<bool> h(N,0);
  h[0] = 1;
  v.resize(N,1);
  rep(i,0,M){
    int x,y;  cin>>x>>y;
    --x;  --y;
    if(h[x]==1 && v[x]>0) h[y]=1;
    v[x]--;
    v[y]++;
    if(v[x]==0) h[x]=0;
  }
  int cnt=0;
  rep(i,0,N){
    if(h[i]){
      if(v[i]>0) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    string s;
    int sum = 700;

    cin >> s;

    if(s[0] == 'o'){
        sum += 100;
    }

    if(s[1] == 'o'){
        sum += 100;
    }

    if(s[2] == 'o'){
        sum += 100;
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	bool B[N][N];
rep(i,N)rep(j,N)B[i][j]= 0;
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		B[a][b] = true;
		B[b][a] = true;
	}

	vector<int> G[N];
	rep(i,N){
		repi(j,i+1,N){
			if(!B[i][j]){
				G[i].emplace_back(j);
				G[j].emplace_back(i);
			}
		}
	}

	queue<int> Q;
	vector<int> C(N);

	rep(i, N){
		if(C[i])continue;
		C[i] = i + 1;
		Q.emplace(i);
		while(Q.size()){
			int u = Q.front(); Q.pop();

			for(int v: G[u]){
				if(C[v] == C[u]){
					cout << -1  << endl;
					return 0;
				}
				if(C[v] == 0){
 					C[v] = -C[u];
                    Q.emplace(v);
				}			
			}
		}
	}
	vector<int> P(N + 1);
	vector<int> W(N + 1);
	rep(i, N){
		if(C[i] < 0)P[-C[i]]++;
		else W[C[i]]++;
	}

	vector<bool> dp(N + 1);
	
	dp[0] = true;
	rep(i, N + 1){
		vector<bool> next(N + 1);
		rep(j, N + 1){
			if(dp[j]){
				next[j + P[i]] = true;
				next[j + W[i]] = true;
			} 
		}
		dp = next;
	}

	int ans = INT_MAX;
	rep(i, N + 1){
		if(dp[i]){
			int t = i;
			int s = N - i;
			ans = min(ans, t * (t - 1) / 2 + s * (s - 1) / 2);
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

typedef unsigned long long ull;
const ull B = 100000007; //???????????\?????°

//a???b???????????????????????????
bool contain(string a,string b){
  int al = a.length(), bl = b.length();
  if(al > bl) return false;
  
  //B???al???????¨????
  ull t = 1;
  for(int i=0; i< al ;i++) t *= B;
  
  //a??¨b????????????al???????????¢?????????????????\???????¨????
  ull ah = 0, bh = 0;
  for(int i=0; i<al ;i++) ah = ah * B + a[i];
  for(int i=0; i<al ;i++) bh = bh * B + b[i];
  
  //b?????´??????1???????????????????????????????????\???????????§??????
  for(int i=0; i+al<=bl; i++){
    if(ah == bh) cout<<i<<endl;
    if(i+al < bl) bh = bh * B + b[i+al] - b[i] * t;
  }
  return false;
}


int main(){
  string a,b;
  cin>>a>>b;
  contain(b,a);  
  
}

Measured memory_bytes: 4936
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var S = Console.ReadLine();
    var D=S.Distinct();
    if(D.Count()==2&&S.Count(n=>n==D.ToList()[0])==2){
        Console.WriteLine("Yes");
    }
    else{
        Console.WriteLine("No");
    }
    }
}

Measured memory_bytes: 13268
#include<iostream>

using namespace std;

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

    if(s.substr(2,1) == s.substr(3,1))
    {
        if (s.substr(4, 1) == s.substr(5, 1))
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else
    {
        cout<<"No";
    }
    
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	long long n, i, j, k, s, MOD = 1000000007, ans = 0;
	cin >> n;
	vector<long long> a(n);
	s = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		ans = (ans + s * a[i]) % MOD;
		s = (s + a[i]) % MOD;
	}
	cout << ans << "\n";


	return 0;
}



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

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

  int N;
  cin >> N;
  
  vector<int> d(N);

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

  int idx, ans, x, y;
  idx = 1;
  ans = 0;
  for (int i = 0; i < (N - 1); i++) {
    x = d.at(i);

    for (int j = idx; j < N; j++) {
      y = d.at(j);
      ans += x * y;
    }

    idx++;
  }
 
  cout << ans << endl;
}


Measured memory_bytes: 256
program step
    implicit none
    integer(8) n, i
    integer(8) :: dai = 0
    integer,allocatable :: a(:)
    read *, n
    allocate(a(n))
    read *, a(:n)
    do i = 2, n
        if(a(i) .lt. a(i-1))then
            dai = dai+(a(i-1)-a(i))
            a(i) = a(i) + (a(i-1)-a(i))
        end if
    end do
    print *, dai
end program

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

#define NMAX 100100
#define INF 2000000000

#define MOD 1000000007

typedef unsigned long long ull;

using namespace std;

int players;
int k;
int answers;

int scores[NMAX];

int main()
{
    cin >> players >> k >> answers;

    for(int i = 0; i < players; i++)
        scores[i] = k - answers;

    for(int i = 0; i < answers; i++)
    {
        int aux;
        cin >> aux;
        aux--;

        scores[aux]++;
    }

    for(int i = 0; i < players; i++)
        cout << (scores[i] > 0 ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

//int masu(int h,int w);
//typedef long long 11;

int main(void){
  long long int h,w;
  scanf("%lld %lld",&h,&w);
  if(h==1||w==1){
    printf("1\n");
  }else{
    printf("%lld\n", (h*w+1)/2);
  }
  
  
  
  //printf("%d\n", ans);
  return 0;
}
/*
int masu(int h, int w){
  int sum=0;
  if(h>w){
    for(int i=0;i<h;i++){
      sum += 2*i+1;
    }
    sum *= w/h;
  }
  else{
    for(int i=0;i<w;i++){
      sum+= 2*i+1;
    }
    sum *= h/w;
  }
  return sum;
}
*/
    

Measured memory_bytes: 1728
def b():
  from math import ceil
  S = input()
  s1,s2 = S[:ceil(len(S) / 2)],S[len(S) // 2:][::-1]
  ans = 0
  for i in range(len(S) // 2):
    ans += int(s1[i] != s2[i])
  print(ans)
b()

Measured memory_bytes: 3060
#include<stdio.h>
int isprime(int m){
	int k;
	for(k=2;k*k <= m;k++){
		if(m%k==0)return 0;
	}
	return 1;
}	
int main(){
	const int max=1000000;
	int sum[max];
	int i, n;
	for(i=2;i<=max;i++){
		if(isprime(i)){
			sum[i+1]=sum[i]+1;
		}else{
			sum[i+1]=sum[i];
		}
	}	
	while(scanf("%d",&n) != EOF){
		printf("%d\n",sum[n+1]);
	}
	return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  vi a(N);
  REP(i, N) cin >> a[i];
  int tmp = 1, ans = 0;
  for (auto x : a) {
    if (x != tmp) {
      ans++;
    } else {
      tmp++;
    }
  }
  if (ans == N) {
    cout << -1 << endl;
    return 0;
  } else {
    cout << ans << endl;
    return 0;
  }
}

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

int main()
{
	int data[10];
	for (int i = 0; i < 10; ++i) {
		cin >> data[i];
	}
	int max[3] = { 0 };
	int n = 0, i = 0, temp;
	while (n < 3) {
		if (max[n] < data[i]) {
			max[n] = data[i];
			temp = i;
		}
		++i;
		if (i == 10) {
			data[temp] = 0;
			++n;
			i = 0;
		}
	}

	cout << max[0] << endl << max[1] << endl << max[2] << endl;
	
	return 0;
}

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

bool comp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b){
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        if(a.second.first != a.second.first){
            return a.second.first < b.second.second;
        }else{
            return a.second.second < b.second.second;
        }
    }
}

int main(){
    ll N, M; cin >> N >> M;
    vector<vector<ll>> P(8, vector<ll>(N)) ;

    rep(i,N){
        ll x, y, z;
        cin >> x >> y >> z;
        rep(j,1 << 3){
            ll t[3] = {x, y, z};
            rep(k, 3){
                if(j & 1 << k){
                    t[k] *= -1;
                }
            }
            P[j][i] = t[0] + t[1] + t[2];
        }
    }

    rep(i, 8){
        sort(P[i].begin(), P[i].end(), greater<ll>());
    }

    ll SUM[8] = {0};
    rep(i, 8){
        SUM[i] = 0;
        rep(j, M) SUM[i] += P[i][j];
    }
    cout << *max_element(SUM, SUM + 8) << endl;
}

Measured memory_bytes: 256
n = int(input())
hashtable = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(n):
    create = input()
    if create in hashtable:
        hashtable[create] += 1
for i in hashtable.keys():
    print(i, end=" x ")
    print(hashtable.get(i))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  REP(i, n) {
    ll h;
    cin >> h;
    v.pb(h);
  }
  ll cnt = 0, ans = 0;
  REP(i, n) {
    if (!i) {
      continue;
    }
    if (v[i - 1] == v[i]) {
      cnt++;
    } else {
      ans += (cnt + 1) / 2;
      cnt = 0;
    }
  }
  ans += (cnt + 1) / 2;
  cout << ans << endl;
}


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

namespace Online_Judge_Problems.Codeforces
{
    public class Solution
    {
		static void Main(string[] args)
        {
            Solution problem = new Solution();
            problem.Solve();
        }
		
		public void Solve()
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[2 * N];

            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < 2* N; i++)
            {
                A[i] = int.Parse(input[i]);
            }

            Array.Sort(A);
            int answer = 0;
            for (int i = 0; i < 2 * N; i += 2)
            {
                answer += Math.Min(A[i], A[i + 1]);
            }

            Console.WriteLine(answer);
        }
    }
}


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

struct node{
    int parent,left,right;
}nodes[25];

int n,tag[25];

void pre(int r){
    cout<<" "<<r;
    if(nodes[r].left!=-1)pre(nodes[r].left);
    if(nodes[r].right!=-1)pre(nodes[r].right);
}

void in(int r){
    if(nodes[r].left!=-1)in(nodes[r].left);
    cout<<" "<<r;
    if(nodes[r].right!=-1)in(nodes[r].right);
}

void post(int r){
    if(nodes[r].left!=-1)post(nodes[r].left);
    if(nodes[r].right!=-1)post(nodes[r].right);
    cout<<" "<<r;
}

int main()
{
    cin>>n;
    int i,r;
    for(i=0;i<n;i++){nodes[i].parent=-1;}
    for(i=0;i<n;i++){
        int ii,l,r;
        cin>>ii>>l>>r;
        nodes[ii].left=l;
        nodes[ii].right=r;
        if(l!=-1)nodes[l].parent=ii;
        if(r!=-1)nodes[r].parent=ii;
    }
    for(i=0;i<n;i++){
        if(nodes[i].parent==-1)r=i;
    }
    cout<<"Preorder"<<endl;pre(r);cout<<endl;
    cout<<"Inorder"<<endl;in(r);cout<<endl;
    cout<<"Postorder"<<endl;post(r);cout<<endl;
    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main(void) {
	char s[100],t[100],c[100],a[100],b[100];
	scanf("%s", s);
	scanf("%s", t);
	int n,i,k,l,ans,p,q;
	n = 0;
	for (i = 0; s[i] != '\0'; i++) {
		n++;
	}
	for (i = 0; i <= n - 1; i++) {
		a[i] = s[i];
		b[i] = t[i];
	}

	ans = 1;
		for (k = 0; k <= n - 1; k++) {
			for (l = 0; l <= n - 1; l++) {
				if (l+k<=n-1) c[l] = a[l + k];
				else c[l] = a[l + k - n ];
			}
			
			p = 0;
			for (i = 0; i <= n - 1; i++) {
				if (c[i] ==b[i]) p++;
				else;
			}
			
			if (p == n)q = 0;
			else q = 1;
			
			ans = ans * q;
		
		}

		if (ans == 0) printf("Yes");
		else printf("No");





	return 0;
}

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

int main(void) {
  int N;
  long long int ans=0;
  cin >> N;

  //vector<int> A(N),B(N),C(N);
  long long int A[N],B[N],C[N];

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

  sort(A,A+N);
  sort(B,B+N);
  sort(C,C+N);


/*
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
*/

  long long int tmp1,tmp2;
  for(int i=0; i<N; i++){
    auto Iter1 = lower_bound(A,A+N,B[i]);
    auto Iter2 = upper_bound(C,C+N,B[i]);
    tmp1 = Iter1 - A;
    tmp2 = C+N - Iter2;
    ans += tmp1*tmp2;

  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

#define max(a,b) ((a)>(b))?(a):(b);
#define min(a,b) ((a)>(b))?(b):(a);

int main(void)
{
	int k, x;
	scanf("%d%d", &k, &x);
	printf(k * 500 >= x ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
#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>

#include <atcoder/all>
using namespace atcoder;

using namespace std;

long long n;
vector<long long> BIT(500050);
void add(long long i, long long x) {
	while (i <= n) {
		BIT[i] += x;
		i += i & -i;
	}
}
long long csum(long long i) {
	long long count = 0;
	while (i > 0) {
		count += BIT[i];
		i -= i & -i;
	}
	return count;
}
long long sum(long long l, long long r) {
	return csum(r) - csum(l - 1);
}
int main() {
	int q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
		long long a;
		cin >> a;
		add(i, a);
    }
	for (int i = 0; i < q; i++) {
		int b, l, r;
		cin >> b >> l >> r;
		if (b == 0) {
			add(l + 1, r);
		}
		else {
			cout << sum(l + 1, r) << endl;
		}
	}
    return 0;
}


Measured memory_bytes: 8204
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long A = long.Parse(Console.ReadLine());
		int ct = 0;
		while(true){
          	ct++;
			if(A==1){
              ct++;
				break;
			} else if(A%2==1){
				A = A * 3 + 1;
			} else {
				A /= 2;
			}
		}
		Console.WriteLine(Math.Max(4,ct));
	}
}

Measured memory_bytes: 13140
module ABC133

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calc_distance
  private :: is_GoodDistance

  ! variables for this <module>
  integer(INT32) :: num_point_all
  integer(INT32) :: num_point_GD
  integer(INT32) :: val_dimension

  ! arrays for this <module>
  real(REAL64), dimension(:,:), allocatable :: coordinate

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! support variables for this <subroutine>
    integer(INT32) :: itr
    integer(INT32) :: itr_orign, itr_target

    ! STEP.01
    ! read out the given data (1/2)
    read(unit=INPUT_UNIT, fmt=*) num_point_all, val_dimension

    ! STEP.02
    ! allocate the array to store the data of the points
    allocate( coordinate(1:val_dimension, 1:num_point_all) )

    ! STEP.03
    ! read out the given data (1/2)
    do itr = 1, num_point_all, 1
      read(unit=INPUT_UNIT, fmt=*) coordinate(:, itr)
    end do

    ! STEP.04
    ! calculate the answer of this task
    num_point_GD = 0_INT32

    do itr_orign  = 1,             num_point_all, 1
    do itr_target = itr_orign + 1, num_point_all, 1

      if ( is_GoodDistance( calc_distance( coordinate(:, itr_orign), coordinate(:, itr_target) ) ) ) then
        num_point_GD = num_point_GD + 1_INT32
      else
        continue
      end if

    end do
    end do

    ! STEP.05
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') num_point_GD

    ! STEP.06
    ! deallocate the array to store the data of the points
    deallocate( coordinate )

    ! STEP.END
    return

  end subroutine task_B

  pure function calc_distance (coordinate_orign, coordinate_target) result(distance)

    ! arguments for this <function>
    real(REAL64), dimension(1:val_dimension), intent(in) :: coordinate_orign
    real(REAL64), dimension(1:val_dimension), intent(in) :: coordinate_target

    ! return value of this <function>
    real(REAL64) :: distance

    ! support variables for this <function>
    real(REAL64)   :: displacement
    integer(INT32) :: itr

    distance = 0.0e+000_REAL64

    do itr = 1, val_dimension, 1
      displacement = coordinate_target(itr) - coordinate_orign(itr)
      distance     = distance + displacement * displacement
    end do

    distance = sqrt(distance)

    return

  end function calc_distance

  pure function is_GoodDistance (val_distance) result(stat)

    ! arguments for this <function>
    real(REAL64), intent(in) :: val_distance

    ! return value of this <function>
    logical :: stat

    stat = (val_distance - aint(val_distance)) .eq. 0.0e+000_REAL64
    return

  end function is_GoodDistance

end module ABC133


program main

  ! <module>s to import
  use, non_intrinsic :: ABC133

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    
    vector<pair<int, int>> p;
    for (int i = 1; i <= N / 2; i++) {
        p.push_back({i, N - i + (N % 2 == 0)});
    }

    vector<pair<int, int>> ans;
    REP(i, 0, p.size() - 1) {
        ans.push_back({p[i].first, p[i + 1].first});
        ans.push_back({p[i].first, p[i + 1].second});
        ans.push_back({p[i].second, p[i + 1].first});
        ans.push_back({p[i].second, p[i + 1].second});
    }

    if (N % 2 == 1) {
        ans.push_back({p[0].first, N});
        ans.push_back({p[0].second, N});
        if (p.size() > 1) {
            ans.push_back({p.back().first, N});
            ans.push_back({p.back().second, N});
        }
    } else {
        if (p.size() > 2) {
            ans.push_back({p[0].first, p.back().first});
            ans.push_back({p[0].first, p.back().second});
            ans.push_back({p[0].second, p.back().first});
            ans.push_back({p[0].second, p.back().second});
        }
    }

    cout << ans.size() << endl;
    for (auto a : ans) cout << a.first << " " << a.second << endl;
    return 0;
}

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

int main(){
   int n,c,k;cin>>n>>c>>k;
   vector<int> t(n);
   for(int i=0;i<n;i++) cin>>t[i];
   int cnt=0;
   //double depart;
   //sort
   sort(t.begin(),t.end());
   //for(int x:t) cout<<x;
   int cur=0;

   while(cur<n){
       int p=t[cur]+k;
       int num=1;
       for(;cur+num<n&&p>=t[cur+num]&&num<c;num++);
       //printf("num=%d\n",num);
       cur+=num;
       cnt++;
       //cout << "cur="<<cur<<endl;
   }
   cout << cnt << endl;
   
}


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

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

    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 1; i <= N; ++i) {
        cin >> A.at(i);
    }

    vector<int> used(N + 1, 0);
    int pnt = 1;
    int cnt = 0;
    while (true) {
        cnt++;
        if (used.at(A.at(pnt))) {
            cout << -1 << endl;
            break;
        }
        if (A.at(pnt) == 2) {
            cout << cnt << endl;
            break;
        }
        used.at(pnt) = 1;
        pnt = A.at(pnt);
    }

    return 0;
}

Measured memory_bytes: 1024
#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)
#define chmin(x, y) x = min(x, y)

const int mod = 1000000007;
struct mint
{
    ll x;
    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
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= 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
    {
        mint res(*this);
        return res /= a;
    }
};
int n,k;
int solve(){
    mint ans=0;
    for(int i=k;i<=n+1;i++){
        mint l= mint(i)*(i-1)/2;
        mint r=mint(i)*(2*n+1-i)/2;
        ans+=r-l+1;
    }
   return ans.x;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>k;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    bool flg = true;
    rep(i, N) {
        if (a[i] % 2 == 1) {
            flg = false;
            break;
        }
    }

    if (flg) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }

    return 0;
}


Measured memory_bytes: 4036
using System;

namespace Five
{
    class Program
    {
        static void Main(string[] args)
        {
            string inD0 = Console.ReadLine();
            string[] cngD0 = inD0.Split(' ');

            for (int i = 0; i <= 4; i++)
            {
                if (cngD0[i] == "0")
                {
                    int j = i + 1;
                    Console.WriteLine(j);

                }
            }

        }
    }
}


Measured memory_bytes: 25760
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){
    scanf("%d %d",&n,&k);
    if(n==0 && k==0)break;

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=(i==j?0:INF);

    for(i=0;i<k;i++){
      
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }
    }
  }
  return 0;
}

void warshall_floyd(void){
  int i,j;
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
    }
  }
}

int min(int x,int y){
  return (x<y)?x:y;
}

Measured memory_bytes: 0
candy = gets.split.map(&:to_i)
combinations = candy.combination(2).to_a
combinations.each do |c|
  sum = c[0] + c[1]
  @output = "No"
  if sum == candy[0] || sum == candy[1] || sum == candy[2]
    @output = "Yes"
    break
  end
end
puts @output

Measured memory_bytes: 1788
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_a
import std.algorithm;
import std.math;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    const int n = readln.chomp.to!int;
    const int[] h = readln.split.map!(to!int).array;

    int[] dp = new int[n];

    dp[1] = abs(h[1]-h[0]);

    for(int i = 2; i < n; ++i)
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));

    dp[$-1].writeln;
}


Measured memory_bytes: 4468
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){

  int a,b,c;
  while(cin>>a>>b>>c){
    double sum=0;
    sum+=a/2.0*sqrt(b*b-a*a/4.0);
    sum+=(double)b*sqrt((b+c)*(b+c)/4.0-b*b/4.0);
    
    
    printf("%.20f\n",sum);
  }

}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int N;
vector<long> p(1001,1);
int main(){
    cin >> N;
    long long ans=1,bikkuri=1;
    int i,j,k;
    for(i=2;i<=N;i++){
        int n=i;
        for(j=2;j<=i;j++){
            while(n%j==0){
                p[j]++;
                n=n/j;
            }
        }
    }
    for(i=0;i<=N;i++) {
        ans =ans*p[i]%(1000000000+7);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;





int main()
{
int n ;
cin>>n;
map<int,int> v;
while(n--)
{
    int a ;
    cin>>a;

    if(!v[a])
        v[a]++;
    else
        v[a]--;
    }


int ans =0;
for(auto it = v.begin();it!=v.end();it++)
{
    //cout<<it->first<< " "<<it->second<<endl;
    if(it->second)
    ans++;
}


    cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 8280
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
 
/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */
 
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

signed main() {
  int n;cin >> n;
  vi rui(n+1);
  rui[0]=0;
  rep1(i, n) {
	  int a;cin >> a;
	  rui[i]+=a+rui[i-1];
  }
  int mi = INF;
  for(int i =1;i<n;i++) {
	  chmin(mi,abs(rui[n]-rui[i]*2));
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B;
	string str1,str2,str3;
	cin >> str1 >> str2;
	cin >> A >>  B;
	cin >> str3;
	if(str3==str1)
		cout << A-1 <<" "<<B << endl;
	else
		cout << A << " "<< B-1 << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC154E
#include <iostream>
#include<vector>
#include<string>
#include<stdio.h>
using namespace std;
int main(int argc, const char * argv[]) {
    string S;
    cin >>S;
    int K;
    cin >> K;
    unsigned long length=S.length(); // 入力された数値の桁数
    vector<vector<int>>dp1(length+1,vector<int>(4));
    vector<vector<int>>dp0(length+1,vector<int>(4));
    // 初期値
    dp1.at(0).at(0)=0;
    dp1.at(0).at(1)=0;
    dp1.at(0).at(2)=0;
    dp1.at(0).at(3)=0;
    dp0.at(0).at(0)=1;
    dp0.at(0).at(1)=0;
    dp0.at(0).at(2)=0;
    dp0.at(0).at(3)=0;
    
    dp0.at(1).at(0)=1; // 入力した数値の右端は必ず０ではない数字
    
    vector<int>n(length+1);
    n.at(0)=0;
    for (int i=1; i<=length; i++) {
        n.at(i) =S[i-1]-'0'; // 各桁の数値をnにセット
    }
    int r1; // 繰り返しの数
    int r2;
    for (int i=1; i<=length; i++) {
        if(n.at(i)>0){
            r1=n.at(i)-1;
            r2=1;
        }else{
            r1=0;
            r2=0;
        }
        dp1.at(i).at(0)=1;
        dp1.at(i).at(1)=dp1.at(i-1).at(0)*9+dp1.at(i-1).at(1)+dp0.at(i-1).at(0)*r1+dp0.at(i-1).at(1)*r2;
        dp1.at(i).at(2)=dp1.at(i-1).at(1)*9+dp1.at(i-1).at(2)+dp0.at(i-1).at(1)*r1+dp0.at(i-1).at(2)*r2;
        dp1.at(i).at(3)=dp1.at(i-1).at(2)*9+dp1.at(i-1).at(3)+dp0.at(i-1).at(2)*r1+dp0.at(i-1).at(3)*r2;

        if(n.at(i)==0){
            dp0.at(i).at(1)=dp0.at(i-1).at(1);
        } else{
            dp0.at(i).at(1)=dp0.at(i-1).at(0);
            dp0.at(i).at(0)=0;
        }
        if(n.at(i)==0){
            dp0.at(i).at(2)=dp0.at(i-1).at(2);
        }else{
            dp0.at(i).at(2)=dp0.at(i-1).at(1);
        }
        if (n.at(i)==0) {
            dp0.at(i).at(3)=dp0.at(i-1).at(3);
        }else{
            dp0.at(i).at(3)=dp0.at(i-1).at(2);
        }
    }
    int ans=dp1.at(length).at(K)+dp0.at(length).at(K);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
 
 
signed main(){
  int L;
  int n;
  cin>>L;
  cin>>n;

  vector<int> num(L+L+10);
  int ofset = L+5;
  for(int i=0;i<n;i++){
    int x,w;
    cin>>x>>w;
    num[x+ofset]+=w; 
  }

  int l = num.size();
  vector<P> ans;
  for(int i=0;i<(int)num.size();i++){
    int a = ofset - i;
    int b = ofset + i;
    if(ofset - i < 0 || ofset + i >=l) continue;
    if(num[a] == num[b]) continue;
    if(num[a] < num[b]) ans.push_back(P(a-ofset,num[b]-num[a]));
    else ans.push_back(P(b-ofset,num[a]-num[b]));
  }

  cout<<ans.size()<<endl;
  for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
   
  return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    long n,p;
    cin >> n >> p;
    int c = 2;
    long t = static_cast<long>(pow(c, n));
    long r = 1;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    else if(n >= 40){
        cout << 1 << endl;
        return 0;
    }
    while (t <= p) {
        if(p % t == 0){
            r = c;
        }
        ++c;
        t = static_cast<long>(pow(c, n));
    }
    cout << r << endl;
}


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

#define MAX 1000
int lcs(string x, string y){
    //最長共通部分列問題
    int dp[MAX+1][MAX+1];
    int ret = 0;
    int n = x.size();
    int m = y.size();
    x = ' ' + x; //x[0]をつくる
    y = ' ' + y; //y[0]をつくる

    rep(i, n) dp[i][0] = 0;
    rep(j, m) dp[0][j] = 0;
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(x[i] == y[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
            ret = max(ret, dp[i][j]);
        }
    }
    return ret;
}

int main() {

    int n;
    cin >> n;

    rep(i, n){
        string s1, s2;
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }

    return 0;
}


Measured memory_bytes: 7116
N = int(input())
s = str(N)
count = 0

if len(s) == 1:
    count = N
elif len(s) == 2:
    count = 9
elif len(s) == 3:
    count = N - 90
elif len(s) == 4:
    count = 909
elif len(s) == 5:
    count = N - 9090
elif len(s) == 6:
    count = 90909
print(count)

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

int main()
{
    int N, C; cin >> N >> C;
    vector<tuple<int, int, int>> CST(N);
    for (auto& e : CST) cin >> get<1>(e) >> get<2>(e) >> get<0>(e);

    sort(CST.begin(), CST.end());
    vector<int> imos(2 * 1E5 + 1, 0);
    for (int i = 0; i < N; i++) {
        if (i != 0 && get<0>(CST[i]) == get<0>(CST[i-1])
            && get<1>(CST[i]) == get<2>(CST[i-1])) {
            imos[get<1>(CST[i])*2] += 1;
        } else {
            imos[get<1>(CST[i])*2-1] += 1;
        }
        imos[get<2>(CST[i])*2] -= 1;
    }
    partial_sum(imos.begin(), imos.end(), imos.begin());
    cout << *max_element(imos.begin(), imos.end()) << endl;
}

Measured memory_bytes: 2304
n=int(input())
card_have=[input().split() for i in range(n)]

nums={1,2,3,4,5,6,7,8,9,10,11,12,13}

s_have={int(s[1]) for s in card_have if s[0]=="S"}
h_have={int(h[1]) for h in card_have if h[0]=="H"}
c_have={int(c[1]) for c in card_have if c[0]=="C"}
d_have={int(d[1]) for d in card_have if d[0]=="D"}

s_lost=list(nums^s_have)
h_lost=list(nums^h_have)
c_lost=list(nums^c_have)
d_lost=list(nums^d_have)

s_lost.sort()
h_lost.sort()
c_lost.sort()
d_lost.sort()

for s in s_lost:
    print("S",s)
for h in h_lost:
    print("H",h)
for c in c_lost:
    print("C",c)
for d in d_lost:
    print("D",d)

Measured memory_bytes: 7772
#include<iostream>

using namespace std;

int main(void)
{
	int a,b;
	cin >> a >> b;
	a=(a==2 ? 2:(a==4||a==6||a==9||a==11 ? 4:1));
	b=(b==2 ? 2:(b==4||b==6||b==9||b==11 ? 4:1));

	cout << (a==b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int K = sc.nextInt();
	if(K <= A){
      System.out.print(K);
    }else if( K <= A+B){
      System.out.print(A);
    }else{
      System.out.print(A-(K-A-B));
    }
  }
}


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

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n, k, d; cin >> n >> k >> d;
	n = abs(n);
	long long p = n / d;
	if (k <= p) cout << n - k * d << '\n';
	else if (k % 2 == p % 2) cout << n % d << '\n';
	else cout << d - n % d << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 != 0) {
      cout << 0 << endl;
      return 0;
    }
    A[i] /= 2;
  }
  sort(A.begin(), A.end());
  ll least_common_mul = 1;
  for (int i = 0; i < N; i++) {
    least_common_mul = (least_common_mul * A[i]) / gcd(A[i], least_common_mul);
  }
  ll ans = 0;
  bool end_flag = false;
  for (int i = 0; i < N; i++) {
    if ((least_common_mul / A[i]) % 2) continue;
    cout << 0 << endl;
    return 0;
  }
  cout << (M / least_common_mul + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////
lint grid[301][301];
int main(void) {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> grid[i][j];
		}
	}

	ll ans = 0;

	for (int i = 0; i < n-1; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			bool flag = true;
			for (int k = 0; k < n; k++)
			{
				if (k == i || k == j) continue;
				if (grid[i][k] + grid[k][j] < grid[i][j]) {
					printf("-1\n"); return 0;
				}
				if (grid[i][k] + grid[k][j] == grid[i][j]) {
					flag = false; 
					break;
				}
			}
			if (flag) ans += grid[i][j];
		}
	}

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


Measured memory_bytes: 896
N, K, C = list(map(int, input().split()))
S = list(input())
o = "o"
x = "x"

W = [0] * N

if S[0] == o:
  W[0] = 1

for i in range(1, N):
  W[i] = W[i - 1]
  if S[i] == o:
    W[i] += 1

BDP = [0] * N
cnt = 0
if S[0] == o:
  BDP[0] = 1
  cnt = C
for i in range(1, N):
  BDP[i] = BDP[i - 1]
  if cnt != 0:
    cnt -= 1
    continue
  if S[i] == o:
    BDP[i] += + 1
    cnt = C

ADP = [0] * N
cnt = 0
if S[-1] == o:
  ADP[-1] = 1
  cnt = C
for i in range(N - 2, -1, -1):
  ADP[i] = ADP[i + 1]
  if cnt != 0:
    cnt -= 1
    continue
  if S[i] == o:
    ADP[i] += 1
    cnt = C

BDP = [0] + BDP

IM = [0] * (N + 2)
ans = 0
for i in range(C):
  if S[i] == x:
    continue
  if ADP[i] >= K:
    IM[max(-1, i - C) + 1] += 1
    IM[i + 1] -= 1
    IM[min(i + 1, N) + 1] += 1
    IM[min(i + C + 1, N) + 1] -= 1
for i in range(C, N - C):
  if S[i] == x:
    continue
  if BDP[i - C] + ADP[i] >= K:
    IM[max(-1, i - C) + 1] += 1
    IM[i + 1] -= 1
    IM[min(i + 1, N) + 1] += 1
    IM[min(i + C + 1, N) + 1] -= 1
for i in range(min(N - C, C), N):
  if S[i] == x:
    continue
  if BDP[i - C] + 1 >= K:
    IM[max(-1, i - C) + 1] += 1
    IM[i + 1] -= 1
    IM[min(i + 1, N) + 1] += 1
    IM[min(i + C + 1, N) + 1] -= 1

for i in range(1, N + 2):
  IM[i] += IM[i - 1]

if BDP[-1] < K:
  exit()

if C == 0:
  if W[-1] == K:
    for i in range(N):
      if S[i] == o:
        print(i + 1)
  exit()

DP = [0] * (N + 1)
for i in range(N):
  k = 0
  k += BDP[i]
  if i + C < N:
    k += ADP[i + C]
  if k >= K:
    DP[max(i, -1)] += 1
    DP[min(i + C, N)] -= 1

for i in range(1, N + 1):
  DP[i] += DP[i - 1]

for i in range(1, N + 1):
  if S[i - 1] == o and IM[i] == 0 and DP[i - 1] == 0:
    print(i)



Measured memory_bytes: 31468
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("============\n")
using namespace std;
typedef long long ll;
typedef pair<int, char> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD =  1e9+7;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 1e6+10;
inline ll f(ll x) {
    return x*x*x*x*x;
}
map<ll, int> v;
int main(){
    for (int i = 0; i<=1000; ++i) v[f(i)] = i;
    ll x; cin >> x;
    for (int i = 0; i<=1000; ++i) {
        if (f(i)==x) {
            cout << i << ' ' << 0 << endl;
            return 0;
        }
        else if (v[x+f(i)]) {
            cout << v[x+f(i)] << ' ' << i << endl;
            return 0;
        }
        else if (v[x-f(i)]) {
            cout << i << ' ' << -v[x-f(i)] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t K;
  cin >> K;
  int64_t x = K %50;
  int64_t y = K/50;
  cout << 50 << endl;
  for(int i=0; i<x; i++){
    cout << 49+y+1 << " ";
  }
  for(int i=x; i<50; i++){
    cout << 49+y-x;
    if(i != 50){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string str;
int main() {
	cin >> str;
	queue<string> que; que.push(str);
	bool ret = (str == "ABC");
	while (!ret && !que.empty()) {
		string s1 = que.front(); que.pop();
		vector<int> v1(s1.size(), 0);
		for (int i = 2; i < s1.size(); i++) {
			if (s1[i - 2] == 'A' && s1[i - 1] == 'B' && s1[i] == 'C') {
				v1[i - 2] = v1[i - 1] = v1[i] = 1;
			}
		}
		vector<bool> ok1(3, true);
		for (int i = 0; i < s1.size(); i++) {
			if (v1[i] == 0) ok1[s1[i] - 65] = false;
		}
		for (int i = 0; i < 3; i++) {
			if (!ok1[i]) continue;
			string res;
			for (int j = 0; j < s1.size();) {
				if (j <= s1.size() - 3 && v1[j] == 1) res += (char)(i + 65), j += 3;
				else res += s1[j], j++;
			}
			if (res == "ABC") { ret = true; break; }
			if(res.size() != s1.size()) que.push(res);
		}
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}

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

int main(){
        int n,i,firstNum=0,secondNum=0;
        cin >> n;
        vector<int> a(n);
        for(i=0;i<n;++i){
                cin >> a.at(i);
                if(a.at(i)>=firstNum){
                        secondNum = firstNum;
                        firstNum = a.at(i);
                }else if(a.at(i)>secondNum) secondNum = a.at(i);
        }
        if(firstNum==secondNum) for(i=0;i<n;++i) cout << firstNum << endl;
        else{
                for(i=0;i<n;++i){
                        if(a.at(i)==firstNum) cout << secondNum << endl;
                        else cout << firstNum << endl;
                }
        }
        return 0;
}

Measured memory_bytes: 3972