akhauriyash/Code-Regression huggingface dataset:
program prob5
    implicit none
    integer :: N, M, i, j, ans, cnt
    integer, allocatable :: a(:), b(:)
    integer, allocatable :: v(:)
    read(*,*) N, M
    allocate(a(M))
    allocate(b(M))
    allocate(v(N))

    do i = 1, M
        read(*,*) a(i), b(i)
    end do
    
    ans = 0
    do i = 1, M
        do j = 1, N
            v(j) = j
        end do
        cnt = N
        do j = 1, M
            if(i == j)then
                cycle
            end if
            if(UFsame(v, a(j), b(j)) .eqv. .false.) then
                cnt = cnt - 1
                call UFunite(v, a(j), b(j))
            end if
        end do

        if(cnt /= 1) then
            ans = ans + 1
        end if

    end do

    write(*,*) ans


    deallocate(b)
    deallocate(a)
    deallocate(v)



    stop
contains
recursive integer function UFroot(v, x) result(r)
    implicit none
    integer :: v(:)
    integer :: x
    if(v(x) == x) then
        r = x
    else
        v(x) = UFroot(v, v(x))
        r = v(x)
    end if
    return
end function UFroot

subroutine UFunite(v, x, y)
    implicit none
    integer :: v(:)
    integer :: x, y
    integer :: rx, ry
    rx = UFroot(v, x)
    ry = UFroot(v, y)
    if(rx == ry) return
    v(rx) = ry
    return
end subroutine UFunite

logical function UFsame(v, x, y) result(r)
    implicit none
    integer :: v(:)
    integer :: x, y
    integer :: rx, ry
    rx = UFroot(v, x)
    ry = UFroot(v, y)
    if(rx == ry) then
        r = .true.
    else
        r = .false.
    end if    
    return
end function UFsame



end program prob5

Measured memory_bytes: 2836
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int n, v[55];
double m;
int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>v[i];
	sort(v, v+n);
	m = (v[0] + v[1]) / 2.0;
	for(i=2; i<n; i++) {
		m = (m + v[i]) / 2.0;
	}
    printf("%.9f", m);
    return 0;
}


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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    int n, k, price[1005] = { 0 };

    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> price[i];

    sort(price, price + n);

    int mn_price = 0;
    for (int i = 0; i < k; ++i)
        mn_price += price[i];

    cout << mn_price;

    return 0;
}

void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

Measured memory_bytes: 3612
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

