akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int a,b,n;
  cin >> n >> a >> b;

  vector<ll> p(n);
  rep(i, n) cin >> p[i];

  sorti(p);

  ll ans[3] = {0,0,0};
  for (int i = 0; i < n; ++i) {
    if (p[i] <= a) {
      ans[0] += 1;
    } else if (p[i] >= a+1 and p[i] <= b) {
      ans[1] += 1;
    } else {
      ans[2] += 1;
    }
  }

  cout << min({ans[0], ans[1], ans[2]}) << endl;
}


Measured memory_bytes: 256
list1 = [int(a) for a in input().split()]
list1_0 = list1[0] #A
list1_1 = list1[1] #B

if (list1_1 % list1_0) == 0:
    print(list1_0 + list1_1)
else:
    print(list1_1 - list1_0)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int[] A = cin.arrayInt();

        var L = new int[N];
        var R = new int[N + 1];

        L[0] = 0;
        R[N] = 0;
        for (int i = 0; i < N - 1; i++)
        {
            L[i + 1] = gcd(L[i], A[i]);
            R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
        }

        int max = 0;
        for (int i = 0; i < N; i++)
        {
            int tmp = gcd(L[i], R[i + 1]);
            if (tmp > max)
            {
                max = tmp;
            }
        }

        Console.WriteLine(max);
    }

    int gcd(int a, int b)
    {
        int tmp;
        if (b > a)
        {
            tmp = a;
            a = b;
            b = tmp;
        }

        if (b == 0)
        {
            return a;
        }

        return gcd(b, a % b);
    }

    int gcd(int[] a)
    {
        int ans = a[0];
        for (int i = 1; i < a.Length; i++)
        {
            ans = gcd(ans, a[i]);
        }
        return ans;
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 25820
package main

import "fmt"

func main() {
    var n, tmp int
    var ans float64
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&tmp)
        ans += 1.0 / float64(tmp)
    }

    ans = 1.0 / ans

    fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define sqr(a) ((a) * (a))
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
#define fe(i, a, b) for (int i = a; i < b; i++)
#define ii pair <int, int>
#define fi first
#define se second
#define sz(a) a.size()
#define RESET(a, b) memset((a), (b), sizeof (a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9 + 7;

int A, B, C;

void enter()
{
   cin >> A >> B >> C;
}

void process()
{
   if (A == 5 && B == 5 && C == 7) cout << "YES";
   else if (A == 5 && B == 7 && C == 5) cout << "YES";
   else if (A == 7 && B == 5 && C == 5) cout << "YES";
   else cout << "NO";
}

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL);
   //freopen("template.inp", "r", stdin);
   //freopen("template.out", "w", stdout);

   enter();
   process();

   return 0;
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
zenhan = S[:2]
kouhan = S[2:]

if 0 < int(zenhan) < 13:
    if 0 < int(kouhan) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < int(kouhan) < 13:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
