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

typedef unsigned long long int uint64;
typedef long long int          int64;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))


void get_NAB (int64 *n, int64 *a, int64 *b)
{
  int cnt;
  
  cnt = scanf("%lld %lld %lld", n, a, b);

  return;
}

int main()
{
  int cnt;
  int i;
  int64 N,A,B;
  int64 taxi, train;

  get_NAB(&N, &A, &B);

  taxi = B;
  train = A*N;

  if (train < taxi) {
    printf("%lld", train);
    return 0;
  }

  printf("%lld", taxi);

  return 0;
}



Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
S = input()[:-1]

ans = ""
for c in S:
    dist = ord(c)-ord('A')
    dist += N
    dist %= 26
    ans += chr(ord('A')+dist)
print(ans)


Measured memory_bytes: 41452
import scala.io.StdIn

object Main extends App {
  val Array(m, d)  = StdIn.readLine().split(" ").map(_.toInt)
  var ans = 0

  (1 to m).foreach { mm =>
    (22 to d).foreach { dd =>
      val d10 = (dd.toDouble / 10).floor.toInt
      val d1 = dd - d10 * 10
      if (d1 >= 2 && d10 * d1 == mm) ans = ans + 1
    }
  }

  println(ans)
}


Measured memory_bytes: 25548
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second