void dfs(int v, int prev, int depth, const vector< vector<int> >& g, vector<int>& cost){
    cost[v] = depth;

    for(auto to : g[v]){
        if(to != prev){
            dfs(to, v, depth + 1, g, cost);
        }
    }

    return;
}

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

    int n;
    cin >> n;

    vector< vector<int> > g(n);
    rep(i, n - 1){
        int u, v;
        cin >> u >> v;
        g[--u].emplace_back(--v);
        g[v].emplace_back(u);
    }

    vector< vector<int> > cost(2, vector<int>(n, IINF));
    dfs(0, -1, 0, g, cost[0]);
    int maxi = -1;
    int maxdex = -1;
    rep(i, n){
        if(chmax(maxi, cost[0][i])){
            maxdex = i;
        }
    }

    assert(maxdex != -1);

    dfs(maxdex, -1, 0, g, cost[1]);

    maxi = -1;
    maxdex = -1;
    rep(i, n){
        if(chmax(maxi, cost[1][i])){
            maxdex = i;
        }
    }

    assert(maxdex != -1);

    dfs(maxdex, -1, 0, g, cost[0]);

    rep(i, n){
        cout << (n - 1) * 2 - max(cost[0][i], cost[1][i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 16840
Na, Nb ,M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
disc = []
ans = float('inf')
for _ in range(M):
    x,y,c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, A[x] + B[y] - c)

print(min(ans, min(A) + min(B)))




Measured memory_bytes: 66924
s = gets.split('').map(&:to_i)
ans = 1000
(s.size-3).times do |i|
  if (s[i]*100+s[i+1]*10+s[i+2]-753).abs < ans
    ans = (s[i]*100+s[i+1]*10+s[i+2]-753).abs
  end
end
puts ans


Measured memory_bytes: 1788
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())

print(math.floor(math.sqrt(N)) ** 2)

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

int main() {
  ll n; cin >> n;
  ll res = 0, tmp = 0;
  rep(i, n) {
    char c; cin >> c;
    if (c == 'I') tmp++;
    else tmp--;
    res = max(res, tmp);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 	int n; cin >> n;
 	for(int i=0;i<=n/100;i++){
 		int cp=n;
 		int k=i*100;
 		cp=n-k;
 		if(0<=cp&&cp<=i*5){
 			cout << 1 << endl;
 			return 0;
 		}
 	}
 	cout << 0 << 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 ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int v[101010];

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        v[l]++;
        v[r+1]--;
    }
    for (int i=1; i<=N; ++i) {
        v[i] += v[i-1];
    }

    int ans = 0;
    rep(i, N+1) {
        if (v[i] == M) ans++;
    }

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


Measured memory_bytes: 640
h,w,m=map(int,input().split())

r=[0]*h
c=[0]*w
s=set()
for _ in range(m):
    i,j=map(int,input().split())
    i-=1
    j-=1
    r[i]+=1
    c[j]+=1
    s.add(i*w+j)

rmx=max(r)
cmx=max(c)
rc=[i for i in range(h) if r[i]==rmx]
cc=[j for j in range(w) if c[j]==cmx]

ans=rmx+cmx-1
ok=False
for i in rc:
    for j in cc:
        if i*w+j not in s:
            ans+=1
            ok=True
            break
    if ok:
        break

print(ans)


Measured memory_bytes: 169188
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    int d, t, s; cin >> d >> t >> s;
    if(d*1.0/s <= t*1.0) cout << "Yes" << nl;
    else cout << "No" << nl;

}

int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define z 100
using namespace std;
int n,a,b,q[1],l[z],la,be,an,ct[z],c[z][z];bool v[z],s[z];void d(int x,int len){if(len>be){la=x;be=len;}v[x]=1,s[x]=1;for(int i=0;i<ct[x];i++)if(!v[c[x][i]]){d(c[x][i],len+1);v[c[x][i]]=0;}}int main(){while(1){cin>>n;if(!n)break;r(i,z)ct[i]=0;r(i,n){cin>>a>>b;a--,b--;c[a][ct[a]]=b,c[b][ct[b]]=a;ct[a]++,ct[b]++;}r(i,z)s[i]=0;an=0;for(int i=0;i<z;i++)if(!s[i]){r(i,z)v[i]=0;be=0;d(i,1);r(i,z)v[i]=0;be=0;d(la,1);an=max(an,be);}cout<<an<<endl;}return 0;}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main() {
    int X;
    cin >> X;
    cout << (X >= 30 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;

    
    while(1){

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

        if (op == '?')
            break;

        else if (op == '+')
            printf("%d\n", a + b);

        else if (op == '-')
            printf("%d\n", a - b);

        else if (op == '*')
            printf("%d\n", a * b);
        
        else if (op == '/')
            printf("%d\n", a / b);

    }

    return 0;
        
}


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

struct node {
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteNode(NodePointer);
void deleteFirst(void);
void deleteLast(void);
void delete(int);
void insert(int);


int main() {
  int key, n, i, size=0, np=0, nd=0;
  char com[20];
  
  scanf( "%d" , &n );
  init();
  for ( i=0; i<n; i++ ) {
    scanf( "%s%d" , com , &key );
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      }
      else {
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
 
  return 0;
}
NodePointer listSearch(int key) {
  NodePointer x = nil->next;

  while ( (x != nil) && (x->key != key) ) x = x->next;
  return x;
}

void init() {
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  NodePointer cur = nil->next;
  int isf = 1;
  
  while( 1 ) {
    if ( cur == nil ) break;
    if ( isf == 0 )  printf( " " );
    printf( "%d" , cur->key );
    cur = cur->next;
    isf = 0;
  }
  printf( "\n" );
}

void deleteNode(NodePointer t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  NodePointer t = nil->next;
  
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast() {
  NodePointer t = nil->prev;
  
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key) {
  NodePointer t = listSearch(key);
  
  deleteNode(t);
}


void insert(int key) {
  NodePointer x;
  
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}



Measured memory_bytes: 32948
N = int(input())
S = input()

w_num = S.count('W')
e_num = S.count('E')

rev_num = S[1:].count('E')
rev_num_list = [rev_num]

for i in range(1, N):
    add = 0
    if S[i-1] == 'W':
        add +=1
    if S[i] == 'E':
        add -=1
    rev_num_list.append(rev_num_list[i-1] + add)

print(min(rev_num_list))



Measured memory_bytes: 15564
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

N = int(input())
dlist = inpl()

ans = 0

for i in range(0,N):
    for j in range(i+1,N):
        ans += (dlist[i]*dlist[j])

print(ans)

Measured memory_bytes: 3952
n = int(input())
temp = 0
lowercase = 'abcdefghijklmnopqrstuvwxyz'
for i in range(1,13):
    temp += 26**i
    if n <= temp:
        break

diff = n - (temp - 26**i + 1)
ans = ''
for j in range(i):
    ans = lowercase[diff % 26] + ans
    diff = diff // 26
print(ans)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		input();
		solve();
	}

	static int r, c, sheet[][];

	private static void input(){
		r=s.nextInt();
		c=s.nextInt();
		sheet=new int[r+1][c+1];
	}

	private static void solve(){
		for(int i=0; i<r; i++){
			int buf;
			for(int j=0; j<c; j++){
				buf=s.nextInt();
				sheet[i][c]+=buf;
				sheet[r][j]+=buf;
				System.out.printf("%d ",buf);
			}
			System.out.println(sheet[i][c]);
		}
		for(int j=0; j<c; j++){
			sheet[r][c]+=sheet[r][j];
			System.out.printf("%d ",sheet[r][j]);
		}
		System.out.println(sheet[r][c]);
	}
}

Measured memory_bytes: 66036
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	double x;
	cin >> x;
	
	cout << (int) ceil((-1.00+sqrt(1+8*x))/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);
	int a, b, c;
	a = n / 100;
	b = (n-100*a)/10;
	c = n - 100*a - 10*b;
	if(c == 3){
		printf("bon\n");
	}
	else if(c == 0 || c == 1 || c == 6 || c == 8){
		printf("pon\n");
	}
	else{
		printf("hon\n");
	}
	return 0;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define ep emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


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

	if ( B % A == 0 )
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
    static int c;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt(), m = sc.nextInt();
            if ((n | m) == 0)
                break;
            c=0;
            System.out.println(gcd(n, m)+" "+c);

        }
    }

    static int gcd(int a, int b) {
        c++;
        if(a<b) {
            int t=a;
            a=b;
            b=t;
        }
        return a % b == 0?b:gcd(a % b, b);
    }
}


