akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 2e5 + 5;
 
int n, p;
string s;
int pref[N];
map<int, int> m;
 
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
 
int32_t main()
{
	IOS;
	cin >> n >> p >> s;
	int ans = 0;
	int c2 = 0, c5 = 0;
	for(int i = 1; i <= n; i++)
	{
		if((s[i - 1] - '0') % 2 == 0)
			c2 += i;
		if((s[i - 1] - '0') % 5 == 0)
			c5 += i;
	}
	if(p == 2)
	{
		cout << c2;
		return 0;
	}
	if(p == 5)
	{
		cout << c5;
		return 0;
	}
	for(int i = n; i >= 1; i--)
	{
		pref[i] = pref[i + 1] + (s[i - 1] - '0') * pow(10, n - i, p);
		pref[i] %= p;
		m[pref[i]]++;
	}
	ans = m[0];
	int rem = 0;
	for(int i = n; i >= 2; i--)
	{
		m[pref[i]]--;
		rem += (s[i - 1] - '0') * pow(10, n - i, p);
		rem %= p;
		ans += m[rem];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2580
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>S>>T;
    cout<<T<<S<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc149_b() {
	ll A, B, K;
	ll ansA, ansB;

	cin >> A >> B >> K;

	ansA = max(0LL, A - K);
	ansB = max(0LL, B - max(0LL, K - A));


	cout << ansA << " " << ansB << "\n";
}

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

	solve_abc149_b();

	return 0;
}

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

int gcd(int a,int b){
    return a%b==0?b:gcd(b,a%b);
}

int  answ(int a[5001],int i,int j,int n)
{
	return  a[i]+(j-i-(a[j]-a[i]))+a[n]-a[j];
}

int main(){

    long double a,b;
    cin>>a>>b;
    for(int i=-100000;i<=1000000;i++){
        long double c=(a+i)/2;
        if(c==b){
            cout<<i;
            return 0;
        }
    }

    return 0;
}


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

int main(void){
    int n;
    cin >>n;
    int c[n-1],s[n-1],f[n-1];
    int ans[n];
    for (size_t i = 0; i < n-1; i++)
    {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (size_t i = 0; i < n-1; i++)
    {
        ans[i]=s[i]+c[i];
        for (size_t j = i+1; j < n-1; j++)
        {
            if (ans[i]<s[j])
            {
                ans[i]=s[j]+c[j];
            }else
            {
                size_t x;
                for (x = 0; ans[i] > s[j]+x*f[j]; x++);
                ans[i]=s[j]+x*f[j]+c[j];
            }
        }
    }
    ans[n-1]=0;
    for (size_t i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <string>

using std::cin;
using std::cout;
using std::endl;

using std::string;

int
main()
{
  string S, T;
  cin >> S >> T;
  cout << ((T.size() == S.size() + 1 && T.substr(0, S.size()) == S) ? "Yes" : "No") << endl;
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

bool possibleGo(ll t, ll x, ll y){
    ll dist = abs(x)+abs(y);
    if(t < dist) return false;
    else if((t-dist)%2) return false;
    else return true;
}
void solve(long long N, std::vector<long long> t, std::vector<long long> x, std::vector<long long> y){
    for(ll i=0; i< N; i++){
        ll tdiff, xdiff, ydiff;
        if(i==0){
            tdiff = t[i];
            xdiff = x[i];
            ydiff = y[i];
        }
        else {
            tdiff = t[i]-t[i-1];
            xdiff = x[i]-x[i-1];
            ydiff = y[i]-y[i-1];
        }
        if(!possibleGo(tdiff, xdiff, ydiff)){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

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


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

int a, b, c;

int main(){
	cin>>a>>b>>c;
	
	if(a==b){
		cout<<c<<endl;
	}
	else{
		if(b==c){
			cout<<a<<endl;
		}
		else{
			cout<<b<<endl;
		}
	}
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	l := iSScan(n)
	if max(l)-(sum(l)-max(l)) < 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1780
// https://atcoder.jp/contests/abc086/tasks/arc089_a

#include <algorithm>
#include <cmath>   // abs() for float, and fabs()
#include <cstdlib> // abs() for integer
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, t, x, y, dt, ans = 0, X = 0, Y = 0, T = 0;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &t, &x, &y);
        // 前回から移動できるか確認
        if (ans == 0) {
            dt = abs((X - x) + (Y - y));
            // 時間内にたどり着けて、余りが２の倍数の場合
            if (dt <= (t - T) && (t - T) % 2 == dt % 2) {
                X = x;
                Y = y;
                T = t;
            } else {
                ans = -1;
            }
        }
    }

    if (ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());

    int s = 0;
    for (int i = 1; i >= 0; i--) {
        int j = i + 1;
        s += abs(a.at(j) - a.at(i));
    }
    cout << s << endl;
}

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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int count = 0;
  int i = 0;
  while (i < N - 1) {
    count++;
    int j = i + 1;
    while (j < N) {
      if (s.at(i) == s.at(j)) {
        j++;
        if (j == N -1) {
          break;
        }
      }
      else {
        break;
      }
    }
    i = j;
  }
  if (N == 1) {
    count = 1;
  }
  else if (s.at(N - 2) != s.at(N - 1)) {
    count++;
  }
  cout << count <<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define lim 100001
using namespace std;
struct point
{
	int x,y,id;
} c[lim];
struct edge
{
	int u,v,cost;
} e[2*lim];
bool cmp1(point a,point b)
{
	return a.x < b.x;
}
bool cmp2(point a,point b)
{
	return a.y < b.y;
}
bool cmp(edge a,edge b)
{
	return a.cost < b.cost;
}
int p[lim];
int dx[lim],dy[lim];
int find(int x){return p[x] == x ? x : p[x] = find(p[x]);}
int n,tot;
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i = 0; i <= n; i++) p[i] = i;
  for(int i = 1; i <= n; i++){
   cin >> dx[i] >> dy[i];
  }
  for(int i = 1; i <= n; i++)
  {
    c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i;
  }
  sort(c+1,c+1+n,cmp1);
  for(int i = 2; i <= n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i-1].id;
    e[tot].cost = c[i].x - c[i-1].x;
    tot++;
  }
  sort(c+1,c+1+n,cmp2);
  for(int i = 2; i <= n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i-1].id;
    e[tot].cost = c[i].y - c[i-1].y;
    tot++;
  }
  sort(e,e+tot,cmp);
  int ans = 0;
  int cnt = 0;
  for(int i = 0; i < tot; i++){
    int f = find(e[i].u);
    int t = find(e[i].v);
    if(f!=t){ans+=e[i].cost;p[f] = t;cnt++;}
    if(cnt == n-1) break;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solove();
	}
	
	public void solove() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		
		int simo2 = x % 100;
		
		int minimumNum = 0;
		int minimumPrice = 0;
		
		while(simo2 >= 5) {
			simo2 -= 5;
			minimumNum++;
			minimumPrice += 105;
		}
		while(simo2 >= 4) {
			simo2 -= 4;
			minimumNum++;
			minimumPrice += 104;
		}

		while(simo2 >= 3) {
			simo2 -= 3;
			minimumNum++;
			minimumPrice += 103;
		}
		

		while(simo2 >= 2) {
			simo2 -= 2;
			minimumNum++;
			minimumPrice += 102;
		}
		

		while(simo2 >= 1) {
			simo2 -= 1;
			minimumNum++;
			minimumPrice += 101;
		}
		
		if(minimumPrice > x) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}
	}
}


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


