akhauriyash/Code-Regression huggingface dataset:
#エストラテネスの篩
def isPrime():
    MAX = 10**5
    is_prime = [1] * (MAX+1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, MAX+1):
        if is_prime[i]:
            for j in range(i*2, MAX+1, i):
                is_prime[j] = 0
    return is_prime

N = int(input())

p = isPrime()
a = []
for i in range(55556):
    if p[i]:
        if i % 5 == 1:
            a.append(i)

print(*a[:N])


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, ans = 0;
  cin >> n;
  int x = 0, y = 0, e = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int i = 0; i + 1 < s.size(); i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') {
        ans++;
      }
    }
    if (s[0] == 'B' && s.back() == 'A') e++;
    else if (s[0] == 'B') x++;
    else if (s.back() == 'A') y++;
  }
  //cout << ans << ' ' << x << ' ' << y << endl;
  if (x == 0 && y == 0) {
    cout << ans + max(0, e - 1) << endl;
  } else if (x == 0 || y == 0) {
    cout << ans + e << endl;
  } else {
    cout << ans + min(x, y) + e << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P{
  int lx,ly;
  int rx,ry;
  bool f;                       // f : ツ篠淞右ツ堕ォ(0) ツ債カツ堕ォ(1)
  int dis;
  P(int lx,int ly,int rx,int ry, bool f, int dis):lx(lx),ly(ly),rx(rx),ry(ry),f(f),dis(dis) {}
};

const bool operator<(const P &a, const P &b) {
  return a.dis > b.dis;
}

const int dx[9] = {1,1,1,1,1,2,2,2,3};
const int dy[9] = {-2,-1,0,1,2,-1,0,1,0};

int dist[30][60][30][60][2];
int main() {
  int w,h;
  while(cin>>w>>h,w||h) {
    char ba[w][h];
    priority_queue<P> Q;
    REP(y,h) {
      REP(x,w) {
        cin >> ba[x][y];
        if (ba[x][y] == 'S') {
          Q.push(P(x,y,x,y,0,0));
          Q.push(P(x,y,x,y,1,0));
        }
      }
    }
    
    REP(i,w)REP(j,h)REP(k,w)REP(l,h)REP(m,2)dist[i][j][k][l][m] = INF;
//    memset(visited,0,sizeof(visited));
    int res = -1;
    while(!Q.empty()) {
      P p = Q.top();
      Q.pop();
      if (dist[p.lx][p.ly][p.rx][p.ry][p.f] < p.dis) continue;

      //printf("%d,%d,%d,%d\n",p.lx,p.ly,p.rx,p.ry);
      if (ba[p.lx][p.ly] == 'T' || ba[p.rx][p.ry] == 'T') {
        res = p.dis;
        break;
      }
      REP(k,9) {
        if (p.f) {                // ツ債カツ堕ォ
          int xx = p.rx - dx[k];
          int yy = p.ry + dy[k];
          if (xx<0||xx>=w||yy<0||yy>=h)continue;
          //printf("ssdfsdf\n");
          if (ba[xx][yy] == 'X') continue;
          int hoge = 0;
          if (isdigit(ba[xx][yy])) 
            hoge = ba[xx][yy] - '0';
          if (dist[xx][yy][p.rx][p.ry][0] > p.dis + hoge) {
            dist[xx][yy][p.rx][p.ry][0] = p.dis + hoge;
            Q.push(P(xx,yy,p.rx,p.ry,0,p.dis+hoge));
          }
        } else {
          int xx = p.lx + dx[k];
          int yy = p.ly + dy[k];
          if (xx<0||xx>=w||yy<0||yy>=h)continue;
          if (ba[xx][yy] == 'X') continue;
          int hoge = 0;
          if (isdigit(ba[xx][yy])) 
            hoge = ba[xx][yy] - '0';
          if (dist[p.lx][p.ly][xx][yy][1] > p.dis + hoge) {
            dist[p.lx][p.ly][xx][yy][1] = p.dis + hoge;
            Q.push(P(p.lx,p.ly,xx,yy,1,p.dis+hoge));
          }
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 25000
n, m = map(int, input().split())
s = [0] * (n + 2)
s[0] = 1
s[1] = 1
for i in range(m):
    a = int(input())
    s[a] = -1

for i in range(2, n + 1):
    if s[i] < 0:
        continue
    if s[i - 2] > 0:
        s[i] += s[i - 2]
    if s[i - 1] > 0:
        s[i] += s[i - 1]
print(s[n] % 1000000007)


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if ( s == u ) {
        cout << a-1 << " " << b << endl;
    } else if ( t == u ) {
        cout << a << " " << b-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool ans = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            ans = true;
        }
    }
    cout << (ans ? "OK" : "NG") << endl;
    return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#define mp make_pair
#define pb push_back
#define mst(a,b)  memset((a),(b),sizeof (a))
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf=1e8;
const int maxn=1e5+100;
const int mod=1e9+7;
int a[120];int ord[120];
char use[]={'+','-'};
void dfs(int cur,int ans){
    if(cur>=4){
        if(ans==7){
            for(int i=1;i<4;++i)cout<<a[i]<<use[ ord[i] ];
            cout<<a[4]<<"=7";
            exit(0);
        }
        return;
    }
    ord[cur]=0;
    dfs(cur+1,ans+a[cur+1]);
    ord[cur]=1;
    dfs(cur+1,ans-a[cur+1]);
}
int main() {
#ifdef local
//    freopen("in.txt", "r", stdin);
#endif
    string u;cin>>u;
    for(int i=0;i<4;++i)a[i+1]=u[i]-'0';
    dfs(1,a[1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n;
	cin>>n;
	cout<<(!n)<<endl;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

const int max = 2*100000;
int cul(int N);
int per10(int X);
int main(){
  int N,ans;
  cin >> N;
  ans = cul(N);
  cout << ans;
  return 0;
}
int cul(int N){
  int count = 0,t1,t2;
  int NUMs[91];//10~90まで
  for(int i = 0;i<91;i++){
    NUMs[i] = 0;
  }
  for(int i = 1;i <= N;i++){
    if(i%10 == 0)continue;
    t1 = (per10(i)*10+i%10)-10;
    t2 = (per10(i)+(i%10)*10)-10;
    NUMs[t1] += 1;
    count += NUMs[t2]*2;
    if(t1 == t2) count--;;
  }
  return count;
}
int per10(int X){
  while(X > 9){
    X/=10;
  }
  return X;
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int s;
	cin >> s;
	set<int> conj;
	int i = 1;
	while (!conj.count(s)) {
		conj.insert(s);
		i++;
		s = s%2 ? s*3+1 : s/2;
	}
	cout << i << ende;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 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())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(T a){
	cout << a << '\n';
}
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int n;
set<string>ans;
void rec(string str, char ch){
	int ps = -1;
	vector<int>ot;
	rep(i,str.size()){
		if(str[i] == 'A'){
			if(ps == -1) ps = i;
			else ot.pb(i);
		}
	}
	if(ps == -1){
		ans.insert(str); return ;
	}
	else{
		str[ps] = ch;
		int sz = ot.size(); //cout << sz << endl;
		rep(m,(1<<sz)){
			rep(j,sz){
				if(((m>>j)&1)) str[ot[j]] = ch;
			}
			rec(str,ch+1);
			rep(j,sz){
				if(((m>>j)&1)) str[ot[j]] = 'A';
			}
		}
	}
}
int main(){
	g(n);
	string s;
	s.resize(n, 'A');
	rec(s, 'a');
	for(auto at:ans) o(at);
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n][3];
    rep(i, 0, n) {
        rep(j, 0, 3) {
            cin >> a[i][j];
        }
    }
    int dp[n + 1][3] = {};
    rep(i, 1, n + 1) {
        rep(j, 0, 3) {
            rep(k, 0, 3) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);
            }
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

const ll PrimeMax = 1005;
int is_prime[PrimeMax],K = 0;
vector<int> v;
ll a,b;
void Eratosthenes(){
  for(int i = 0; i < PrimeMax; i++){
    is_prime[i] = 1;
  }
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i < a+1 ; i++){
    if(is_prime[i]){
      v.emplace_back(i);
      ++K;
      for(int j = 0; i * (j + 2) < a+1; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a;
  Eratosthenes();
  map<int,int> m;
  ll c = 1,d = 1;
  for(int j = 0; j < v.size();++j){
    d = v[j];
    while( a >= d){
      m[v[j]] += a / d;
      d *= v[j];
    }
  }
  for(auto &&n :m){
    /* cout << n.fi << ',' << n.se << endl; */
    c = c % mod * (n.se + 1) %mod;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S, T, U;
  cin >> N >> S >> T;
  
  for (int i = 0; i < 2*N; i++)
  {
  	if (i % 2 == 0) U[i] = S[i/2];
    else U[i] = T[i/2];
    cout << U[i];
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
T_1, T_2 = map(int, input().split())
A_1, A_2 = map(int, input().split())
B_1, B_2 = map(int, input().split())
ans = 0
if T_1 * A_1 + T_2 * A_2 == T_1 * B_1 + T_2 * B_2:
    print("infinity")
else:
    # 速いほうをＡと仮定
    if T_1 * A_1 + T_2 * A_2 < T_1 * B_1 + T_2 * B_2:
        A_1, A_2, B_1, B_2 = B_1, B_2, A_1, A_2
    if A_1 < B_1:
        sa_12 = T_1 * A_1 + T_2 * A_2 - (T_1 * B_1 + T_2 * B_2)  # 1サイクルでできる差
        sa_1 = -T_1 * A_1 + T_1 * B_1  # T_1でできる差
        if sa_1 % sa_12 == 0:
            ans = int((sa_1 / sa_12)*2)
        else:
            kari = math.ceil(sa_1 / sa_12)
            ans = (kari-1)*2+1
    print(ans)


Measured memory_bytes: 3064
// --------------
// Tejas Pandey  |
// 19 - 06 - 20  |
// Atcoder BC 171|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll cnt[100007];
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  ll a[n],xo = 0;
  for(int i = 0;i < n;i++) cin >> a[i],xo ^= a[i];
  for(int i = 0;i < n;i++) cout << (a[i]^xo) << " ";
  return 0;
}


Measured memory_bytes: 5168
import math

a, b, h, m = map(int, input().split())

m += h * 60

num_a = m * 0.5
num_b = m * 6 % 360

theta = abs(num_a - num_b)
rad = math.radians(theta)

ans = a**2 + b**2 - (2*a*b*math.cos(rad))
print(math.sqrt(ans))

Measured memory_bytes: 9576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  string s;cin >> s;
  bool fa=false, fb = false, fc = false;
  for(int i = 0; i < 3; ++i){
    if(s[i]=='a')fa= true;
    if(s[i]=='b')fb= true;
    if(s[i]=='c')fc= true;
  }
  string ans = "No";
  if(fa&&fb&&fc)ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	var s string
	fmt.Scan(&a, &b, &s)
	if len(s) == a+b+1 {
		if s[a] == '-' {
			for i := 0; i < len(s); i++ {
				if i != a && s[i] == '-' {
					fmt.Println("No")
					return
				}
			}
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N), P(N);
    for (int i = 0; i < N; ++i)cin >> X[i] >> Y[i];

    // 初期値
    for (int i = 0; i < N; ++i) P[i] = i;
    int cnt = 0;
    double d = 0.0;
    do {
        for (int i = 0; i < N - 1; ++i) {
            int s = P[i], t = P[i + 1];
            double tmp = (X[s] - X[t]) * (X[s] - X[t]) + (Y[s] - Y[t]) * (Y[s] - Y[t]);
            d += sqrt(tmp);
        }
        ++cnt;
    } while (next_permutation(P.begin(), P.end()));

    printf("%.8f\n", d / cnt);
    //cout << d / cnt << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 13 15:44:15 2018
ABC048D
@author: maezawa
"""

s = input()

n = len(s)
n0 = s.count(s[0])
n1 = s.count(s[-1])

if s[0] == s[-1]:
    if (n-2*n0+1)%2 != 0:
        print('First')
    else:
        print('Second')
elif (n-2*min(n0,n1))%2 != 0:
    print('First')
else:
    print('Second')
    
    


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3564
N = int(input())
inis = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s = list(input())
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H":
        inis[s[0]] += 1

ans = 0
march = ["M","A","R","C","H"]
for i in range(len(march)):
    for j in range(i, len(march)):
        for k in range(j, len(march)):
            if march[i] != march[j] and march[i] != march[k] and march[j] != march[k]:
                ans += inis[march[i]] * inis[march[j]] * inis[march[k]]

print(ans)

Measured memory_bytes: 3064
import itertools
import decimal
import math
import collections
import sys
#input = sys.stdin.readline
import copy

# S=(input())
# N=int(input())
# N,K=map(int,input().split())
# ListA=list(map(int,input().split()))
# ListA.sort()#reverse=True)

def resolve():
    
    N=int(input())
    ListA=list(map(int,input().split()))

    cnt=0
    for i in range(N):
        if((i+1)%2==1 and ListA[i]%2==1):
            cnt+=1

    print(cnt)



resolve()

Measured memory_bytes: 9940
#coding:utf-8
s = input()
tmp = 0
ans = 0
for i in s:
  if i in ('A','G','C','T'):
    tmp += 1
  elif ans < tmp:
    ans = tmp
    tmp = 0
  else:
    tmp = 0
if ans < tmp:
  ans = tmp

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void){
  char str[1010];
  int i,sum;
 
  scanf("%s",str);
  while(str[0]!='0'){
    i=0;  sum=0;
    while(str[i]){
      sum+=str[i]-'0';  i++;
    }
    printf("%d\n",sum);
    scanf("%s",str);
  }
 
  return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
using ld = long double;

int main(void)
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    int hm_to_min = h*60 + m;
    int min_day = 12*60;
    //ld h_angle = ((ld)hm_to_min / min_day);
    ld h_angle = ((ld) h / 12.0 + ((ld)m / 60.0) / 12.0 );
    ld m_angle = ((ld) m / 60);

    ld angleBetween = 2 * M_PI * (h_angle - m_angle);
    
    ld l2 = (ld)(a*a + b*b) - (ld) (2 * a * b * cosl(angleBetween));
    cout << fixed<< setprecision(15) << sqrtl(l2) << endl;
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> child[N];
  bool seen[N];
  vector<int> Deep(N);
  vector<int> CandParent[N];
  vector<set<int>> Set(N);
  
  for (int i = 0; i < N; i++) {
    seen[i] = false;
  }
  for (int i = 0; i < N-1+M; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    child[a].push_back(b);
    CandParent[b].push_back(a);
    Set[b].insert(a);
    seen[b] = true;
  }
  int Parent = 0;
  for (int i = 0; i < N; i++) {
    if (!seen[i]) {
      Parent = i;
    }
  }

  for (int i = 0; i < N; i++) {
    Deep[i] = 999999;
  }
  Deep[Parent] = 0;
  int cnt = 0;
  vector<int> vec = {Parent};
  while (!vec.empty()) {
    vector<int> newvec = {};
    for (int j = 0; j < (int)vec.size(); j++) {
      for (int k = 0; k < (int)child[vec[j]].size(); k++) {
        int C = child[vec[j]][k];
        Set[C].erase(vec[j]);
        if (Set[C].empty()) {
          newvec.push_back(C);
          Deep[C] = cnt+1;
        }
      }
    }
    cnt++;
    vec = newvec;
  }
  
  vector<int> ans(N);
  ans[Parent] = -1;
  for (int i = 0; i < N; i++) {
    if (i == Parent) {
      continue;
    }
    for (int j = 0; j < (int)CandParent[i].size(); j++) {
      if (Deep[i] - 1 == Deep[CandParent[i][j]]) {
        ans[i] = CandParent[i][j];
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 24232
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  cin>>n;
  char s[100000];
  rep(i,0,n) cin>>s[i];

  int ans=1;
  char tmp=s[0];
  rep(i,1,n){
    if(s[i]!=tmp){
      ans++;
      tmp=s[i];
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
    return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x=y;
    y = y->parent;
  }
  return y;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
	    
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }

}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

long long GCD(long long x, long long y) {
    return (y ? GCD(y, x%y) : x);
}

int main() {
    long long A, B;
    cin >> A >> B;
    long long G = GCD(A, B);
    cout << A/G * B << endl;
}



Measured memory_bytes: 256
#include<algorithm>
#include<fstream>
#include<cstring>
#include<stdio.h>
using namespace std;
struct  pai{
  //char a;char b;
  char a[100];
}x[105],y[105];

bool cmp(pai o,pai p)
{
    return o.a[1]<p.a[1];
}
int main()
{
      int n;
      scanf("%d",&n);
      for(int i=0;i<n;i++)
      {
          scanf("%s",x[i].a);
          strcpy(y[i].a,x[i].a);
      }
      //sort(x,x+n,cmp);
      for(int i=0;i<n;i++)
      {
          for(int j=n-1;j>0;j--)
          {
              if(x[j].a[1]<x[j-1].a[1])
                swap(x[j],x[j-1]);
          }
      }
      for(int i=0;i<n;i++)
      {
          if(i!=n-1)
          printf("%s ",x[i].a);
          else printf("%s\n",x[i].a);
      }
      printf("Stable\n");
      /*for(int i=0;i<n;i++)
      {
          if(i!=n-1)
          printf("%s ",y[i].a);
          else printf("%s\n",y[i].a);
      }*/
      for(int i=0;i<n;i++)
      {
          int k=i;
          for(int j=i;j<n;j++)
          {
              if(y[j].a[1]<y[k].a[1])
              {
                  k=j;
              }
          }
          swap(y[k],y[i]);
      }
      for(int i=0;i<n;i++)
      {
          if(i!=n-1)
          printf("%s ",y[i].a);
          else printf("%s\n",y[i].a);
      }
      for(int i=0;i<n;i++)
      {
          if(strcmp(x[i].a,y[i].a)!=0)
          {
              printf("Not stable\n");
              return 0;
          }
      }
      printf("Stable\n");
      return 0;
}

Measured memory_bytes: 2752
s = gets.chomp

if s.chars.group_by(&:itself).map { |k, v| v.size }.max == 1
  puts "-1 -1"
  exit
end

def unbalance?(str)
  max = str.chars.group_by(&:itself).map { |k, v| v.size }.max
  max > str.size / 2
end

def check(str, l)
  (0..str.size - l).each do |i|
    if unbalance?(str[i, l])
      puts "#{i + 1} #{i + l}"
      exit
    end
  end
end

check(s, 2)
check(s, 3)

puts "-1 -1"


Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair



const  ll modo=1e9+7;

class ppo
{
    public:
    int l;
    int r;
};

bool comp(ppo a,ppo b)
{
    return a.r<b.r;
}

int main()
{
    faf;
    int n;
    cin>>n;
    ppo ar[n];
    int i;
    int a,b;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        ar[i].l=a;
        ar[i].r=b;
    }
    
    sort(ar,ar+n,comp);
    ll curr=0;
    int fl=0;
    for(i=0;i<n;i++)
    {
        curr+=ar[i].l;
        if(curr>ar[i].r)fl=1;
    }
    if(fl)cout<<"No";
    else cout<<"Yes";
}


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

int main()
{
	int a;
	int 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: 1156
#include <bits/stdc++.h>
using namespace std;
#define NIL -1

struct Node
{
  int location, l, r;
};

struct Point
{
  int id, x, y;
};

int n;
vector<Node> T;
vector<Point> P;

void init()
{
  T.resize(n);
  P.resize(n);
}

bool less_x(Point p1, Point p2)
{
  return p1.x < p2.x;
}

bool less_y(Point p1, Point p2)
{
  return p1.y < p2.y;
}

int node_index = 0;

int make2DTree(int l, int r, int depth)
{
  if (!(l < r))
  {
    return NIL;
  }
  int mid = (l + r) / 2;
  int t = node_index;
  node_index++;
  if (depth % 2 == 0)
  {
    // x軸を基準にソート
    sort(P.begin() + l, P.begin() + r, less_x);
  }
  else
  {
    // y軸を基準にソート
    sort(P.begin() + l, P.begin() + r, less_y);
  }
  T.at(t).location = mid;
  T.at(t).l = make2DTree(l, mid, depth + 1);
  T.at(t).r = make2DTree(mid + 1, r, depth + 1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<int> &ans)
{
  int x = P.at(T.at(v).location).x;
  int y = P.at(T.at(v).location).y;
  if (sx <= x && x <= tx && sy <= y && y <= ty)
  {
    ans.push_back(P.at(T.at(v).location).id);
  }

  if (depth % 2 == 0)
  {
    // x軸が基準のとき
    if (T.at(v).l != NIL && sx <= x)
    {
      find(T.at(v).l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T.at(v).r != NIL && x <= tx)
    {
      find(T.at(v).r, sx, tx, sy, ty, depth + 1, ans);
    }
  }
  else
  {
    // y軸が基準のとき
    if (T.at(v).l != NIL && sy <= y)
    {
      find(T.at(v).l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T.at(v).r != NIL && y <= ty)
    {
      find(T.at(v).r, sx, tx, sy, ty, depth + 1, ans);
    }
  }
}

int main()
{
  cin >> n;
  init();
  for (int i = 0; i < n; i++)
  {
    int x, y;
    scanf("%d %d", &x, &y);
    P.at(i) = Point{i, x, y};
  }
  make2DTree(0, n, 0);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    vector<int> ans;
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    find(0, sx, tx, sy, ty, 0, ans);
    sort(ans.begin(), ans.end());
    for (int j = 0; j < ans.size(); j++)
    {
      printf("%d\n", ans.at(j));
    }
    printf("\n");
  }
}


Measured memory_bytes: 14096
import java.util.*;

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

        int N = sc.nextInt();
        int mod = (int)Math.pow(10, 9)+7;
        sc.close();

        int[] c = new int[N];

        for(int i = 2; i <= N; i++){
            int n = i;
            for(int j = 2; j <= i; j++){
                while(n%j == 0){
                    c[j-1]++;
                    n /= j;
                }
            }
        }
        long sum = 1;
        for(int i = 1; i < N; i++){
            sum = (sum*(c[i]+1)) % mod;
        }
        System.out.println(sum);
    }

}

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

int main() {
  int x,a,b;
  	cin>>x>>a>>b;
  int sum=b-a;
  if(sum<=0){
    cout<<"delicious"<<endl;
  }
  else if(sum<=x){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"dangerous"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int time_q[101];
struct drink
{
    int x,y;
}a[101];
int main()
{
    int N,M,cnt=0;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>time_q[i];
        cnt+=time_q[i];
    }
    cin>>M;
    for(int i=1;i<=M;i++)
        cin>>a[i].x>>a[i].y;
    for(int i=1;i<=M;i++)
        cout<<cnt+a[i].y-time_q[a[i].x]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;

    for(int i = 0 ; i <= k ; ++i){
      for(int j = 0 ; j <= k ; ++j){
        int num = s-i-j;
        if(num >= 0 && num <= k){
          ++count;
        }
      }
    }
    
    System.out.println(count);
    
  }
}

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

static const int MAX = 100;
#define INF 2000000000000ll
int V, E;
long long dp[MAX][MAX];

void Warshall_Floyd()
{
	for (int k = 0; k < V; k++)
	{
		for (int i = 0; i < V; i++)
		{
			for (int j = 0; j < V; j++)
			{
				if (dp[i][k] == INF||dp[k][j]==INF)
				{
					continue;
				}

				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
}

int main()
{
	cin >> V >> E;
	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			if (i == j)
			{
				dp[i][j] = 0;
			}
			else
			{
				dp[i][j] = INF;
			}

		}
	}
	for (int i = 0; i < E; i++)
	{
		int s, t, d;
		cin >> s >> t >> d;
		dp[s][t] = d;
	}
	Warshall_Floyd();

	bool minus = false;
	for (int i = 0; i < V; i++)
	{
		if (dp[i][i] < 0)
		{
			minus = true;
		}
	}

	if (minus)
	{
		cout << "NEGATIVE CYCLE" << endl;
	}
	else
	{
		for (int i = 0; i < V; i++)
		{
			for (int j = 0; j < V; j++)
			{
				if (j != 0)
				{
					cout << " ";
				}
				if (dp[i][j] == INF)
				{
					cout << "INF";
				}
				else
				{
					cout << dp[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;


}




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

int main() {
  string s; cin>>s;
  int i=0,j=s.size()-1;
  int a,z;
  while(true){
    if(s.at(i)=='A'){a=i;break;}
    i++;
  }
  while(true){
    if(s.at(j)=='Z'){z=j;break;}
    j--;
  }
  cout<<z-a+1;
}
      

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		int ans = K;
		for(int i = 1; i < N; i++ ) {
			ans *= (K-1);	
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 1e5 + 10;

int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    ll n, m, cnt = 0;
    ll sum = 0, dd = 4;
    ll a[1000];
    cin >> n >> m;
    for(int i = 0; i < n; i ++) cin >> a[i], sum += a[i];
    for(int i = 0; i < n; i ++){
        if(a[i] * 4 * m >= sum){
            cnt ++;
        }
    }
    cout << (cnt >= m ? "Yes" : "No");
    return 0;
}
/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/
//! N.N


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

ans = [['#'] * 100 for _ in range(50)] + [['.'] * 100 for _ in range(50)]
# print(ans)

i, j = 0, 1
for _ in range(A-1):
    ans[i][j] = '.'
    j += 2
    if j == 101:
        i += 2
        j = 1

i, j = 51, 1
for _ in range(B-1):
    ans[i][j] = '#'
    j += 2
    if j == 101:
        i += 2
        j = 1

print('100 100')
for a in ans:
    print(*a, sep='')


Measured memory_bytes: 40176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	s := nextString()
	t := nextString()
	a := nextInt()
	b := nextInt()
	u := nextString()
	if u == s {
		a--
	} else if u == t {
		b--
	}
	fmt.Println(a, b)
}

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

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

int main() {
    int x,y;
    cin>>x>>y;
    REP(i,51) REP(j,51){
        if(i+j==x && 2*i +4*j==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll s, c;
	cin >> s >> c;
	ll ans;
	if (s > c / 2) ans = c / 2;
	else ans = s + (c - s * 2) / 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
sum = {}
ans = 0

for i in range(n):
  k = list(map(int,input().split()))
  for j in range(1,k[0] + 1):
    if k[j] not in sum:
      sum[k[j]] = 1
    else:
      sum[k[j]] += 1
for l in sum:
  if sum[l] == n:
    ans += 1
print(ans)

Measured memory_bytes: 3064
n=int(input())
nt=n
i=1
temp=0
al=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans=[]
while True:
  if n<=temp+26**i:
    break
  else:
    temp=temp+26**i
    i=i+1
while True:
  if i==1:
    ans.append(al[(nt-temp-1)%26])
    break
  else:
    k=(nt-temp-1)//26**(i-1)
    ans.append(al[k])
    i=i-1
    nt=nt-26**i*(k+1)
    temp=temp-26**i
print("".join(ans))

Measured memory_bytes: 9212
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		int d=Integer.parseInt(scan.next());
    		
    		int ans=(a>=b?b:a) +(c>=d?d:c);
    		System.out.print(ans);
    		

;
    		
     
    }
    }
// end 
    

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

int dp[100005][3], v[100005][3];

int find(int pos, int i, int n)
{
	if(i>=n)	return 0;

	int x,y;

	if(pos==0)
		x=1, y=2;
	else if(pos==1)
		x=0, y=2;
	else
		x=0, y=1;

	if(dp[i][pos]!=0)	return dp[i][pos];

	int ans = max(v[i][pos] + find(x,i+1,n), v[i][pos] + find(y,i+1,n));

	dp[i][pos]= ans;

	return ans;

}

int main()
{
	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif



	int n;	cin>>n;

	for(int i=0;i<n;++i)	
		cin>>v[i][0]>>v[i][1]>>v[i][2];

	dp[0][0] = v[0][0] + max(find(1,1,n), find(2,1,n)) ;
	dp[0][1] = v[0][1] + max(find(0,1,n), find(2,1,n));
	dp[0][2] = v[0][2] + max(find(0,1,n), find(1,1,n));

	int ans = max(max(dp[0][2], dp[0][1]), dp[0][0]);

//	for(int i=0;i<n;++i)
//		cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;

	cout<<ans<<endl;
}

Measured memory_bytes: 13680
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  string S;
  cin >> S;

  if (S[0] != 'A') {
    COUT("WA");
    return 0;
  }

  ll c_count = 0;
  rep(i, S.size()) {
    if (i == 0 || i == 1) continue;
    if (i == (ll)S.size() - 1) continue;
    if (S[i] == 'C') {
      c_count++;
    }
  }

  if (c_count != 1) {
    COUT("WA");
    return 0;
  }
  rep(i, S.size()) {
    if (i == 0) continue;
    if (S[i] == 'C') continue;
    if (isupper(S[i])) {
      COUT("WA");
      return 0;
    }
  }
  COUT("AC");
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto& x : a){
        cin >> x;
    }

    int i = 0; int j = n - 1;

    while (j >= 0){
        b[i] = a[j];
        ++i;
        j -= 2;
    }

    j = (j == -1) ? 0 : 1;

    while (i < n){
        b[i] = a[j];
        ++i;
        j += 2;
    }

    for (int i = 0; i < n; ++i){
        cout << b[i];

        if (i != n - 1){
            cout << " ";
        } else{
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		long[] dp = new long[n+10];
		
		dp[0] = 2;
		dp[1] = 1;
		
		for(int i = 2; i <= n; i++) {
			dp[i] = dp[i-2] + dp[i-1];
		}
		
		out.println(dp[n]);
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22996
N,W = [int(c) for c in input().split()]
wv = [[int(c) for c in input().split()] for d in range(N)]

dp = [[0]*(W+1) for c in range(N)]
#i番目の品物まで候補としたとき(使うかはわからない)、重さj以下のときの価値の総量がdp[i][j]
for i in range(N):
    for j in range(W+1):
        #重さj以下で、iを使うときと使わないときの大きい方
        if j-wv[i][0] >= 0:
            dp[i][j] = max([dp[i-1][j-wv[i][0]]+wv[i][1],dp[i-1][j]])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[-1][-1])

Measured memory_bytes: 152080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int a = sc.nextInt();
		
		out.println(n*n-a);
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21716
# -*- coding utf-8 -*-
import math

MOD = 10 ** 9 + 7

a, b, x = map(int, input().split())

if x > a * a * b / 2:
    s = (a * a * b - x) / a
    tantheta = 2 * s / a/ a
    theta = math.degrees(math.atan(tantheta))
else:
    s = x / a
    tantheta = b * b / 2 / s
    theta = math.degrees(math.atan(tantheta))

ans = theta

print(ans)



Measured memory_bytes: 3060