Measured memory_bytes: 32544
#include"bits/stdc++.h"
using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int f=0,c=0;
    
    scanf("%d\n",&f);
    
    if(((30<=f)&&(f<=100))&&(f%2==0)){
        
            c = (f-30)/2;
        
            printf("%d\n",c);
        
            return 0;               
    }
}




Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

bool IsMm(int n) {
  return 0 < n && n <= 12;
}

void _main() {
  string S;
  cin >> S;
  int N = stoi(S.substr(0, 2));
  int M = stoi(S.substr(2, 2));

  bool yymm = IsMm(M);
  bool mmyy = IsMm(N);
  if (yymm && mmyy) {
    cout << "AMBIGUOUS" << endl;
  } else if (yymm) {
    cout << "YYMM" << endl;
  } else if (mmyy) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
import heapq


def main():
    num_sushi, chose_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num_sushi)]

    data.sort(key=lambda x: -x[1])
    delicious_heap = []
    count_d, count_n = 0, 0
    neta_data = [0 for i in range(num_sushi + 1)]

    for i in range(chose_num):
        neta, oishisa = data[i]

        if neta_data[neta]:
            heapq.heappush(delicious_heap, oishisa)
        else:
            neta_data[neta] = 1
            count_n += 1

        count_d += oishisa

    ans = count_d + count_n ** 2

    for i in range(chose_num, num_sushi):
        if len(delicious_heap) == 0:
            break
        neta, oishisa = data[i]

        if neta_data[neta]:
            continue
        neta_data[neta] = 1
        count_n += 1
        pop_oishisa = heapq.heappop(delicious_heap)
        count_d += oishisa - pop_oishisa

        ans = max(ans, count_d + count_n ** 2)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 70488
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	ll a[x], b[y], c[z];
	for(int i=0; i<x; i++) cin >> a[i];
	for(int i=0; i<y; i++) cin >> b[i];
	for(int i=0; i<z; i++) cin >> c[i];
	sort(a, a+x, greater<ll>());
	sort(b, b+y, greater<ll>());
	sort(c, c+z, greater<ll>());

	vector<ll> v;
	for(int i=0; i<x; i++){
		for(int j=0; j<y; j++){
			v.push_back(a[i]+b[j]);
		}
	}
	sort(v.begin(), v.end(), greater<ll>());
	v.resize(min(k,x*y));

	vector<ll> u;
	for(int i=0; i<v.size(); i++){
		for(int j=0; j<z; j++){
			u.push_back(v[i]+c[j]);
		}
	}
	sort(u.begin(), u.end(), greater<ll>());

	for(int i=0; i<k; i++) cout << u[i] << endl;
	return 0;
}