bool prime[1000005];
void init(){
	rep(i,1000005){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	reg(i,2,1000004){
		if(!prime[i])continue;
		for(int j=i*2;j<1000005;j+=i)prime[j]=false;
	}
}

int cam[1000005];

int main(void){
	init();
	int m,n;
	for(;;){
		scanf("%d%d",&n,&m);
		if(n==0)break;
		int dat[35];
		rep(i,n){
			scanf("%d",&dat[i]);
		}
		memset(cam,0,sizeof(cam));
		cam[0]=1;
		rep(i,n){
			int no=dat[i];
			reg(j,0,m-no){
				if(cam[j]==1)cam[j+no]=1;
			}
		}
		int ans=0;
		reg(i,2,m){
			if(cam[i]==1 && prime[i])ans=i;
		}
		if(ans!=0)printf("%d\n",ans);
		else printf("NA\n");
	}
		
	return 0;
}

Measured memory_bytes: 5928
N, Q = map(int, input().split())
S = input()
total = [0] * len(S)
for i in range(1,len(S)):
    if S[i-1:i+1] == "AC":
        total[i] = total[i-1] + 1
    else:
        total[i] = total[i-1]
ranges = []
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ranges.append((l,r))
for l, r in ranges:
    if l == 0:
        print(total[r])
    else:
        print(total[r]-total[l])


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

void solve(long long A, long long B) {
    if (A - B * 2 <= 0) {
        cout << 0 << endl;
    } else {
        cout << A - B * 2 << endl;
    }
}

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


Measured memory_bytes: 3652
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
S = int(input().rstrip())
print(l[S-1])


Measured memory_bytes: 2940
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext()
    {
        return $this->pointer < $this->count;
    }
    public function nextInt()
    {
        return (int) $this->next();
    }
    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();

$h1 = $sc->nextInt();
$m1 = $sc->nextInt();
$h2 = $sc->nextInt();
$m2 = $sc->nextInt();
$k = $sc->nextInt();

$a = $h1 * 60;
$b = $h2 * 60;

$a1 = $a + $m1;
$b1 = $b + $m2;

$calc = $b1 - $a1 - $k;

echo $calc;

Measured memory_bytes: 16216
#include<bits/stdc++.h>
int book[100001], n, k, q, t;
using namespace std;
int main() {
	cin >> n >> k >> q;
	for (int i = 1; i <= q; i++) {
		scanf("%d", &t);
		book[t]++;
	}
	for (int i = 1; i <= n; i++) {
		if (k - q + book[i] > 0)
			cout << "Yes" << endl;
		else
			cout << "No" <<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
input()
A = list(map(int, input().split()))
x = 0
y = 0
t = 0
while A:
	m = max(A)
	if t == 0:
		x += m
		t = 1
	else:
		y += m
		t = 0
	A.remove(m)
print(x-y)

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

constexpr int MAX_N = 100;

struct edge {
	int from_, to_, cost_;
	edge() = default;
	edge(int from, int to, int cost) :from_(from), to_(to), cost_(cost) {}
	bool operator<(const edge& rhs) const{
		return (cost_ == rhs.cost_) ? to_ < rhs.to_ : cost_ < rhs.cost_;
	}
};

int n, m;
std::vector<edge> edges;

class Union {
	int par[MAX_N], rank[MAX_N];
public:
	Union() {
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (x == par[x])
			return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y])
			std::swap(x, y);
		par[y] = x;
		rank[x] += rank[y];
	}
};

int main() {
	while (1) {
		std::cin >> n;
		if (!n)
			break;
		std::cin >> m;
		Union uni;
		edges.clear();
		int a, b, d;
		char ch;
		for (int i = 0; i < m; ++i) {
			std::cin >> a >> ch >> b >> ch >> d;
			d /= 100;
			--d;
			edges.push_back(edge(a, b, d));
		}

		std::sort(edges.begin(), edges.end());

		long long int ans = 0;
		for (int i = 0; i < edges.size(); ++i) {
			if (!uni.same(edges[i].from_, edges[i].to_)) {
				uni.unite(edges[i].from_, edges[i].to_);
				ans += edges[i].cost_;
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

lli a, b, c, k;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> a >> b >> c >> k;
	if(k % 2 == 0)
		cout << a - b;
	else
		cout << b - a;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main() {
    
    ll N;
    cin >> N;
    int lim = sqrt(N);
    ll out = N+1;
    for(int i=2;i<=lim;i++){
            if(N % i == 0){
                if(i+N/i < out) out = i+N/i;
            }
    }
    cout << out-2 << 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++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

lint app() {
  int n;
  cin>>n;

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

  sort(a.begin(),a.end(),greater<int>());

  lint ans=0;
  rep(i,n){
    if(i==0){
      continue;
    }
    ans+=a[(i)/2];
  }
  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const int MOD = 1000000007;
// const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
    int n;
    cin >> n;
    vector<string> S(n);
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        S[i] = s;
    }
    for(int i = 0; i < 26; i++)
    {
        int count = 1000;
        for(int j = 0; j < n; j++)
        {
            int num = 0;
            for(int k = 0; k < S[j].size(); k++)
            {
                if(S[j][k] == 'a' + i) num++;
            }
            count = min(count,num);
        }
        char a = 'a' + i;
        for(int e = 0; e < count; e++)
        {
            cout << a;
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>
#include<string>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<double> que;
  for(int i = 0; i < n; i++){
    double t;
    cin >> t;
    que.push(t);
  }
  for(int i = 0; i < m; i++){
    double now = que.top();
    que.pop();
    now = now/2;
    que.push(now);
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    double t = que.top(); que.pop();
    ans += floor(t);
  }
  cout << ans << endl;
}


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

using namespace std;


int main()
{  
    string x;
    cin >> x;
    for(int i = 0; i<x.length(); i++){
        if(x[i] == '7') {cout << "Yes"; return 0;}
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{

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





}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  double sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  int cnt = 0;

  rep(i,n){
    if (a[i] * 4 * m >= sum) cnt++;
  }
  if (cnt >= m) puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 256
import math
a, b = map(int, input().split())

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if b%i == 0:
        k = b//i
        if a%k == 0:
            if is_prime(k):
                c.append(k)
        if a%i == 0:
            if is_prime(i):
                c.append(i)
print(len(set(c))+1)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#define INF 2000000
using namespace std;
typedef long long ll;//声明// 
int q1[4050];
int q2[4050];
int q3[4050];
int main()
{   ll n,sum=0,i,t=0,t1=0,t2=0,j,t3=0,t4=0,t5=0,k;
    char b[4050];
    cin>>n;
    cin>>b;
    
    for(i=0;i<n;i++)
    { if(b[i]=='R') t++;
       if(b[i]=='G') t1++;
        if(b[i]=='B')  t2++;
	}
	sum=t1*t2*t;
	for(i=0;i<n;i++)
	{ for(j=0;j<n;j++)
	   {    k=2*j-i;
	        if(i<j&&j<k&&k<n&&b[i]!=b[j]&&b[j]!=b[k]&&b[k]!=b[i])
	               sum--;
	   }
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3644
from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst, len_prime):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if i < len_prime and prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)
len_prime = len(prime_lst)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst, len_prime))



Measured memory_bytes: 16396
#include <iostream>
#include <vector>
#include <map>
#include <set>

int main(void){

  int n;
  std::cin >> n;
  std::vector<int> A(n);
  std::vector<int> groupid(n, -1);
  std::vector<std::set<int> > groups;

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

  std::set<std::pair<int, int> > tops;
  int count = 0;
  for(int i=0; i<n; i++){
    std::pair<int, int> now = std::make_pair(A[i], n-i);
    if(tops.size() == 0){
      tops.insert(now);
      count++;
      continue;
    }

    auto target = tops.lower_bound(now);
    if(target == tops.begin()){
      tops.insert(now);
      count++;
      continue;
    }
    auto before = target--;
    //std::cout << (*target).first << " " << (*target).second << std::endl;
    //std::cout << (*before).first << " " << (*before).second << std::endl;
    if(*(target) < now){
      tops.erase(*(target));
      tops.insert(now);
    }else{
      tops.insert(now);
      count++;
    }
  }

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, A, B;
    cin >> K >> A >> B;
    if (A <= B) {
        if (A >= K) {
            cout << 1 << endl;
        }
        else {
            cout << -1 << endl;
        }
        return 0;
    }
    ll diff = max(K - A, 0LL);
    cout << ((diff + A - B - 1) / (A - B)) * 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int H,W,N,sr,st,i,koma,check;
  check=0;
  cin>>H>>W>>N>>sr>>st;
  string S,T;
  cin>>S>>T;
  koma=sr;
  for(i=0;i<N;i++){
  if(S.at(i)=='U') koma--;
    if(koma==0){
    check++;
      break;
    }
    if(T.at(i)=='D') koma++;
    if(koma>H) koma--;
  }
    koma=sr;
  for(i=0;i<N;i++){
    if(check==1) break;
  if(S.at(i)=='D') koma++;
    if(koma>H){
    check++;
      break;
    }
    if(T.at(i)=='U') koma--;
    if(koma==0) koma++;
  }
    koma=st;
  for(i=0;i<N;i++){
    if(check==1) break;
  if(S.at(i)=='L') koma--;
    if(koma==0){
    check++;
      break;
    }
    if(T.at(i)=='R') koma++;
    if(koma>W) koma--;
  }
      koma=st;
  for(i=0;i<N;i++){
    if(check==1) break;
  if(S.at(i)=='R') koma++;
    if(koma>W){
    check++;
      break;
    }
    if(T.at(i)=='L') koma--;
    if(koma==0) koma++;
  }
  if(check==1){
  cout<<"NO"<<endl;
  }else{
  cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 776
from fractions import gcd
n, x = map(int,input().split())
xi = list(map(int,input().split()))

for i, n in enumerate(xi):
    xi[i] = abs(xi[i]-x)
ans = xi[0]
for i in range(len(xi)):
    ans = gcd(ans, xi[i])
print(ans)

Measured memory_bytes: 16284
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,m,k,l,r;
LL f[505][505];
template<class T>
inline void read(T& x) {
	char c = getchar(); int f = 1; x = 0;
	while(!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while(isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	x *= f;
}
int main()
{
	read(n),read(m),read(k);
	rep(i,1,m)
	{
		read(l),read(r);
		f[l][r]++;
	}
	rep(i,1,500)rep(j,1,500)f[i][j]+=f[i][j-1]+f[i-1][j]-f[i-1][j-1];
	rep(i,1,k)
	{
		read(l),read(r);
		l--;
		cout<<f[r][r]-f[l][r]-f[r][l]+f[l][l]<<endl;
	}
}


Measured memory_bytes: 2944
import math
import numpy as np
n, d = map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int, input().split())))
ans=0
mat= np.array(a, dtype=object)
for i in range(n-1):
  for j in range(i+1,n):
    x= (mat[i]-mat[j])**2
    hei=math.sqrt(sum(x))
    if int(hei)==hei:
      ans+=1
      
print(ans)
    

Measured memory_bytes: 27152
main = do
    n <- readLn
    if n == 0 then return () else do
        s <- getLine
        putStrLn $ iterate operate s !! n
        main

operate :: String -> String
operate "" = ""
operate (c:cs) = operate' cs c 1
    where
    operate' [] c' n        = (show n) ++ [c']
    operate' (c:cs) c' n
        | c == c'           = operate' cs c' (n+1)
        | otherwise         = (show n) ++ c' : operate' cs c 1

Measured memory_bytes: 4120
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int n,x=0,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x++;
		}
		else{
			x--;
		}
		if(ans<x)ans=x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 504
h1, m1, h2, m2, k = map(int, input().split())
hk = k // 60
mk = k - 60 * hk

if m1+mk >=60:
    h1 += 1
    m1 = m1 + mk -60
else:
    m1 = m1 + mk
h1 += hk

if m2- m1< 0:
    h2 -= 1
    m2 = m2- m1+ 60
else:
    m2 = m2 -m1
h = h2 - h1
print(h*60 + m2)

Measured memory_bytes: 9192
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	v := getNextInt(scanner)
	e := getNextInt(scanner)
	fw := makeGrid(v, v)
	for i := 0; i < v; i++ {
		for j := 0; j < v; j++ {
			if i == j {
				continue
			}
			fw[i][j] = math.MaxInt32
		}
	}
	for i := 0; i < e; i++ {
		s := getNextInt(scanner)
		t := getNextInt(scanner)
		d := getNextInt(scanner)
		fw[s][t] = d
	}
	for k := 0; k < v; k++ {
		for i := 0; i < v; i++ {
			for j := 0; j < v; j++ {
				if fw[i][k] == math.MaxInt32 {
					continue
				}
				if fw[k][j] == math.MaxInt32 {
					continue
				}
				if fw[i][j]-fw[i][k] > fw[k][j] {
					fw[i][j] = fw[i][k] + fw[k][j]
				}
			}
		}
	}
	for k := 0; k < v; k++ {
		for i := 0; i < v; i++ {
			for j := 0; j < v; j++ {
				if fw[i][k] == math.MaxInt32 {
					continue
				}
				if fw[k][j] == math.MaxInt32 {
					continue
				}
				if fw[i][j]-fw[i][k] > fw[k][j] {
					fmt.Fprintln(writer, "NEGATIVE CYCLE")
					return
				}
			}
		}
	}
	for i := 0; i < v; i++ {
		for j := 0; j < v; j++ {
			if j > 0 {
				fmt.Fprint(writer, " ")
			}
			if fw[i][j] == math.MaxInt32 {
				fmt.Fprint(writer, "INF")
				continue
			}
			fmt.Fprint(writer, fw[i][j])
		}
		fmt.Fprintln(writer, "")
	}
}
func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}



Measured memory_bytes: 1620
k = int(raw_input())


l,r = 0,k
while (r-l)>1:
	m = (l+r)/2
	if (m * (m + 1)) < k:
		l = m
	else:
		r = m

b = l

#print b
ad = k - (b * (b + 1))

d = ((ad - 1) % (b + 1)) + 1

#print ad,d
x = 2 * b + 1
y = 1
if (ad - d) > 0:
	x += 1
	
if d  <= (b + 1 + 1) / 2:
	dd = d * 2 - 1
else:
	dz = (b + 1 - d)
	dd = dz * 2 + 2

x -= (dd-1)
y += (dd-1)

mod = 1000000007

def mul(a,b):
	res = [[0,0],[0,0]]
	p,q,r = 2,2,2
	for s in xrange(p):
		for t in xrange(q):
			res[s][t] = 0
			for u in xrange(r):
				y = a[s][u] * b[u][t]
				res[s][t] += y
			res[s][t] %= mod
	return res


def fib(x):
	bt = [[1,1],[1,0]]
	r = [[1,1],[1,0]]
	while x > 0:
		if x % 2 != 0:
			r = mul(r,bt)
		bt = mul(bt,bt)
		x /= 2
	
	return r[0][0]
	

#print x,y

ans = fib(x-1) * fib(y-1)
ans %= mod
print ans

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main(){
    ll n, k, a, b;
    cin >> n >> k;
    set<int>st;
    rep(i, k) {
        cin >> a;
        rep(j, a){
            cin >> b;
             st.insert(b); 
        }
    }
    cout << n - st.size() << endl;
}

Measured memory_bytes: 3640
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

last_di = [0] * 26

v = 0
for d in range(D):
    i = t[d]
    v += s[d][i - 1]

    last_di[i - 1] = d + 1

    S = 0
    for j in range(len(c)):
        S += c[j] * (d + 1 - last_di[j])

    v -= S
    print(v)

Measured memory_bytes: 9268
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		switch(str) {
		case "SUN":
			System.out.println(7);
			break;
		case "MON":
			System.out.println(6);
			break;
		case "TUE":
			System.out.println(5);
			break;
		case "WED":
			System.out.println(4);
			break;
		case "THU":
			System.out.println(3);
			break;
		case "FRI":
			System.out.println(2);
			break;
		case "SAT":
			System.out.println(1);
			break;
		default:
			break;
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long int llf;
llf pelsar(int i){
	if(i<0)
	return 0;
	return pow(10,i-1)*9+pelsar(i-2);
}
int main() {
	// your code goes here
	llf n;
	while(cin >> n && n!=0){
		bool minus=n<0;
		n=abs(n);
		int start=0;
		llf ans=0;
		for(int i=0;n!=0;i++){
			if((!(i%2)^minus))
				ans+=(n%10)*pow(10,i);
			else if(n%10 != 0)
				ans+=(10-(n%10))*pow(10,i);
			if(n%10!=0 && ((i%2)^minus))
			n+=10;
			n/=10;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<string> s;
  for (int i = 1; i <= n; i++) {
    string a;
    cin >> a;
    s.insert(a);
  }
  cout << (int) s.size() << "\n";
  return 0;
}


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

int main() {
  int N, num, count;
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end()); //sort
  reverse(vec.begin(), vec.end());

  num = 0;
  count = 0;
  for (int i=0; i<N; i++) {
    count++;
    if (num == vec.at(i)) {
	  count--;
    }
    num = vec.at(i); // num に大きい方からvecを代入
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3608
import java.io.*;

class Main {

   public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int x = Integer.valueOf(br.readLine()).intValue();
      int i = 1;
      while (x != 0) {
         System.out.println("Case " + i + ": " + x);
         i++;
         x = Integer.valueOf(br.readLine()).intValue();
      }
   }
}

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


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 1E2 + 10;

int n;
vector<int> E[N];
ll son[N];

int mark[N];

void DFS2(int u, int d = 0, int pre = 0){
	int cnt = 0;
	for (auto &v: E[u]){
		if (v == pre || mark[v])
			continue;
		DFS2(v, d + 1, u);
		++cnt;
	}
	son[d] = max(son[d], (ll)cnt);
}

int DFS(int u, int pre = 0){
	int ret = 0;
	for (auto &v: E[u]){
		if (v == pre)
			continue;
		ret = max(ret, DFS(v, u) + 1);
	}
	return ret;
}

ll getVal(){
	ll ret = 1;
	for (int i = 0; i <= n; ++i)
		ret *= son[i];
	return ret;
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}

	vector<pii> dep;
	for (int i = 1; i <= n; ++i)
		dep.emplace_back(DFS(i), i);
	sort(all(dep));

	ll ans;
	if (dep[0].st < dep[1].st){
		int u = dep[0].nd;
		mark[u] = true;
		fill_n(son, n + 1, 1);
		DFS2(u);
		ans = getVal();
		for (auto &v: E[u]){
			mark[v] = true;
			fill_n(son, n + 1, 1);
			DFS2(u);
			DFS2(v);
			mark[v] = false;
			ans = min(ans, getVal() * 2);
		}
	}
	else{
		int u = dep[0].nd, v = dep[1].nd;
		mark[u] = mark[v] = true;
		fill_n(son, n + 1, 1);
		DFS2(u);
		DFS2(v);
		ans = getVal() * 2;
	}
	printf("%d %lld\n", dep[0].st + (dep[0].st != dep[1].st), ans);
	return 0;
}


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


int main() {
int n;
cin >> n;
vector<string> s(n);
rep(i,n) cin >> s[i];
int ac = 0,wa = 0, tle = 0,re = 0;
rep(i,n){
    if(s[i] == "AC"){
        ac++;
    }
    else if(s[i] == "WA"){
        wa++;
    }
    else if(s[i] == "TLE"){
        tle++;
    }
    else{
        re++;
    }

} 
cout << "AC x " <<  ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " <<  re << endl;

}

Measured memory_bytes: 6424
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
//This code is written by Itst
using namespace std;

inline int read(){
	int a = 0;
	char c = getchar();
	while(!isdigit(c))
		c = getchar();
	while(isdigit(c)){
		a = a * 10 + c - 48;
		c = getchar();
	}
	return a;
}

const int MAXN = 2e5 + 3;
struct Edge{
	int s , t , w;
	bool operator <(const Edge a)const{return w < a.w;}
}Ed[MAXN << 1];
int fa[MAXN] , minN[MAXN] , N , Q , cnt;
long long sum;

int find(int x){return fa[x] == x ? x : (fa[x] = find(fa[x]));}

int main(){
	memset(minN , 0x7f , sizeof(minN));
	N = read();
	Q = read();
	for(int i = 1 ; i <= Q ; ++i){
		Ed[++cnt].s = read();
		Ed[cnt].t = read();
		Ed[cnt].w = read();
		minN[Ed[cnt].s] = min(minN[Ed[cnt].s] , Ed[cnt].w + 1);
		minN[Ed[cnt].t] = min(minN[Ed[cnt].t] , Ed[cnt].w + 2);
	}
	for(int i = 0 ; i < 2 * N ; ++i)
		minN[(i + 1) % N] = min(minN[(i + 1) % N] , minN[i % N] + 2);
	for(int i = 0 ; i < N ; ++i){
		Ed[++cnt].s = i;
		Ed[cnt].t = (i + 1) % N;
		Ed[cnt].w = minN[i];
		fa[i] = i;
	}
	sort(Ed + 1 , Ed + cnt + 1);
	for(int i = 1 ; i <= cnt ; ++i)
		if(find(Ed[i].s) != find(Ed[i].t)){
			fa[find(Ed[i].s)] = find(Ed[i].t);
			sum += Ed[i].w;
		}
	cout << sum;
	return 0;
}


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

const int N=1e6+5;
int n;
char s[N];

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int i,ans1=0,ans2=0;
	for(i=1;i<=n;++i)
	{
		if((i&1)&&s[i]=='1') ++ans1;
		if(i%2==0&&s[i]=='0') ++ans1;
	}
	for(i=1;i<=n;++i)
	{
		if((i&1)&&s[i]=='0') ++ans2;
		if(i%2==0&&s[i]=='1') ++ans2;
	}
	printf("%d\n",min(ans1,ans2));
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    string t, u;
    t += s[0]; t += s[1];
    u += s[2]; u += s[3];
    int a = stoi(t), b = stoi(u);
    int x = (1 <= a && a <= 12), y = (1 <= b && b <= 12);
    if(!x && !y){
        puts("NA");
    }else if(x && !y){
        puts("MMYY");
    }else if(!x && y){
        puts("YYMM");
    }else {
        puts("AMBIGUOUS");
    }
    return 0;
}

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

const ll INF = 1LL << 60;

string S;
int main() {
    cin >> S;
    ll ans = 0;
    bool prev_one = false;

    rep(i, S.size()) {
        // 最後の2個
        if (i == S.size() - 2 && S[i] == S[i + 1]) {
            ans++;
            break;
        }

        // 直前の1個が同じ
        if (prev_one && S[i] == S[i - 1]) {
            // 2文字とる
            i++;
            ans++;
            prev_one = false;
        } else {
            // 1文字とる
            ans++;
            prev_one = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N%1000 == 0){
            System.out.println(0);
        } else {
            System.out.println(1000-N%1000);
        }
    }

    public static void main(String[] args){
        new Main();
    }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
char s[105];
int main() {
	scanf("%s", s);
	bool tak = false;
	for(int i = 0; i < (int) strlen(s); ++i) {
		if(s[i] == 'C') tak = true;
		if(s[i] == 'F' && tak) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

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

	cout << "ABC" << n;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;
    cout<<string(dx,'R')<<string(dy,'U');
    cout<<string(dx,'L')<<string(dy,'D');
    cout<<"D"<<string(dx+1,'R')<<string(dy+1,'U')<<"L";
    cout<<"U"<<string(dx+1,'L')<<string(dy+1,'D')<<"R";
    cout<<endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  long long K; cin >> K;

  vector<int> bit0(50, 0);
  vector<int> bit1(50, 0);
  for (int i = 0; i < N; i++) {
    long long A; cin >> A;
    for (int j = 0; j < 50; j++)
    {
      if (A % 2 == 1) bit1[j]++;
      else bit0[j]++;

      A /= 2;
    }
  }


  long long Amax = 0, Kmax = 0;
  long long order = 1;
  for (int i = 0; i < 50; i++)
  {
    if (K % 2 == 1) {
      Kmax = max(bit0[i] * order + Kmax, bit1[i] * order + Amax);
    } else {
      Kmax = bit1[i] * order + Kmax;
    }

    Amax += max(bit0[i], bit1[i]) * order;
    
    K /= 2;
    order *= 2;
  }


  cout << Kmax << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 24020
K,S = map(int, input().split())
count = 0
# 計算量大きすぎる
# for x in range(K+1):
#     for y in range(K+1):
#         for z in range(K+1):
#             if x+y+z == S:
#                 count += 1

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
            
print(count)


Measured memory_bytes: 2940
def count_line(l, k):
    i, p, c = l
    total = 0
    count = 0
    for j in range(p):
        if total >= k:
            return count
        
        total += i * 100
        count += 1
        if j == p - 1:
            total += c
    return count


def choice_line(i, f, total_count, total_score):
    f_copy = f.copy()
    if i == D:
        if total_score == G:
            m_c.append(total_count)
        elif total_score < G:
            for l in L:
                j = l[0]
                k = G - total_score
                if not j in f and k <= t_L[j-1]:
                    m_c.append(total_count + count_line(l, k))
        return
        
    choice_line(i + 1, f_copy, total_count, total_score)
    f_copy.append(i + 1)
    choice_line(i + 1, f_copy, total_count + L[i][1], total_score + t_L[i])


D, G = map(int, input().split())
L = []
t_L = []
m_c = []

for i in range(1, D + 1):
    p, c = map(int, input().split())
    L.append([i, p, c])
    total = p * i * 100 + c
    t_L.append(total)
   
choice_line(0, [], 0, 0)
print(min(m_c))

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char *argv[]) {
    int a, b;
    int cnt = 0;

    scanf("%d%d", &a, &b);

    for (int i = a; i <= b; i++) {
        if ((i / 10000 % 10 == i % 10) && (i / 1000 % 10 == i / 10 % 10)) cnt++; 
    }

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

    return 0;
}


Measured memory_bytes: 128
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		elif(q[1] < p[1]):
			print(0)
			exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7)
print(P) 


Measured memory_bytes: 27072
N = int(input())
al = "abcdefghijklmnopqrstuvwxyz"
name = ""
for i in range(1,12):
    b = N%26
    if b == 0:
        b = 26
    name = al[b-1] + name
    N -= b
    if N == 0:
        print(name)
        exit()
    N //= 26

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int M = 1e9 + 7;
int A[N];
int n;

void solve()
{
	string s;
	cin >> s;

	if(s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes";
	}
	else cout << "No";
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);

 	
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String sc = br.readLine();
		int n = Integer.parseInt(sc);
		String[] str = new String[n];
		for (int i =0;i<n ;i++ ) {
			str[i] = br.readLine();
		}
		String[] mark = {"S","H","C","D"};
		for (String ma : mark) {
			for (int i = 1; i<=13 ;i++ ) {
				String s = Integer.toString(i);
				String st = ma + " " + s;
				if (Arrays.asList(str).contains(st)) {
					continue;
				}else{
					System.out.println(st);
				}
			}
		}
	}

}

Measured memory_bytes: 24472
import sys

def z_algo(S):
    N = len(S)
    #print(N)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    #print(A)
    return A

#input = sys.stdin.readline

N = int(input())
S = list(input())
ans = 0

for t in range(N):
    L = z_algo(S[t:])
    for u in range(len(L)):
        if L[u] <= u:
            ans = max(ans,L[u])

print(ans)

Measured memory_bytes: 50756
import sys
K = int(input())
if not (2 <= K <= 100):
    sys.exit()

array_all = [ all for all in range(K) ]
array_even = array_all[0::2]
array_odd = array_all[1::2]

count = 0
for I in array_even:
    for J in array_odd:
        count += 1
print(count)

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    ll ans = 0; // ans == アナグラムのペアの数
    string s;
    // map<キー, 要素>
    // pair<キー, 要素>を参照するイテレータを返す．
    // ソート後の文字列をキーとする
    map<string, int> Mp;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        // キーに対応する値の取得はMp["キー"]で (右辺値やインクリメント)
        Mp[s]++;
    }
    map<string, int>::iterator itr;
    for (itr = Mp.begin(); itr != Mp.end(); itr++)
    {
        ll cnt = (ll) itr->second;
        // n_C_2 ... n個の同文字列から2個選ぶ組み合わせ
        ans += cnt*(cnt-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
n,m = map(int,input().split())
visited = [-1 for _ in range(n+1)]
visited[1] = 0
will = []
root = [[] for _ in range(n+1)] 
for i in range(m):
    a,b = map(int,input().split())
    root[a].append(b)
    root[b].append(a)

will.append(1)

while will:
    visit = will.pop(0)
    for i in root[visit]:
        if visited[i] != -1:
            continue
        will.append(i)
        visited[i] = visit

if visited[1:] == -1:
    print('No')
else:
    print('Yes')
    for i in range(2,len(visited)):
        print(visited[i])

Measured memory_bytes: 34284
(r, c) = [int(i) for i in input().split()]

a = []
for i in range(r):
    a.append([int(i) for i in input().split()])
a.append([0 for i in range(c)])

for i in range(r + 1):
    sum = 0
    count = 0
    for j in a[i]:
        print(j, end=' ')
        sum += j
        if i != r:
            a[r][count] += j
            count += 1
    print(sum)

Measured memory_bytes: 6828
import sys

def parse(inp):
    n=int(next(inp))
    v=list(map(int,next(inp).split()))
    c=list(map(int,next(inp).split()))    
    return n,v,c
  
def main(inp):
    n,v,c=inp    
    ans = 0
    for i in range(n):
        if(v[i]-c[i]>0): ans +=  v[i]-c[i]            
    return ans
  
print(main(parse(sys.stdin)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    
        if((n+1)/2>=k){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,a,b;
  scanf("%d%d%d",&w,&a,&b);
  if(a<b&&a+w<b)
    printf("%d\n",b-a-w);
  else if(b<a&&b+w<a)
    printf("%d\n",a-b-w);
  else
    puts("0");
  return 0;
}

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

using namespace std;

int main()
{int N; cin >> N;
 vector<int> t(N), x(N), y(N);
  for(int i = 0; i < N ; i++)
 { cin >> t[i] >> x[i] >> y[i];}
 
 vector<int> s(N), X(N), Y(N);
 s[0] = t[0];X[0] = x[0]; Y[0] = y[0];
 if( N != 1){for(int i = 1; i < N; i++)
 {s[i] = t[i] - t[i-1];
  X[i] = x[i] - x[i-1];
  Y[i] = y[i] - y[i-1];}}
 //Nが１より大きいとき、差分vectorを作った
 
 bool big_flag = true;
 for(int j = 0; j < N; j++)
 { bool flag = false;
   int Z = abs(X[j]) + abs(Y[j]);
 if( Z % 2 == 0 && s[j] % 2 == 0 && Z <= s[j]){flag = true;}
  else if(Z % 2 == 1 && s[j] % 2 == 1 && Z <= s[j]){flag = true;}
  if(!flag){big_flag = false;
    break;}}
 
 if(big_flag){cout << "Yes" << endl;}
 else {cout << "No" << endl;}
 return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;
int sw;

class dice{
private:

public:
    int face[6];
    void operate(char order);
    bool equal(dice a2);
};

void dice::operate(char order){
if(order=='E'){
    sw=face[5];
    face[5]=face[2];
    face[2]=face[0];
    face[0]=face[3];
    face[3]=sw;
}else if(order=='W'){
    sw=face[5];
    face[5]=face[3];
    face[3]=face[0];
    face[0]=face[2];
    face[2]=sw;
}else if(order=='N'){
    sw=face[5];
    face[5]=face[4];
    face[4]=face[0];
    face[0]=face[1];
    face[1]=sw;
}else if(order=='S'){
    sw=face[5];
    face[5]=face[1];
    face[1]=face[0];
    face[0]=face[4];
    face[4]=sw;
}else if(order=='R'){
    sw=face[1];
    face[1]=face[2];
    face[2]=face[4];
    face[4]=face[3];
    face[3]=sw;
}
}
bool dice::equal(dice a2){
REP(i,4){
    if(face[0]==a2.face[0]&&face[5]==a2.face[5])break;
    a2.operate('N');
}
if(!(face[0]==a2.face[0]&&face[0]==a2.face[0]))a2.operate('W');
REP(i,4){
    if(face[0]==a2.face[0]&&face[5]==a2.face[5])break;
    a2.operate('N');
}
REP(i,4){
    if(face[1]==a2.face[1]&&face[4]==a2.face[4])break;
    a2.operate('R');
}
if(face[0]==a2.face[0]&&face[1]==a2.face[1]&&face[2]==a2.face[2]
&&face[3]==a2.face[3]&&face[4]==a2.face[4]&&face[5]==a2.face[5])return true;
else return false;
}

int main(){
int n;
int count=0;
cin>>n;
dice dice[n];

REP(i,n)REP(j,6)cin>>dice[i].face[j];

REP(i,n-1){
    if(dice[0].equal(dice[i+1])){
    cout<<"No"<<endl;
    break;
    }
    count++;
}

if(count==n-1){
    cout<<"Yes"<<endl;
}
}


Measured memory_bytes: 3104
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//料理の種類
int x;
int sum;
bool prime[1000001];
int main()
{

  for(int i = 0;i <1000001;i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i = 2;i <1000001;i++){
    if(prime[i]){
      for(int j = 2*i;j <1000001;j+=i){
	prime[j]= false;
      }
    }
  }
  while(cin>>n>>x,n||x){
    bool flag1=false;
    int dish[40];
    bool check[1000001];
    for(int i = 0;i < 1000001;i++){
      check[i]=false;
    }
    for(int i = 0;i < n;i++){
      cin>>dish[i];
    }
    check[0] =true;//0はどの料理からでも作れる
    for(int i = 0;i <=x;i++){
      if(check[i]){
	for(int j = 0;j <n;j++){
	  if(i + dish[j]<=x)
	    check[i+dish[j]] = true;
	}
      }
    }
    int ans = 0;

    for(int i =x;i >0;i--){//上から調べる
      if(check[i]&&prime[i]){
	flag1 = true;
	ans = i;
	break;
      }
    }
    if(flag1)
      cout <<ans<<endl;
    else
      cout <<"NA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3112