akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define TRUE 0
#define FALSE 1
#define MAX 1000

int main(void){
  int i,j,x;
  
  int Exp[1000];
  
  for( Exp[0]=FALSE, Exp[1]=TRUE, i=2; i<MAX; i++){
    Exp[i] = FALSE;
  }
  
  for( i=2; i<MAX; i++){
    for( j=i*i; j<MAX; j *= i){
      Exp[j] = TRUE;
    }
  }
  
  scanf("%d",&x);
  
  for( i=x; i>0; i--){
    if( Exp[i] == TRUE ){
      printf("%d\n",i);
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        
        int b = scan.nextInt();
        
        System.out.print(a * b);
        
        System.out.print(" ");

        System.out.println(2 * (a + b));
    }
}


Measured memory_bytes: 26216
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>

#define MAXCHAR 255

using namespace std;

int main()
{
	int strlen = 0;
	string input = "";
	int numOfABC = 0;
	cin >> strlen;
	cin >> input;
	
	for (int i = 0; i < strlen; i++)
	{
		if (i + 2 > strlen)
			break;
		if (input[i] == 'A' && input[i+1] == 'B' && input[i+2] == 'C')
		{
			numOfABC++;
		}
	}
	
	cout << numOfABC << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する



int main() {
    int H,W;
    cin >> H >> W;
    REP(i,0,W+2) cout << "#";
    cout << endl;
    REP(i,0,H){
        cout << "#";
        string s;
        cin >> s;
        cout << s;
        cout << "#";
        cout << endl;
    }
    REP(i,0,W+2) cout << "#";
    cout << endl;
}


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


int main()
{
    long long  n,m,k; std::cin >> n >> m >> k;
    //long long  a[n+1], b[m+1];
    std::vector<long long>  a(n+1), b(m+1);
    a[0]=0; b[0]=0;
    for (int i=1;i<n+1;i++)
        std::cin >> a[i];
    for (int i=1; i<m+1; i++)
        std::cin >> b[i];
    
    for (int i=1; i<n+1; i++)
        a[i]+=a[i-1];
    for (int i=1; i<m+1; i++)
        b[i]+=b[i-1];

    int ans=0, r=m;
    for (int i=0; i<n+1; i++)
    {
        if(a[i]>k) break;
        while (a[i]+b[r]>k)
            r--;
        ans = std::max({ans, i+r});
    }
    
    std::cout << ans;

    return 0;
}


Measured memory_bytes: 6400
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    sort(s.begin(),s.end());
    cout<<(s[0]!=s[2]?"Yes":"No")<<endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const ll inf=1e18;
const int maxn=55;
ll dp[maxn][3005];
ll c[maxn],d[maxn];

class edge
{
	public:
		int to,money,t;
		edge(int v,int a,int b)
		{
			to=v;
			money=a;
			t=b;
		}
};
vector<edge> v[maxn];
bool in[maxn];
queue<int> q;
void push(int x)
{
	if(in[x]) return ;
	in[x]=1;
	q.push(x);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	rept(i,1,50)
		rept(j,0,2500)
				dp[i][j]=inf;
	int n,m,xx;
	cin>>n>>m>>xx;
	rep(i,0,m)
	{
		int x,y,a,b;
		cin>>x>>y>>a>>b;
		v[x].pb(edge(y,a,b));
		v[y].pb(edge(x,a,b));
	}
	rept(i,1,n) cin>>c[i]>>d[i];
	if(xx<2500)
	{
		dp[1][xx]=0;
		for(int i=1;;i++)
		{
			if(i*c[i]+xx>=2500)
			{
				dp[1][2500]=i*d[1];
				break;
			}
			dp[1][i*c[1]+xx]=i*d[1];
		}
	}
	else rept(i,0,2500) dp[1][i]=0;
	q.push(1);
	in[1]=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		in[x]=0;
		rep(i,0,v[x].size())
		{
			int to=v[x][i].to,money=v[x][i].money,t=v[x][i].t;
			rept(j,money,2500)
			{
				if(dp[to][j-money]>dp[x][j]+t)
				{
					dp[to][j-money]=dp[x][j]+t;
					push(to);
				}
			}
			rept(j,0,2500)
			{
				int plus=1;
				while(plus*c[to]+j<=2500)
				{
					if(dp[to][plus*c[to]+j]>dp[to][j]+plus*d[to])
					{
						push(to);
						dp[to][plus*c[to]+j]=dp[to][j]+plus*d[to];
					}
					plus++;
				}
				if(dp[to][2500]>dp[to][j]+plus*d[to])
				{
					push(to);
					dp[to][2500]=dp[to][j]+plus*d[to];
				}
			}
		}
	}
	rept(i,2,n)
	{
		ll ans=inf;
		rept(j,0,2500) ans=min(ans,dp[i][j]);
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4808
import itertools
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(n)]
ans=0
for a,b,c in itertools.product([-1,1],repeat=3):
  tmp=[]
  for x,y,z in xyz:
    tmp.append(a*x+b*y+c*z)
  tmp.sort(reverse=True)
  ans=max(ans,sum(tmp[:m]))
print(ans)

Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;


//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    n--;
    vector<ll> c(n+1);
    vector<ll> s(n+1);
    vector<ll> f(n+1);
    c[0] = s[0] = f[0] = 0;
    rep2(i, 1, n+1){
        cin >> c[i] >> s[i] >> f[i];
    }

    rep2(j, 1, n+1){
        ll now_time = 0;
        rep2(i, j, n+1){
            if(now_time < s[i]) now_time = s[i];
            if(now_time != s[i] && (now_time-s[i]) % f[i] != 0){
                now_time += f[i] - (now_time - s[i]) % f[i];
            }
            now_time += c[i];
        }

        cout << now_time << endl;
    }
    cout << 0 << endl;
    
    return 0;
}


Measured memory_bytes: 256
def _input():
    return

def solve():
    _input()
    a, b, c, d = list(map(int, input().split()))
    if ((abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    vvi dp(n+1, vi(2, INF));
    dp[0][0] = 0;
    rep(i, n) rep(j, 2) {
        int x = s[i] - '0';
        x += j;
        if (x < 10) chmin(dp[i+1][0], dp[i][j] + x);
        if (x > 0) chmin(dp[i+1][1], dp[i][j] + 10 - x);
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 55964
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int sum=0;
    long long int h;
    long long int i=1;
    cin>>h;
    while (h>0) {
        h/=2;
        sum+=i;
        i*=2;
    }
    cout<<sum<<endl;
}


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

using namespace std;

#define MAX 300000

int n;
bool prime[MAX];

int main() {
	for (int i = 0; i < MAX; i++)
		prime[i] = true;
	for (int i = 6; i * i < MAX; i++)
		if (i % 7 == 1 || i % 7 == 6)
			if (prime[i])
				for (int j = i; i * j < MAX; j++)
					if (j % 7 == 1 || j % 7 == 6)
						prime[i * j] = false;

	while (1) {
		scanf("%d", &n);
		if (n == 1)
			return 0;

		printf("%d:", n);

		for (int i = 6; i <= n; i++)
			if (n % i == 0 && prime[i])
				if (i % 7 == 1 || i % 7 == 6)
					if (n / i % 7 == 1 || n / i % 7 == 6)
						printf(" %d", i);

		printf("\n");
	}
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int N;
    cin >> N;
    int A[N+1];
    map<int, int> mp1;
    map<int, int> mp2;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        mp1[A[i]-i]++;
        mp2[-(A[i]+i)]++;
    }
    int ans = 0;
    for(auto p : mp1){
        int x = p.first;
        int y = p.second;
        ans += y * mp2[x];
    }
    cout << ans << endl;
}

Measured memory_bytes: 39384
<?php
[$n] = ints();
$mod = 10**9+7;

$array[0] = 1;
for($i = 1; $i <= $n; $i++){
    $array[$i] = 0;
    for($j = 0; $j <= $i-3; $j++){
        $array[$i]+=$array[$j];
        $array[$i] %= $mod;
    }
}
echo $array[$n];



function str(){return trim(fgets(STDIN));}
function ints($n = false){
  if($n===false){
    return array_map('intval',explode(' ',trim(fgets(STDIN))));
  }else{$ret = [];for($i = 0; $i < $n; $i++)foreach(array_map('intval',explode(' ',trim(fgets(STDIN)))) as $j => $v)$ret[$j][] = $v;return $ret;}
}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array\n";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      if($both == 0){
        $G[$a][] = $b;
      }elseif($both == 1){
        $G[$a][] = $b;
        $G[$b][] = $a;
      }else{
        $G[$b][] = $a;
      }
    }else{
      list($a, $b, $d) = $values;
      if($both == 0){
        $G[$a][] = [$b, $d];
      }elseif($both == 1){
        $G[$a][] = [$b, $d];
        $G[$b][] = [$a, $d];
      }else{
        $G[$b][] = [$a, $d];
      }
    }
  }
  return $G;
}

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