Measured memory_bytes: 43236
#include<stdio.h>
int a[]={0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,0,0,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int main(){
  int n;
  scanf("%d",&n);
  puts(a[n]?"Yes":"No");
  //for(int i=1;i<101;i++)printf("%03d %s\n",i,a[i]?"Yes":"No");
}

Measured memory_bytes: 128
#include <cstdio>
#include <stack>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int h[100000];
int l[100000];
int r[100000];
int main() {
  while(true) {
    scanf("%d",&n);
    if (n==0) break;
    for(int i=0;i<n;++i) {
      scanf("%d", &h[i]);
    }
    long long answer = 0;
    stack<int> S;
    for(int i=0;i<n;++i) {
      while(!S.empty() && h[S.top()] >= h[i]) S.pop();
      if (S.empty()) {
        l[i] = 0;
      } else {
        l[i] = S.top() + 1;
      }
      S.push(i);
    }
    S=stack<int>();
    for(int i=n-1;i>=0;--i) {
      while(!S.empty() && h[S.top()] >= h[i]) S.pop();
      if (S.empty()) {
        r[i] = n-1;
      } else {
        r[i] = S.top() - 1;
      }
      S.push(i);
    }
    
    for(int i=0;i<n;++i) {
      answer = max(answer, 1ll * h[i] * (r[i]- l[i] +1));
    }
    
    printf("%lld\n", answer);
break;
  }
  return 0;
}

Measured memory_bytes: 4160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(long long i=(long long)(m) ; i < (long long) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

const long long inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

signed main(){
	long long n;
	cin>>n;
	long long m;
	cin>>m;
	long long a[m];
	rep(i,m)cin>>a[i];
	long long sum[m+1];
	sum[m]=0;
	rep(i,m-1)sum[i]=a[i+1]-a[i]-1;
	sum[m-1]=n-a[m-1];
	sort(sum,sum+m);
	long long b[m];
	rep(i,m)b[i]=sum[i];
	rep(i,m-1)sum[m-i-2]+=sum[m-i-1];
	long long ans[n+1];
	ans[0]=longinf;
	REP(i,1,n+1){
		long long idx=lower_bound(b,b+m,i)-b;
		ans[i]=sum[idx]-(m-idx)*(i-1);
	}
	rep(i,n+1)ans[i]=-ans[i];
	long long q;
	cin>>q;
	while(q--){
		long long x;
		cin>>x;
		x-=a[0]-1;
		if(x<0){
			cout<<-1<<endl;
		}
		else {
			long long ret=lower_bound(ans,ans+n+1,-x)-ans;
			cout<<ret<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 6228
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
ll f[3];int n;
int Fu[1000010];
int main()
{
	memset(f,-0x3f,sizeof(f));
	n=read();n--;
	f[0]=read();
	for(rint i=1;i<=n;++i){char s[2];
		scanf("%s",s+1);int x=read();if(s[1]=='+') Fu[i]=1;
		else Fu[i]=-1;x*=Fu[i];
		f[0]+=x;f[1]-=x;f[2]+=x;
		if(x<0) f[2]=max(f[2],f[1]),f[1]=max(f[0],f[1]);
		f[1]=max(f[1],f[2]);f[0]=max(f[0],f[1]);
	}cout<<f[0];
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using  namespace std;

void a()
{
    string s;
    cin >> s;
    if(s.size() < 4)
    {
        cout << "No" << endl;
    }else{
        if(s.substr(0, 4) == "YAKI")
        {
            cout << "Yes" << endl;
        } else{
            cout << "No" << endl;
        }
    }
    return;
}

void b()
{

}

void c()
{

}
int main() {
    a();
    return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int N,K;
    long long int sum=0,h;
    vector<long int>H;

    cin>>N>>K;
    rep(i,N){
        cin>>h;
        H.push_back(h);
    }

    sort(H.begin(),H.end());
    rep(i,K){
        H.pop_back();
    }
    rep(i,N-K){
        sum+=H[i];
    }

    cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,L;
  cin>>N>>L;
  vector<string> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  sort(all(vec));
  for(ll i=0;i<N;i++) {
cout<<vec[i];
  }
  cout<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  long double a, b, c;
  cin>>a>>b>>c;
  if(c > 2 * sqrt(a * b) + a + b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
//解説
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int MAX = 1000005;

int c[2005];
vector<int> g[2005];
int n, x, y;

void bfs(int s){
  int d[2005];
  queue<int> q;
  rep(i,1,2005) d[i] = -1;
  d[s] = 0;
  q.push(s);
  while(!q.empty()) {
    int u = q.front(); q.pop();
    for(int i=0; i<(int)g[u].size(); i++) {
      int v = g[u][i];
      if (d[v]==-1) {
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  rep(i, s+1, n+1) c[d[i]]++;

}

int main(void) {
  cin >> n >> x >> y;
  rep(i, 1, n+1) {
    g[i].pb(i+1);
    g[i+1].pb(i);
  }
  g[x].pb(y);
  g[y].pb(x);
  
  rep(i,1,n+1) bfs(i);
  
  rep(k, 1, n) {
    printf("%d\n", c[k]);
  }

  
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

long long dp[100010];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];

	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	dp[0] = 0;

	for (int i = 0; i < N; ++i){
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N - 1] << endl;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n=in();
  vi num(55556);
  rep(i,num.size()) num[i]=0;
  num[0]=num[1]=1;
  for(int i=2;i<=55555;++i)
  {
    if(num[i]==0)
    {
      for(int j=2*i;j<=55555;j+=i)
      {
        num[j]=1;
      }
    }
  }
  vi ans;
  for(int i=2;;++i)
  {
    if(ans.size()>=n) break;
    if(num[i]==0&&i%5==1) 
    {
      ans.pb(i);  
    }

  }
  print(ans); 

  return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;

int main(){
    int k;cin>>k;
    vector<string> a(k);
    vector<string> b(k);
    rep(i,0,k) cin>>a[i];
    rep(i,0,k) cin>>b[i];
    int a1 = 0;
    int a2 = 0;
    string d2 = "tameru";
    string d1 = "kougekida";
    string d3 = "mamoru";
    string ans = "Hikiwake-kun";
    rep(i,0,k){
        if (a[i]==d1&&b[i]==d1){
            if (a1<a2) {ans="Nakajima-kun";break;}
            if (a1>a2) {ans="Isono-kun";break;}
            a1 = 0;a2=0;
        }else if((a[i]==d1&&b[i]==d2)){
            if (a1==0) {ans="Nakajima-kun";break;}
            ans="Isono-kun";break;
        }else if(a[i]==d2&&b[i]==d1){
            if (a2==0) {ans="Isono-kun";break;}
            ans="Nakajima-kun";break;
        }else if(a[i]==d1&&b[i]==d3){
            if (a1==0) {ans="Nakajima-kun";break;}
            if (a1>=5) {ans="Isono-kun";break;}
            a1 = 0;
        }else if(a[i]==d3&&b[i]==d1){
            if (a2==0) {ans="Isono-kun";break;}
            if (a2>=5) {ans="Nakajima-kun";break;}
            a2 = 0;
        }else if(a[i]==d2&&b[i]==d2){
            a1++;a2++;
        }else if(a[i]==d2&&b[i]==d3){
            a1++;
        }else if(a[i]==d3&&b[i]==d2){
            a2++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){double pi = 2*acos(0.0);
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	double angle =abs((30*h)-(5.5*m));
	double r= double(angle)/double(180);
	cout << fixed << setprecision(16);
	double sum= pow(a,2)+pow(b,2);
	cout << fixed << setprecision(16);
	double rum=(2*a*b*cos(pi*r));
	cout << fixed << setprecision(16);
	double yu =sum-rum;
	cout << fixed << setprecision(16);
	double sr=sqrt(yu);
	 cout << fixed << setprecision(16) << sr;
	

	
	return 0;
}


Measured memory_bytes: 4084
N = int(input())
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
As_sum = sum(As)
for i in range(N-1):
  As_sum = As_sum - As[i]
  result += (As[i] * As_sum) % m

print(result % m)

Measured memory_bytes: 94248
#include <bits/stdc++.h>
using namespace std;
struct rest
{
	string name;
	int score, number;
}memory[111];
bool cmp(rest x, rest y)
{
	if (x.name!=y.name) return x.name<y.name;
	else return x.score>y.score;
}
int main()
{
	int n;
	cin >> n;
	for (int i=1; i<=n; i++)
	{
		cin >> memory[i].name >> memory[i].score;
		memory[i].number=i;
	}
	sort (memory+1, memory+n+1, cmp);
	for (int i=1; i<=n; i++) cout << memory[i].number << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string b;
  cin >> b;
  if(b[0] == 'A') {
      cout << "T" << '\n';
  } else if(b[0] == 'T') {
      cout << "A" << '\n';
  } else if(b[0] == 'C') {
      cout << "G" << '\n';
  } else {
      cout << "C" << '\n';
  }
}

Measured memory_bytes: 256
I[]={0x1059a25,0x109b0906,0x4069807,0x7059e99,0x706089f,0x92029d9c,0x11059093,0x1009103};unsigned char*C="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?",*strchr(),*L="68443586484588538455886888366866",*B=I;b,l;main(c){for(;c=getchar(),c+1;)if(c-10)for(c=strchr(C,c)-C,b=b<<(L[c]-48)|B[c],l+=L[c]-48;l>4;putchar(C[b>>l&31]))l-=5;else l&&putchar(C[(b<<=5-l)&31]),l=0,putchar(c);exit(0);}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double a=sc.nextDouble(),b=sc.nextDouble(),x=sc.nextDouble();
    double s=x/a;
    if(s<=a*b/2) {
    	double w=2*s/b;
    	System.out.println(Math.atan2(b,w)/Math.PI*180);
    }else {
    	double h=2*(a*b-s)/a;
    	System.out.println(Math.atan2(h,a)/Math.PI*180);
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    boolean[] used;
    int[] perm, time;
    int out;
    void solve(){
        Scanner scan = new Scanner(System.in);
        time = new int[5];
        for(int i = 0; i < 5; i++) time[i] = scan.nextInt();
        perm = new int[5];
        used = new boolean[5];
        out = Integer.MAX_VALUE;
        permutation(0);
        System.out.println(out);
        scan.close();
    }

    void permutation(int i){
        if(i == 5){
            int t = 0;
            for(int j = 0; j < 5; j++){
                t += time[perm[j]];
                if(j == 4) continue;
                t = t % 10 == 0 ? t : 10 * (t / 10 + 1);
            }
            out = Math.min(out, t);
            return;
        }
        for(int j = 0; j < 5; j++){
            if(!used[j]){
                perm[i] = j;
                used[j] = true;
                permutation(i + 1);
                used[j] = false;
            }
        }
    }

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

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

typedef int Weight;
struct Edge
{
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
bool operator < (const Edge &e, const Edge &f)
{
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!! ???????????????????????????
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0)
{
  int n = g.size();
  Edges T;
  Weight total = 0;
  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push(Edge(-1,r,0));
  while (!Q.empty())
  {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for(auto f: g[e.dst]) if(!visited[f.dst]) Q.push(f);
  }
  return pair<Weight, Edges>(total, T);
}

int main()
{
  int n;
  while(cin >> n,n)
  {
    Graph g(n);
    int m; cin >> m;
    REP(i,m)
    {
      int s,d,w;scanf("%d,%d,%d\n",&s,&d,&w);
      g[s].push_back(Edge(s,d,w/100-1));
      g[d].push_back(Edge(d,s,w/100-1));
    }
    cout << minimumSpanningTree(g).first << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    X, K, D = LI()

    if abs(X) >= K * D:
        ans = abs(X) - K * D
    else:
        if (K - abs(X) // D) % 2 == 0:
            ans = abs(X) % D
        else:
            ans = D - abs(X) % D

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10116
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    when (a) {
        in 0..5 -> print(0)
        in 6..12 -> print(b / 2)
        else -> print(b)
    }
}


Measured memory_bytes: 31788
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  long N, M; cin >> N >> M;
  long dmax=1;
  for (long i=1; i*i<=M; i++) {
    if (M%i == 0) {
      if(i*N <= M)
        dmax = max(dmax, i);
      if (M/i*N <= M)
        dmax = max(dmax, M/i);
    }
  }
  cout << dmax << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: [Chars; h],
    }
    let mut res = 0;
    for r in 0..1 << h {
        for c in 0..1 << w {
            let mut x = 0;
            for i in 0..h {
                if r >> i & 1 == 1 {
                    continue;
                }
                for j in 0..w {
                    if c >> j & 1 == 1 {
                        continue;
                    }
                    if s[i][j] == '#' {
                        x += 1;
                    }
                }
            }
            if x == k {
                res += 1;
            }
        }
    }
    println!("{}", res);
}


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

int main() {
    int INF = 100100100;
    // 八方向の定義
    vector<int> dw = {-1, 0, 1, 0};
    vector<int> dh = {0, -1, 0, 1};
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s.at(i);
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s.at(i).at(j) == '#') continue;
            // スタートからの距離を格納する配列
            vector<vector<int>> dist(h, vector<int>(w, INF));
            // 直前に調べた座標を保持
            queue<pair<int, int>> q;
            auto update = [&](int i, int j, int x) {
                // すでに調べ終わっているなら何もしない
                if (dist.at(i).at(j) != INF) return;
                // 距離を更新
                dist.at(i).at(j) = x;
                // 調べ終わったものは追加
                q.push(pair<int, int>(i, j));
            };
            // スタート位置はもちろん距離は0
            update(i, j, 0);
            // ここから距離を埋めていく
            while (!q.empty()) {
                // まず調べる座標は(x, y)
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                for (int dir = 0; dir < 4; ++dir) {
                    // これから探索する座標は(ni, nj)
                    int ni = x + dh.at(dir);
                    int nj = y + dw.at(dir);
                    // 探索するところがマス目の外だったら飛ばす
                    if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                    // もし探索する場所が#だったら飛ばす
                    if (s.at(ni).at(nj) == '#') continue;
                    // 上の二つの条件を突破したらupdate
                    update(ni, nj, dist.at(x).at(y) + 1);
                }
            }
            
            // 定めたスタートから最も遠い場所を見つける
            for (int k = 0; k < h; ++k) {
                for (int l = 0; l < w; ++l) {
                    // たどり着けていなかったら飛ばす
                    if (dist.at(k).at(l) == INF) continue;
                    ans = max(ans, dist.at(k).at(l));
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<int> g[200005];
int ans[200005];

void dfs(int now, int from) {
    for (int to : g[now]) {
        if (to == from) continue;
        ans[to] += ans[now];
        dfs(to, now);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, 0, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    queue<int> que;
    que.push(0);
    vector<bool> visited(n, false);
    visited[0] = true;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : g[v]) {
            if (visited[nv]) continue;
            visited[nv] = true;
            ans[nv] += ans[v];
            que.push(nv);
        }
    }
    rep(i, 0, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 15604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n,m;
    std::cin >> n;
    std::multiset<int> d;
    rep(i,n){
        int di;
        std::cin >> di;
        d.insert(di);
    }

    std::cin >> m;
    rep(i,m){
        int ti;
        std::cin >> ti;
        if(d.find(ti)==d.end()){
            std::cout << "NO" << "\n";
            return 0;
        }else{
            d.erase(d.find(ti));
        }
    }
    std::cout << "YES" << "\n";
    return 0;
}

Measured memory_bytes: 12924
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun (xs, ys) a -> (ys, a :: xs)) ([], []) as_
  |> (fun (xs, ys) -> ys @ List.rev xs)
  |> List.iter (Printf.printf "%d ")

Measured memory_bytes: 17024
open Printf
open Scanf

let solve s =
  let l = String.length s in
  let rec f i n =
    if i = n then "Yes"
    else if s.[i] = 'h' && s.[i+1] = 'i' then f (i + 2) n
    else "No" in
  if l mod 2 = 1 then "No"
  else f 0 l

let () =
  scanf "%s " solve |> printf "%s\n"


Measured memory_bytes: 384
// abc134_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<int> lis;
    REP(i, N){
        int a = -A[i];
        auto it = upper_bound(ALL(lis), a);
        if (it == lis.end()){
            lis.emplace_back(a);
        } else {
            *it = a;
        }
    }
    print(lis.size());

    return 0;
}


Measured memory_bytes: 1276