// D - Sum of Divisors
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int N; cin>>N;
	ll s = 0;
	for(int k=N, m=1; m<=N; k=N/++m)
		s += (ll)k * (k+1) * m / 2;
	cout<< s <<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<pair<lint, lint>> a;
    for (int i = 0; i < n; ++i) {
        lint b;
        cin >> b;
        a.emplace_back(b, i);
    }
    sort(a.begin(), a.end(), greater<>());
    vector<vector<lint>> dp(n + 1, vector<lint>(n, -inf));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j != 0)
                chmax(dp[i][j], dp[i - 1][j - 1] + a[i - 1].first * abs(j - 1 - a[i - 1].second));
            chmax(dp[i][j], dp[i - 1][j] + a[i - 1].first * abs(n - 1 - (i - 1 - j) - a[i - 1].second));
        }
    }
    lint ret = 0;
    for (int j = 0; j < n; ++j) {
        chmax(ret, dp[n][j]);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 34624
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define gcd(a,b) __gcd(a,b);
int main()
{
    fastio;
    double ans,r,p=3.1416;
    cin>>r;
    ans=p*r*2;
    cout<<ans<<endl;
 
}

Measured memory_bytes: 3792
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a,b,c,d=h//2,h%2,w//2,w%2
l=[b&d,d*a+b*c,0,a*c]
for i in map(s.count,set(s)-{'\n'}):
  for j in(3,1,0):
    while l[j]and i>j:
      i-=j+1
      l[j]-=1
print('YNeos'[sum(l)>0::2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d);
}

Measured memory_bytes: 256
from collections import*
n,*a=map(int,open(0).read().split())
C=Counter(a)
r=0
for x in sorted(a)[::-1]:
	if C[x]>0:y=1<<x.bit_length();C[x]-=1;r+=C[y-x]>0;C[y-x]-=1
print(r)

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

#define PB emplace_back
#define mid ((be+en)/2)
#define cl c*2
#define cr cl+1

using namespace std;

const int N = 60;

long long int mod = 1e9+7;

struct matrix{
    long long int a[N][N], n, m;
    void identity() {
        for(int i = 0 ; i < n ; i++ ) {
            for(int j = 0 ; j < m ; j++ ) {
                a[i][j]=(i==j);
            }
        }
    }
    void emp() {
        for(int i = 0 ; i < n ; i++ ) {
            for(int j = 0 ; j < m ; j++ ) {
                a[i][j]=0;
            }
        }
    }
};

void out(matrix x) {
    for(int i = 0 ; i < x.n ; i ++ ) {
        for(int j = 0 ; j < x.m ; j++ ) {
            cout << x.a[i][j] << ' ';
        }
        cout << '\n';
    }
}

matrix ans;

matrix operator *(matrix x, matrix y) {
    matrix ret;
    ret.n=x.n;
    ret.m=y.m;
    ret.emp();
    for(int i = 0 ; i < x.n ; i++ ) {
        for(int j = 0 ; j < y.m ; j++) {
            for(int k = 0 ; k < x.m ; k++ ) {
                ret.a[i][j]+=x.a[i][k]*y.a[k][j];
                ret.a[i][j]%=mod;
            }
        }
    }
    return ret;
}

matrix wop(matrix bas, long long int k) {
    matrix ret;
    ret.n=ret.m=bas.n;
    ret.identity();
    for(; k >= 1 ; k /= 2) {
        if(k&1)ret=ret*bas;
        bas=bas*bas;
    }
    return ret;
}

int main () {
    long long int n, k;
    cin >> n >> k;
    ans.m=ans.n=n;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            cin >> ans.a[i][j];
        }
    }
    matrix mas = wop(ans,k);
    long long int jav=0;
    for(int i = 0 ; i < mas.n ; i++ ) {
        for(int j = 0 ; j < mas.m ; j++ ) {
            jav+=mas.a[i][j];
            jav%=mod;
        }
    }
    cout << jav;
}


Measured memory_bytes: 512
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max(A*B,C*D) << endl;
    return 0;
}