int main() {
  double L; cin >>L;
  L /= 3;
  cout <<fixed <<setprecision(12) <<L*L*L <<endl;
}


Measured memory_bytes: 256
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
n = int(input())
li_num=[int(input()) for i in range(n)]
 
li_card = [li_a, li_b, li_c]
 
ans = False
 
#print(li_card)
#print(li_b)
#print(li_c)
#print(n)
#print(li_num)
 
for m in li_num:
    for i in range(3):
        for j in range(3):
          if li_card[i][j] == m:
              li_card[i][j] = 0
 
for i in range(3):
    if li_card[i][0] == li_card[i][1] == li_card[i][2] == 0:
        ans = True
        break
    elif li_card[0][i] == li_card[1][i] == li_card[2][i] == 0:
        ans = True
        break
 
if not ans:
  if li_card[0][0] == li_card[1][1] == li_card[2][2] == 0:
      ans = True
  elif li_card[0][2] == li_card[1][1] == li_card[2][0] == 0:
      ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Double D = sc.nextDouble();
        Double T = sc.nextDouble();
        Double S = sc.nextDouble();
        boolean answer = D/S <= T;

        if (answer == true){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int p,q,r;

signed main() {
    cin >> p >> q >> r;
    cout << p + q + r -max(max(p,q),r) << endl;
}


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

int main() {
	int a,b;
	cin >> a>>b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){

  int waseda[10];
  int keo[10];

  for( int i = 0 ; i < 10 ; i++ ){
    cin >> waseda[i];
  }
  for( int i = 0 ; i < 10 ; i++ ){
    cin >> keo[i];
  }

  sort( waseda , waseda + 10 );
  sort( keo , keo + 10);

  cout << waseda[9] + waseda[8] + waseda[7] << " " << keo[9] + keo[8] + keo[7] << endl;
}

Measured memory_bytes: 1180
#include<stdio.h>
#define N 8
#define NOT 1
#define FREE -1
int row[10],col[N],dpos[2*N-1],dneg[2*N-1];
int A[N][N];
void printB();
void put(int i){
  int j;
  if(i==N){
    printB();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOT||dpos[i+j]==NOT||dneg[i-j+N-1]==NOT){
      continue;
    }
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT;
    put(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}


int main(){
  int i,j,k;
  int n,a,b;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]=0;
    }
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    A[a][b]=1;
  }
  put(0);
  return 0;
}