int main(){
  int h,w;
  cin>>h>>w;
  string a;
  for (int i=0;i<w+2;i++){
    cout<<'#';
  }
  cout<<endl;
  for (int i=0;i<h;i++){
    cout<<'#';
    cin>>a;
    cout<<a;
    cout<<'#'<<endl;
  }
  for (int i=0;i<w+2;i++){
    cout<<'#';
  }
  cout<<endl;
}

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

void push(int);
int pop(void);

int top = 0;
int S[1000];

int main(){
int x,y;
char s[100];

while(scanf("%s",s) != EOF){

if(s[0] == '-'){
  x = pop();
  y = pop();
  push(y - x); /*注意*/
}

else if(s[0] == '+'){
  x = pop();
  y = pop();
  push(x + y);
}

else if(s[0] == '*'){
  x = pop();
  y = pop();
  push(x * y);
  }

else push(atoi(s));
}

printf("%d\n",pop());

return 0;
}

int pop(void){
if (top == 0) {
  printf("Stack is empty!\n");
  exit(3);
}
  top--;
  return S[top+1];
}

void push(int a){
  if(top == 1000){
    printf("Stack overflow!\n");
    exit(3);
  }
  S[++top] = a;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main(void){
    COMinit();
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<ll> wa(N+1);
    for(int i = 0; i < N; i++) cin >> A[i];
    wa[0] = 0;
    for(int i = 1; i <= N; i++){
        wa[i] = wa[i-1] + A[i-1];
        wa[i] %= M;
    }
    sort(wa.begin(), wa.end());
    wa.push_back(M);
    ll cnt = 1;
    ll ans = 0;
    for(int i = 0; i < wa.size(); i++){
        if(wa[i] != wa[i+1]){
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
        }else{
            cnt++;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200009
#define MAXM 320
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	if (n < m) swap(n, m);

	if (n == 1) {
		cout << 1 << endl;
	} else if (m == 1) {
		cout << n-2 << endl;
	} else {
		cout << 1LL*(n-2)*(m-2) << endl;
	}
}

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

const int dir_h[] = {-1, 0, 1, 0};
const int dir_w[] = { 0,-1, 0, 1};

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> S(H, vector<char>(W, '.'));
	rep(i, H) rep(j, W) cin >> S[i][j];
	
	int max_dist = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if('.' == S[i][j]){
				vector<vector<int>> dist(H, vector<int>(W, -1));
				queue<P> q;
				dist[i][j] = 0;
				q.push(make_pair(i, j));
				while(!q.empty()){
					int ni = q.front().first;
					int nj = q.front().second;
					q.pop();
					rep(k, 4){
						if( ni + dir_h[k] < 0 || H <= ni + dir_h[k]) continue;
						if( nj + dir_w[k] < 0 || W <= nj + dir_w[k]) continue;
						if(-1 != dist[ni + dir_h[k]][nj + dir_w[k]]) continue;
                      	if('#' == S[ni + dir_h[k]][nj + dir_w[k]]) continue;
						dist[ni + dir_h[k]][nj + dir_w[k]] = dist[ni][nj] + 1;
						q.push(make_pair(ni + dir_h[k], nj + dir_w[k]));
					}
				}
				rep(k, H) rep(l, W) max_dist = max(max_dist, dist[k][l]);
			}
		}
	}
	cout << max_dist << endl;
	return 0;
}


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

