akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second

vector<int> bulb[11];

int main(){
   
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int sz;
        cin>>sz;
        while(sz--){
        int x;
        cin>>x;
        x--;
        bulb[i].push_back(x);
    }
    }
    int parity[m];
    for(int i=0;i<m;i++){
        cin>>parity[i];
    }
    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        vector<bool> swit(n,false);
        bool flag = true;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                swit[j]=true;
            }
        }
        for(int j=0;j<m;j++){
        int par = 0;
            for(auto it:bulb[j]){
                if(swit[it]) par++;
            }
            if(parity[j]!=par%2) flag = false;
        }
        ans+=flag;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


///////////////////////////////////////////////////

constexpr ll MAX18 = 1e18;

ll f(int N, const vll &A)
{
    ll ans = 1;

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

    for (int i = 0; i < N; i++)
    {
        ll b = (MAX18 + A[i]) / A[i];
        if (ans >= b)
        {
            ans = -1;
            break;
        }
        else
        {
            ans *= A[i]; 
        }
    }

    return ans;
}

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

    vll A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    ll ans = f(N, A);
    cout << ans << endl;
}

Measured memory_bytes: 4056
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B = sc.nextLong()
    println(
      if (A % 2 == 0 && B % 2 == 0)
        if ((B - A) % 4 != 0)
          1 ^ B
        else
          B
      else if (A % 2 == 0)
        if ((B - A + 1) % 4 != 0)
          1
        else
          0
      else if (B % 2 == 0)
        if ((B - A - 1) % 4 != 0)
          1 ^ A ^ B
        else
          A ^ B
      else if ((B - A) % 4 != 0)
        1 ^ A
      else
        A)
  }
}


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

