akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int n, c, d[33][33], cnt[3][33];

int main()
{
    cin >> n >> c;
    
    for(int i = 1; i <= c; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            cin >> d[i][j];
        }
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            int a;
            cin >> a;
            cnt[(i + j) % 3][a]++;
        }
    }
    
    int res = 1e9;
    for(int i = 1; i <= c; i++)
    {
        int sum1 = 0;
        rep(x, c + 1)
        {
            if(i == x) continue;
            sum1 += cnt[0][x] * d[x][i];
        }

        for(int j = 1; j <= c; j++)
        {
            if(i == j) continue;
            int sum2 = 0;
            rep(x, c + 1)
            {
                if(j == x) continue;
                sum2 += cnt[1][x] * d[x][j];
            }

            for(int k = 1; k <= c; k++)
            {
                if(i == k || j == k) continue;
                int sum3 = 0;
                rep(x, c + 1)
                {
                    if(k == x) continue;
                    sum3 += cnt[2][x] * d[x][k];
                }
               res = min(res, sum1 + sum2 + sum3);
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		try {
			String[] data = in.readLine().split(" ");
			double x0 = Double.parseDouble(data[0]);
			double y0 = Double.parseDouble(data[1]);
			double x1 = Double.parseDouble(data[2]);
			double y1 = Double.parseDouble(data[3]);
			
			System.out.println(Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)));
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24520
n = int(input())
cnt = 0
l = len(str(n))
heads_tails = [[0 for i in range(9)] for j in range(9)]

for i in range(1, n+1):
    if i % 10 == 0:
        continue
    head = int(str(i)[0]) - 1
    tail = int(str(i)[-1]) - 1
    heads_tails[head][tail] += 1

for i in range(9):
    for j in range(9):
        cnt += heads_tails[i][j]*heads_tails[j][i]

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mo=1000000007;
int f[4005][2005],n,m,k,ans,fl;
int main(){
	scanf("%d%d%d",&m,&n,&k);
	f[0][0]=1;
	for (int i=1;i<=(n+m-1)/(k-1);++i)
	for (int j=0;j<=n;++j){
		if ((n-j)%(k-1)==0&&i*(k-1)-j<m&&(i*(k-1)-j-m+1)%(k-1)==0) fl=1; else fl=0;
		for (int t=0;t<k;++t){
			if (j<t) break;
			(f[i][j]+=f[i-1][j-t])%=mo;
			if (t&&fl) (ans+=f[i-1][j-t])%=mo;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31616
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        int[] sumcon = new int[201];
        for(int i = -100; i <= 100; i++){
            for(int j = 0; j < n; j++){
                sum = sum + (i - a[j])*(i - a[j]);
            }
            sumcon[i+100] = sum;
            sum = 0;
        }
        Arrays.sort(sumcon);
        System.out.print(sumcon[0]);
    }
}

Measured memory_bytes: 23252
#ARC077C

from collections import deque
d=deque()
n=int(raw_input())
a=raw_input().split()
for i in xrange(n):
 if i%2==n%2:
  d.append(a[i])
 else:
  d.appendleft(a[i])
for i in xrange(n):
 print d[i],
print


Measured memory_bytes: 17448
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
    return os << "(" << P.fi << "," << P.se << ")";
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
    os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 200010
string s;

int main() {
    cin >> s;
    s[3] = '8';
    cout << s;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];   
    }
    int count=1;
    bool ans = true;
    for(int i=1;i<n;i++){
        ans = true;
        for(int j=0;j<i;j++){
            if(h[i]<h[j]){
                ans=false;
            }
        }
        if(ans){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $a, $b);

if($a < $b){
    $min = $a;
    $max = $b;
}else{
    $min = $b;
    $max = $a;
}
$ans = $min;
for($i=1;$i<$max;$i++){
    $ans = $ans * 10 + $min;
}
echo $ans;

Measured memory_bytes: 4728
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [i64; n],
    }
    let mut ans = std::i64::MAX;
    let x: i64 = a.iter().sum::<i64>();
    let mut acc = 0;
    for i in 0..n - 1 {
        acc += a[i];
        ans = min(ans, (x - 2 * acc).abs());
    }
    println!("{}", ans);
}


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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;
const int INF = 1001001001;


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

    int n,x,y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n);

    rep(sv,n){
        vector<int> dist(n,INF);
        queue<int> q;
        auto push = [&](int v,int d){
            if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v = q.front();q.pop();
            int d = dist[v];
            if(v-1 >= 0) push(v-1,d+1);
            if(v+1 < n) push(v+1,d+1);
            if(v == x) push(y,d+1);
            if(v == y) push(x,d+1);
        }
        rep(i,n){
            ans[dist[i]]++;
        }
    }
    rep(i,n){
        ans[i] /= 2;
    }
    for(int i = 1;i <= n-1; ++i){
        cout << ans[i] << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "string.h"

int main(){
  char a[10] = {};
  int b;
  scanf("%s", a);
  if(b = (strcmp(a, "Sunny")) == 0)
  {
    printf("Cloudy");
    return 0;
  }
  else if(b = (strcmp(a, "Cloudy")) == 0)
  {
    printf("Rainy");
    return 0;
  }
  else if(b = (strcmp(a, "Rainy")) == 0)
  {
    printf("Sunny");
    return 0;
  }
}


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

int main()
{
  string S,T;
  
  cin >>S;
  cin >>T;
  

  for(int i=0;i<S.length();i++)
  {
    if(S[i]==T[i])
    {
    }else{
      cout << "No";
      return 0 ;    
    }
  }
    
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 3624
#  not resolved
n_ori =int(input())
n_dif = n_ori - 1
sq_ori = int(n_ori**.5)
sq_dif = int(n_dif**.5)
divisor_ori = []
divisor_dif = []

for i in range(1, sq_ori+1):
	if n_ori % i == 0:
		divisor_ori.append(i)
		if i != n_ori // i:
			divisor_ori.append(n_ori//i)

for i in range(1, sq_dif+1):
	if n_dif % i == 0:
		divisor_dif.append(i)
		if i != n_dif // i:
			divisor_dif.append(n_dif//i)
			
cnt = 0
for k in divisor_ori:
	if k == 1:
		continue
	else:
		tmp = n_ori
		while tmp % k == 0:
			tmp = tmp//k

		if tmp % k == 1:
			cnt += 1

print(cnt + len(divisor_dif) - 1)



# # num = n - 1
# # sq = int(num**.5)
# # if sq == 1:

# # for k in range(2, sq+1):
# # 	if k == sq and num % k == 0:
# # 		cnt += 1
# # 	elif num % k == 0:
# # 		cnt += 2
# # cnt += 1

# # sq2 = int(n ** .5)
# # for k in range(2, sq2+1):
# # 	x = n
# # 	if x % k == 0:
# # 		while x % k == 0:
# # 			x = x//k
# # 		if x % k == 1:
# # 			cnt += 1

# # cnt += 1

# # print(cnt)





Measured memory_bytes: 3188
#include<stdio.h>
int main()
{int i,j,x,y,tmp;
    for(i=1; ;i++)
{
    for(j=1;j<=2;j++)
    {
        scanf("%d%d",&x,&y);
        if( x==0 && y==0 )break;
        if(x>y){tmp=x; x=y; y=tmp;}
        printf("%d %d\n",x,y);
    }

if( x==0 && y==0 )break;
}

return 0;
}


Measured memory_bytes: 2052
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
A=get_i.sort
MOD=10**9+7
$fac=array(N+1)
$finv=array(N+1)
$inv=array(N+1)
def comb_init()
  $fac[0]=$fac[1]=1
  $finv[0]=$finv[1]=1
  $inv[1]=1
  2.upto(N) do|i|
      $fac[i]=$fac[i-1]*i%MOD
      $inv[i]=MOD-$inv[MOD%i]*(MOD/i)%MOD
      $finv[i]=$finv[i-1]*$inv[i]%MOD
  end
end

def comb(n,k)
    return 0 if n<k
    return 0 if n<0 or k<0
    return $fac[n]*($finv[k]*$finv[n-k]%MOD)%MOD
end
comb_init
ans=0
A.each_with_index do|a,i|
  ans+=(comb(i,K-1)-comb(N-i-1,K-1))*a
  ans%=MOD
end
puts ans

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

char grid[55][55];
int dist[55][55];
const int INF=INT_MAX;
int di[]={0,1,0,-1};
int dj[]={1,0,-1,0};

int main(){
  int h,w;
  cin>>h>>w;
  int black=0;
  rep(i,h)rep(j,w){
    cin>>grid[i][j];
    dist[i][j]=INF;
    if(grid[i][j]=='#') black++;
  }
  dist[0][0]=0;
  queue<P> q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    int pi,pj;
    tie(pi,pj)=q.front(); q.pop();
    int past = dist[pi][pj];
    rep(tmp,4){
      int now=past+1;
      int ni=pi+di[tmp],nj=pj+dj[tmp];
      if(grid[ni][nj]=='#') continue;
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(dist[ni][nj]<=now) continue;
      dist[ni][nj]=now;
      q.push(make_pair(ni,nj));
    }
  }
  if(dist[h-1][w-1]!=INF) cout<<h*w-black-dist[h-1][w-1]-1<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 3572
#include<stdio.h>

int N;

int A[101][101];

int hantei(int x,int y){
  int i;
  int flag =0;

  for(i=2;i<=N;i++){
    if(A[x][i]==y){
      flag=1;
    }
  }
  if(flag==1){
    return 1;
  }
  else if(flag==0){
    return 0;
  }
}



main (){
  int i,j,k;

  scanf("%d",&N);

  for(i=1;i<=N;i++){
    j=1;
    scanf("%d %d",&A[i][1],&k);
    for(j=2;j<k+2;j++){
      scanf("%d",&A[i][j]);
    }
  }

  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){    
      if(j==N){
	printf("%d\n",hantei(i,j));
      }
      else {
	printf("%d ",hantei(i,j));
      }
    }
    
  }


  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int N, M;
    cin >> N >> M;

    vector<int> p(M);
    vector<string> S(M);
    REP(i, M) {cin >> p[i] >> S[i]; p[i]--;}

    vector<bool> ok(N, false);
    vector<int> b(N, 0);
    int a = 0, c = 0;
    REP(i, M){
        if (!ok[p[i]]){
            if (S[i] == "AC"){
                ok[p[i]] = true;
                a++;
            }else b[p[i]]++;
        }
    }
    REP(i, N)if(ok[i]) c += b[i];
    cout << a << " " << c << endl;


    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  if (n & 1)
    cout << n * 2 << endl;
  else
    cout << n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 100000
//---------------------

ll s1=0,s2=0,a[MAXN],n;

int main(){
	cin>>n;
	REP(i,n){
		cin>>a[i];
	}

	ll sum1=0;//patern +-+-+-
	ll sum2=0;//patern -+-+-+
	REP(i,n){
	  	if(i==0){
	  		s1=s2=a[0];
	  	}
	  	else{
	  		s1+=a[i];
	  		s2+=a[i];
	  	}
		if(!(i%2)){
			if(s1<=0){
				sum1+=abs(1-s1);
				s1=1;
			}
			if(s2>=0){
				sum2+=abs(-1-s2);
				s2=-1;
			}
		}else{
		  	if(s1>=0){
				sum1+=abs(-1-s1);
				s1=-1;
			}
			if(s2<=0){
				sum2+=abs(1-s2);
				s2=1;
			}
		}
	}
	cout<<min(sum1,sum2)<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int pre = INF;
    int b;
    for (int i = 0; i < n - 1; i++) {
        cin >> b;
        ans += min(pre, b);
        pre = b;
    }
    ans += b;

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]



for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])


y = len(s)
x = len(t)
ans = ""
while 1:
	#print(y, x, ans)
	if x*y == 0:
		break
	elif s[y-1] == t[x-1]:
		ans += s[y-1]
		x -= 1
		y -= 1
	else:
		if dp[y][x] == dp[y-1][x]:
			y -= 1
		elif dp[y][x] == dp[y][x-1]:
			x -= 1

lcs  = dp[len(s)][len(t)]

q = deque([(len(s), len(t))])
common = [set() for _ in range(lcs)]

while q:
	#print(q)
	y, x =q.popleft()
	if x*y != 0 :
		if s[y-1] == t[x-1]:
			common[dp[y][x]-1].add(t[x-1])
			y -= 1
			x -= 1
			q.append((y, x))
		else:
			if dp[y][x] == dp[y-1][x]:
				q.append((y-1, x))

			elif dp[y][x] == dp[y][x-1]:
				q.append((y, x-1))

print(*[list(common[i])[0] for i in range(lcs)], sep="")



Measured memory_bytes: 131928
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using lint = long long;

int main() {
    lint N, A, B;
    cin >> N >> A >> B;
    if (A > B) {
        cout << 0 << endl;
        return 0;
    }
    if (N == 1 && A != B) {
        cout << 0 << endl;
        return 0;
    }
    lint mini = (N-1) * A + B;
    lint maxi = A + (N-1) * B;
    cout << maxi - mini + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
int ConvertInt(string s){ int a = 0; rep(i, s.size())if(s[i]!='-')a+=(s[i]-'0')*pow(10,(float)s.size()-i-1); return s[0]!='-'?a:-a;}

vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}

int main()
{
	vint v(5);
	string str;

	getline(cin, str);
	vector<string> vs = split(str, " ");

	rep(i, 5)
		v[i] = ConvertInt(vs[i]);

	sort(ALL(v), greater<int>());
	
	rep(i, 5)
		cout << v[i] << (i != 4 ? " " : "");
	
	cout << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>

using namespace std;

int main() {
    
    string s, t;
    cin >> s >> t;
    string tt = t;
    for (int i = 0; i <= t.size(); ++i)
    {
        if (tt == s)
        {
            cout << "Yes" << endl;
            return 0;
        }
        tt = tt.substr(t.size() - 1, 1) + tt.substr(0, t.size() - 1);
    }
    cout << "No" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
string s;
  int k;
cin >> s >> k;
int cnt = 0;
rep(i,s.size()){
  if(s.at(i) !=  '1')break;
  cnt++;
}
if(cnt >= k) cout << 1 << endl;
else cout << s.at(cnt) << endl;
} 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-8;
const int N = 1000+10;
map<string,int> m;
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		m[s]++;
	}
	printf("AC x %d\n",m["AC"]);
	printf("WA x %d\n",m["WA"]);
	printf("TLE x %d\n",m["TLE"]);
	printf("RE x %d\n",m["RE"]);
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


int main(){
    int n;  cin >> n;
    int a[n];
    int all=0;

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

    }

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            all+=a[i]*a[j];
        }
    }

    cout << all << endl;
}




Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w, k, ans int
	fmt.Scan(&h, &w)
	grid := make([][]int, h)
	var S string
	for j := range grid {
		fmt.Scan(&S)
		grid[j] = make([]int, w)
		for i, s := range S {
			if string(s) == "#" {
				k++
				grid[j][i] = -1
			} else {
				grid[j][i] = 0
			}
		}
	}
	grid[0][0] = 1
	q := make([][]int, 0)
	q = append(q, []int{0, 0})
	for len(q) != 0 {
		y, x := q[0][0], q[0][1]
		q = q[1:]
		for _, d := range [][]int{{0, 1}, {0, -1}, {-1, 0}, {1, 0}} {
			ny, nx := y+d[0], x+d[1]
			if ny < 0 || ny == h || nx < 0 || nx == w {
				continue
			}
			if grid[ny][nx] == 0 {
				grid[ny][nx] = grid[y][x] + 1
				q = append(q, []int{ny, nx})
			}
		}
	}
	ans = h*w - k - grid[h-1][w-1]
	if grid[h-1][w-1] == 0 {
		ans = -1
	}
	fmt.Println(ans)
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int takashiT= C/B;
    int AokiT= A/D;
    if(C%B > 0){
        takashiT= takashiT + 1;
    }
    if(A%D > 0){
        AokiT= AokiT + 1;
    }
    if(takashiT < AokiT || takashiT == AokiT){
        cout<< "Yes";
    }else{
        cout<< "No";
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string s; cin >> s;
    ll ss = s.size();

    int a_count = 0;
    // int bc_count = 0;
    ll ans = 0;
    ll cnt = 0;
    
    int i = 0;
    while (i < ss-1) {
        if (s[i] == 'A') {
            a_count += 1;
            i += 1;
        } else if (s[i] == 'B' && s[i+1] == 'C') {
            ans += a_count;
            i += 2;
            // bc_count = 0;
        } else {
            a_count = 0;
            i += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
# AOJ 0074 Videotape
# Python3 2018.6.14 bal4u

while True:
	T, H, S = list(map(int, input().split()))
	if T < 0: break
	t = 7200 - (3600*T + 60*H + S)
	print('{:02d}:{:02d}:{:02d}'.format(t//3600, (t%3600)//60, t%60))
	t *= 3
	print('{:02d}:{:02d}:{:02d}'.format(t//3600, (t%3600)//60, t%60))



Measured memory_bytes: 5608
import java.util.Scanner;

// B - Toll Gates
// https://atcoder.jp/contests/abc094/tasks/abc094_b
public class Main {

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

        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        int X = Integer.parseInt(scanner.next());
        boolean[] A = new boolean[N + 1];
        for (int i = 0; i < M; i++) {
            int index = Integer.parseInt(scanner.next());
            A[index] = true;
        }
        scanner.close();

        int costA = 0;
        for (int i = X; i <= N; i++) {
            if (A[i]) costA++;
        }
        int costB = 0;
        for (int i = X; i >= 0; i--) {
            if (A[i]) costB++;
        }

        System.out.println(Math.min(costA, costB));
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(int argc, char *argv[]){
  int n, m;
  cin >> n >> m;
  vector<vector<lli> > g(n, vector<lli>(n, 1LL<<40));
  int from, to, cost;
  for (int i = 0; i < n; i++) {
    g[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> from >> to >> cost;
    g[from][to] = cost;
  }
  //???????????§?????????
  //???????????????????????£???????????????
  bool neg_cycle = false;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if(g[i][j] == 1LL<<40 &&
           (g[i][k] == 1LL<<40 || g[k][j] == 1LL<<40))continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if(g[i][i] < 0)neg_cycle = true;
  }
  if(neg_cycle){
    std::cout << "NEGATIVE CYCLE" << std::endl;
    return 0;
   }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if(g[i][j] >= 1LL<<40)std::cout << "INF ";
      else std::cout << g[i][j] << " ";
    }
    if(g[i][n - 1] >= 1LL<<40)std::cout << "INF" << std::endl;
    else std::cout << g[i][n - 1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

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

    int n, a;
    cin >> n >> a;

    cout << n * n - a;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    n = int(readline())
    cnt = Counter()
    for i in range(n):
        s = input()
        cnt[s] += 1

    print("AC x {}".format(cnt["AC"]))
    print("WA x {}".format(cnt["WA"]))
    print("TLE x {}".format(cnt["TLE"]))
    print("RE x {}".format(cnt["RE"]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 69840
import socket
import sys

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'd1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


mod = 10 ** 9 + 7
N = 2 * 10 ** 5
MAX = N + 2
inv = [0] * MAX
inv[1] = 1
for i in range(2, MAX):
    inv[i] = - inv[mod % i] * (mod // i)
    inv[i] %= mod


def solve():
    n, a, b = read_int_list()
    total = pow(2, n, mod)
    res = total - 1
    c = 1
    for i in range(b):
        c = (c * (n - i) * inv[i + 1]) % mod
        if i == a - 1:
            res -= c
    res -= c
    res %= mod
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11508
#include<iostream>
#include<queue>
using namespace std;
#define MAX_N 100
#define MAX_M 100000
int n, c, v;
int dis[MAX_N + 1];
int Adjacency_matrix[MAX_N + 1][MAX_N + 1];
const int INF = 100000000;
void Dijkstra(int s, int g){
  queue<int> que;
  for(int i = 0; i <= MAX_N; i++){
    dis[i] = INF;
  }
  que.push(s);
  dis[s] = 0;
  while(que.size()){
    int p = que.front();
    que.pop();
    for( int i = 0; i < n; i++ ){
      if(Adjacency_matrix[p][i] + dis[p] < dis[i] ){
        que.push(i);
        dis[i] = Adjacency_matrix[p][i] + dis[p];
      }
    }
  }
}

int main(){
  int k_1, u;
  for(int i = 0; i <= MAX_N; i++){
    for( int k = 0; k <= MAX_N; k++){
      Adjacency_matrix[i][k] = INF;
    }
  }
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> u >> k_1;
    for(int j = 1; j <= k_1; j++){
      cin >> v >> c;
      Adjacency_matrix[i][v] = c;
    }
  }
  for(int i = 0; i < n; i++){
    Dijkstra(0, i);
    cout<<i<<" "<<dis[i]<<endl;
  }
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  if (a == c) {
    printf("0");
  }
  else if (a != c) {
    printf("1");
  }
  return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> f, s;
map<int, int> cntF, cntS;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i += 2) {
        if (cntF[a[i]] == 0) {
            f.push_back(a[i]);
        }
        cntF[a[i]]++;
    }
    sort(f.begin(), f.end(), [](int x, int y) {
        return cntF[x] > cntF[y];
    });
    for (int i = 1; i < n; i += 2) {
        if (cntS[a[i]] == 0) {
            s.push_back(a[i]);
        }
        cntS[a[i]]++;
    }
    sort(s.begin(), s.end(), [](int x, int y) {
        return cntS[x] > cntS[y];
    });
    if (f.size() == 1 && s.size() == 1) {
        if (f[0] == s[0]) {
            cout << n / 2 << '\n';
        } else {
            cout << 0 << '\n';
        }
    } else if (f[0] == s[0]) {
        if (f.size() == 1) {
            int bakiF = (n / 2) - cntF[f[0]];
            int bakiS = (n / 2) - cntS[s[1]];
            cout << bakiF + bakiS << '\n';
        } else if (s.size() == 1) {
            int bakiF = (n / 2) - cntF[f[0]];
            int bakiS = (n / 2) - cntS[s[1]];
            cout << bakiF + bakiS << '\n';
        } else {
            int costA = ((n / 2) - cntF[f[0]]) + ((n / 2) - cntS[s[1]]);
            int costB = ((n / 2) - cntF[f[1]]) + ((n / 2) - cntS[s[0]]);
            cout << min(costA, costB) << '\n';
        }
    } else {
        int bakiF = (n / 2) - cntF[f[0]];
        int bakiS = (n / 2) - cntS[s[0]];
        cout << bakiF + bakiS << '\n';
    }
    return 0;
}


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

typedef long long ll;
using namespace std;

string S;
int a[2];

int main() {
    cin >> S;
    int len = S.length();
    for (int i = 0; i < len; i++) {
        a[S[i] - '0']++;
    }
    cout << min(a[0], a[1]) * 2 << endl;
}

Measured memory_bytes: 512
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  n <- readLn
  --qs <- replicateM n $ fmap (map read . words) getLine :: IO [[Integer]]
  qs <- replicateM n readInts :: IO [[Int]]
  let ans = map solve qs
  seq ans $ mapM_ (\x -> putStrLn $ if x then "Yes" else "No") ans

solve :: [Int] -> Bool
solve as
  | a < b || b > d = False
  | b == d = a `mod` b <= c
  | c >= b = True
  | otherwise = ow
  where
    (a:b:c:d:_) = as
    gcdbd = gcd b d
    --ow = all (\x -> (x + if x <= c then d else 0) >= b) $ [(a + x * gcdbd) `mod` b| x <- [0..(div b gcdbd)]]
    ow = b - gcdbd + a `mod` gcdbd <= c


Measured memory_bytes: 1020
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
      int n = a;
	 int b = a%10;
      int i = 10;
while(a/i != 0){
    b += a%(i*10)/i;
  i *= 10;
}
     
      if(n%b==0){
		System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 21716
# @author 

import sys

class DSumOfDivisors:
    def solve(self, tc=0):
        # def divCount(n):
        # 
        #     # sieve method for
        #     # prime calculation
        #     hh = [1] * (n + 1);
        # 
        #     p = 2;
        #     while ((p * p) < n):
        #         if (hh[p] == 1):
        #             for i in range((p * 2), n, p):
        #                 hh[i] = 0;
        #         p += 1;
        # 
        #         # Traversing through
        #     # all prime numbers
        #     total = 1;
        #     for p in range(2, n + 1):
        #         if (hh[p] == 1):
        # 
        #             # calculate number of divisor
        #             # with formula total div =
        #             # (p1+1) * (p2+1) *.....* (pn+1)
        #             # where n = (a1^p1)*(a2^p2)....
        #             # *(an^pn) ai being prime divisor
        #             # for n and pi are their respective
        #             # power in factorization
        #             count = 0;
        #             if (n % p == 0):
        #                 while (n % p == 0):
        #                     n = int(n / p);
        #                     count += 1;
        #                 total *= (count + 1);
        # 
        #     return total;
        # 
        # so_far = 0
        # for i in range(1, 10):
        #     d = divCount(i)
        #     so_far += d * i
        #     print(so_far, end=',')

        n = int(input())

        print(int(sum(k/2 * int(n/k) * int(1 + n/k) for k in range(1, n + 1))))


solver = DSumOfDivisors()
input = sys.stdin.readline

solver.solve()


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

using namespace std;

int main()
{
    string S;
    cin >> S;

    int ans = 0;

    while(true) {
        if (S.empty()) {
            break;
        }

        int index = -1;

        for (int i = 0; i < S.size()-1; ++i) {
            if (S[i] != S[i+1]) {
                index = i;
                break;
            }
        }

        if (index == -1) {
            break;
        }

        auto it = S.begin() + index;
        S.erase(it, it+2);

        ans += 2;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

bool isEnd(vector<bool> &u){
  REP(i, u.size()) if(!u[i]) return false;
  return true;
}

bool check(int n, vector<bool> &u, vector< vector<int> > &v){
  if(u[n]) return false;
  REP(i, v[n].size()) if(!u[v[n][i]]) return false;
  return true;
}

int main() {
  int N, M; cin >>N >>M;
  vector< vector<int> > v(N);
  REP(i, M){
    int a, b; cin >>a >>b;
    --a; --b;
    v[b].push_back(a);
  }
  vector<bool> used(N, false);
  vector<int> ans;
  while(!isEnd(used)){
    int n = -1;
    REP(i, N) if(check(i, used, v)) n = i;
    used[n] = true;
    ans.push_back(n);
  }
  REP(i, ans.size()) cout <<ans[i] + 1 <<endl;
  return 0;
}

Measured memory_bytes: 1220
n = gets.chomp.to_i
cards = (1..2*n).to_a

m = gets.chomp.to_i
m.times do
	k = gets.chomp.to_i
	if k == 0
		a = cards[0..n-1]
		b = cards[n..2*n-1]
		cards = a.zip(b).flatten
	else
		a = cards[0..k-1]
		b = cards[k..2*n-1]
		cards = b + a
	end
end

cards.each do |c|
	puts c
end

Measured memory_bytes: 9296
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
	int N;
	double T, A, H[1000], t[1000];
	cin >> N >> T >> A;
	REP(i, N) {
		cin >> H[i];
		t[i] = T - 0.006*H[i];
	}

	int k = 0;
	double ans;
	ans = abs(t[0] - A);
	REP(i, N) {
		if (abs(t[i] - A) < ans) {
			ans = abs(t[i] - A);
			k = i;
		}
	}

	cout << k+1 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
bf=False
d={}
a=[]
b=[]
for t in sys.stdin:
    l=t.strip().split(",")[0]
    if not l:
        bf=True
        continue
    if not bf:
        b.extend([l])
    else:
        a.extend([l])
aa=Counter(a)
bb=Counter(b)
for i in sorted(set(aa.keys())&set(bb.keys()),key=lambda x:int(x)):
    print(i,aa[i]+bb[i])


Measured memory_bytes: 5996
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#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/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}

namespace adaptor = boost::adaptors;

void Main()
{
	std::uint64_t N, P;
	std::cin >> N >> P;
	if (N == 1)
	{
		out::write_line(P);
		return;
	}
	auto p = P;
	std::uint64_t res = 1;
	if (p % 2 == 0)
	{
		std::size_t i = 0;
		do
		{
			p /= 2;
			++i;
		} while (p % 2 == 0);
		res *= lib::pow<std::uint64_t>(2, i / N);
	}
	for (std::uint64_t q = 3; q*q <= P; q += 2)
	{
		if (p%q == 0)
		{
			std::uint64_t i = 0;
			do
			{
				p /= q;
				++i;
			} while (p%q == 0);
			res *= lib::pow(q, i / N);
		}
	}
	out::write_line(res);
}

int main()
{
	std::cin.tie(nullptr);
	std::cin.sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main(){
    std::string numberstr;
    std::string temp;
    std::string print = "No";
    int bsize = 0;
    int number;
    int j = 0;

    std::cin >> numberstr;
    std::cin >> temp;

    bsize = temp.size();

    for(int i = 0; i < bsize; i++){
        numberstr.push_back(temp[i]);
    }

    number = atoi(numberstr.c_str());

    while(j * j <= 100100){
        if(j * j == number){
            print = "Yes";
            break;
        }
        j++;
    }

    std::cout << print << std::endl;
    

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (L, R) = listOfLong()
    var ans = Long.MAX_VALUE
    for (i in L .. R - 1) {
        if (i > L + 2019) break
        for (j in i + 1 .. R) {
            if (j > i + 2019) break
            ans = Math.min(ans, (i * j) % 2019)
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0L) = listOfString().map { it.toLong() + delta }


Measured memory_bytes: 37992
h = int(input())
w = int(input())
n = int(input())
 
ans = 0
sum = 0
 
while(sum < n):
  if h >= w :
    sum += h
    ans += 1
    w -= 1
  else :
    sum += w
    ans += 1
    h -= 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] alpha = new int[26];
        for(int i = 0; i < 26; i++) alpha[i] = 0;
        while(sc.hasNext()) {
            String str = sc.next().toLowerCase();
            int S = str.length();
            for(int i = 0; i < S; i++) {
                int x = str.charAt(i);
                if(x >= 97 && x <= 122) alpha[x-97]++;
            }
        }

        for(int i = 0; i < 26; i++) System.out.printf("%c : %d\n", (char)(i+97), alpha[i]);
    }
}


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

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

using namespace std;

const int INF = 10000;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a < b && b < c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;
 
	return 0;

}



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

int main() {

  char c;
  cin >> c;
  
  vector<char> A = {'a','b','c','d','e','f','g','h','i',
                    'j','k','l','m','n','o','p','q','r',
                    's','t','u','v','w','x','y','z'};
  
  for(int i = 0; i < 26; i++) {
    if(c == A.at(i)) {
      cout << A.at(i+1) << endl;
      break;
    }
  }  
  
}

Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
#include<cmath>
using lint = long long;
using namespace std;

int main()
{
	lint N, K;
	lint cnt = 0;
	lint ans = 0;

	cin >> N >> K;

	for (lint i = 1; i <= N; i++)
		if (i%K == 0)cnt++;

	ans += pow(cnt, 3);

	if (K % 2 == 0)
	{
		cnt = 0;
		for (lint i = 1; i <= N; i++)
			if (i%K == K / 2)cnt++;
		ans += pow(cnt, 3);
	}

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


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

using namespace std;

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

int main() {
  int iii = 0;
  while (true) {
    ++iii;
    int n;
    cin >> n;
    if (n == 0) break;
    int a[10][10];
    int x = 0, y = 0;
    rep (i, n * n) {
      //cout << x << " " << y << endl;
      a[y][x] = i + 1;
      if ((x + y) % 2 == 0) {
	if (x == n - 1) {
	  ++y;
	} else if (y == 0) {
	  ++x;
	} else {
	  ++x;
	  --y;
	}
      } else {
	if (y == n - 1) {
	  ++x;
	} else if (x == 0) {
	  ++y;
	} else {
	  --x;
	  ++y; 
	}
      }
    }
    printf("Case %d:\n", iii);
    rep (i, n) {
      rep (j, n) printf("%3d", a[i][j]);
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 1160
g1 =[1,3,5,7,8,10,12]
g2 =[4,6,9,11]
g3 = [2]
x,y = map(int, input().split())
if x== 2 and y == 2:
    print("Yes")
elif x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
from networkx import *
N,M = map(int,input().split())

if M==0:
  print(1)
  exit()
else:
  A = [list(map(int,input().split())) for m in range(M)]
  G = Graph()
  G.add_edges_from(A)
  print(len(max(connected_components(G),key=len)))

Measured memory_bytes: 279616