Measured memory_bytes: 256
def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res += [i, N // i]
        i += 1
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3060
import numpy as np

n, ww = map(int, input().split())

s = np.full(1000*100+1, 10**11, dtype=np.int64)
s[0] = 0
for i in range(n):
    w, v = map(int, input().split())
    s[v:] = np.minimum(s[v:], s[:-v] + w)

print(np.max(np.where(s<=ww)))

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll ans = 0;
    ll z = n / k;
    ans += z * z * z;
    if(k %2 == 0){
        ll hz = (n + k / 2) / k;
        ans += hz * hz * hz;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

const int N=200005;
queue<int> uft_q1;
int uft_parent[2][N];
int uft_num[2][N];

int uft_check_parent(int mode,int uft_x){
	if(uft_parent[mode][uft_x]!=-1)return uft_check_parent(mode,uft_parent[mode][uft_x]);
	int uft_a;
	while(!uft_q1.empty()){
		uft_a=uft_q1.front(),uft_q1.pop();
		uft_parent[mode][uft_a]=uft_x;
	}
	return uft_x;
}

bool uft_connect(int mode,int uft_x,int uft_y){
	uft_x=uft_check_parent(mode,uft_x),uft_y=uft_check_parent(mode,uft_y);
	if(uft_x==uft_y)return true;
	if(uft_num[uft_x]>uft_num[uft_y])swap(uft_x,uft_y);
	uft_parent[mode][uft_x]=uft_y;
	uft_num[mode][uft_y]+=uft_num[mode][uft_x];
	return false;
}

map<LL,int> m1;
int s[N];

int main(){
	int n,m,p;
	int i,j,k;
	LL a,b,c;
	int z[5];
	memset(uft_parent,-1,sizeof(uft_parent));
	cin>>n>>z[0]>>z[1];
	for(i=0;i<2;i++){
		for(j=0;j<z[i];j++){
			cin>>a>>b;
			a--,b--;
			uft_connect(i,a,b);
		}
	}
	for(i=0;i<n;i++){
		a=(LL)uft_check_parent(0,i)*n+uft_check_parent(1,i);
		m1[a]++;
	}
	for(i=0;i<n;i++){
		a=(LL)uft_check_parent(0,i)*n+uft_check_parent(1,i);
		s[i]=m1[a];
	}
	array_show(s,n);
}

Measured memory_bytes: 14592
/* ITP1_6_A: Reversing Numbers */

#include <iostream>

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

    int array[n];
    for (int i = 0; i < n; i++) {
        std::cin >> array[i];
    }

    std::cout << array[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        std::cout << " " << array[i];
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

ll fact[4001];
ll ifact[4001];
constexpr ll MOD = 1000000007;
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll comb(ll n, ll k) {
  return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int main() {
  fact[0] = 1;
  REP(i,4000) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  ifact[4000] = inv(fact[4000], MOD);
  REP(ri,4000) {
    int i = 4000 - ri;
    ifact[i-1] = ifact[i] * i % MOD;
  }
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll s;
  cin>>s;
  ll ans = 0;
  FOR(i,1,s) {
    ll rem = s - 3*i;
    if (rem < 0) break;
    ans += comb(rem + i - 1, rem);
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3704
import sys
input=sys.stdin.readline
import heapq
n,m=map(int,input().split())

def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge = heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v = minedge[1]
    d[v] = minedge[0]
    used[v] = False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d
edge = [[] for i in range(n)]
for i in range(m):
  l,r,c=map(int,input().split())
  edge[l-1].append([c,r-1])
for i in range(1,n):
  edge[i].append([0,i-1])


d=dijkstra_heap(0)
print(-1 if d[-1]==float("inf") else d[-1])


  

Measured memory_bytes: 53928
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 305;
const Int MAX2 = MAX*2;
signed ex[MAX2][MAX2];
signed dp1[MAX2+2][MAX2+2];
signed dp2[MAX2+2][MAX2+2];
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  memset(ex,0,sizeof(ex));
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]!='#') continue;
      vp.emplace_back(1+i+j,1+i-j+w);
      ex[1+i+j][1+i-j+w]=1;      
    }
  }
  
  auto ch=
    [&](Int i,Int j)->Int{
      if(i<0||i>=MAX2) return 0;
      if(j<0||j>=MAX2) return 0;
      return ex[i][j];
    };
  
  memset(dp1,0,sizeof(dp1));
  memset(dp2,0,sizeof(dp2));
  Int ans=0;
  
  const Int LIM = h+w;
  for(Int k=1;k<=LIM;k++){
    for(Int i=0;i<MAX2;i++){
      for(Int j=0;j<MAX2;j++){
        dp1[i][j+1]=dp1[i][j]+(ex[i][j]&&ch(i,j-k));
        dp2[i][j+1]=dp2[i][j]+(ex[j][i]&&ch(j-k,i));
      }
    }
    for(P p:vp){
      Int i,j;
      tie(i,j)=p;
      
      if(i-k>=0) ans+=dp1[i-k][min(MAX2,j+k+1)]-dp1[i-k][j];
      if(j-k>=0) ans+=dp2[j-k][min(MAX2,i+k+1)]-dp2[j-k][i];
      
      if(i+k<MAX2) ans+=dp1[i+k][min(MAX2,j+k+1)]-dp1[i+k][j];
      if(j+k<MAX2) ans+=dp2[j+k][min(MAX2,i+k+1)]-dp2[j+k][i];
    }            
  }

  //cout<<ans<<endl;
  for(P p:vp){
    Int i,j;
    tie(i,j)=p;
    for(Int k=1;k<=LIM;k++){
      if(ch(i+k,j)&&ch(i,j+k)) ans--;
      if(ch(i+k,j)&&ch(i,j-k)) ans--;
      if(ch(i-k,j)&&ch(i,j+k)) ans--;
      if(ch(i-k,j)&&ch(i,j-k)) ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6388
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;






int main(void)
{


    int D, T, S;
    cin >> D >> T >> S; // x, y
    if( D*1.0/S  <= T)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    




    return 0;
}


Measured memory_bytes: 3620
x, k, d = map(int,input().split())

amari = abs(x) % d
shou = (abs(x)-amari)/d

if k <= shou:
    print(int(abs(x)-d*k))
else:
    nokorikaisuu = k-shou
    if nokorikaisuu % 2 == 1:
        print(int(abs(abs(x)-d*shou-d)))
    else:
        print(int(abs(x)-d*shou))

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

int main(void){
    char str[4];
    int i;
    scanf("%s", str);
    i = strchr(str, '7');
    if (i != 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
import heapq
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
INF = 10**18
edge = [[] for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
s,t = map(int,input().split())

def dijkstra_heap(s,g,p):
    d = [[INF] * p for i in range(n)] 
    used = [[True] * p for i in range(n)] 
    used[s][0] = False
    ed_list = []
    for es in edge[s]:
        heapq.heappush(ed_list,[1,es,1]) # 回数、向かう頂点、あまり
    while len(ed_list):
        ken,v,md = heapq.heappop(ed_list)
        if not used[v][md]:
            continue
        d[v][md] = ken
        used[v][md] = False
        if not used[g][0]:
            break
        for e in edge[v]:
            if used[e][(md+1)%p]:
              if (md+1)%p == 1:
                heapq.heappush(ed_list,[ken+1,e,1])
              else:
                heapq.heappush(ed_list,[ken,e,(md+1)%p])
    return d[g][0]

ans = dijkstra_heap(s-1,t-1,3)
if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 41676
w = gets.chomp.to_i
n = gets.chomp.to_i
arrays = (1..w).to_a
n.times do | a |
  b = gets.chomp.split(',').map(&:to_i)
  arrays[b[0] - 1], arrays[b[1] -1] = arrays[b[1] -1], arrays[b[0] - 1]
end
arrays.each do |array|
    puts array
end


Measured memory_bytes: 6864
s = input()
N = len(s)
flag = False
for i in range(N):
  if s[i]=='1':
    if s[N-2-i]!='1':
      print(-1)
      break
else:
  if s[0]=='0' or s[-1]=='1':
    print(-1)
  else:
    s = list(s)
    s[-1] = '1'
    ls = []
    for i in range(N):
      if s[i]=='1':
        ls.append(i)
    ps = 0
    for i in range(N-1):
      if i==ls[ps]:
        ps += 1
      print(i+1,ls[ps]+1)

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

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

    string t = "";
    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    if(n == 0) {
        cout << s << endl;
        return 0;
    }

    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < al.size(); j++) {
            if(s[i] == al[j]) {
                s[i] = al[(j+n)%26];
                break;
            }
        }    
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x;
    scanf("%d %d %d",&x,&a,&b);
    if("x<=1000 && a<=1000 && b<=1000")
    {

    if(abs(x-a) <abs(x-b))
    {
        printf("A");
    }
    else
    {
        printf("B");
    }
    }
    return 0;



}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

bool g[50][50];
int n, m;
bool visited[50];
int ans = 0;

void dfs(int u)
{
    visited[u] = 1;
    rep(i, n)
    {
        if (g[u][i] == 1 && !visited[i])
            dfs(i);
    }
}

int main()
{
    rep(i, 50) rep(j, 50) g[i][j] = 0;

    cin >> n >> m;
    vector<pii> edge;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a][b] = 1;
        g[b][a] = 1;
        edge.push_back(pii(a, b));
    }

    rep(i, m)
    {
        pii e = edge[i];
        int cnt = 0;
        g[e.first][e.second] = g[e.second][e.first] = 0;
        rep(i, 50) visited[i] = 0;
        rep(i, n)
        {

            if (!visited[i])
            {
                dfs(i);
                cnt++;
            }
        }
        if (cnt >= 2)
            ans++;
        g[e.first][e.second] = g[e.second][e.first] = 1;
    }

    OP(ans);

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

struct tomy{
	int v, l, r;
	bool operator<(const tomy &rhs) const {
		return v < rhs.v;
	}
	bool operator>(const tomy &rhs) const {
		return v > rhs.v;
	}
};

int n,a[2][225816],segtree[2][816225];
priority_queue<tomy, vector<tomy>, greater<tomy> > pq;
vector<int> ans;

void init(int k, int l=0, int r=n, int i=0){
	int vl,vr;
	if(r-l>1){
		init(k,l,(l+r)>>1,i*2+1);
		init(k,(l+r)>>1,r,i*2+2);
		vl = segtree[k][i*2+1];
		vr = segtree[k][i*2+2];
		if(a[k][vl] < a[k][vr]){
			segtree[k][i] = vl;
		}else{
			segtree[k][i] = vr;
		}
	}else{
		segtree[k][i] = l;
	}
}

void update(int k, int p, int l=0, int r=n, int i=0){
	int vl,vr;
	if(p<l || r<=p){
		return;
	}else if(r-l>1){
		update(k,p,l,(l+r)>>1,i*2+1);
		update(k,p,(l+r)>>1,r,i*2+2);
		vl = segtree[k][i*2+1];
		vr = segtree[k][i*2+2];
		if(a[k][vl] < a[k][vr]){
			segtree[k][i] = vl;
		}else{
			segtree[k][i] = vr;
		}
	}else{
		segtree[k][i] = p;
	}
}

int query(int k, int p, int q, int l=0, int r=n, int i=0){
	int vl,vr;
	if(q<=l || r<=p){
		return n;
	}else if(p<=l && r<=q){
		return segtree[k][i];
	}else{
		vl = query(k,p,q,l,(l+r)>>1,i*2+1);
		vr = query(k,p,q,(l+r)>>1,r,i*2+2);
		if(a[k][vl] > a[k][vr]){
			return vr;
		}else{
			return vl;
		}
	}
}

int main(void){
	int i,p,q;
	tomy t[4];
	fill(a[0],a[2],INF);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i%2][i];
	}
	init(0); init(1);
	t[0].l = 0; t[0].r = n; t[0].v = a[0][query(0,0,n)];
	pq.push(t[0]);
	while(!pq.empty()){
		t[0] = pq.top();
		pq.pop();
		p = query((t[0].l)%2,t[0].l,t[0].r);
		q = query((p+1)%2,p,t[0].r);
		ans.push_back(a[p%2][p]);
		ans.push_back(a[q%2][q]);
		t[1].l = t[0].l; t[1].r = p;
		t[2].l = p+1; t[2].r = q;
		t[3].l = q+1; t[3].r = t[0].r;
		for(i=1; i<4; ++i){
			t[i].v = a[t[i].l%2][query(t[i].l%2,t[i].l,t[i].r)];
			if(t[i].v<INF){
				pq.push(t[i]);
			}
		}
	}
	for(i=0; i<n; ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 10892
#include <stdio.h>

#define MAX 10005
#define NIL -1

typedef struct node{
  int parent,left,right;
} Node;

Node T[MAX];
int N,D[MAX],H[MAX];

void setdepth(int,int);
int setheight(int);
int getsibling(int);
void print(int);

int main(){
  int id,l,r,i;
  int root = 0;

  scanf("%d",&N);

  for(i=0;i<N;i++)T[i].parent = NIL;

  for(i=0;i<N;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].left = l;
    T[id].right = r;
    if( l != NIL) T[l].parent = id;
    if( r != NIL) T[r].parent = id;
  }

  for(i=0;i<N;i++) if(T[i].parent == NIL)root = i;

  setdepth(root,0);
  setheight(root);

  for(i=0;i<N;i++)print(i);

  return 0;
}

void setdepth(int n,int d){
  if(n == NIL)return;
  D[n] = d;
  setdepth(T[n].left,d + 1);
  setdepth(T[n].right,d + 1);
}

int setheight(int n){
  int h1 = 0;
  int h2 = 0;

  if( T[n].left != NIL) h1 = setheight(T[n].left) + 1;

  if( T[n].right != NIL) h2 = setheight(T[n].right) + 1;

  return H[n] = ( h1 > h2 ? h1 : h2 );
}

int getsibling(int n){
  if(T[n].parent == NIL)return NIL;
  if(T[T[n].parent].left != n && T[T[n].parent].left != NIL)return T[T[n].parent].left;
  if(T[T[n].parent].right != n && T[T[n].parent].right != NIL)return T[T[n].parent].right;

  return NIL;
}

void print(int n){
  int deg =0;
  printf("node %d: ",n);
  printf("parent = %d, ",T[n].parent);
  printf("sibling = %d, ",getsibling(n));

  if(T[n].left != NIL)deg++;
  if(T[n].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[n]);
  printf("height = %d, ",H[n]);

  if(T[n].parent == NIL){
    printf("root\n");
  }

  else if(T[n].left == NIL && T[n].right == NIL){
    printf("leaf\n");
  }

    else {
      printf("internal node\n");
    }
}
  
  



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<tuple<string, int,int>>v;
	rep(i, 0, N) {
		string x; cin >> x;
		int y; cin >> y;
		v.emplace_back(x, -y, i + 1);
	}
	sort(all(v));
	rep(i, 0, N) {
		cout << get<2>(v[i]) << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int a; cin >> a;
  string s; cin >> s;
  if (a >= 3200) cout << s << endl;
  else           cout << "red" << endl;
}


Measured memory_bytes: 3576
#include<stdio.h>
int main()
{
    int n,i,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        k=i;
        if(i%3==0)
        {
            printf(" %d",i);
        }
        else
        {
            while(k!=0)
            {
                if(k%10==3)
                {
                    printf(" %d",i);
                    k=0;
                }
                 k=k/10;
            }

        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2128
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    Scanner in=new Scanner(System.in);
    PrintWriter pw=new PrintWriter(System.out, true);
    int n=in.nextInt();
    ArrayList<Integer> arr=new ArrayList<>();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    {
      int num=in.nextInt();
      arr.add(num);
      a[i]=num;
    }
    Collections.sort(arr);
    for(int i=0;i<n;i++)
    {
      if(a[i]<=arr.get((n/2)-1))
      pw.println(arr.get(n/2));
      else
      pw.println(arr.get((n/2)-1))  ;
    //  arr.add(ind,a[i]);
    }
  }
}


Measured memory_bytes: 101880
h,w=map(int,input().split())
S=[list(map(str,input().split())) for _ in range(h)]

alpha=[chr(ord('A') + i) for i in range(26)]
for i in range(h):
  for j in range(w):
    if S[i][j]=='snuke':
      print(alpha[j]+str(i+1))
      exit()

Measured memory_bytes: 3060
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long A, long long B){
    cout<<(A-1)*(B-1)<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
  Scanner sc= new Scanner(System.in);
  int w = sc.nextInt();
  int n = sc.nextInt();
  int[] values = new int[w];
  for(int i= 0; i < values.length; i++) {
   values[i] = i + 1;
  }
  for(int i= 0; i < n; i++){
   String str= sc.next();
   String[] ab = str.split(",");
   int a = Integer.parseInt(ab[0]) -1;
   int b = Integer.parseInt(ab[1]) -1;
   int c = values[a];
    values[a] = values[b];
    values[b] = c; 
  }
  for(int i = 0;i<values.length;i++){
   System.out.printf("%d\n",values[i]);
  }
 }
}

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

int n, m, e[51][51], ans, u[51 << 1], v[51 << 1];
bool vis[51];

void dfs(int node) {
    vis[node] = 1;
    for(int i = 1; i <= n; ++i) {
        if(i == node) continue;
        if(!vis[i] && e[node][i]) dfs(i);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> u[i] >> v[i];
        e[u[i]][v[i]] = e[v[i]][u[i]] = 1;
    }
    for(int i = 1; i <= m; ++i) {
        e[u[i]][v[i]] = e[v[i]][u[i]] = 0;
        memset(vis, 0, sizeof(vis));
        dfs(1);
        for(int i = 1; i <= n; ++i)
            if(!vis[i]) {
                ++ans;
                break;
            }
        e[u[i]][v[i]] = e[v[i]][u[i]] = 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main(){
    int A, B, C, X, Y, m = INF;
    cin >> A >> B >> C >> X >> Y;
    REP(i, max(X,Y)+1){
        m = min(2*C*i + A*max(0,X-i) + B*max(0,Y-i), m);
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ss[1005];
int a,b,c,d;
int main()
{
	scanf("%s",ss+1);
	int k=strlen(ss+1);
	for(int i=1;i<=k;i++)
	{
		if(ss[i]=='S')a++;
		else if(ss[i]=='N')b++;
		else if(ss[i]=='W')c++;
		else d++;
	}
	if((a>0&&b>0)||(a==0&&b==0))
	{
		if((c>0&&d>0)||(c==0&&d==0))printf("Yes");
		else printf("No");
	}
	else printf("No");
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  long long k;
  cin >> s >> k;
  k--;

  long long fst_idx = s.size();
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != '1') {
      fst_idx = i;
      break;
    }
  }

  if (k < fst_idx) {
    cout << 1 << '\n';
  } else {
    cout << s[fst_idx] << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
B = gets.split.map(&:to_i)

s = 0
(N-1).times do |i|
  if i == 0
    s += B[0]
    next
  end
  s += [B[i],B[i-1]].min
end
s += B[-1] # 最後の要素分
p s

Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>
using namespace std; 
int main() {
  long long int a, b, n, k, i, minimum; 
  scanf("%lld%lld%lld", &a, &b, &n); 
  if (b > n) {
    printf("%lld", (a*n)/b); 
  }
  else 
    printf("%lld", (a*(b-1))/b); 
  return 0; 
}

Measured memory_bytes: 1724
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	int N, M;

	cin >> N >> M;
	bool ans = false;
	if (N == M) {
		ans = true;
	}
	puts(ans ? "Yes" : "No");
	return 0;
}

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

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    char c;
    cin >> c;
    const string vowels = "aeiou";
    cout << (count(ALL(vowels), c) ? "vowel" : "consonant") << endl;
    return 0;
};


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int h,w;
int main() {
  cin >> h >> w;

  char a[h+2][w+2];
  rep(i,0,h+2){
    rep(j,0,w+2){
      a[i][j] = '#';
    }
  }
  rep(i,1,h+1){
    rep(j,1,w+1){
      cin >> a[i][j];
    }
  }
  rep(i,0,h+2){
    rep(j,0,w+2){
      printf("%c",a[i][j]);
    }
    printf("\n");
  }
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


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

    int wcnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '.') wcnt++;
    }

    int ans = wcnt;
    int b = 0, w = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '#') b++;
        if(s[i] == '.') w++;
        ans = min(ans, b + wcnt - w);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3764
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    map<int,int>mp;
    rep(i,n){
        int hoge; cin>>hoge;
        mp[hoge]++;
    }
    int d; cin>>d;
    rep(i,d){
        int hoge; cin>>hoge;
        if(mp[hoge]==0)return puts("NO")*0;
        mp[hoge]--;
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int r; cin >> r;
    cout << r * r << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

ll N;
map<string, ll> M;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        string str;
        cin >> str;
        M[str]++;
    }
    ll maxvl = 0;
    for(map<string, ll>::iterator it=M.begin();it!=M.end();it++) {
        pair<string, ll> u = *it;
        if(u.second>maxvl) maxvl = u.second;
    }
    //cout << maxvl << endl;
    for(map<string, ll>::iterator it=M.begin();it!=M.end();it++) {
        pair<string, ll> u = *it;
        if(u.second==maxvl) cout << u.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
 
int main() {
  float d;
  std::cin >> d;
  float t;
  std::cin >> t;
  float s;
  std::cin >> s;
  
  if ((d / s) > t) {
    std::cout << "No";
  }
  else {
    std::cout << "Yes";
  }
}

Measured memory_bytes: 3188
n = int(input())
enemy_hp = [int(i) for i in input().split()]
hero_str = [int(i) for i in input().split()]
enemy_hp_sum = sum(enemy_hp)

def than_zero(x):
  if x < 0:
    y = 0
  else:
    y = x
  return y

for i in range(n):
  temp_hp = enemy_hp[i]
  enemy_hp[i] = than_zero(enemy_hp[i] - hero_str[i])
  hero_str[i] = than_zero(hero_str[i] - temp_hp)
  enemy_hp[i+1] = than_zero(enemy_hp[i+1] - hero_str[i])

print(enemy_hp_sum - sum(enemy_hp))

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> p(n); for (int i = 0; i < n; i++) cin >> p[i];
  vector<bool> a(n);
  for (int i = 0; i < n; i++) a[i] = p[i] == i + 1;
  int i = 0, res = 0;
  while (i < n - 1) {
    if (a[i]) {
      res++;
      if (a[i + 1]) i += 2;
      else i++;
    } else i++;
  }
  res += i == n - 1 and a[n - 1];
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class ZAlgo:
    def __init__(self, seq):
        self.n = len(seq)
        # seq 自身と seq[i:] とが、先頭から最大で何文字一致しているか
        self.lcp = [0] * self.n
        self.lcp[0] = self.n
        i, j = 1, 0
        while i < self.n:
            while i + j < self.n and seq[j] == seq[i+j]:
                j += 1
            self.lcp[i] = j
            if j == 0:
                i += 1
                continue

            k = 1
            while i + k < self.n and k + self.lcp[k] < j:
                self.lcp[i + k] = self.lcp[k]
                k += 1
            i += k
            j -= k

    # seq[0:]とseq[i:]のLCP
    def getLCP(self, i): return self.lcp[i]

def main():
    N = I()
    S = SL()

    ans = 0

    for i in range(N):
        z = ZAlgo(S[i:])
        for j in range(N-i):
            ans = max(ans, min(z.getLCP(j), j))

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 84068
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = 0
for i in range(n):
    if a[i] >= b[i]:
        c += b[i]
    elif a[i] + a[i + 1] >= b[i]:
        a[i + 1] -= b[i] - a[i]
        c += b[i]
    else:
        c += a[i] + a[i + 1]
        a[i + 1] = 0
print(c)

Measured memory_bytes: 18624
mod = 10**9+7
def factrial(N):
    fc = [1, 1] + [None] * N
    inv = [0, 1] + [None] * N
    fcInv = [1, 1] + [None] * N
    for i in range(2, N+1):
        fc[i] = i*fc[i-1]%mod
        inv[i] = mod-(inv[mod%i]*(mod//i))%mod
        fcInv[i] = fcInv[i-1]*inv[i]%mod
    return fc, fcInv

def modCom(n, k):
    return 0 if n < k else fc[n] * fcInv[k] * fcInv[n-k] % mod

K = int(input())
S = input()
L = len(S)
fc, fcInv = factrial(L+K)
ans = 0
for i in range(K+1):
    ans += modCom(K-i+L-1, L-1) * pow(25, K-i, mod) * pow(26, i, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 253136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
template<class T>void prarr(vector<vector<T>>& a){
rep(i, a.size()){
rep(j, a[i].size()){
cout << a[i][j]; printf(" ");}
printf("\n");} printf("\n");}

int n, m;
set<int> s[305];
arr<bool> G;

void makeG(int a, int b){
    if(G[a][b]) return;

    G[a][b] = true;
    rep(i, n){
        if(!G[i][a]) continue;
        rep(j, n){
            if(!G[b][j]) continue;
            G[i][j] = true;
        }
    }
}

int main()
{
    cin >> n >> m;
    G.resize(n, vector<bool>(n, false));
    // memset(G, 0, sizeof(G));
    rep(i, n) {
        G[i][i] = true;
        // s[i].insert(i);
    }
    rep(i, m){
        int a, b; cin >> a >> b;
        makeG(--a,--b);
    }

    // prarr(G);
    vector<int> ans[n];
    rep(i, n){
        rep(j, n){
            if(G[i][j] && G[j][i]) ans[i].push_back(j+1); 
        }
    }

    rep(i, n){
        prvec(ans[i]);
    }
    return 0;}


Measured memory_bytes: 3680