int main() {
  int num_500, num_100, num_50, total;
  cin >> num_500 >> num_100 >> num_50 >> total;
  int result = 0;

  for(int i = 0; i <= num_500; i++){
    for(int j = 0; j<= num_100; j++){
      for(int k= 0; k <= num_50; k++){
        if((500*i + 100*j + 50*k) == total){
          //cout << i << j << k << endl;
          result++;
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int gyo = sc.nextInt();
		int retu = sc.nextInt();
		//      int gyo = Integer.parseInt(args[0]);
		//      int retu = Integer.parseInt(args[1]);

		int[][] vec_1 = new int[gyo][retu];

		//int[] output = new[vec_1];
		//vec_1
		for (int i = 0; i < gyo; i++) {
			for (int j = 0; j < retu; j++) {
				vec_1[i][j] = sc.nextInt();
				//      vec_1[i][j] = Integer.parseInt(args[4*i+(j+2)]);
				//      System.out.print(vec_1[i][j]+" ");
			}
			//  System.out.println("");
		}

		//vec_2
		int[] vec_2 = new int[retu];
		for (int i = 0; i < retu; i++) {
			vec_2[i] = sc.nextInt();
			//  vec_2[i] = Integer.parseInt(args[gyo*retu+2+i]);
			//  System.out.println(vec_2[i]);
		}

		//output
		int[] output = new int[gyo];
		for (int i = 0; i < gyo; i++) {
			for (int j = 0; j < retu; j++) {
				output[i] = output[i] + vec_1[i][j] * vec_2[j];
			}
			System.out.println(output[i]);
		}

	}

}



Measured memory_bytes: 40416
#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
using namespace std;

int main() {
  int n;
  scanf("%d",&n);
  list<int> l;
  char com[20];
  for (int i=0; i<n; i++) {
    scanf("%s",com);
    int x;
    if (!strcmp(com,"insert")) {
      scanf("%d",&x);
      l.push_front(x);
    } else if (!strcmp(com,"delete")) {
      scanf("%d",&x);
      for (list<int>::iterator it=l.begin(); it!=l.end(); it++) {
        if (*it==x) {
          l.erase(it);
          break;
        }
      }
    } else if (!strcmp(com,"deleteFirst")) {
      l.pop_front();
    } else if (!strcmp(com,"deleteLast")) {
      l.pop_back();
    }
  }
  for (list<int>::iterator it=l.begin(); it!=l.end(); it++) {
    cout<<(it!=l.begin()?" ":"")<<*it<<flush;
  }
  cout<<endl;
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
      cin >> h.at(i);
  }
  
  vector<int> DP(N);
  DP[0] = 0;
  DP[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; i++) {
    int h0 = h[i];
    int h1 = h[i-1];
    int h2 = h[i-2];
    DP[i] = min(DP[i-1]+abs(h1-h0), DP[i-2]+abs(h2-h0));
  }
  cout << DP[N-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1;
    cin>>s1;
    string s2=s1;
    reverse(s1.begin(),s1.end());
    for(int i=0;i<s1.size();++i)
    {
        if(s1[i]=='b') s1[i]='d';
        else if(s1[i]=='d') s1[i]='b';
        else if(s1[i]=='p') s1[i]='q';
        else if(s1[i]=='q') s1[i]='p';
    }
    if(s1==s2) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll a, b, x;
string str;

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

Measured memory_bytes: 256
/*
    なせば大抵なんとかなる！
*/

#define VERNIY st();int ver=0,niy=0

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vpLL vector<pair<long long int,long long int>>
#define vLLU vector<unsigned long long int>
#define vpLLU vector<pair<unsigned long long int,unsigned long long int>>
#define pd pair<int,int>
#define pLL pair<long long int,long long int>
#define pLLU pair<unsigned long long int,unsigned long long int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define maxpqd priority_queue<int>
#define minpqd priority_queue<int, vector<int>, greater<int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forineq(a,b,c) for(int a=b ; a<=c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}
inline void scllu(LLU &a){scanf("%I64u",&a);}
inline void scdllu(LLU &a,LLU &b){scanf("%I64u %I64u",&a,&b);}
inline void sctllu(LLU &a,LLU &b,LLU &c){scanf("%I64u %I64u %I64u",&a,&b,&c);}

template<class Ver>
inline void prd(Ver a){cout<<a<<endl;};
template<class Ver>
inline void prdd(Ver a,Ver b){cout<<a<<" "<<b<<endl;};
template<class Ver>
inline void prtd(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<endl;};

inline void debug(){printf("asd\n");}
template<class Ver>
inline void debugd(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debugdd(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debugtd(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
	int a[200005];
	scd(ver);
	forin(i,0,ver)
	scd(a[i]);
	sort(a,a+ver);
	prd(a[ver-1]-a[0]);

	return 0;
}


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

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

double yukidama(double a, double b){

  return pow(pow(a,3.0)+pow(b,3.0),1.0/3.0);
}

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> bsum(N+1,0);
  vector<int> wsum(N+1,0);
  rep(i,N){
    if(S[i]=='#'){
       bsum[i+1]=1+bsum[i];
       wsum[i+1]=wsum[i];
    }
    else{
       bsum[i+1]=bsum[i];
      wsum[i+1]=1+wsum[i];
    }
  }
  int tmp;
  int ans=N;
  rep(i,N+1){
    tmp=bsum[i]+wsum[N]-wsum[i];
    ans=min(ans,tmp);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int n;
    int m = 0;
    cin >> n;
    
    vector<int> a(n+1, 0);
    vector<int> b(n+1, 0);
    vector<int> c;
    
    for(int i = 1; i <= n; i++){
      int tmp;
      cin >> tmp;
      a[i] = tmp;
    }

    for(int i = n; i > 0; i--){
      int sum = 0;
      for(int j = 2; i * j <= n; j++){
        sum += b[i * j];
      }
      if(a[i] == sum % 2){
        b[i] = 0;
      }else if(a[i] == (sum + 1) % 2){
        b[i] = 1;
        m++;
        c.push_back(i);
      }else{
        cout << "-1" << endl;
        return 0;
      }
    }

    cout << m << endl;
    for(int i = 0; i < m; i++){
      cout << c[i] << " ";
    }

    return 0;
}


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

using namespace std;

int main(){
    int r,d,old_x,new_x;
    cin >> r >>d >> new_x;
    for(int i=0; i<10;i++){
        old_x = r*new_x-d;
        cout << old_x << endl;

        new_x = old_x;

    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	while(true){
	int goukei;
	cin >> goukei;
	if(goukei == 0){
		break;
	}
	for(int i = 0; i < 9; i++){
		int a;
		cin >> a;
		goukei = goukei - a;
	}
	cout << goukei << endl;
	}
	return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int N;
bool odd;
vii edges;

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> N;
	if (N & 1)
		odd = true, N--;
	for (int i = 1; i <= N; ++i)
		for (int j = i + 1; j <= N; ++j)
			if (i != N + 1 - j)
				edges.pb(mp(i, j));
	if (odd)
		for (int i = 1; i <= N; ++i)
			edges.pb(mp(N + 1, i));
	cout << sz(edges) << '\n';
	for (auto& edge : edges)
		cout << edge.fs << ' ' << edge.sc << '\n';
	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define Modulo 1000000007ll

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

int D,G;
vpii v1;

ll f(int D,ll G)
{
    //cout << D << " " << G << " ";
    if(G<=0ll)
        return 0;
    if(D<=0)
        return INT_MAX;
    else
    {
        if(G >= v1[D-1].fi*(100*(D)))
        {
            ll x = G - v1[D-1].se - v1[D-1].fi*(100*(D));
//            cout << x << " ";
//            cout << "if\n";
            return min(ll(v1[D-1].fi + f(D-1,x)),ll(f(D-1,G)));
        }
        else
        {
            if(G%(100*(D)) == 0)
            {
                //cout << "else-if\n";
                return min(G/(100ll*(D)),ll(f(D-1,G)));
            }
            else
            {
               // cout << "else-else\n";
                return min(1 + (G/(100*(D))),ll(f(D-1,G)));
            }
        }
    }
}

void init()
{
    cin >> D >> G;
    int x,y;
    rep(i,0,D)
    {
        cin >> x >> y;
        v1.pb({x,y});
    }
    cout << f(D,G);
}

int main()
{
    clock_t time1 = clock();
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll ans = ((n - 1) / min({a, b, c, d, e})) + 5;
    cout << ans << endl;
}


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

using namespace std;

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

  long long int a, b;
  a = b = (long long int)ceil(sqrt((long double)s));

  long long int rs = a*b-s;
  long long int c = 0, d = 0;
  for (long long int i = 1; i*i <= rs; ++i) {
    if (rs%i == 0 && rs/i < 1000000000) {
      c = i;
      d = rs/i;
      break;
    }
  }

  cout << 0 << " " << 0 << " " << a << " " << c << " " << d << " " << b << " " << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool flag;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			flag=true;
		}
		if(s[i]=='F'&&flag==true)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define INF 100000000000000000
using namespace std;

typedef vector<vector<ll> > graph;
graph dist;
int flag = 1;
vector<int> len;

void warshall_floyd(int n){
  for(int i = 0; i < n; i++){ //経由する頂点
    for(int j = 0; j < n; j++){ //開始頂点
      for(int k = 0; k < n; k++){ //終端
        if(dist[j][i] != INF && dist[i][k] != INF) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
      if(dist[j][j] < 0) flag = 0; //dist[j][j]が負 = 負の回路がある
    }
  }
}

int main(){

  int v, e, r, l;
  cin >> v >> e >> r;
  for(int i = 0; i < r; i++){
    cin >> l;
    l--;
    len.push_back(l);
  }

  sort(len.begin(), len.end());
  dist = graph(v, vector<ll>(v, INF));
  for(int i = 0; i < v; i++) dist[i][i] = 0;

  int from, to;
  ll cost;
  for(int i = 0; i < e; i++){
    cin >> from >> to >> cost;
    from--, to--;
    dist[from][to] = min(dist[from][to], cost);
    dist[to][from] = min(dist[from][to], cost);
  }
  ll ans = INF;
  warshall_floyd(v);
  do{
    ll sum = 0;
    for(int i = 1; i < r; i++){
      sum += dist[len[i-1]][len[i]];
    }
    ans = min(ans, sum);
  }while(next_permutation(len.begin(), len.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
  "fmt"
)

func main() {
  var N, Y int
  fmt.Scan(&N, &Y)

  flag := true
  for i := 0; i <= N; i++ {
    for j := 0; j <= N; j++ {
      th := (Y - 10000*i - 5000*j)/1000
      if (Y - 10000*i - 5000*j)%1000 == 0 && i + j + th == N  && th >= 0 {
        fmt.Println(i, j, th)
        flag = false
        break
      }
    }
    if !(flag) {
      break
    }
  }

  if flag {
    fmt.Println(-1, -1, -1)
  }

}


Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int min=100001;
    for(int i=1; i<N; i++){
      
      int sum=0;
      int A = i;
      while(A>0){
        sum += A % 10;
        A = A / 10;
      }
      
      int B = N - i;
      while(B>0){
        sum += B % 10;
        B = B / 10;
      }
      min = Math.min(min,sum);
    }
    
    System.out.println(min);
  }
}
    
      
      
    
  

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
vvi g;

bool matched[100010];

bool dfs(int cur,int pre){
    if(g[cur].size()==1 && pre!=-1){
        if(matched[pre]) return false;
        else{
            matched[pre] = matched[cur] = true;
            return true;
        }
    }

    for(int v : g[cur]) if(v != pre){
        if(!dfs(v,cur)) return false;
    }

    if(!matched[cur]){
        if(pre==-1 or matched[pre]) return false;
        else{
            matched[cur] = matched[pre] = true;
            return true;
        }
    }
    return true;
}

int main(){
    cin >> N;
    g = vvi(N,vi());
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    if(dfs(0,-1)){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    string L=S,R=S;
    int ans=0;
    int ar=0,al=0;
    char c;
    for(int i=0;i<S.size();i++){
        if(i==0){
            c=R[i];
        }
        else{
            if(c==R[i]){
                R[i]=(c=='0')?'1':'0';
                ar++;
            }
            c=R[i];
        }
    }
    string M=S;
    int am=0;
    for(int i=0;i<S.size();i++){
        if(i==0){
            c=(M[i]=='0')?'1':'0';
            am++;
        }
        else{
            if(c==M[i]){
                M[i]=(c=='0')?'1':'0';
                am++;
            }
            c=R[i];
        }
    }
    for(int i=0;i<S.size();i++){
        if(i==0){
            c=L[N-i-1];
        }
        else{
            if(c==L[N-1-i]){
                L[N-1-i]=(c=='0')?'1':'0';
                al++;
            }
            c=L[N-1-i];
        }
    }
    cout << min(al,ar) << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
public static void main(String[] args) {
	try(Scanner sc = new Scanner(System.in)){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
	
	if(a < b)
		if(b < c)
			System.out.println("Yes");
		else
			System.out.println("No");
	else
		System.out.println("No");
	
	}
}
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			if(10000*i+5000*j+1000*(n-i-j)==y){
				cout<<i<<" "<<j<<" "<<n-i-j<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

inline int add(int a, int b)
{
	return ((ll)a+b+modn)%modn;
}

inline int mul(int a, int b)
{
	return ((ll)a*b)%modn;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	vector<vector<int>> adj(n);
	vector<vector<int>> dp(n, vector<int>(2));
	assignVV(dp, -1);
	for(int i=0; i<n-1; i++) {
		int x, y;
		cin>>x>>y;
		x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	function<int(int, int, int)> solve = [&](int u, int pr, int c)
	{
		if(dp[u][c]!=-1) return dp[u][c];
		int ans1=1;
		int ans2=1;
		for(int v:adj[u]) {
			if(v==pr) continue;
			if(c==0) {
				int tmp1=solve(v, u, 0);
				int tmp2=solve(v, u, 1);
				ans1=mul(ans1, tmp1);
				ans2=mul(ans2, tmp2); 
			}
			else if(c==1) {
				int tmp=solve(v, u, 0);
				ans1=mul(ans1, tmp);
			}
		}
		
		return dp[u][c]=(c?ans1:add(ans1, ans2));
	};
	cout<<solve(0, -1, 0)<<"\n";
    return 0;
}



Measured memory_bytes: 25088
#include<stdio.h>
int main(void)
{
    int i;
    int n;
    int cnt=0;
    long int a[10000];
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
        while(a[i]%2==0){
            a[i]=a[i]/2;
            cnt++;
        }
    }
    printf("%d",cnt);
    
    return 0;
    
}


Measured memory_bytes: 256
from sys import stdin,stdout
input=stdin.buffer.readline

ip=[int(x) for x in input().split()]
a=ip[0]
b=ip[1]
n=ip[2]
if n<b:
	print(((a*n)//b)-a*(n//b))
else:
	x=n-(n%b)-1
	a1=((a*n)//b)-a*(n//b)
	a2=((a*x)//b)-a*(x//b)
	print(max(a1,a2))

Measured memory_bytes: 9204
n,y = map(int,input().split())
for i in range(n+1):
  for j in range(n+1):
    k=n-(i+j)
    if y==10000*i + 5000*j + 1000*k and k>=0:
      print(i,j,k)
      exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#AOJのコース用からJOI2006用に編集
import math
n=int(input())
L=input().split( )
x=int(L[0])
y=int(L[1])
if n==3:
    z=int(L[2])
if x<y:
    w=x
    x=y
    y=w

while x%y!=0:
    w=y
    y=x%y
    x=w

if n==3:
    if z<y:
        w=z
        z=y
        y=w

    while z%y!=0:
        w=y
        y=z%y
        z=w

sup=int(math.sqrt(y))
Common=[]
Common2=[]
for i in range(sup):
    if y%(i+1)==0:
        Common.append(i+1)
        Common2.append(int(y/(i+1)))
l=len(Common)
for j in range(l):
    Common.append(Common2[l-j-1])

if int(y/sup)*sup==y and int(y/sup)==sup:
    del Common[l-1]

l=len(Common)
for j in range(l):
    print(Common[j])



Measured memory_bytes: 5680
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int N = 3;
constexpr int INF = 1000000000 + 8;

bool isTakahashiTrue(array<int, N> &a, array<array<int, N>, N> &c)
{
    array<int, N> b;
    b.fill(INF);

    bool can = true;

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
        {
            if (b[j] == INF)
                b[j] = c[i][j] - a[i];

            if (a[i] + b[j] != c[i][j])
                can = false;
        }

    return can;
}

bool tryAllA(array<array<int, N>, N> &c)
{
    array<int, N> a = {};

    bool can = false;

    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100; j++)
        {
            for (int k = 0; k <= 100; k++)
            {
                a = {i, j, k};
                can |= isTakahashiTrue(a, c);
            }
        }
    }

    return can;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    array<array<int, N>, N> c;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> c[i][j];

    bool ans = tryAllA(c);

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>




int main(void){
int h,w;

for(;;){
    scanf("%d %d",&h,&w);
    if(h==w&&h==0){break;}

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0||(i==h-1)||((i!=0&&i!=h-1)&&(j==0||j==w-1))){printf("#");}
            else{printf(".");}
        }
        printf("\n");
    }
    printf("\n");
}



return 0;
}



Measured memory_bytes: 2056
S=list(map(int,input()))

ans1=0
for i in range(0,len(S),2):
  if S[i]==1:
    ans1+=1
for i in range(1,len(S),2):
  if S[i]==0:
    ans1+=1

ans2=0
for i in range(0,len(S),2):
  if S[i]==0:
    ans2+=1
for i in range(1,len(S),2):
  if S[i]==1:
    ans2+=1

print(min(ans1,ans2))


Measured memory_bytes: 9956
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define REP(i,a,b) for(int i = a ; i <= b ; ++i) 
# define Rep(i,a,b) for(int i = a ; i < b ; ++i) 
# define Rrep(i,a,b) for(int i = b ; i >= a ; --i) 
# define FOR(i,b) for(int i = 0 ; i <= b ; ++i)
# define For(i,b) for(int i = 0 ; i < b ; ++i)
# define Rfor(i,b) for(int i = b ; i >= 0 ; --i)

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

void pe(int a) { cout << a << "\n" ; }
void pe(ll a) {	cout << a << "\n" ; }
void pe(string a) {	cout << a << "\n" ; }
void ps(int a) { cout << a << ' ' ; }
void ps(string a) {	cout << a << " " ; }
void ps(ll a) {	cout << a << " " ; }
template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353 ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}
ll power(ll a , ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
			res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res%MOD;
}

const ll inf = 1e18 ; 
const int MxN = 300005; 
const ll mod = 1e9+7 ; 

vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============

void solve() {
	

}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 	
	ll n ,a ,b ; 
	cin >> n >> a >> b ; 
	if(b < a) {
		cout << 0 ; 
		return 0 ; 
	}
	if(n==1) {
		if(a==b) {
			cout << 1 ; 
		} else {
			cout << 0 ; 
		}
		return 0; 
	}

	ll minsum = (n-1)*a+b ; 
	ll maxsum = (n-1)*b+a;
	cout << maxsum - minsum + 1 ; 


	cerr <<"\nTime : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
	return 0 ; 
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n;
  cin >> n;
  ll d;
  cin >> d;
  d = d * d;
  int ans = 0;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
using namespace std;

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

    double arr[n];

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

    //create the dp table
    double dp[2][n+1];

    memset(dp, 0, sizeof(dp));

    //maintain the track of row being computed
    int row = 0;//this is the total

    while(row<n+1){
        if(row==0){
            dp[0][0]=1;
        }
        else if(row%2==0){
            for(int i=0; i<n+1; i++){
                dp[0][i] = dp[1][i]*(1-arr[row-1])+dp[1][i-1]*(arr[row-1]);
            }
        }
        else{
            for(int i=0; i<n+1; i++){
                dp[1][i] = dp[0][i]*(1-arr[row-1])+dp[0][i-1]*(arr[row-1]);
            }
        }
        row++;
    }
    //at the end...the 1st row contains the answers
    //sum the probs with required contsraints
    double res = 0;
    for(int j=(n/2)+1; j<n+1; j++){
        res+=dp[1][j];
    }
    printf("%.10f\n", res);
}

Measured memory_bytes: 384
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$a[] = array_map('intval',explode(" ",trim(fgets(STDIN))));

if (str_replace("hi","",$S)=="") {
  printf("Yes\n");
}
else {
  printf("No\n");
}


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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
           
        void solve(){
            cin >> n;
            int cnt = 0;
            for(ll i=1; i<n;i++){
                for(ll j = 1; j<n;j++){
                    if(i*j < n) cnt++;
                    else break; 
                }
            }
            cout << cnt << endl;
        }

      
 
        int main(){
            ios_base::sync_with_stdio(false);

            
         

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(){
  long long L[87],N;
  L[0]=2;L[1]=1;
  cin >> N;
  for(int i=2;i<=N;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout << L[N] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,n1,n2,n3;
  
  do{
    scanf("%d",&n);
  }while(n<100 || n>999);
  
  n1 = n/100;
  n = n%100;
  n2 = n/10;
  n = n%10;
  n3 = n;
  
  if(n1 == 7 || n2 == 7 || n3 == 7){
    printf("Yes");
  }
  else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[200000];
int main(){
	cin >> s;
	int n = strlen(s);

	REP(i,n - 1) {
		if(s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	REP(i,n - 2) {
		if(s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


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

int calc(string a, string b) {
    int n = a.size();
    b += b + b;
    vector<int> sum(3*n+1, 0);
    for (int i = 0; i < 3*n; i++) {
        sum[i+1] = sum[i] + (b[i] == '1');
    }
    int ret = 1e9;
    for (int i = 0; i <= n; i++) {
        vector<int> v;
        for (int j = 0; j < n; j++) {
            if (a[j] != b[i+j]) v.emplace_back(j);
        }
        if (v.empty()) {
            ret = min(ret, n - i);
            continue;
        }
        auto right = [&](int j) {
            int l = -1; int r = n;
            while (r - l > 1) {
                int m = (l + r) / 2;
                if (sum[n+j+1+m] - sum[i+j] == 0) l = m;
                else r = m;
            } 
            return r;
        };
        auto left = [&](int j) {
            int l = 0; int r = i+1;
            while (r - l > 1) {
                int m = (l + r) / 2;
                if (sum[n+j+1] - sum[m+j] == 0) r = m;
                else l = m;
            }
            return i - l;
        };
        vector<pair<int, int>> s;
        for (auto &x: v) {
            s.emplace_back(left(x), right(x));
        }
        sort(s.rbegin(), s.rend());
        int maxi = 0, tmp = 1e9;
        for (int i = 0; i < s.size(); i++) {
            tmp = min(tmp, maxi + s[i].first);
            maxi = max(maxi, s[i].second);
        }
        tmp = min(tmp, maxi) * 2 + n - i + v.size(); 
        ret = min(ret, tmp);
    }
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a, b; cin >> a >> b;
    if (a == b) {
        cout << 0 << "\n";
        return 0;
    }
    string d = b;
    sort(d.begin(), d.end());
    if (d.back() == '0') {
        if (a == b) cout << 0 << "\n";
        else cout << -1 << "\n";
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] != b[i]) {
            if (b[i] == '0') {
                ans = 1e9; break;
            } else {
                ans++;
            }
        }
    }
    ans = min(ans, calc(a, b));
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    ans = min(ans, calc(a, b));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

char s[10];

int main()
{
    scanf("%s",s);
    bool a=0,b=0;
    for (int i=0;i<3;i++) if (s[i]=='A') a=1;
    else b=1;
    if (a&b) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(void)
{
    long long x, k, d, m, y;
    m = 0;
    cin >> x >> k >> d;
    y = abs(x);
    if (y > 0)
    {
        /*      while ((y - (m + 1) * d) > 0 && m < k)
        {
            m++;
        }
        */
        m = min(k, y / d);
        if ((k - m) % 2 == 0)
        {
            cout << abs(y - m * d) << endl;
        }
        else
        {
            cout << abs(y - (m + 1) * d) << endl;
        }
        return 0;
    }
    if (y == 0)
    {
        if (k % 2 == 1)
        {
            cout << d << endl;
        }
        else
        {

            cout << "0" << endl;
        }
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
ans = n
for i in range(n + 1):
  cc = 0
  t = i
  while t > 0:
    cc += t % 6
    t //= 6
  t = n - i
  while t > 0:
    cc += t % 9
    t //= 9
  ans = min(ans, cc)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public 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 D = sc.nextInt();
    int sum = 0;

    if (A < B) {
      sum = A;
    } else {
      sum = B;
    }

    if (C < D) {
      sum = sum + C;
    } else {
      sum = sum + D;
    }
    
    System.out.println(sum);

  }
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    bool flag = true;
    cin >> N;
    if (N < 10)
    {
        cout << N << endl;
        return 0;
    }
    int x = 0;
    while (N >= 10)
    {
        x++;
        if (N % 10 != 9)
            flag = false;
        N = N / 10;
    }
    if (flag == true)
    {
        cout << (x * 9) + N << endl;
        return 0;
    }
    cout << (x * 9) + N - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n;
void solve(){
	cin>>n;
	cout<<3*n*n;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

int main() {

	int n, k;
	cin >> n >> k;
	// Cost to jump to stone i
	vector<int> cost(n);
	for (int &x : cost) {
		cin >> x;
	}

	// The shortest cost path to stone i is stored in dp[i]
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		// now, arbitrarily sized paths

		for (int j = 1; j <= k && i - j >= 0; ++j) {
			dp[i] = min(dp[i],
				    dp[i - j] + abs(cost[i - j] - cost[i]));
		}
	}

	cout << dp[n - 1];

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	ll k,a,b;
	cin>>k>>a>>b;
	if(a%k==0||b%k==0||b/k-a/k!=0)
	{
		cout<<"OK"<<endl;
	}
	else
	{
		cout<<"NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int N = readln.chomp.to!int;
    foreach(i; 0..N) {
        int k, p;
        readf("%d %d\n", &k, &p);
        writeln(k%p==0 ? p:k%p);
    }
}

Measured memory_bytes: 2500
s=input()

cnt=0
ans=0
for i in range(len(s)):
    if s[i]=='g':
        if cnt>0:
            ans+=1
            cnt-=1
        elif cnt==0:
            cnt+=1
    else:
        if cnt==0:
            ans-=1
            cnt+=1
        else:
            cnt-=1
print(ans)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		
		Student[] students = new Student[n];
		for(int i = 0; i < n; i++) {
			students[i] = new Student(i + 1, Integer.parseInt(tmpArray[i]));
		}
		
		Arrays.sort(students);
		
		for(int i = 0; i < n; i++) {
			System.out.print(students[i].id);
			
			if(i != n - 1) {
				System.out.print(" ");
			}
		}
		
		System.out.println();
	}

}

class Student implements Comparable<Student> {
	int id;
	int time;
	
	Student(int id, int time) {
		this.id = id;
		this.time = time;
	}

	@Override
	public int compareTo(Student s) {
		// TODO Auto-generated method stub
		return this.time - s.time;
	}
	
	
}

Measured memory_bytes: 53808
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int m=read(),d=read(),ans=0;
	For(i,4,m){
		For(j,10,d){
			int x=j/10,y=j%10;
			if (x>=2&&y>=2&&x*y==i) ++ans;
		}
	}
	printf("%d\n",ans);
}

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

typedef long long int64;
int a[3], n;
int64 dp[5005];

int main() {
	scanf("%d%d%d%d", &a[0], &a[1], &a[2], &n);

	dp[0] = 1;
	for(int i = 0; i < 3; i++) {
		for(int k = 1; k <= n; k++) {
			if(k >= a[i])
				dp[k] += dp[k - a[i]];
		}
	}

	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
const int Max=0x7fffffff;
const int P=1000000007;
using namespace std;
int main()
{
    int h,w,c[8][2]={{0,1},{0,-1},{1,1},{1,-1},{1,0},{-1,1},{-1,0},{-1,-1}};
    char a[51][51],b[51][51];
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
    {
        scanf("%s",&a[i]);
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='#'){b[i][j]='#';continue;}
            int l=0;
            for(int k=0;k<8;k++)
            {
                int x=i+c[k][0];
                int y=j+c[k][1];
                if(a[x][y]=='#')l++;
            }
            b[i][j]='0'+l;
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cout<<b[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = [0] + gets.split.map(&:to_i) + [0]

sum = 0
(n+1).times do |i|
    sum += (a[i] - a[i+1]).abs
end

n.times do |i|
    puts sum - (a[i+1] - a[i]).abs - (a[i+2] - a[i+1]).abs + (a[i+2] - a[i]).abs
end

Measured memory_bytes: 14596
N = int(input())
A = [int(a) for a in input().split()]

maximum = 0
minimum = 0
used = [0]*9
for i in A:
    i //= 400
    if i >= 8:
        maximum += 1
    elif used[i] == 0:
        maximum += 1
        minimum += 1
        used[i] = 1
if minimum == 0:
    minimum += 1
print(minimum, maximum)


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    int count = 0;
    for(int i=0;i<N-2;i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
        count++;
        }
    }

    cout << count <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		while ((n = in.nextInt()) > 0) {
			boolean[][] map = new boolean[n][n];
			int[] fnum = new int[n];
			int[][] ffnum = new int[n][n];
			int fcount = 0;
			int[] ffcount = new int[n];
			int m = in.nextInt();
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				if (a == 0) {
					fnum[fcount] = b;
					fcount++;
				} else {
					ffnum[a][ffcount[a]] = b;
					ffcount[a]++;
					ffnum[b][ffcount[b]] = a;
					ffcount[b]++;
				}
				map[a][b] = true;
				map[b][a] = true;
			}
			int count = fcount;
			for (int i = 0; i < fcount; i++) {
				int id = fnum[i];
				for (int j = 0; j < ffcount[id]; j++) {
					int fid = ffnum[id][j];
					if (!map[0][fid]) {
						count++;
					}
					map[0][fid] = true;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 46116