int main(){
  vector<int> vec(10);

  for(int i=0;i<10;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  for(int i=0;i<3;i++){
    cout << vec.at(i) << endl;
  }
}



Measured memory_bytes: 3088
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arrA = new int[m];
		int[] arrB = new int[m];
		for (int i = 0; i < m; i++) {
			arrA[i] = sc.nextInt() - 1;
			arrB[i] = sc.nextInt() - 1;
		}
		UnionFindTree uft = new UnionFindTree(n);
		long[] ans = new long[m];
		ans[m - 1] = (long)n * (long)(n - 1) / 2L;
		for (int i = m - 1; i >= 1; i--) {
			if (uft.same(arrA[i], arrB[i])) {
				ans[i - 1] = ans[i];
			} else {
				ans[i - 1] = ans[i] - uft.getCount(arrA[i]) * uft.getCount(arrB[i]);
				uft.unite(arrA[i], arrB[i]);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (long x : ans) {
			sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
	
	static class UnionFindTree {
		int[] parents;
		int[] counts;
		public UnionFindTree(int size) {
			parents = new int[size];
			counts = new int[size];
			for (int i = 0; i < size; i++) {
				parents[i] = i;
				counts[i] = 1;
			}
		}
		
		public int find(int x) {
			if (x == parents[x]) {
				return x;
			}
			int ans = find(parents[x]);
			parents[x] = ans;
			return ans;
		}
		
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		
		public long getCount(int x) {
			return counts[find(x)];
		}
		
		public void unite(int x, int y) {
			if (same(x, y)) {
				return;
			}
			int xx = find(x);
			int yy = find(y);
			parents[xx] = yy;
			counts[yy] += counts[xx];
		}
	}
}


Measured memory_bytes: 66524
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int K;
    string S;
    cin >> K >> S;
    if(S.size()<=K) cout << S << endl;
    else{
        for(int i=0; i<K; i++){
            cout << S.at(i);
        }
      	cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
using namespace std;

//	1 2 3 4 4 4 5 6 7 7 8 8 9 9

int num[20];
int pattern[20][3];
int m;
bool ok[20];

bool Search(int i, int j)
{
	if (j == 4){
		int cnt = 0;
		for (int k = 1; k <= 9; k++){
//			printf("%d ", num[k]);
			
			cnt += !num[k];
		}
//		puts("");
		
		return (cnt == 9);
	}
	
	if (i == m){
		return false;
	}
	
	if (Search(i + 1, j)){
		return true;
	}
	
	for (int k = 0; k < 3; k++){
		num[pattern[i][k]]--;
	}
	
	bool f = Search(i, j + 1);
	
	for (int k = 0; k < 3; k++){
		num[pattern[i][k]]++;
	}
	
	return (f);
}

int main()
{
	char str[128];
	
	while (scanf("%s", str) != EOF){
		memset(num, 0, sizeof(num));
		memset(pattern, 0, sizeof(pattern));
		memset(ok, false, sizeof(ok));
		
		for (int i = 0; i < 13; i++){
			num[str[i] - '0']++;
		}
/*		
		for (int i = 1; i <= 9; i++){
			printf(" %d", num[i]);
		}
		puts("");
*/		
		for (int i = 1; i <= 9; i++){
			if (num[i] == 4){
				continue;
			}
			
			num[i]++;
			
			m = 0;
			
			for (int j = 1; j <= 9; j++){
				if (num[j] >= 3){
					for (int k = 0; k < 3; k++){
						pattern[m][k] = j;
					}
					m++;
				}
				
				if (num[j] > 0 && num[j + 1] > 0 && num[j + 2] > 0){
					for (int k = 0; k < 3; k++){
						pattern[m][k] = j + k;
					}
					m++;
				}
			}
/*			
			for (int j = 0; j < m; j++){
				for (int k = 0; k < 3; k++){
					printf("%d ", pattern[j][k]);
				}
				puts("");
			}
*/				
			for (int j = 1; j <= 9; j++){
				num[j] -= 2;
				if (Search(0, 0)){
					ok[i] = true;
				}
				num[j] += 2;
			}
			
			num[i]--;
		}
		
		bool f = false;
		for (int i = 1; i <= 9; i++){
			if (ok[i]){
				if (f){
					printf(" ");
				}
				f = true;
				
				printf("%d", i);
			}
		}
		
		if (!f){
			printf("0");
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 984
""" B
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(_a, _b, _c, _d):
    return max([_a * _c, _a * _d, _b * _c, _b * _d])


if __name__ == "__main__":
    _a, _b, _c, _d = readIntegerSet(4)

    print(main(_a, _b, _c, _d))


Measured memory_bytes: 9576
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.substring(2,3).equals(s.substring(3,4)) && s.substring(4,5).equals(s.substring(5,6))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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



void solve(long long K){
    rep(i,K){
        cout<<"ACL";
    }
    cout<<endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3764
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
	for j in range(N-M+1):  # 左上のますが(i, j)
		tmp_lis = []
		for k in range(M):
			tmp_lis.append(A[i+k][j:j+M])
		if tmp_lis == B:
			print("Yes")
			exit()
else:
	print("No")



Measured memory_bytes: 5396
import sys
def input():
    return sys.stdin.readline()[:-1]
N,K=map(int,input().split())
S=input()
l=[0]
t="1"
for i in S:
    if t==i:
        l[-1]+=1
    else:
        l.append(1)
        if t=="1":
            t="0"
        else:
            t="1"
if t=="0":
    l.append(0)
a=sum(l[:2*K+1])
A=a
for i in range(2*K+2,len(l),2):
    a+=l[i]+l[i-1]
    a-=l[i-2*K-2]+l[i-2*K-1]
    A=max(A,a)
print(A)

Measured memory_bytes: 4472
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;

int digit_sum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  for(int i=1;i<=N;i++){
    if(A<=digit_sum(i) && digit_sum(i)<=B) ans += i;
  }

  cout << ans <<endl;

  return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int main() {
    ios_base::sync_with_stdio(false);
    int n, W, sum_values = 0;
    cin >> n >> W;
    vector < ll > weights(n + 5), values(n + 5);
    for (int i = 1; i <= n; i++) {
      cin >> weights[i] >> values[i];
      sum_values += values[i];
    }
    vector < ll > DP(sum_values + 5, 2e9);
    DP[0] = 0;
    // DP[i] --> min weight to obtain value i
    for (int i = 1; i <= n; i++) {
      for (int last_value = sum_values - values[i]; last_value >= 0; last_value--) {
        if (DP[last_value] == 2e9) continue;
        DP[last_value + values[i]] = min(DP[last_value + values[i]], DP[last_value] + weights[i]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= sum_values; i++) {
    if (DP[i] <= W) {
      ans = i;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll n=b-a+1;
    ll cn,dn;
    if(a%c==0) cn=b/c-a/c+1;
    else cn=b/c-a/c;
    if(a%d==0) dn=b/d-a/d+1;
    else dn=b/d-a/d;
    ll m=lcm(c,d),mn;
    if(a%m==0) mn=b/m-a/m+1;
    else mn=b/m-a/m;

    ll ans=n-cn-dn+mn;
    cout << ans << endl;

}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define FOR(i,a,b) for (int i=a;i<b;i++)

int main(){
    int A, B;
    cin>>A>>B;
    cout<<(A-1)*(B-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
x = 0
y = 0

while True:
    R1 = input()
    if R1 == '0':
        break
    R2 = input()
    R3 = input()
    
    R1A = R1[1:].count('A')
    R1B = len(R1)-R1A-1
    if R2[0]=='A':
        R1A += 1
    else:
        R1B += 1
        
    R2A = R2[1:].count('A')
    R2B = len(R2)-R2A-1
    if R3[0] == 'A':
        R2A += 1
    else:
        R2B += 1
        
    R3A = R3[1:].count('A')
    R3B = len(R3)-R3A-1
    if R3A > R3B:
        R3A += 1
    else:
        R3B += 1
        
    print(R1A, R1B)
    print(R2A, R2B)
    print(R3A, R3B)


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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> H(N);
  vector<vector<int>> edge(N, vector<int>(0));
  
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  // for(int i=0; i<edge[1].size() ; i++) cout << edge[1][i] << endl;
  
  
  vector<bool> yoi(N, true);
  
  for(int i=0; i<N; i++){
    // if( edge[i].size()==0 ) continue;
    for(int j=0;  j < edge[i].size();  j++){
      if(H[i]<=H[edge[i][j]]){
        yoi[i] = false;
        break;
      }
    }
  }
  
  int cnt = 0;
  
  for(int i=0; i<N; i++){
     //  cout << H[i] << ' ' << yoi[i] << endl;
    if(yoi[i]) cnt++;
  }
  
   cout << cnt << endl;
}
    
  

Measured memory_bytes: 8800
N = int(input())
S = sorted(list(map(int, input().split())))
stk = []
tmp = 0
res = 0
passed = set()
for e in S:
    if e in passed:
        res += 1
        continue
    if tmp == 0:
        tmp = e
    if e == tmp:
        stk.append(e)
    else:
        res += len(stk)
        stk = [e]
        tmp = e
    if tmp == len(stk):
        stk = []
        passed.add(tmp)
res += len(stk)
print(res)

Measured memory_bytes: 14212
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);

    int sum=0;

    for(int i=0;i<2;i++)
    {
        if(a>=b)
        {
            sum=sum+a;
            a--;
        }

        else
        {
            sum=sum+b;
            b--;
        }
        
    }

    printf("%d",sum);

}

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	ll x, y;
	cin >> x >> y;
	int ans = 0;
	for(; x <= y; ++ans, x <<= 1);
	cout << ans << endl;
}


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

int main() {
  int N; cin >> N;
  string s = to_string(N);
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) ans += s[i] - '0';
  cout << ( (N % 10) ? ans : 10 ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vv<ll> dp = vvec(N + 1, 2 * W + 1, 0LL);
    rep(i, N) rep(j, W + 1) {
        dp[i + 1][j + w[i]] = dp[i][j] + v[i];
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }

    ll ans = 0;
    rep(j, W + 1) ans = max(ans, dp[N][j]);
    write(ans);
}

Measured memory_bytes: 159744
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {
long N;
cin>>N;
vector<long> A(N);
vector<long> B(N);
vector<long> C(N);
long money=1000;
long stock=0;
long nowstock=0;

for(long i=0;i<N;i++){
cin>>A.at(i);
    if(i>0&&A.at(i)>A.at(i-1)){
        B.at(i)=2;//UP
    }else if(i>0){
        B.at(i)=1;//DOWN
    }
}

if(B.at(1)==2){
    C.at(0)=2;//to buy stocks;
}
for(long i=1;i<N-1;i++){
    if((B.at(i)==2||B.at(i)==3)&&(B.at(i+1)==1||B.at(i+1)==3)){
    C.at(i)=1;//to sell
    }else if((B.at(i)==1||B.at(i)==3)&&(B.at(i+1)==2||B.at(i)==3)){
    C.at(i)=2;
    }else{
    C.at(i)=3;
    }
}

for(long i=0;i<N-1;i++){
    if(C.at(i)==1){
        money=money+stock*A.at(i);
        stock=0;
    }
    if(C.at(i)==2){
        nowstock=money/A.at(i);
        money=money-nowstock*A.at(i);
        stock=stock+nowstock;
    }

}
money=money+stock*A.at(N-1);
cout<<money<<endl;

}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0019
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Console.WriteLine(Factorial(n));
        }

        /// <summary>
        ///階乗
        /// </summary>
        public static long Factorial(long n, long mod = 0)
        {
            checked
            {
                if (n == 0) return 1L;
                if (mod == 0)
                { return n * Factorial(n - 1); }
                else
                { return n * Factorial(n - 1, mod) % mod; }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 15904
#include<iostream>

using namespace std;

int n, m;
int a[100005];
bool judge[100005];
long long inf = 1000000007;
  

void solver(){
  int dp[100005];
  dp[0] = 1;
  dp[1] = 1;
  for(int i = 1; i <= n; ++i){
    if(judge[i] == 1 && judge[i - 1] == 1){
      dp[i + 1] = 0;
    }else if(judge[i] == 1){
      dp[i + 1] = dp[i - 1] % inf;
    }else if(judge[i - 1] == 1){
      dp[i + 1] = dp[i] % inf;
    }else{
      dp[i + 1] = (dp[i] + dp[i - 1]) % inf;
    }
  }
  cout << dp[n] << endl;
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < n; ++i){
    judge[i] = 0;
  }
  for(int i = 0; i < m; ++i){
    cin >> a[i];
    judge[a[i]] = 1;
  }
  solver();
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    char c; cin >> c;
    if(c > 'Z')out("a");
    else out("A");
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main() {
    
    int N, K;
    vector<int> D;
    int ans;
    
    cin >> N;
    cin >> K;
    
    for ( int i = 0; i < K; i++ ) {
        int d;
        cin >> d;
        
        D.push_back( d );
    }
    
    for ( int i = N; i < 100000; i++ ) {
        
        bool is_OK = true;
        
        string s = to_string( i );
        
        for ( int j = 0; j < s.length(); j++ ) {
            for ( int k = 0; k < D.size(); k++ ) {
                if ( s.substr( j, 1 ) == to_string( D[k] ) ) {
                    is_OK = false;
                    break;
                }
            }
        }
        
        if ( is_OK ) {
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;



int main(){
	int a, b, c;
	int m = 0, n = 0;

	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if(a*a+b*b == c*c) m++;
		if(a == b)n++;
	}
	cout << m << endl << n << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 x; cin >> x;
  i64 c;
  c = x / 11;
  if (x - 11 * c == 0) cout << c * 2 << '\n';
  else if (x - 11 * c <= 6) cout << c * 2 + 1 << '\n';
  else cout << c * 2 + 2 << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll a, b, c,d;
	cin >> a >> b >> c >> d;
	if (a*b != c*d) {
		cout << max(a*b, c*d) << endl;;
	}
	else {
		cout << a * b << endl;
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    ll x;
    cin>>x;
    
    ll y=0;
    if(x%11>6) y=2;
    else if(x%11>0) y=1;
    
    cout<<(x/11)*2+y<<endl;
}


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
int deg[100005] ; 
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int n,m ;
    cin >> n >> m ;
    int a, b;
    while(m--){
        cin >> a >> b ;
        deg[a]++ ;
        deg[b]++ ;
    } 
    for(int i = 1 ; i <= n ; i++){
        if(deg[i] & 1){
            cout << "NO\n" ;
            return 0 ;
        }
    }
    cout << "YES\n" ;
    return 0 ; 
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	var k int64
	rd := bufio.NewReader(os.Stdin)
	fmt.Fscan(rd, &n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rd, &a[i])
		a[i]--
	}

	v := make([]bool, n)
	path := make([]int, 0, n)
	var s int
	for !v[s] {
		v[s] = true
		path = append(path, s)
		s = a[s]
	}

	var l int
	for i := 0; i < len(path); i++ {
		if path[i] == s {
			break
		}
		l++
	}

	var ans int
	if k < int64(l) {
		ans = path[int(k)]
	} else {
		k -= int64(l)
		k %= int64(len(path) - l)
		ans = path[l+int(k)]
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 6680
fun main(arr:Array<String>) {
    val num = readLine()!!.toLong()
    var tmp = Pair<Long, Long>(1,num)
    for(i in (2..num)) {
        if(i*i> num) {
            break
        }
        if(num % i == 0L) {
            tmp = Pair(i, num / i)
        }
    }
    val ans = Math.max(tmp.first, tmp.second).toString().length
    println(ans)
}



Measured memory_bytes: 31848
function Main(input) {
    input = input.split('\n')
    input.pop()
    input.shift();
    var sheet = {};
    input.forEach(function(e) {
        if (sheet[e]) {
            sheet[e] = 0
        } else {
            sheet[e] = 1
        }
    });
    var r = 0;
    for (var key in sheet) {
        if (sheet[key])
            r++
    }
    console.log(r)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 39900
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    if(n==1){
        OUT("Hello World");
    }else{
        int a,b;
        cin>>a>>b;
        OUT(a+b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;

  vector<int> Front;
  int cnt = 0;
  rep(i, N) {
    if (S[i] == 'o' && cnt < K) {
      Front.emplace_back(i);
      ++cnt;
      i += C;
    }
  }

  vector<int> Back;
  cnt = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'o' && cnt < K) {
      Back.emplace_back(i);
      ++cnt;
      i -= C;
    }
  }
  reverse(Back.begin(), Back.end());

  rep(i, K) {
    if (Front[i] == Back[i]) cout << Front[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 5832
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define ni(i) (i)*(i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n;
set<P> s;
P d[3000];
ll ans=0;
bool ok(ll a,ll b){
	P v=P(d[b].first-d[a].first,d[b].second-d[a].second);
	P A=d[a];
	P B=d[b];
	return (s.count(P(B.first+v.second,B.second-v.first)) && s.count(P(A.first+v.second,A.second-v.first)) )
				|| (s.count(P(B.first-v.second,B.second+v.first)) && s.count(P(A.first-v.second,A.second+v.first)) );
}


int main()
{while(1){
	ans=0;
	cin>>n;
	if(!n) return 0;
	s.clear();
	for(ll i=0;i<n;i++){
		cin>>d[i].first>>d[i].second;
		s.insert(d[i]);
	}
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			if(ni(d[i].first-d[j].first)+ni(d[i].second-d[j].second)>ans&&ok(i,j)){
				ans=ni(d[i].first-d[j].first)+ni(d[i].second-d[j].second);
			}
		}
	}
	cout<<ans<<endl;
}}

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

//最大公約数 greatest common divison
ll gcd(ll x, ll y){ return y ? gcd(y, x%y) : x;}

int main() {
  ll A,B; cin>>A>>B;
  set<ll> st;
  ll C = gcd(A,B);
  //Cの、2以上の素因数の数を求める
  //√Cより大きい素因数は高々1個まで！（2個以上あると、それらをかけたときにCより大きくなってしまう）
  for(ll i=2;i<=pow(C,0.5);i++){
    while(C%i==0){
      st.insert(i);
      C /= i;
    }
    if(C==1)break;
  }
  ll ans=st.size()+1;
  if(C!=1) ans++;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n,fn,buf;
  cin>> n;  
  buf=n;
  while (buf>=1) {
    fn += buf%10;
    buf /=10;
  }
  if (n%fn==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int n;
vector<int> a, b;
vector<bool> used;

bool check () {
    vector<vector<bool>> data(51,vector<bool>(51,false));
    rep(i,51) if(i && used[i]) rep(j,51) data[j][j%i] = true; rep(i,51) data[i][i] = true;
    rep(i,51) rep(j,51) rep(k,51) if (data[i][k] && data[k][j]) data[i][j] = true;
    rep(i,n) if (!data[a[i]][b[i]]) return false;
    return true;
}

int main(){
    cin >> n;
    a.resize(n); rep(i,n) cin >> a[i];
    b.resize(n); rep(i,n) cin >> b[i];
    rep(i,n) if(a[i] < b[i]) { cout << -1 << "\n"; return 0; }

    used.assign(51,true); 

    if (!check()) { cout << -1 << "\n"; return 0; }
    for (int i = 50; i >= 1; i--) {
        used[i] = false;
        if (!check()) used[i] = true;
    }
    ll ans = 0; rep(i,51) if(i && used[i]) ans += 1ll<<i;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3616