akhauriyash/Code-Regression huggingface dataset:
function Main(s) {
  var s = s.split("\n");
  var n = s[0]*1;
  var a = s.slice(1, 3).map(e => e.split(" ").map(t => t*1));
  var b = new Array(n).fill(0);
  for(var i = 0; i < n; i++) {
    for(var j = i; j < n; j++) b[j] += a[0][i];
    for(var j = i; j < n; j++) {
      b[i] += a[1][j];
    }
  }
  max = 0;
  for(var i of b) max = Math.max(max, i);
  console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<malloc.h>
#include<math.h>
#include<algorithm>

using namespace std;

int n,x,y,t,xi,yi,ti,tag;

int main()
{
    scanf("%d",&n);
    x = 0, y = 0, t = 0;
    tag = 1;
    for (int i=0;i<n;i++)
    {
        scanf("%d %d %d",&ti,&xi,&yi);
        int need = abs(x-xi)+abs(y-yi);
        if (need > ti-t) tag = 0;
        if ((ti-t-need) % 2) tag = 0;
        x = xi, y = yi, t = ti;
    }
    if (tag) printf("Yes");
    else
        printf("No");
    return 0;
}


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

static const int mod = 1e9+7;

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

    long long ans;
    if(abs(N-M) >= 2)  ans = 0;
    else{
        ans = 1;
        for(int i=1; i<=N; i++){
            ans = (ans*i) % mod;
        }

        for(int i=1; i<=M; i++){
            ans = (ans*i) % mod;
        }
    }

    if(N-M == 0) ans = (2*ans)%mod;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    string s;
    cin>>n>>s;
    s+='*';
    ll cnt=0;
    FOR(i,n)
    {
        if(s[i]!=s[i+1])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
/*
5
4
3
2
3
4
4
3
3
4
2
3
*/


Measured memory_bytes: 512
import math
n = int(input())
x = [float(f) for f in input().split()]
y = [float(f) for f in input().split()]
L1 = 0
for i in range(n):
    L1 += abs(x[i] - y[i])
L2 = 0
for i in range(n):
    L2 += abs(x[i] - y[i])**2
L2 = pow(L2, 1.0/2.0)
L3 = 0
for i in range(n):
    L3 += abs(x[i] - y[i])**3
L3 = pow(L3, 1.0/3.0)
Linf = 0
for i in range(n):
    Linf = max(Linf, abs(x[i] - y[i]))
print(L1)
print(L2)
print(L3)
print(Linf)


Measured memory_bytes: 5724
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <stdio.h>
 
using namespace std;

//-------------------------------------------------------------------------
// geometric library
 
namespace geometry {
 
struct point {
    double x;
    double y;
};
 
struct circle {
    point center;
    double radius;
};
 
struct line { // ax + by + c = 0
    double a;
    double b;
    double c;
};
 
std::istream& operator >> (std::istream& is, point& p)
{
    is >> p.x >> p.y;
    return is;
}
 
bool operator == (const point& p1, const point& p2)
{
    return p1.x == p2.x && p1.y == p2.y;
}
 
///! 2点の距離
double get_distance(const point& p1, const point& p2)
{
    return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}
 
///! 2直線の交点
bool get_crosspoint(const line& l1, const line& l2, point *result)
{
    double denominator = l1.a * l2.b - l1.b * l2.a;
    if (denominator == 0) {
        return false;
    }
    result->x = (l1.b * l2.c - l2.b * l1.c) / denominator;
    result->y = (l2.a * l1.c - l1.a * l2.c) / denominator;
    return true;
}
 
///! 2点の垂直2等分線
bool get_bisector(const point& p1, const point& p2, line *result)
{
    if (p1 == p2) {
        return false;
    }
    result->a = 2 * (p1.x - p2.x);
    result->b = 2 * (p1.y - p2.y);
    result->c = -(p1.y - p2.y) * (p1.y + p2.y) - (p1.x - p2.x) * (p1.x + p2.x);
    return true;
}
 
///! 外接円を求める
bool get_circum_circle(const point& p1, const point& p2, const point& p3, circle *result)
{
    double a = get_distance(p1, p2);
    double b = get_distance(p2, p3);
    double c = get_distance(p3, p1);
 
    // 半径の公式
    result->radius = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
 
    line line_p1p2;
    line line_p2p3;
 
    // 頂点の垂直2等分線の交点が外心
    return get_bisector(p1, p2, &line_p1p2) &&
           get_bisector(p2, p3, &line_p2p3) &&
           get_crosspoint(line_p1p2, line_p2p3, &result->center);
}
 
} // namespace geometry

using namespace geometry; 


int main(void)
{
	int steps, dtheta;
	char comma;
	double theta;
	point p;

	p.x = p.y = 0.0;
	theta = 90.0;

	while (cin >> steps >> comma >> dtheta) {
		assert(comma == ',');

		if (steps == 0 && dtheta == 0) {
			break;
		}

		p.x += steps * cos(theta * M_PI / 180.0);
		p.y += steps * sin(theta * M_PI / 180.0);
		theta -= dtheta; // 正の数は右に回る
	}

	cout << (int)p.x << endl << (int)p.y << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
       boost;
       int n,d=0;
       cin>>n;
       string s;
       cin>>s;
       set<char> s1,s2;
       forn(i,s.size()-1)
       {
             s1.insert(s[i]);
             for(int j=i+1;j<s.size();j++)
             {
                   if(s1.find(s[j])!=s1.end())
                   {
                        s2.insert(s[j]);
                   }
             }
             int l=s2.size();
             d=max(d,l);
             s2.clear();
       }
       cout<<d<<endl;
}

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

int main() {
  
	int N, L;
	cin >> N;
  
  int S = 0;
  int M = 0;
   for (int i = 1; i < N + 1 ; i++) {
     cin >> L;
     S = S + L;
     if (M < L) {
       M = L;
     }
   }
  
  if (2*M < S) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}



Measured memory_bytes: 256
/*input
10 10
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe";
    }
    else cout<<"safe";
}


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

int main() {
  int n, m;
  int data[1000];
  int sum;


  while(1) {
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(int i = 0; i < n; i++) {
      cin >> data[i];
    }
    sort(data, data+n);
    sum = 0;
    int i = n-1;
    while(1) {
      for(int j = 0; j < m; j++) {
	if(i < 0) {
	  break;
	}
	if(j+1 == m) {
	} else {
	  sum += data[i];
	}
	i--;
      }
      if(i < 0) break;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void dfs(int y, int x, vector<vector<int>> &c)
{
  c[y][x] = 0;
  for (int i = 0; i < 8; ++i)
  {
    int ny = y + dy[i], nx = x + dx[i];
    if (0 <= nx && nx < c[0].size() && 0 <= ny && ny < c.size() && c[ny][nx])
      dfs(ny, nx, c);
  }
}

int main()
{
  int w, h;
  while (cin >> w >> h, w || h)
  {
    vector<vector<int>> c;
    c.clear();
    c.shrink_to_fit();
    c.assign(h, vector<int>(w));
    for (int i = 0; i < h; ++i)
    {
      for (int j = 0; j < w; ++j)
      {
        cin >> c[i][j];
      }
    }
    int cnt = 0;
    for (int i = 0; i < h; ++i)
    {
      for (int j = 0; j < w; ++j)
      {
        if (c[i][j])
        {
          dfs(i, j, c);
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}



Measured memory_bytes: 3248
from math import sqrt

n, m = map(int, input().split())
l = []
for i in range(1, int(sqrt(m)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)

ans = 1
for d in l:
	if d * n <= m:
		ans = max(ans, d)

print(ans)

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

using namespace std;
typedef long long int ll;

#define INF (1e9)

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

    int x, y, z;

    for (x = 0; x <= N; x++)
    {
        for (y = 0; x + y <= N; y++)
        {
            z = (N - x - y);
            if (10000 * x + 5000 * y + 1000 * z == Y)
            {
                cout << x << ' ' << y << ' ' << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int sun(int n)
{
    int a, sum;
    sum = n%10;
    while(n>0)
    {
        n=n/10;
        sum = sum + (n%10);
    }
    return sum;
}
int main()
{
    int n, sn;
    scanf("%d", &n);
    sn = sun(n);
    //printf("%d\n", sn);
    if(n%sn==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

const int N=200010;

int s[N],a[N],c[N];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,q;scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);a[i]=n-a[i]+1;s[a[i]]++;
    }
    int ans=0;
    for (int i=1;i<=n;i++)
        for (int j=0;j<s[i]&&i+j<=n;j++)
            if (!(c[i+j]++)) ans++;
    while (q--)
    {
        int x,y;scanf("%d%d",&x,&y);y=n-y+1;
        if (a[x]+s[a[x]]-1<=n)
        {
            if (!(--c[a[x]+s[a[x]]-1])) ans--;

        }
        s[a[x]]--;
        ++s[y];
        if (y+s[y]-1<=n)
        {
            if (!(c[y+s[y]-1]++)) ans++;
        }
        a[x]=y;
        printf("%d\n",n-ans);
    }
	return 0;
}



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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	char c;
	cin >> c;
	cout << char(c + 1);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = "";
        while(sc.hasNext()) {
            int count = 0;
            s = sc.nextLine();
            if (s.equalsIgnoreCase("ssr") || s.equalsIgnoreCase("srs") || s.equalsIgnoreCase("rss") || s.equalsIgnoreCase("rsr")) {
                count = 1;
            }
            else if (s.equalsIgnoreCase("rrs") || s.equalsIgnoreCase("srr")) {
                count = 2;
            }
            else if(s.equalsIgnoreCase("rrr")) {
                count = 3;
            }
            else
                count = 0;
            System.out.println(count);                
        }
        
    }
}

Measured memory_bytes: 26980
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(s.length() - 1) == 's') {
            s += "es";
        } else {
            s += 's';
        }
        System.out.println(s);
	}
}

Measured memory_bytes: 38436
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 0.000000000001
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A; cin >> A;
	long double B; cin >> B;
	int C = A * B;
	cout << C << endl;
	return 0;
}



Measured memory_bytes: 3736
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const int maxn = 1e2+5;
const int mod = 1e6;
const double eps = 1e-8;
const double pi = asin(1.0)*2;
const double e = 2.718281828459;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}

int n;
int a, b, c;
int ans;
int city;
int num;
int plat[maxn][maxn];
int sum[maxn];

inline int max(int a, int b, int c) {
	return max(max(a, b), c);
}

void Floyd() {
	for (int k = 0; k <= num; ++k) {
		for (int i = 0; i <= num; ++i) {
			for (int j = 0; j <= num; ++j) {
				if (i == j) {
					plat[i][j] = 0;
					continue;
				}
				plat[i][j] = min(plat[i][j], plat[i][k] + plat[k][j]);
			}
		}
	}
}

int main(int argc, char *argv[]) {
//#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
	while (~scanf("%d", &n), n) {
		mem(plat, INF);
		num = 0;
		for (int i = 1; i <= n; ++i) {
			read(a); read(b); read(c);
			plat[a][b] = c;
			plat[b][a] = c;
			num = max(num, a, b);
		}
		Floyd();
		mem(sum, 0);
		ans = INF;
		for (int i = 0; i <= num; ++i) {
			for (int j = 0; j <= num; ++j) {
				sum[i] += plat[i][j];
			}
			if (sum[i] < ans) {
				ans = sum[i];
				city = i;
			}
		}
		printf("%d %d\n", city, ans);
	}
//#ifndef ONLINE_JUDGE
//	fclose(stdin);
//	fclose(stdout);
//	system("gedit out.txt");
//#endif
    return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>

void
swp(int *a, int *b)
{
        int tmp;
        tmp = *a;
        *a = *b;
        *b = tmp;
}

int
main()
{
        int lines[31] = {0};
        int *itr;
        int w, n;
        int s1, s2;

        for (scanf("%d", &w); w >= 0; w--)
                lines[w - 1] = w;
        for (scanf("%d", &n); n > 0; n--) {
                scanf("%d,%d", &s1, &s2);
                swp(&lines[s1 - 1], &lines[s2 - 1]);
        }
        for (itr = lines; *itr != 0; itr++)
                printf("%d\n", *itr);
        return 0;
}

Measured memory_bytes: 592
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }

    constexpr ll MAX = 1e5;
    vector<vector<ll>> num(2, vector<ll>(MAX + 1, 0));
    for (ll i = 0; i < n; i++) {
        num[i % 2][v[i]]++;
    }

    ll ans = 0;

    ll max_index[2] = { -1, -1 };
    ll max_value[2] = { -1, -1 };
    
    for (ll i = 0; i < 2; i++) {
        for (ll j = 0; j <= MAX; j++) {
            if (num[i][j] > max_value[i]) {
                max_value[i] = num[i][j];
                max_index[i] = j;
            }
        }
    }

    if (max_index[0] == max_index[1]) {
        ll second_index[2] = { -1, -1 };
        ll second_value[2] = { -1, -1 };

        for (ll i = 0; i < 2; i++) {
            for (ll j = 0; j <= MAX; j++) {
                if (j == max_index[i]) {
                    continue;
                }
                if (num[i][j] > second_value[i]) {
                    second_value[i] = num[i][j];
                    second_index[i] = j;
                }
            }
        }

        ll ans0 = n - max_value[0] - second_value[1];
        ll ans1 = n - max_value[1] - second_value[0];
        ans = min(ans0, ans1);
    } else {
        ans += n - max_value[0] - max_value[1];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if 1 <= A <= 9 and 1 <= B <= 9:
        print(A * B)
    else:
        print(-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
L = [0]

for _ in range(N):
    L.append(int(input()))

tmp = 1
cnt = 0

while True:
    tmp = L[tmp]
    cnt += 1
    if tmp == 2:
        print(cnt)
        quit()
    if cnt > 10**5 +1:
        print(-1)
        quit()


Measured memory_bytes: 7080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

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

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

double fix(double a){
	if(a < 0) return a+360;
	if(a >= 360) return a-360;
	return a;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a, b;
	cin >> a >> b;
	if(b < a) swap(a, b);
	double res1 = (b-a)/2;
	if(res1 > 90) res1 = res1-180;
	cout << fix(a+res1) << endl;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;


li n, k;
li a[200100];
li f[200100];

inline bool ok(li x) {
	if (x == 0) {
		return false;
	}
	li count = 0;
	rep(i, n) {
		// 12, {5, 3}
		li lim_a = x / f[i];
		count += max(0ll, a[i] - lim_a);
	}
	return count <= k;
}

int main(void)
{
	cin >> n >> k;
	li sum_a = 0;
	rep(i, n) {
		cin >> a[i];
		sum_a += a[i];
	}
	rep(i, n) {
		cin >> f[i];
	}
	if (sum_a <= k) {
		puts("0");
		return 0;
	}

	sort(a, a + n);
	reverse(a, a + n);
	sort(f, f + n);


	li l = 0;
	li r = 1000000ll * 1000000ll;

	while (l + 1 < r) {
		li med = (l + r) / 2;
		if (ok(med)) {
			r = med;
		} else {
			l = med;
		}
	}
	cout << r << endl;


	return 0;
}

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

#define INF 99999

int main(){
    long n,input[5];
    cin >> n;
    cin >> input[0];
    cin >> input[1];
    cin >> input[2];
    cin >> input[3];
    cin >> input[4];
    
    long min = std::min({input[0],input[1],input[2],input[3],input[4]});
    
    if(min >= n){
        cout << 5 << endl;
        return 0;
    }else{
        long count;
        if(n % min == 0){
            count = n / min;
        }else{
            count = n / min + 1;
        }
        cout << 5 + count - 1 << endl;
    }
    
    return 0;
}


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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i=0; i<M; i++){
    cin >> B.at(i);
  }
  int A=0, Sum=0, Ans=0;
  for(int i=0; i<N; i++){
    Sum=0;
    for(int j=0; j<M; j++){
      cin >> A;
      Sum+=A*B.at(j);
    }
    if(Sum>-C){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	ll n,p;
	cin>>n>>p;
	ll ans=1;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	ll i=2;
	
	while(p>1){
		ll cnt=0;
		while(p%i==0){
			p/=i;
			cnt++;
			if(cnt>=n){
				ans*=i;
				cnt=0;
			}
		}
		i++;
		if(i>sqrt(p)){
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

















Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<int,Pil>Piil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int l[100001]={},r[100001]={};

int main() {

	int n,k;
	string s;
	cin>>n>>k;
	cin>>s;

	int ls=0,rs=0;
	int c=1,f=0;
	int ans=0;
	for(int i=1; i<n; i++){
		if(s[i]==s[i-1])c++;
		else{
			ans+=c-1;
			c=1;
			if(s[i-1]=='L'){
				l[ls]=2;
				ls++;
				if(f==0)l[ls-1]--;
			}else{
				r[rs]=2;
				rs++;
				if(f==0)r[rs-1]--;
			}
			f=1;
		}
	}
	ans+=c-1;
	if(s[n-1]=='L'){
		l[ls]=1;
		if(f==0)l[ls]--;
		ls++;
	}
	else{
		r[rs]=1;
		if(f==0)r[rs]--;
		rs++;
	}
	sort(l,l+ls,greater<int>());
	sort(r,r+rs,greater<int>());

	int lc=0,rc=0;
	rep(i,min(k,ls))lc+=l[i];
	rep(i,min(k,rs))rc+=r[i];
	rc=max(rc,lc);
	cout<<ans+rc<<endl;

	return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    V(string) hb(2, "");
    int cnt = 0;
    rep(i, Q) {
        int a;
        cin >> a;
        if(a==1) {
            cnt++;
        } else {
            int b;
            char c;
            cin >> b >> c;
            if(b==1) {
                hb[cnt%2] += c;
            } else {
                hb[(cnt+1)%2] += c;
            }
        }
    }

    string res = "";
    if(cnt%2==0) {
        reverse(ALL(hb[0]));
        res += hb[0];
        res += s;
        res += hb[1];
    } else {
        reverse(ALL(hb[1]));
        reverse(ALL(s));
        res += hb[1];
        res += s;
        res += hb[0];
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> b(N);
  for (int i = 0; i < N; i++){
    cin >> b[i];
  }
  long long sum1 = 0;
  long long sum2 = 0;
  long long sum3 = 0;
  for (int i = 0; i < N; i++){
    sum1 += b[i] - a[i];
    if (a[i] >= b[i]){
      sum2 += a[i] - b[i];
    } else {
      sum3 += (b[i] - a[i] + 1) / 2;
    }
  }
  if (sum1 >= max(sum2, sum3)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3684
N = int(input())
S = [list(input()) for _ in range(N)]

result = S[0]
for i in range(1,N):
    temp = []
    for j in S[i]:
        if j in result:
            temp.append(j)
            result.remove(j)
    result = temp       
result.sort()
print("".join(result))


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, ans;
ll cnt[1100000];
bool used[1100000];
int main() {
    cin >> n;
    vector<ll> s(n);
    REP(i, n){
        cin >> s[i];
        cnt[s[i]]++;
    }
    sort(ALL(s));
    REP(i, n){
        bool ok = true;
        for (ll j = 1; j <= sqrt(s[i]); j++)
        {
            if (s[i] % j == 0){
                if(used[s[i] / j]) ok = false;
                if(used[j]) ok = false;
            }
        }
        used[s[i]] = true;
        if (ok and cnt[s[i]] == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13548
#include<stdio.h>
int main()
{
	int a,b,r,tmp;
	scanf("%d%d",&a,&b);
	
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	r=a%b;
	while(r!=0)
	{
		a=b;
		b=r;
		r=a%b;
	}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 592
# -*- coding: utf-8 -*-
from collections import defaultdict
from itertools import permutations
def inpl(): return list(map(int, input().split()))

K, A, B = inpl()
if B <= A + 2 or K <= A:
    print(K+1)
else:
    T = K - A + 1
    d, m = divmod(T, 2)
    print(A + (B-A)*d + m)

Measured memory_bytes: 3444
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int n, m;
  scanf("%i %i", &n, &m);
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%i", &a[i]);
  }
  
  long long tot = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] >= a[i-1]) tot += a[i] - a[i-1];
    else                tot += m+a[i] - a[i-1];
  }
  
  vector<int> open(m+1);
  vector<vector<int>> close(m+1);
  for (int i = 1; i < n; i++) {
    open[a[i-1]%m+1]++;
    close[a[i]].push_back(a[i-1]%m+1);
  }
    
  long long dec = 0;
  
  int count = 0;
  for (int i = 0; i+1 < n; i++) {
    if (a[i] > a[i+1]) {
      count++;
      dec += m+1 - a[i] - 1;
    }
  }  
  long long ans = tot - dec;
  for (int e : close[1]) {
    count--;
    if (1 >= e) dec -= 1 - e;
    else        dec -= m+1 - e;
  }
  
  for (int i = 2; i <= m; i++) {
    dec += count;
    ans = min(ans, tot - dec);
    count += open[i];
    for (int e : close[i]) {
      count--;
      if (i >= e) dec -= i - e;
      else        dec -= m+i - e;
    }
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string S; cin >> S;
  ll a = 0, ab = 0, abc = 0, str_cnt = 1;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'A') {
      (a += str_cnt) %= MOD;
    } else if (S[i] == 'B') {
      (ab += a) %= MOD;
    } else if (S[i] == 'C') {
      (abc += ab) %= MOD;
    } else {
      ((abc *= 3) += ab) %= MOD;
      ((ab *= 3) += a) %= MOD;
      ((a *= 3) += str_cnt) %= MOD;
      (str_cnt *= 3) %= MOD;
    }
  }

  cout << abc << endl;
}




Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	long long int a,b,c,d,e,f;
	while(scanf("%lld %lld",&a,&b)!=EOF){
		e=a;
		f=b;
		while(1){
			if(a>b){
				a=a-b;
			}else if(a<b){
				b=b-a;
			}else{
				c=a;
				break;
			}
		}
		d=e*f/c;
		printf("%lld %lld\n",c,d);
	}
	return 0;
}


Measured memory_bytes: 2036
import math

mod = 10**9+7
n, k = map(int, input().split())

cnt = [0]*(k+1)

for i in range(1, k+1):
    cnt[i] = pow(math.floor(k/i), n, mod)

for i in range(k+1, 0, -1):
    j = 2
    while i*j <= k:
        cnt[i] -= cnt[i*j]
        cnt[i] %= mod
        j += 1

ans = 0

for i in range(1, k+1):
    ans += cnt[i]*i
    ans %= mod

print(ans)


Measured memory_bytes: 71344
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	vii a;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		a.emplace_back(x, i);
	}
	sort(all(a));
	for (auto p : a) printf("%d ", p.second); puts("");
}


Measured memory_bytes: 1780
#include<iostream>

using namespace std;

int main(){
    int N, D, X;
    int a[101];
    cin >> N >> D >> X;

    for (int i = 0; i < N;i++){
        cin >> a[i];
    }
    int cnt = 0;
    for (int i = 0; i < N;i++){
        int tmp = a[i];
        if(D<=tmp){
            cnt += 1;
        }else if(D%tmp==0){
            cnt += D / tmp;
        }else{
            cnt += D / tmp + 1;
        }
    }
    cout << cnt + X << endl;
}

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

int main( void )
{
	while ( !cin.eof() )
	{
		string low;
		getline( cin, low );
		if ( cin.eof() )
			break;

		for ( string::iterator it = low.begin(); it != low.end(); it++ )
		{
			if ( *it >= 'a' && *it <= 'z' )
				*it = toupper( *it );
		}

		cout << low << endl;

	}
}

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

using namespace std;

int main()
{
	vector<int> a(101, 0);
	int n, max = 0;
	
	while (cin >> n)
	{
		a[n]++;
		if (a[n] > max) max = a[n];
	}

	for (int i = 1; i < a.size(); ++i)
		if (a[i] == max) cout << i << endl;

	return 0;
}

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

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xv(n), yv(m);
    for(int i = 0; i < n; i++){
        cin >> xv[i];
    }
    for(int i = 0; i < m; i++){
        cin >> yv[i];
    }
    sort(xv.begin(),xv.end(), greater<int>());
    sort(yv.begin(),yv.end());
    int ans = false;
    for(int z = xv[0]+1; z <= yv[0]; z++){
        if(z > x && z < y) ans = true;
    }
    if(ans){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
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;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 ll n;
  cin>>n;
  vin a(n);
  ll yon=0,ni=0;
  rep(i,0,n) {
    cin>>a[i];
   if( a[i]%4==0) yon++;
   else if(a[i]%2==0) ni++;
  }
  ll ok=0;
  
   
    ok+=yon*2;
  
  if(ni>1){
   ok+=ni; 
  }
  else{
    if(yon>0) ok++;
  }
  if(ok>=n) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll                  long long
#define rep(i,n)            for(ll i=0;i<n;i++)
#define hell                1000000007LL
#define vi                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define pii                 pair<int,int>
#define all(c)              c.begin(),c.end()
#define mini(c)             min_element(all(c))
#define maxi(c)             max_element(all(c))
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll Max(ll a, ll b) { return a > b ? a : b; }
ll Min(ll a, ll b) { return a < b ? a : b; }
ll power(ll x, ll y,ll p)
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=((res%p)*(x%p))%p;
        y=y>>1;
        x=((x%p)*(x%p))%p;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string x;
    cin>>x;
    ll n=0,e=0,s=0,w=0;
    rep(i,x.length())
    {
        if(x[i]=='N') n++;
        else if(x[i]=='S') s++;
        else if(x[i]=='E') e++;
        else w++;
    }
    if(n>0 && s>0)
    {
        if(e==0 && w==0) cout<<"Yes";
        else if(e>0 && w>0) cout<<"Yes";
        else cout<<"No";
    }
    else if(n==0 && s==0)
    {
        if(e==0 && w==0) cout<<"Yes";
        else if(e>0 && w>0) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import re
         
a,b,c,n = list(map(int,re.split(" ",input())))
N = n
s = []
s.append(a)
s.append(b)
s.append(c)
s.sort()
a,b,c = s
#print(a,b,c)
ans = 0
for i in range(int(N/c)+1):
  for j in range(int((N-i*c)/b)+1):
      if (N - i*c  - j*b)%a == 0:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

signed main() {
    string s; cin>>s;
    int n=s.size();
    int lo=0, hi=2*n; // lo impossible, hi possible
    while (hi-lo >= 2) {
        int mid = (lo+hi)/2;
        int cur = mid*9, carry=0;
        //P("trying "<<mid);
        bool ok=true;
        DEC(i,n) {
            while ((cur+carry)>=0 && (cur+carry)%10 != s[i]-'0')
                cur--;
            //D(cur);
            if (cur+carry < 0) {
                ok = false;
                break;
            }
            carry = (cur+carry)/10;
        }
        if (ok) {
            hi = mid;
            //P("okay");
        } else {
            lo = mid;
            //P("not okay");
        }
    }
    P(hi);
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n,p;
  cin >> n >> p;
  ll odd = 0,even = 0;
  rep(i,n){
    int x;cin >> x;
    if(x & 1)odd++;
    else even++;
  }
  if(odd > 0){
    cout << (ll)pow(2,n-1) << endl;
  }else{
    if(p & 1)cout << 0 << endl;
    else cout << (ll)pow(2,n) << endl;
  }




  return 0;
}

Measured memory_bytes: 256
//codeforces
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <set>
#include <map>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<bitset>
#include <climits>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
#include<cassert>

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9+7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

class TrieNode{
    public:
    bool isword;
    char c;
    map<char,TrieNode*> m;
    string word;
    public:
    TrieNode(){}
    TrieNode(char ch){
        c=ch;
        isword=false;
    }
};

void insert(TrieNode* root,string word){
    TrieNode* temp=root;
    for(char c:word){
        if(temp->m.find(c)==temp->m.end())
            temp->m[c]=new TrieNode(c);
        temp=temp->m[c];
    }
    temp->isword=true;
    temp->word=word;
}


#pragma GCC optimize ("Ofast")
static auto _ = [] { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); std::cerr.tie(0); return 0; } ();


vector<vector<int>> graph;
vector<bool> visited;
vector<int> indeg;
vector<int> dp;

void dfs(int i){
	if(visited[i])
      return ;
    visited[i]=true;
    for(int neigh:graph[i]){
        indeg[neigh]--;
        dp[neigh] = max(dp[neigh],dp[i]+1);
        if(indeg[neigh]==0)
            dfs(neigh);
    }
}

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

    graph = vector<vector<int>> (n);
    visited = vector<bool> (n,false);
    indeg = vector<int> (n,0);
    dp = vector<int> (n,0);

    int s,d;
    for(int i=0;i<m;i++){
        cin>>s>>d;
        graph[s-1].push_back(d-1);
        indeg[d-1]++;
    }

    for(int i=0;i<n;i++){
        if(!visited[i] && indeg[i]==0)
            dfs(i);
    }

    cout<<*max_element(dp.begin(),dp.begin()+n);
   

    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

bool isWin(vector<ll> &p, ll a, ll b, ll sumExp)
{
    ll n = p.size();
    ll countExp = 0;
    REP(i, n)
    {
        if (p[i] - b * sumExp > 0)
        {
            if ((p[i] - b * sumExp) % (a - b) == 0)
            {
                countExp += (p[i] - b * sumExp) / (a - b);
            }
            else
            {
                countExp += (p[i] - b * sumExp) / (a - b) + 1;
            }   
        }
    }
    return countExp <= sumExp;
}

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    sort(ALL(h));
    reverse(ALL(h));
    
    ll left = 0, right = 1000000000;
    ll mid = (left + right) / 2;
    while(left + 1 < right)
    {
        if(isWin(h, A, B, mid))
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
        mid = (left + right) / 2;
    }

    cout << right << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define same(p1, p2) (dp(vec(p1, p2), vec(p1, p2)) < EPS)
#define dp(a, b) ((conj(a) * (b)).real())
#define cp(a, b) ((conj(a) * (b)).imag())
#define length(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a) / length(a)
#define rotateO(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define clr(a, b) memset(a, b, sizeof(a));

const ll N = 3005;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

string s, t;
ll memo[N][N], n, m;

ll solve(ll i, ll j)
{
	if(i == n || j == m)
		return 0;

	ll& ret = memo[i][j];

	if(~ret)	
		return ret;

	if(s[i] == t[j])
		ret = solve(i + 1, j + 1) + 1;

	ret = max(ret, solve(i + 1, j));
	ret = max(ret, solve(i, j + 1));
	
	return ret;
}

void build(ll i, ll j)
{
	if(i == n || j == m)
		return;

	ll& best = memo[i][j];

	if(s[i] == t[j] && best == solve(i + 1, j + 1) + 1)
	{
		cout << s[i];
		build(i + 1, j + 1);
	}
	else
	{
		if(best == solve(i + 1, j))
		{
			build(i + 1, j);
			return;
		}
		else
		{
			build(i, j + 1);
			return;
		}
	}
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    clr(memo, -1);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    solve(0, 0);
    build(0, 0);
}

Measured memory_bytes: 71168
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector> 
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, m;
vector<int>a[N];
int col[N];
bool BIP; int BLK, WHT;
void dfs(int x)
{
	if (col[x] == 1)++BLK; else ++WHT;
	for (auto y : a[x])
	{
		if (col[y] == col[x])
		{
			BIP = 0;
			return;
		}
		else if (!col[y])
		{
			col[y] = 3 - col[x];
			dfs(y);
		}
	}
}
int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; ++i)a[i].clear();
		for (int i = 1; i <= m; ++i)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			a[x].push_back(y);
			a[y].push_back(x);
		}
		BIP = 1; BLK = WHT = 0; col[1] = 1; dfs(1);
		printf("%lld\n", BIP ? (LL)BLK * WHT - m : (LL)n * (n - 1) / 2 - m);
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】


【数据】


*/

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
	string s; cin >> s;
	int res = 0;
	char pre = s[0];
	for (int i = 0; i < s.size(); i++)
	{
		if(s[i] != pre) {
			res++;
			pre = s[i];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def M(n): return ModInt(n)
def MI(): return M(I())


def main():
    k,a,b = LI()
    if k <= a:
        return 1
    if a <= b:
        return -1
    t = a-b
    r = int((k-a) / t)
    for i in range(r-10,r+10):
        if i*t + a >= k:
            return i*2+1

    return -1



print(main())




Measured memory_bytes: 65132
import java.io.*;

public class Main {

  static int s, w;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    s = Integer.parseInt(in[0]);
    w = Integer.parseInt(in[1]);

    br.close();

    System.out.println(w >= s ? "unsafe" : "safe");
    
  }
}

Measured memory_bytes: 32484