void printB(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]==1){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
	printf("Q");
      }else{
	printf(".");
      }
    }
    printf("\n");
  }
}
      



Measured memory_bytes: 2088
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, m;
long a[105];
long sum, cnt;

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < n; i++){
        scanf("%ld", a+i);
        sum += a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] * 4 * m >= sum){
            cnt++;
        }
    }
    if(cnt >= m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int N;cin>>N;
  int W[N];
  int i,j;
  rep(i,N) cin>>W[i];
  int sum=0;
  rep(i,N){
    sum+=W[i];
  }
  int tmp=0,ans=INF,tmp1;
  rep(i,N){
    tmp+=W[i];
    tmp1=abs(tmp-abs(tmp-sum));
    ans=min(ans,tmp1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int m,d;
  cin >> m >> d;

  int ans = 0;
  FOR(i_m,1,m+1) {
    FOR(i_d,1,d+1) {
      if (i_d%10 >= 2 && i_d/10 >= 2 && (i_d%10) * (i_d/10) == i_m) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

ull gcd(ull x, ull y) {
  if (y > x)
    return gcd(y, x);

  auto r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

int main() {
  unsigned long long n;
  vector<unsigned long long> a;

  cin >> n;
  each(i, n) {
    int tmp;
    cin >> tmp;
    a.push(tmp);
  }

  auto result = a[0];
  for (auto i=1; i < n; i++) {
    result = gcd(result, a[i]);
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1400
program main
  implicit none
  integer :: h, w, i, j
  character(102) :: line
  character(1), allocatable :: tab(:, :)
  read(*, *) h, w
  allocate(tab(0:w + 1, 0:h + 1))
  tab(:, :) = "#"
  do i = 1, h
    read(*, *) line
    do j = 1, w
      tab(j, i) = line(j:j)
    end do
  end do
  do i = 0, h + 1
    do j = 0, w + 1
      line(j + 1:j + 1) = tab(j, i)
    end do
    write(*, "(a)") trim(line)
  end do
end program main


Measured memory_bytes: 256
N,C,K = list(map(int,input().split()))
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
cnt = 0

Bus = 1
Capa = 0
first = T[0]
for i in range(N):
    t = T[i]
    if t-first>K or Capa+1>C:
        Bus+=1
        Capa = 1
        first = t
    else:
        Capa += 1
print(Bus)

Measured memory_bytes: 50392
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

int main(){
	int n; cin>>n;
	vector<vector<ll>>v(n,vector<ll>(2)); 
	for(int i=0;i<n;i++) cin>>v[i][0]>>v[i][1];
	sort(v.begin(),v.end());
	
	ll mi=-v[0][1];  ll sum=0; ll ret=v[0][1];
	for(int i=1;i<n;i++){
		sum+=v[i][1]-(v[i][0]-v[i-1][0]);
		mi=min(mi,sum-v[i][1]);
		ret=max(ret,sum-mi);
	}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 30328
dy = [-1, 1, 0, 0, -1, 1, -1, 1]
dx = [ 0, 0,-1, 1, -1, 1,  1,-1]
h, w = map(int, input().split())
S = [input() for _ in range(h)]
ans = [[-1]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '#': continue
        ans[i][j] = 0
        for k in range(8):
            y = i + dy[k]; x = j + dx[k]
            if y<0 or h<=y or x<0 or w<=x: continue
            if S[y][x] == '#': ans[i][j] += 1
for i in range(h):
    for j in range(w): print('#' if ans[i][j] < 0 else ans[i][j], end='')
    print('')


Measured memory_bytes: 9252
K = int(input()) - 1
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[K])

Measured memory_bytes: 9188
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = rs()
    K = ri()
    a = [int(c) for c in N]
    dp = [[0] * (K + 1) for i in range(2)]

    dp[1][0] = 1
    dp[1][1] = a[0] - 1
    dp[0][1] = 1

    for i in range(1,len(a)):
        ndp = [[0] * (K + 1) for i in range(2)]

        for k in range(K+1):
            if k + 1 <= K:
                ndp[1][k + 1] += 9 * dp[1][k] # 1 ~ 9
            ndp[1][k] += dp[1][k] # 0
        
        for k in range(K+1):
            if a[i] == 0:
                ndp[0][k] += dp[0][k] #0
            else:
                ndp[1][k] += dp[0][k] #0
                if k + 1 <= K:
                    ndp[1][k + 1] += (a[i] - 1) * dp[0][k] # 1 ~ (a[i]-1)
                    ndp[0][k + 1] += dp[0][k]
        
        dp = ndp
    print(dp[0][K] + dp[1][K])
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 12368
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>

#define ll long long

using namespace std;

const int maxn=1e5+10;

ll a,b,c,d;
ll ans1,ans2,ans3;
int main(){
    cin >> a >>b;
    ans1=a+b;
    ans2=a-b;
    ans3=a*b;
    cout <<max(ans1,max(ans2,ans3));
   // system("pause");
    return 0;
}

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

using namespace std;

const long long INF = 1LL << 60;
int n, k;
long long h[M], dp[M];

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

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

    for (int i = 0; i < M; ++i)
        dp[i] = INF;

    dp[0] = 0;

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

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


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

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

    vector<int> s;
    vector<int> o(n+1,-1);
    int t=1,l=0,v=1;
    while(o[v]==-1){
        o[v]=s.size();
        s.push_back(v);
        v=a[v-1];
    }
    t=s.size()-o[v];
    l=o[v];

    if(k<l) cout<<s[k]<<endl;
    else{
        k-=l;
        k%=t;
        cout<<s[l+k]<<endl;
    }
}

Measured memory_bytes: 5848
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;

    int total = 0;
    REP(i, N) {
        int a;
        cin >> a;

        for (int i = 0; i < D; i += a) total++;
    }

    cout << total + X << endl;

    return 0;
}


Measured memory_bytes: 256
//AtCoder Beginner Contest 045 B問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	int turn = 0;
	int card[3];
	for(int i=0; i<3; i++) card[i] = 0;
	char s[3][105];
	for(int i=0; i<3; i++) scanf("%s", s[i]);
	for(int i=0; i<315; i++) {
		switch(s[turn][card[turn]]){
			case 'a':
					card[turn]++;
					turn = 0;
					break;
			case 'b':
					card[turn]++;
					turn = 1;
					break;
			case 'c':
					card[turn]++;
					turn = 2;
					break;
			default:
					break;
		}
	}
	switch(turn){
		case 0:
				printf("%s\n", "A");
				break;
		case 1:
				printf("%s\n", "B");
				break;
		case 2:
				printf("%s\n", "C");
				break;				
	}
	//printf("%d\n",s[turn-1][card[turn-1]]);
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d) cout<<"Yes"<<endl;
  else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
// Union-Find
// ある人が喋れる言語は全て同じグループとする(翻訳したら同じになる)
// union - find tree !!!!!!!!!!!!!!!!!!!!!!!!!
vector<int> par; //oya
vector<int> rnk; //ki no hu ka sa
// n要素で初期化
void init(int n){
    par.resize(n);rnk.resize(n);
    FOR(i, 0, n){par[i] = i;rnk[i] = 0;}
}
//木の根を求める
int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y])par[x] = y;
    else{par[y] = x;if(rnk[x] == rnk[y]) rnk[x]++;}
    return;
}
bool isSame(int x, int y){return find(x) == find(y);}
int main()
{
  int N, M;
  cin >> N >> M;
  init(100005);
  bool use[100005];
  FOR(i,0,100005) use[i] = false;
  FOR(i,0,N) {
    int K;
    cin >> K;
    int pre;
    cin >> pre;
    use[pre] = true;
    FOR(j, 0, K - 1) {
      int L;
      cin >> L;
      use[L] = true;
      unite(pre, L);
      pre = L;
    }
  }
  int x = 0;
  while(!use[x]) x++;
  int oya = find(x);
  FOR(i,0,100005) {
    if(use[i] && find(i) != oya) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 1152
s = input()
t = input()
s_dash = []
t_dash = []
s_d = ""
t_d = ""
for i in range(len(s)):
  s_dash.append(s[i])
for j in range(len(t)):
  t_dash.append(t[j])
s_dash.sort()
t_dash.sort()
t_dash.reverse()
for i in range(len(s_dash)):
  s_d += s_dash[i]
for j in range(len(t_dash)):
  t_d += t_dash[j]
if s_d<t_d:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        if(n != 0){
            for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            list.add(a);
            }
            sc.close();
            int i = 0;
            int ans;
            while(true){
                int a = x - i;
                int b = x + i;
                if(!list.contains(a)){
                    ans = a;
                    break;
                }else if(!list.contains(b)){
                    ans = b;
                    break;
                }
                i++;
            }
            System.out.print(ans);
        }else{
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

int main() {
    int n; cin >> n;
    vector<int> a,b;
    for(int i = 0;i < n;i++){
        int z; cin >> z;
        a.push_back(z);b.push_back(z);
    }
    sort(b.begin(),b.end());
    
    int right = b[n / 2 - 1];
    int left = b[n / 2];
    for(int i = 0;i < n;i++){
        if(a[i] < b[n/2]){
            cout << left << endl;
        }else{
            cout << right << endl;
        }
    }
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	int N;
	cin >> N;
	map<string, int> C;
	C["AC"] = 0;
	C["WA"] = 0;
	C["TLE"] = 0;
	C["RE"] = 0;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		C[S]++;
	}
	cout << "AC x " << C["AC"] << endl;
	cout << "WA x " << C["WA"] << endl;
	cout << "TLE x " << C["TLE"] << endl;
	cout << "RE x " << C["RE"] << endl;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
}


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

int main()
{
    double w, h;
    int x, y;
    cin >> w >> h >> x >> y;

    double maxSize = (w / 2) * h;
    bool multipleWaysPossible = (((x == w / 2) && (y == h / 2)) ? true : false);

    cout << fixed << setprecision(9);
    cout << maxSize << " " << (multipleWaysPossible ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void check()
{
   string s,t;
   ll cou=0;
   cin>>s;
   cin>>t;
   for(ll i=0;i<s.size();i++)
   {
       if(s[i]!=t[i])
       {
            cou++;
       }
   }
   cout<<cou;
}
int main()
{
    check();
}


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

int main(){
  int a, b;
  cin >> a  >> b;
  if (a == b) cout << a + b << endl;
  else cout << max(a,b) + max(a,b) -1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
i=0
check=0


if(len(t)>len(s)):
    for ch in s:
        if(ch!=t[i]):
            check+=1
            break
        i+=1
        if(i>=len(s)):
            break

if(len(t)-len(s)!=1):
    print("No")
elif(check!=0):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9056
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
    vector<ll>v;
    
    ll res=6;
    
    v.pb(1LL);
    
    while(res<=100000)
    {
        v.pb(res);
        res*=6;
    }
    
    res=9;
    
    while(res<=100000){
        v.pb(res);
        res*=9;
    }
    
    ll n=(ll)v.size();
    
    ll dp[100001][n+1];
    
    for(ll i=0;i<100001;i++){
        for(ll j=0;j<=n;j++)
        dp[i][j]=INF;
    }
    
    dp[0][0]=0;
    
    
    for(ll i=0;i<=n;i++)
    dp[0][i]=0;
    
    
    for(ll i=1;i<=n;i++){
        for(ll sum=1;sum<=100000;sum++){
            
            
            if(i>0)
            dp[sum][i]=min(dp[sum][i],dp[sum][i-1]);
            
            if(sum>=v[i-1])
            dp[sum][i]=min(dp[sum][i],1+dp[sum-v[i-1]][i]);
        }
    }
    
    
    ll x;
    cin>>x;
    cout<<dp[x][n]<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];  
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int m = *(d.begin());
  int count = 1;
  for (auto i = (d.begin() + 1); i != d.end(); i++) {
	if (m == *i)
      continue;
	m = *i;
    count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 3604
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename String> bool isPalindrome(const String &s) {
  int n = s.size();
  rep(i, n / 2) if (s[i] != s[n - 1 - i]) return false;
  return true;
}

template<typename String> bool isPalindromeOf(String s, const String &t) {
  reverse(all(s));
  return s == t;
}

main {
  int n, l;
  cin >> n >> l;
  vs s(n);
  cin >> s;
  vi used(n);
  V<string> palis;
  rep(i, n) {
    if (used[i]) continue;
    loop(j, i + 1, n) {
      if (used[j]) continue;
      if (isPalindromeOf(s[i], s[j])) {
        used[i] = used[j] = true;
        string t = s[i];
        reverse(all(t));
        palis.emplace_back(min(t, s[i]));
        goto next;
      }
    }
  next:;
  }
  string midS = string(1, char('z' + 1));
  // int midSLen = 0;
  rep(i, n) {
    if (used[i]) continue;
    if (!isPalindrome(s[i])) continue;
    // if (midSLen == s[i].size()) cmin(midS, s[i]);
    // if (cmax(midSLen, s[i].size())) midS = s[i];
    cmin(midS, s[i]);
  }
  sort(all(palis));
  for (auto &t : palis) cout << t;
  if (midS != string(1, char('z' + 1))) cout << midS;
  reverse(all(palis));
  for (auto t : palis) {
    reverse(all(t));
    cout << t;
  }
  cout << endl;
}

Measured memory_bytes: 3292
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => (get().parse::<i64>().unwrap());
    }
    
    let mut xs = vec![];
    xs.push(get!());
    xs.push(get!());
    xs.push(get!());
    let mut ans = 0;
    loop {
    	xs.sort();
        if xs[0] == xs[2] {
        	break;
        }
        ans += 1;
        if xs[0] == xs[1] {
        	xs[0] += 1;
            xs[1] += 1;
        } else {
        	xs[0] += 2;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
s = input()
t = input()
slist = list(s)
tlist = list(t)
count = 0
if len(slist)+1 == len(tlist):
    for i in range(len(slist)):
        if slist[i] == tlist[i]:
            count += 1
            if count ==len(slist):
                print("Yes")
        else:
            print("No")
            break
else:
    print("No")

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 200010;
int cnt[mxN],on[mxN];

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

	int N,M,ind,v;
	cin>>N>>M;
	vector<int> a(N);
	for(int i = 0;i < N;i++) cin>>a[i],cnt[a[i]]++;
	int left = N;
	for(int i = 1;i <= N;i++) {
		if(cnt[i]) {
			for(int j = max(1,i-cnt[i]+1);j <= i;j++) {
				if(!on[j]) left--;
				on[j]++;
			}
		}
	}
	for(int i = 0;i < M;i++) {
		cin>>ind>>v;
		ind--;
		cnt[a[ind]]--;
		if(a[ind]-cnt[a[ind]] >= 1)on[a[ind]-cnt[a[ind]]]--, left += on[a[ind]-cnt[a[ind]]] == 0;
		cnt[v]++;
		a[ind] = v;
		if(v-cnt[v]+1 >= 1) on[v-cnt[v]+1]++, left -= on[v-cnt[v]+1] == 1;
		cout<<left<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define inf pow(2,60);
using namespace std;

long long dp[3001][3001];
long long sum[500][500];

long long solve(vector<int>&slimes,int i,int j){
    
    if(i==j){
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
        
    long long minCost = inf;
    
    for(int k=i;k<j;k++){
        
        minCost = min(minCost,(sum[i][j]+solve(slimes,i,k)+solve(slimes,k+1,j)));
    }
    
    return dp[i][j] = minCost;
}

void preprocess(vector<int>&v,int n){
    
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            if(i==j)
                sum[i][j] = v[j];
            else
                sum[i][j] = sum[i][j-1] + v[j];
        }
    }
}

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	
	vector<int> slimes(n+1);
	
	for(int i=1;i<=n;i++){
	    cin>>slimes[i];
	}

	memset(dp,-1,sizeof(dp));
	
	preprocess(slimes,n);
	
// 	for(int i=1;i<=n;i++){
// 	    for(int j=i;j<=n;j++){
// 	        cout<<sum[i][j]<<" ";
// 	    }
// 	    cout<<endl;
// 	}
	
    long long ans = solve(slimes,1,n);
    
    cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 75592
n=int(input())
adj=[]
for i in range(n):
      adj.append(list(map(int, input().split())))

edge=[[0 for i2 in range(n)]for i1 in range(n)]

#??£??\???????????????

for i in range(n):
    for j in range(adj[i][1]):
        edge[i][adj[i][j+2]-1]=1


time=1
discover=[0 for i in range(n)]
final=[0 for i in range(n)]
stack=[]

def dfs(id,time):
    for i in range(n):
        c=0
        if edge[id][i]==1 and discover[i]==0:
            stack.append(id)
            discover[i]=time
            c+=1
            #print(discover,final,i,stack)
            dfs(i,time+1)
        else:
            pass
    if c==0:
        if len(stack)>0:
            if final[id]==0:
                final[id] = time
                #print("back",discover,final,id,stack)
                dfs(stack.pop(), time + 1)
            else:
                #print("back", discover, final, id, stack)
                dfs(stack.pop(),time)

discover[0]=time
stack.append(0)
dfs(0,time+1)


for i in range(n):
    if discover[i]==0:
        discover[i]=final[0]+1
        stack.append(i)
        dfs(i,final[0]+2)
        break

for i in range(n):
    print(i+1,discover[i],final[i])

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

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

    if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	if (W / 2 == x && H / 2 == y) {
		printf("%.10f 1\n", ((double)W * (double)H)/2.0);
	}
	else {
		printf("%.10f 0\n", ((double)W * (double)H) / 2.0);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

vector<string> strv;

int main()
{
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1,0));
    rep(i, 0, s.size())
        rep(j, 0, t.size())
        {
            if (s[i] == t[j])
                dp[i+1][j+1] = dp[i][j] + 1;
            else 
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    int i = s.size();
    int j = t.size();
    string ch = "";
    while (i>0 && j>0)
    {
        if (dp[i][j] == dp[i][j-1])
            j--;
        else if (dp[i][j] == dp[i-1][j])
            i--;
        else 
        {
            ch += s[i-1];
            i--;
            j--;
        }
    }
    reverse(begin(ch), end(ch));
    cout << ch;
    return 0;
}

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

int main() {
  int N,a,b;
  cin>>N;
  int m=N;
  int A[5]={},B[5]={};
  for(int i=1;i<N/2;i++){
    int sum=0;
    a=i;
    b=N-a;
    for (int j=0;j<5;j++){
      A[j]=a%10,a/=10;
      B[j]=b%10,b/=10;
      sum+=A[j]+B[j];
    }
    m=min(sum,m);
 	 }
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  cout <<(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
  	cin>>s>>t;
  	if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]){
		cout<<"YES"<<endl;
    }else{
		cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    B = []
    C = []
    for a in A:
        if a % 4 == 0:
            B.append(a)
        else:
            C.append(a)

    if len(C) <= len(B) + 1:
        print('Yes')
    else:
        cnt = 0
        for c in C:
            if c % 2 == 0:
                cnt += 1
        if len(C) - cnt < len(B) + 1:
            print('Yes')
        else:
            print('No')


main()


Measured memory_bytes: 12496
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val Z = readLine()!!

    val A = 'A'
    val B = 'B'
    val C = 'C'

    var i = 0
    var answer = 0

    if(N < 3){
        println("0")
        return
    }

    while(true){
        if(Z[i] == A && Z[i+1] == B && Z[i+2] == C){
            answer++
            i+=3
        }else{
            i++
        }
        if(i >= N-2)break
    }

    println(answer)
}

Measured memory_bytes: 31796
from sys import exit
import math

N, D = map(int, input().split())

Xs = []

for i in range(N):
    x = list(map(int, input().split()))
    Xs.append(x)

count = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        distance = 0
        for k in range(D):
            distance += (Xs[i][k] - Xs[j][k]) ** 2
        if math.sqrt(distance).is_integer():
            count += 1

print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed main(){
	fast;
	int k,x;
	cin>>k>>x;
	for(int i=max((int)-1000000,x-k+1);i<=min((int)1000000,x+k-1);i++){
		cout<<i<<" ";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin>>a>>b;
  vector<bool> v(3, false);
  v[a-1]=true;
  v[b-1]=true;
  for(int i = 0; i < 3; ++i){
    if(!v[i]){cout<<i + 1<<endl;return 0;}
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int M = 1e9 + 7;
using namespace std;
int main() {
    long long n, m, ans = 1; cin >> n >> m; //注意ans要开long long，否则会爆；并且还要赋初值为1，否则下面乘法会全部乘0
    if (abs(m - n) > 1) {cout << "0\n"; return 0;}
    for (int i = 1; i <= n; i++) ans = ans * i % M; //算N!
    for (int i = 1; i <= m; i++) ans = ans * i % M; //算M!
    cout << (n != m ? ans : ans * 2 % M) << endl;
}

Measured memory_bytes: 256