akhauriyash/Code-Regression huggingface dataset:
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let r = read_as_vec::<f64>()[0];
    let g = read_as_vec::<f64>()[0];
    println!("{}", g*2.0-r);

    // (r+x)/2 = g
    // x = g*2-r
}


Measured memory_bytes: 4352
//
//AtCoder Beginner Contest 174
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<char> c(n);
    int rCnt=0;
    int wCnt=0;
    REP(i, n) {
        cin >> c[i];
        if (c[i]=='R') rCnt++;
        if (c[i]=='W') wCnt++;
    }
    int ans=0;

    int rEnd = rCnt;
    REP(i, rCnt){
        if(c[i]=='W') {
            FOR(j, rEnd, n-1){
                if (c[j]=='R') {
                    swap(c[i], c[j]);
                    ans++;
                    rEnd = j+1;
                    break;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19216
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    n = int(input())
    p = input_nums()
    cnt = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] and p[i] < p[i+1]:
            cnt += 1
        elif p[i+1] < p[i] and p[i] < p[i-1]:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO  freopen("C:\\Users\\sourav\\Documents\\cp files\\input.txt", "r", stdin); freopen("C:\\Users\\sourav\\Documents\\cp files\\output.txt", "w", stdout); 
#define maxn 1000000
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


signed main()
{
	
 	FLASH
 	int n , k;
 	cin>>n>>k;
 	int arr[n];
 	bool verdict[k + 2];
 	for(int i = 1; i<= k; i++)
 		verdict[i] = false;
 	for (int i = 0; i < n; ++i)
 		{
 			/* code */
 			cin>>arr[i];
 			verdict[arr[i]] = true;

 		}
 		//sort(arr , arr + n);
 		int j = 1;
 		while(!verdict[j])
 		{
 			j++;
 		}
 		for(int i = j + 1; i <= k; i++)
 		{
 			if(!verdict[i])
 			{
 				int flag = 0;
 				for(int a = 0; a<n;a++)
 				{
 					if(i - arr[a] >= 1)
 					{
 						if(!verdict[i - arr[a]])
 						{
 							flag = 1;
 						}
 					}
 				}
 				if(flag == 1)
 					verdict[i] = true;
 			}
 		}
 		if(verdict[k] == true)
 			cout<<"First";
 		else
 			cout<<"Second";

}

Measured memory_bytes: 384
def iskaibun(s):
    for i in range(len(s)):
        if s[i] != s[-i-1]:
            return False
    return True
            

S = input()
N = len(S)
if N % 2 == 0:
    print('No')
else:
    if iskaibun(S) and iskaibun(S[:(N-1)//2]) and iskaibun(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')
    

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

vector<int> opr(const vector<int> &a) {
	const int n = a.size();
	vector<int> b(n + 1, 0);

	rep(i, n) {
		const int from = max(i - a[i], 0);
		const int to = min(i + a[i] + 1, n);
		b[from]++, b[to]--;
	}

	rep(i, 1, n) b[i] += b[i - 1];
	b.pop_back();
	return b;
}

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

	chmin(k, 50);

	vector<int> a(n, 0);
	rep(i, n) cin >> a[i];

	rep(loop, k) {
		a = opr(a);
	}

	rep(i, n) cout << (i ? " ":"") << a[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d) {
        cout << "Balanced" << endl;
    }
    else if(a+b<c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Left" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
arms = []
finishtime = float('-inf')
for i in range(N):
    x,l = map(int,input().split())
    arms.append((x-l,x+l))
arms.sort(key=itemgetter(1))
cnt=0
for L,R in arms:
    if finishtime<=L:
        cnt+=1
        finishtime = R
print(cnt)

Measured memory_bytes: 18284
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n = int(input())
def f(n):
    return (n+1)*n // 2
m = BisectSearch(f, l=1, r=10**7)(n)
m += f(m) != n
A = set()
for i in range(m, 0, -1):
  if n - i >= 0:
    A.add(i)
    n -= i
print(*A, sep='\n')

Measured memory_bytes: 9268
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n, x; cin >> n >> x;
  int l[n]; for(int i = 0; i < n; i++) cin >> l[i];
  int d[n];
  d[0] = 0;
  for(int i = 1; i <= n; i++){
    d[i] = d[i - 1] + l[i - 1];
  }
  for(int i = 0; i <= n; i++){
    if(d[i] > x){
      cout << i << endl;
      return;
    }
    if(i == n){
      cout << n + 1 << endl;
      return;
    }
  }
  return;
}

int main(){
  solve();
  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 a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans1 = a + b > a - b ? a+b : a-b;
        int ans2 = a * b;
        System.out.println(Math.max(ans1, ans2));
    }
}

Measured memory_bytes: 23124
#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 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

int main()
{
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  
  vector<vector<int>> dist(H,vector<int> (W,-1));
  ll ans = 0;
  REP(i,H){
    REP(j,W){
      if(A.at(i).at(j)=='#'&&dist[i][j]==-1){
        ll cntblack = 1;
        ll cntwhite = 0;
        queue<P> que;
        que.push(make_pair(i,j));
        dist[i][j]=0;
        while(!que.empty()){
          int vy = que.front().first;
          int vx = que.front().second;
          que.pop();
          REP(k,4){
            int nvy = vy+dy[k];
            int nvx = vx+dx[k];
            if(nvy<0||nvy>H-1||nvx<0||nvx>W-1||dist[nvy][nvx]!=-1||(A[vy][vx]=='#'&&A[nvy][nvx]!='.')||(A[vy][vx]=='.'&&A[nvy][nvx]!='#')) continue;
            dist[nvy][nvx]=0;
            que.push(make_pair(nvy,nvx));
            if(A[nvy][nvx]=='#'){
              cntblack++;
            }else{
              cntwhite++;
            }
          }
        }
        ans+=cntblack*cntwhite;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4476
n, m = map(int, input().split())
aas = list(map(int, input().split()))
import heapq
hq = []
for i in aas:
    heapq.heappush(hq,-i)
for i in range(m):
    tmp = heapq.heappop(hq)
    heapq.heappush(hq,-((-tmp)//2))
print(-sum(hq))

Measured memory_bytes: 20044
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int x;cin >>x;
    x=1-x;
    cout <<x<<endl;
}



Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
const int N = 55;
typedef long long ll;

struct data{
	ll sum , d;
	int size;
	
	bool operator < (const data &x) const{
		return size * x.sum > x.size * sum; 
	}
	
}a[N];

struct edge{
	int pos , nx;
}e[N << 1];

int n , X , D , num , head[N];
ll dp[N * N * N] , sum[N] , sz[N] , val[N];

void add(int u , int v){
	e[++num].pos = v; e[num].nx = head[u]; head[u] = num;
}

void dfs(int now){
	sz[now] = 1; sum[now] = val[now];
	for(int i = head[now] ; i ; i = e[i].nx){
		dfs(e[i].pos);
		sz[now] += sz[e[i].pos];
		sum[now] += sum[e[i].pos];
	}
}

int main(){
	int temp;
	scanf("%d%d%d",&n,&X,&D);
	for(int i = 1 ; i <= n ; i++){
		scanf("%lld",&val[i]);
		if(i != 1){
			scanf("%d",&temp);
			add(temp , i);
		}
	}
	dfs(1);
	memset(dp , 0x3f , sizeof(dp)); dp[0] = 0;
	for(int i = 1 ; i <= n ; i++)
		for(int j = n * n * n ; j >= 0 ; j--)
			for(int k = 1 ; k <= min(n , (i == 1) ? n : D) && sum[i] * k <= X && j >= k * sz[i] ; k++)
				dp[j] = min(dp[j] , dp[j - k * sz[i]] + sum[i] * k);		
	for(int i = 1 ; i <= n ; i++){
		a[i].size = sz[i];
		a[i].sum = sum[i];
		a[i].d =  (i == 1) ?  X : (D - min(D , n));
	}
	sort(a + 1 , a + 1 + n);
	ll ans = 0;
	for(int i = n * n * n ; i >= 0 ; i--){
		if(dp[i] > X) continue;
		ll r = X - dp[i] , now = i;
		
		for(int j = 1 ; j <= n && r ; j++){
			now += a[j].size * min(a[j].d , r / a[j].sum);
			r	-= a[j].sum * min(a[j].d , r / a[j].sum);
		}
		ans = max(ans , now);
	}

	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

const double EPS = 1e-6;
const int MAX = 33;

int C[MAX][3];
VI G[MAX];
int X[MAX];
int E[MAX];
int CNT[3];
int DP[MAX][3];
int U[MAX];

int key(char ch)
{
    if (ch >= 'A' && ch <= 'M')return 1;
    if (ch >= 'N' && ch <= 'Z')return 2;
    return 0;
}

int DFS(int v, int p = -1)
{
    bool need = 0;
    if (C[v][1] || C[v][2])need = 1;
    U[v] = 1;
    DP[v][0] = DP[v][1] = DP[v][2] = INF/30;
    if (X[v] == 0)DP[v][0] = DP[v][1] = DP[v][2] = 0;
    else DP[v][X[v]] = 0;
    
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (to == p)continue;
        if(DFS(to, v))need = 1;
        FOR(k, 0, 3)
            DP[v][k] += min(DP[to][k], 1 + min(DP[to][1], DP[to][2]));
    }
    return need;
  //  cout << "*" << v << " " << DP[v][0] << " " << DP[v][1] << " " << DP[v][2] << endl;
}


int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m, k;
    cin >> n >> m >> k;
    FOR(i, 0, n+1)
        FOR(j, 0, m + 1)
    {
        int res = i * m - 2 * i * j + j * n;
        if (res == k)
        {
            cout << "Yes" << endl;
            return 0;
        }
        
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[input()for _ in[0]*N]
B=[input()for _ in[0]*M]
for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if A[i+k][j:j+M]!=B[k]:
                break
        else:
            print('Yes');exit()
print('No')

Measured memory_bytes: 3060
import Control.Monad

main = do
  n <- getLine
  a <- map read . words <$> getLine
  forM_ (solve a) $ \t -> 
    putStrLn . show $ t

solve :: [Int] -> [Int]
solve xs =
  let wp = wholePath xs
  in inSolve 0 wp (xs ++ [0])

inSolve prev ttl [] = []
inSolve prev ttl (x:[]) = []
inSolve prev ttl (x:y:xs) = 
  if prev <= x && x <= y || prev >= x && x >= y then
    ttl:(inSolve x ttl (y:xs))
  else
    (ttl + (abs (prev - y)) - (abs (x - y)) - (abs (prev - x))):(inSolve x ttl (y:xs))

wholePath xs = (abs (head xs)) + difsum xs 

difsum :: [Int] -> Int
difsum [] = 0
difsum (x:[]) = abs x
difsum (x:y:xs) = (abs (x-y)) + (difsum (y:xs))

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 1000;
int h, w;
string a[N];
bool seen[N][N];

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

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    queue<pair<int, int>> q;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(a[i][j] == '#') {
                q.emplace(i, j);
                seen[i][j] = true;
            }
        }
    }

    int ans = 0;
    while(!q.empty()) {
        int sz = q.size();
        while(sz--) {
            auto cur = q.front(); q.pop();
            for(int d = 0; d < 4; ++d) {
                int x = dx[d] + cur.first, y = dy[d] + cur.second;
                if(x >= 0 && y >= 0 && x < h && y < w && !seen[x][y] && a[x][y] == '.') {
                    q.emplace(x, y);
                    seen[x][y] = true;
                }
            }
        }
        ans++;
    }

    cout << ans-1 << endl;
    
    return 0;
}


Measured memory_bytes: 18612
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string a[3];
    int len = 0;
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
        len = max(len, (int)a[i].length());
    }

    bool match1[3][3][len+1];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k <= len; k++) {
                if (k > a[i].length() || k > a[j].length()) {
                    match1[i][j][k] = false;
                } else {
                    match1[i][j][k] = true;
                    for (int x = 0; x < k; x++) {
                        char ci = a[i][a[i].length()-k+x], cj = a[j][x];
                        if (ci != '?' && cj != '?' && ci != cj) {
                            match1[i][j][k] = false;
                        }
                    }
                }
            }
        }
    }

    bool match2[3][3][len+1];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k <= len; k++) {
                if (k + a[j].length() > a[i].length()) {
                    match2[i][j][k] = false;
                } else {
                    match2[i][j][k] = true;
                    for (int x = 0; x < a[j].length(); x++) {
                        char ci = a[i][k+x], cj = a[j][x];
                        if (ci != '?' && cj != '?' && ci != cj) {
                            match2[i][j][k] = false;
                        }
                    }
                }
            }
        }
    }

    int ans = len * 3;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (i == j) {
                continue;
            }
            for (int l1 = 0; l1 <= a[i].length(); l1++) {
                if (l1 + a[j].length() <= a[i].length() && !match2[i][j][l1]) {
                    continue;
                }
                if (l1 + a[j].length() > a[i].length() && !match1[i][j][a[i].length()-l1]) {
                    continue;
                }

                int r = max(a[i].length(), l1 + a[j].length());

                int k = 3 - i - j;
                for (int l2 = l1; l2 <= r; l2++) {
                    if (l2 < l1 + a[j].length()) {
                        if (l2 - l1 + a[k].length() <= a[j].length() && !match2[j][k][l2-l1]) {
                            continue;
                        }
                        if (l2 - l1 + a[k].length() > a[j].length() && !match1[j][k][a[j].length()-(l2-l1)]) {
                            continue;
                        }
                    }

                    if (l2 < a[i].length()) {
                        if (l2 + a[k].length() <= a[i].length() && !match2[i][k][l2]) {
                            continue;
                        }
                        if (l2 + a[k].length() > a[i].length() && !match1[i][k][a[i].length()-l2]) {
                            continue;
                        }
                    }

                    ans = min(ans, max(r, l2 + (int)a[k].length()));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
//頂点数N,辺数Mのグラフの全頂点について頂点Sからの最短距離を O((N+M)logN) で求める
int kita[100000]={0};
typedef pair<int,int> P;
const int POINT = 100001;
struct Edge{int to;int cost;};
void Dijk(vector<Edge> G[],int n,int s,int res[POINT]){
	bool vis[POINT]={0};
	fill(res,res+n,-1);
	priority_queue<P,vector<P>,greater<P>> que;
	P p;
	vis[s]=true;
	res[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		p = que.top();
		que.pop();
		for(Edge e:G[p.second]){
			if(!vis[e.to] || res[e.to]>res[p.second]+e.cost){
				vis[e.to]=true;
				kita[e.to]=p.second;
				res[e.to]=res[p.second]+e.cost;
				que.push(P(res[e.to],e.to));
			}
		}
	}
}
int main(){
	int N,M,u,v;
	int ans[POINT];
	vector<Edge> G[POINT];
	cin>>N>>M;
	for(int i=0;i<M;i++){//辺の追加,{辺の先,コスト}
		cin>>u>>v;u--;v--;
		G[u].push_back({v,1});
		G[v].push_back({u,1});
	}
	fill(kita,kita+N,-1);
	Dijk(G,N,0,ans);//(グラフ,頂点数,スタート,結果)
	cout<<"Yes"<<endl;
	for(int i=1;i<N;i++)cout<<kita[i]+1<<endl;
	return 0;
}

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

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

  int result = 0;
  int prev_b = 100000;
  for (int i = 0; i < N - 1; ++i) {
    int b;
    std::cin >> b;
    result += std::min(prev_b, b);
    prev_b = b;
  }
  result += prev_b;

  std::cout << result;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int Max = 100010;

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

int dp[Max];

int main(){
    int n;
    cin >> n;
    for (int i = 1; i < Max; i++) dp[i] = Max;

    for (int i = 0; i < n; i++){
        int cnt = 1;
        while(i + cnt <= n){
            dp[i + cnt] = min(dp[i + cnt], dp[i] + 1);
            cnt *= 6;
        }

        cnt = 1;
        while(i + cnt <= n){
            dp[i + cnt] = min(dp[i + cnt], dp[i] + 1);
            cnt *= 9;
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,A,cnt,now,sum=0;
bool flag=true,te[1000]={};

int main(){
    cin>>N;
    queue<int> opp[N];
    rep(i,N){
        rep(j,N-1){
            cin>>A;
            A--;
            opp[i].push(A);
        }
    }
    while(flag){
        // out(cnt);
        flag=false;
        bool lo[N];
        // rep(i,N){
        //     lo[i]=false;
        // }
        memcpy(lo,te,sizeof(lo));
        rep(i,N){
            if(lo[i]||opp[i].size()==0)continue;
            now=opp[i].front();
            if(opp[now].front()==i&&!lo[now]){
                flag=true;
                opp[i].pop();
                opp[now].pop();
                lo[i]=lo[now]=true;
                sum+=2;
            }
            lo[i]=true;
        }
        cnt++;
        if(sum==N*(N-1)){
            out(cnt);
            return 0;
        }
        if(cnt>100000){
            out(N*(N-1)/2);
            return 0;
        };
    }
    out(-1);
    
}


Measured memory_bytes: 4736
S = input()
N = len(S)
ans = 0

if S == S[::-1]:
    ans += 1

i = (N-1) // 2
if S[:i] == S[:i:-1]:
    ans += 1

j = (N+3) // 2 - 1
if S[j:] == S[N:j-1:-1]:
    ans += 1

if ans == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main(void){
  long int n;
  long int ret;
  long int i,j;
  int num;
  j = 0;
  scanf("%ld",&n);
  num = (int)sqrt(n);
  for(i = num; i>=1;i--){
    if (n % i == 0){
     break;
    }
  }
  j = (long)(n/i);
  printf("%ld",i+j-2);
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  if((S.at(0)==S.at(1) && S.at(2)==S.at(3)) || (S.at(0)==S.at(2) && S.at(1)==S.at(3)) || (S.at(0)==S.at(3) && S.at(1)==S.at(2))){
    if(S.at(0)==S.at(1) && S.at(1)==S.at(2)){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 2e3 + 13, mod = 1e9 + 7;
int n, k, dp[maxN][maxN], fac[maxN * maxN], rfac[maxN * maxN];

int pw (int a, int b) {
    int ret = 1;
    for (; b; b >>= 1, a = 1ll * a * a % mod)
	if (b & 1)
	    ret = 1ll * ret * a % mod;
    return ret;
}

int c (int a, int b) {
    return 1ll * fac[b] * rfac[a] % mod * rfac[b - a] % mod;
}

int32_t main () {
    cin >> n >> k;
    dp[0][0] = 1;
    fac[0] = rfac[0] = 1;
    for (int i = 1; i <= n * k; i++) {
	fac[i] = 1ll * fac[i - 1] * i % mod;
	rfac[i] = 1ll * rfac[i - 1] * pw(i, mod - 2) % mod;
    }

    for (int i = 1; i <= n; i++)
	for (int j = 0; j <= i; j++) {
	    if (j)
		dp[i][j] = dp[i][j - 1];
	    dp[i][j] = (dp[i][j] + (1ll * dp[i - 1][j] * c(k - 2, i * (k - 1) + j - 1) % mod)) % mod;
	    // cout << i << " " << j << " " << dp[i][j] << endl;
	}
    //cout << dp[n][n] << endl;
    if (k == 1)
	return cout << 1 << endl, 0;
    cout << 1ll * dp[n][n] * fac[n] % mod << endl;
}


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

int main() {
  int N, sum, x, a;
  cin >> N;
  a = N;
  sum = 0;
  for (int i = 0; i < 8; i++){
    x = N % 10;
    N /= 10;
    sum += x;
  }
  
  if (a % sum == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

int main() 
{
	int N, K;
	std::cin >> N >> K;
	int ans = (N - 1) / (K - 1);
	if ((N - 1) % (K - 1) > 0) {
		ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[2][n];
	REP(i,n) cin >> a[0][i];
	REP(i,n) cin >> a[1][i];
	int max = 0;
	REP(i,n){
		int num = 0;
		for(int j = 0; j <= i; j++){
			num += a[0][j];
		}
		for(int j = i; j < n; j++){
			num += a[1][j];
		}
		if(max < num) max = num;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
typedef long long LL;
typedef pair<LL, int> pli;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef map<char, int> mci;
typedef map<string, int> msi;
template<class T>
void read(T &res) {
  int f = 1; res = 0;
  char c = getchar();
  while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); }
  while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); }
  res *= f;
}
int main() {
  string s1, s2, s3;
  int a, b;
  cin >> s1 >> s2 >> a >> b >> s3;
  if(s3 == s1) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
  return 0;
}


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

int main() {

  long int N;
  cin >> N;

  long int c = N - 1;
  for(long int i = (int)sqrt(N);i>0;i--){
    long int q;
    q = N / i;
    if(i * q == N && i + q - 2 <= c){
        c = i + q - 2;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
using System;
class Program
    {
        static void Main()
        {
            int K=int.Parse(Console.ReadLine());
            int R=0;
            for(int a=1;a<=K;a++)
            {
                for(int b=1;b<=K;b++)
                {
                    for(int c=1;c<=K;c++)
                    {
                        var t=E(ref a,ref b);
                        R+=E(ref t,ref c);
                    }
                }
            }
            Console.WriteLine(R);
        }
        private static int E(ref int a,ref int b)
        {
            int L=0,S=0;
            if(a>b)
            {
                L=a;
                S=b;                
            }
            else
            {
                L=b;
                S=a;
            }
            var E=L%S;
            if(E!=0)
                return Program.E(ref S,ref E);
            else
                return S;
        }
    }

Measured memory_bytes: 27484
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int N= scan.nextInt();
        HashSet hs = new HashSet();
        for(int i=0;i<N;i++){
            hs.add(scan.next());
        }
        System.out.println(hs.size());
    }
}


Measured memory_bytes: 78624
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
#print(A)
#print(B)
#print(C)

res=0
for i in range(N):
  res+=B[A[i]-1]
  #print(res)
  if i>=1:
    if A[i]==A[i-1]+1:
      res+=C[A[i-1]-1]
  #print(res)
print(res)
      

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

using namespace std;

typedef long long ll;

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

    char S[101], T[101], tmp[101];
    cin >> S >> T;

    bool can = false;
    for (int j = 1; j < strlen(S)+1; j++) {
        tmp[0] = S[strlen(S) - 1];
        int i = 1;
        while(i < strlen(S)) {
            tmp[i] = S[i - 1];
            i++;
        }
        tmp[strlen(S)] = '\0';
        if (strcmp(tmp, T) == 0) {
            can = true;
            break;
        }
        for (int k = 0; k < strlen(S); k++) {
            S[k] = tmp[k];
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


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



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


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

    vector<P> primes = prime_factorize(n-1);

    ll res1 = 1;
    for(auto prim: primes){
        res1 *= (1 + prim.sc);
    }
    res1--;  // 1の分を引く

    ll res2 = 0;
    vector<ll> divs = enum_divisors(n);
    for(auto div: divs){
        if(div == 1){
            continue;
        }
        ll N = n;
        while(N % div == 0){
            N /= div;
        }
        if(N % div == 1){
            res2++;
        }
    }

    cout << res1 + res2 << endl;



    return 0;
}


Measured memory_bytes: 384
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(d);
        var center = N / 2 - 1;
        var answer = d[center + 1] - d[center];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

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

int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i=0; i<N; i++) cin >> v.at(i);
    sort(v.begin(), v.end());
    double a = v.at(0);
    for (int i=1; i<N; i++) a = (a+v.at(i))/2;
    cout << fixed << setprecision(6);
    cout << a << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int sum[3];
int main()
{

    char str[100000+10];
    cin>>str;
    for(int i=0;i<strlen(str);++i)
    {
        if(str[i]=='a') sum[0]++;
        if(str[i]=='b') sum[1]++;
        if(str[i]=='c') sum[2]++;
    }
    sort(sum,sum+3);
    //cout<<sum[2]<<sum[1]<<sum[0]<<endl;
    if(2*sum[2]-sum[1]-sum[0]>2) cout<<"NO"<<endl;
    else cout<<"YES\n";
    return 0;
}


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

const int mod=1e9+7;

int ways(vector<vector<char>> ar, int h, int w)
{
    int i,j;
    vector<vector<int>> dp(h, vector<int>(w,0));



    for(i=0;i<h;i++)
    {
        if(ar[i][0]=='#')
        {
            dp[i][0]=0;
            break;
        }
        dp[i][0]=1;
    }

    for(j=i;j<h;j++)
        dp[j][0]=0;


    for(j=0;j<w;j++)
    {
        if(ar[0][j]=='#')
        {
            dp[0][j]=0;
            break;
        }
        dp[0][j]=1;
    }

    for(i=j;i<w;i++)
        dp[0][i]=0;




    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(ar[i][j]=='.')
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }

        }
    }





/// correct

//    dp[0][0]=1;
//
//    for(i=0;i<h;i++)
//    {
//        for(j=0;j<w;j++)
//        {
//            if(i+1<h && ar[i+1][j]=='.')
//            {
//                dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
//            }
//            if(j+1<w && ar[i][j+1]=='.')
//            {
//                dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
//            }
//
//        }
//    }




    return dp[h-1][w-1];
}

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int h,w,i,j;
    cin>>h>>w;

    vector<vector<char>> ar(h,vector<char>(w));

    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
            cin>>ar[i][j];
    }

    cout<<ways(ar,h,w);

    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    for (int i=0;i<N;i++) cin>>A.at(i); 
    
    double ans = 0;
    for (int i=0;i<N;i++) {
        ans+=(1/A.at(i));
    }

    cout << setprecision(1000) << 1/ans << endl;
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/05 10:59:32 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
int					n;
vector<vector<PII>>	G;
VI					color;

void	dfs(int v, int p, int cur = 0)
{
	color[v] = cur;
	for (auto e : G[v])
	{
		if (e.first == p)
			continue;
		if (e.second)
			dfs(e.first, v, 1 - cur);
		else
			dfs(e.first, v, cur);
	}
}

void	Main()
{
	cin >> n;

	G.assign(n, vector<PII>());
	rep(i, n - 1)
	{
		int u, v, w; cin >> u >> v >> w;
		u--;
		v--;
		G[u].push_back(PII(v, (w & 1)));
		G[v].push_back(PII(u, (w & 1)));
	}
	color.assign(n, 0);
	dfs(0, -1);
	rep(v, n)
		cout << color[v] << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

#define sf(n) scanf("%d",&n)
#define pd(n)  printf("%.12lf",n)
#define pf(n)  printf("%d\n", n)
#define p() 	printf("\n")
#define ps() 	printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000000000
#define pi 3.1415926536
#define ex 1e9
#define dbl 1e09
#define  qu(q)    queue<int>q
#define pqu(q)    priority_queue<int>q
#define len(s)   s.length()
#define sz(x)    x.size()
#define pb(x)    push_back(x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

int main() {
    //freopen("input.txt","r",stdin);
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<sz(s);++i){
        if(s[i]=='2')
            cnt+=1;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<tgmath.h>
#include<iostream>
#define M_PI  3.14159265358979323846

using namespace std;


int main() {
  double a, b; cin >> a >> b;
  double h, m; cin >> h >> m;
  printf("%.13f", hypot(a*sin(2*M_PI*(h/12+m/(60*12)))-b*sin(2*M_PI*m/60),a*cos(2*M_PI*(h/12+m/(60*12)))-b*cos(2*M_PI*m/60)));
}


Measured memory_bytes: 4100
s = list(input())
flag = 1
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            flag *= 1
        else:
            flag *= 0
    else:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            flag *= 1
        else:
            flag *= 0
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(){
    ioboost;

    int a,b;cin >> a >> b;
    if(a >= 10 or b >= 10)cout << -1 << endl;
    else cout << a * b << endl;
}

Measured memory_bytes: 256
N, L = map(int,input().split(' '))

# 絶対値が一番小さいものを選択し、それ以外での合計を出力

list_aji = []
abs_aji_min = 100000
index_abs_aji_min = 0
for n in range(1,N+1):
  aji = n + L - 1
  if abs(aji) < abs_aji_min:
    abs_aji_min = abs(aji)
    index_abs_aji_min = n-1
  
  list_aji.append(aji)
  
ans = sum(list_aji) - list_aji[index_abs_aji_min]
print(ans)

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    string s;
    cin >> s;

    if(s.size() == 1){
        puts("0");
        return 0;
    }


    bool fkai = true;
    for(int i=0; i<s.size(); i++){
        if(s[i] != s[s.size()-1-i]){
            fkai = false;
        }
    }
    if(fkai){
        puts("0");
        return 0;
    }

    int now = 0;
    string t = "";
    for(int i=0; i<s.size(); i++){
        if(s[i] != 'x'){
            t += s[i];
        }else{
            now++;
        }
    }

    bool f = true;
    for(int i=0; i<t.size(); i++){
        if(t[i] != t[t.size()-1-i]){
            f = false;
        }
    }
    if(!f){
        puts("-1");
        return 0;
    }

    if(now == 0 || now == s.size()){
        puts("0");
        return 0;
    }

    int j=0;
    int k=0;
    int ans = 0;
    for(int i=0; i<=t.size()/2; i++){
        int cnt1 = 0;
        int cnt2 = 0;
        while(t[i] != s[j] ){
            j++;
            cnt1++;
        }
        while(t[i] != s[s.size()-1-k] ){
            k++;
            cnt2++;
        }
        //printf("%d %d\n", cnt1, cnt2);
        j++;
        k++;
        ans += abs(cnt1 - cnt2);
    }
    cout << ans << endl;

    /*
    int mid = 0;
    if(t.size() % 2 == 1){
        mid = t.size()/2;
    }else{
        mid = t.size()/2-1;
    }
    //cout << mid << endl;

    bool f1 = false;
    ll l = 0;
    ll r = 0;
    int j = 0;
    for(int i=0; i<t.size(); i++,j++){
        while(t[i] != s[j]){
            if(!f1){
                l++;
            }else{
                r++;
            }
            j++;
        }
        if(i == mid){
            f1 = true;
            if(t.size()%2 == 0){
                i++;
                j++;
                while(t[i] != s[j]){
                    j++;
                    //cout << j << endl;
                }
            }
        }
    }
    if(j < s.size()){
        for(int k=j; k<s.size(); k++){
            r++;
        }
    }
    cout << l << endl;
    cout << r << endl;

    int need = max(l, r);
    //int need2 = (t.size() + 1) / 2;
    //cout << need2 << endl;
    //need = max(need, need2);
    int ans = 0;
    ans += need - l;
    ans += need - r;
    cout << ans << endl;
    */

    /*
    int need = t.size() + 1;
    cout << need << endl;
    cout << now << endl;
    cout << need - now << endl;
    */
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int a, b, c, x;
	cin >> a >> b >> c;

	if (a > b) {
		x = a;
		a = b;
		b = x;
	};
	if (b > c) {
		x = b;
		b = c;
		c = x;
	};
	if (a > b) {
		x = a;
		a = b;
		b = x;
	};
	cout << a << " " << b << " " << c << endl;
	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

vector<int> memo(100005, -1);

int f(int N){
    if(memo[N] != -1){
        return memo[N];
    }

    int ret = inINF;
    if(N >= 1) ret = min(ret, f(N-1) + 1);
    if(N >= 6) ret = min(ret, f(N-6) + 1);
    if(N >= 36) ret = min(ret, f(N-36) + 1);
    if(N >= 216) ret = min(ret, f(N-216) + 1);
    if(N >= 1296) ret = min(ret, f(N-1296) + 1);
    if(N >= 7776) ret = min(ret, f(N-7776) + 1);
    if(N >= 46656) ret = min(ret, f(N-46656) + 1);
    if(N >= 9) ret = min(ret, f(N-9) + 1);
    if(N >= 81) ret = min(ret, f(N-81) + 1);
    if(N >= 729) ret = min(ret, f(N-729) + 1);
    if(N >= 6561) ret = min(ret, f(N-6561) + 1);
    if(N >= 59049) ret = min(ret, f(N-59049) + 1);
    return memo[N] = ret;
}

int main(){
    int N;
    cin >> N;
    memo[0] = 0;
    printf("%d\n", f(N));
}

Measured memory_bytes: 10012
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
P = primes(55555)
A = []
i = 0

while len(A)<n:
    if P[i] % 5 == 1:
        A += [P[i]]
    i += 1

print(*A)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    cout<<v[n/2]-v[n/2-1]<<endl;

    return 0;
}

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

int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    if (b == 'T') cout << 'A' << endl;
    if (b == 'G') cout << 'C' << endl;
    if (b == 'C') cout << 'G' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10;
vector<int>e[N];
queue<pair<int,int> >q;
int d[N];
int n;
int vis[N];
int main()
{
    scanf("%d",&n);
    for(int i=1,x;i<=n;i++){
        int y=i;
        scanf("%d",&x);
        if(x<y)swap(x,y);
        int u=y*1001+x;
        for(int j=1,x;j<n-1;j++){
            y=i;
            scanf("%d",&x);
            if(x<y)swap(y,x);
            int v=y*1001+x;
            e[u].push_back(v);d[v]++;
            //cout<<u/1001<<" "<<u%1001<<"---"<<v/1001<<" "<<v%1001<<endl;
            u=v;
        }
    }
    for(int i=1;i<=n*1001+n;i++){
        if(d[i]==0&&e[i].size()!=0)q.push(make_pair(i,1));
    }
    int tot=0;
    int ans=0;
    while(!q.empty()){
        int u=q.front().first,sum=q.front().second;q.pop();
        int x=u/1001,y=u%1001;
        //cout<<x<<" "<<y<<endl;
        ans=max(sum,ans);
        if(vis[x]!=sum&&vis[y]!=sum){
            for(int v:e[u]){
                if(--d[v]==0){
                    q.push(make_pair(v,sum+1));
                }
            }
            tot++;
            vis[x]=sum;vis[y]=sum;
        }
        else{
            q.push(make_pair(u,sum+1));
        }
    }
    //cout<<tot<<endl;
    if(tot<n*(n-1)/2)puts("-1");
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 70144