akhauriyash/Code-Regression huggingface dataset:
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>

using namespace std;

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

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

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 555 * 1 + 47;


string s[MAX];
int A[2][MAX][MAX];
int main()
{
    //freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    FOR(i, 0, n)
        cin >> s[i];
    FOR(j, 0, m)
    {
        A[0][0][j] = 1;
        A[1][n-1][j] = 1;
        FOR(i, 1, n-1)
        A[j % 2][i][j] = 1;
    }
    
    //cout << "*" << endl;
    
    FOR(i, 0, n)
        FOR(j, 0, m)
            if (s[i][j] == '#')
                A[0][i][j] = A[1][i][j] = 1;
   
    FOR(k, 0, 2)
    {
        FOR(i, 0, n)
        {
            FOR(j, 0, m)
            cout << (A[k][i][j] ? '#' : '.');
            cout << endl;
        }
        cout << endl;
    }
    
    /*FOR(i, 0, n)
    {
        FOR(j, 0, m)
        {
            cout << (A[0][i][j] & A[1][i][j] ? '#' : '.');
        
        }
        cout << endl;
    }
     */
    
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int i,j;
  int tmp = 0,ans = 0 ;
  for(i=1;i<n+1;i += 2){
    tmp = 0;
    for(j=1;j<i+1;j+=2){
      if(i % j == 0){
        tmp++;
      }
    }
    if(tmp  == 8){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	int cnt=0;
	while(n!=0||x!=0){
		int i,j,k;
		
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x) cnt++;
				}
			}
		}
		
		printf("%d\n",cnt);
		cnt=0;
		scanf("%d%d",&n,&x);
	}
	return 0;
}



Measured memory_bytes: 2036
object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	var map = Map[Int, Int]()
	var flg = true

	for(i<-0 until m){
		val Array(s, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
		if(map.contains(s)){
			if(map(s) != c) flg = false
		}else{
			map += s->c
		}
	}

	if(flg){
		var ans = 1000

		for(x<-0 until 1000){
			val tp = x.toString.toList.toArray
			var flg1 = true

			if(tp.size == n){
				for(y<-map){
					val (s, c) = y
					if(tp(s-1).toString != c.toString) flg1 = false
				}

				if(flg1){
					ans = math.min(ans, x)
				}
			}
		}

		if(ans == 1000) println(-1)
		else println(ans)
	}else{
		println(-1)
	}

}

Measured memory_bytes: 25516
def judge(n):
    global count,num_list
    if n[-1]==0:
        judge(int(n)-1)
    else:
        for i in range(1,int(n)+1):
            i=str(i)
            if int(i[-1])-1!=-1:
                num_list[int(i[0])-1][int(i[-1])-1]+=1

        for i in range(1,int(n)+1):
            i=str(i)
            if int(i[-1])-1!=-1:
                count=count+num_list[int(i[-1])-1][int(i[0])-1]

N=int(input())
count=0
num_list=[[0]*9 for i in range(9)]
judge(str(N))
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <climits>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;


ll N;
ll a[100100];
int main(){
  cin >> N;
  for(ll i=0;i<N;i++){
    cin >> a[i];
  }
  ll now_pos = 1;
  ll t=0;
  ll ans=1;
  for(ll i=0;i<N;i++){
    if(a[i] >= now_pos){
      a[i] = now_pos;
      now_pos+=2;
    }
    else{
      ans = (ans*(i+1-t)) % MOD;
      t++;
    }
  }
  for(ll i=1;i<=N-t;i++){
    ans = (ans*i) % MOD;
  }
  cout << ans << endl;
  /*
  ll b=0;
  ll c=0;
  ll d=0;
  ll num_count = 0;
  ll ans=1;
  ll now_pos = 0;
  for(ll i=0;i<N;i++){
    ll t = a[i] - now_pos;
    num_count++;
    if(t==1 && a[i]%2 == 0){
      b++;
      if(d>0){
        b--;
        d--;
      }
      else{
        ans =(ans*(num_count-c)) % MOD;
        c++;
      }
    }
    if(t>3){
      if(a[i]%2 == 0){
        d += (t-2)/2;
      }
      else{
        d += (t-1)/2;
      }
    }
    now_pos = a[i];
  }
  for(ll i=1;i<=num_count-c;i++){
    ans = (ans*i) % MOD;
  }
  cout << ans << endl;
  */
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
    int r,g,b,x;
    scanf("%d%d%d",&r,&g,&b);
   x = r*100+g*10+b;
   if(x%4==0){
   printf("YES"); 
  } else{
   printf("NO");
  }
   return 0;
}

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

using namespace std;

void Main() {
    int K;
    cin >> K;

    if (7 % K == 0) {
        cout << 1 << endl;
        return;
    }

    int ans = -1;
    set<int> reminder;
    reminder.insert(7 % K);
    int n7 = 7;
    int pow10 = 10;
    int counter = 1;
    while (true) {
        ++counter;
        n7 += pow10 * 7;
        n7 %= K;
        if (n7 == 0) {
            ans = counter;
            break;
        }
        if (reminder.count(n7) > 0) {
            ans = -1;
            break;
        }
        reminder.insert(n7);
        pow10 *= 10;
        pow10 %= K;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 50480
using System;
using System.Collections.Generic;
using System.Linq;

namespace Contest
{
    class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string odd = "RUD";
            string even = "LUD";
            for(int i = 0; i < S.Length; i++)
            {
                if(i % 2 == 0)
                {
                    //odd
                    if (!odd.Contains(S[i].ToString()))
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    //even
                    if (!even.Contains(S[i].ToString()))
                    {

                        Console.WriteLine("No");
                        return;
                    }
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    unordered_map<ll, ll> mp1;
    vl a(n);
    forr(i, n)
    {
    	cin>>a[i];
    	mp1[a[i]]++;
    }
    if(mp1.find(1)==mp1.end())
    {
    	cout<<-1<<endl;
    	return;
    }
    ll to_be_found=1;
    for(ll i=0; i<n; i++)
    {
    	if(a[i]==to_be_found)
    	{
    		to_be_found++;
    	}
    }
    cout<<(n-to_be_found+1)<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12952
S = input()
flag = True
if S[0] != "A":
    flag = False
C = 0
bi = 0
for i in range(len(S)):
    if 2 <= i < len(S) - 1:
        if S[i] == "C":
            C += 1
    if S[i].upper() == S[i]:
        bi += 1

if bi != 2:
    flag = False

if C != 1:
    flag = False

if flag:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<map>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN   10001
#define MOD 1000000007
#define X first
#define Y second
ll t,n,i,j;
int main()
{
    cin>>n;
    vector <vector <char > > v;
    v.reserve(n);
    for(i=0;i<n;i++){
        vector <char> ch(10);
        for(j=0;j<10;j++)
            cin>>ch[j];
        sort(ch.begin(),ch.end());
        v.push_back(ch);
    }
    j=0;
    sort(v.begin(),v.end());
    ll ans=0,len;
    for(i=1;i<n;i++){
        if(v[j]!=v[i]){
            len=i-j;
            ans+=len*(len-1)/2;
            j=i;
            //cout<<j<<endl;
        }
    }
    len=i-j;
    ans+=len*(len-1)/2;

    cout<<ans<<endl;
}


Measured memory_bytes: 5760
import math
a,b,C = map(float,input().split())
C = math.radians(C)

c =(a ** 2 + b ** 2 - 2 * a * b * math.cos(C)) ** 0.5

S = 1/2 * a * b * math.sin(C)
L = a + b + c
h = b * math.sin(C)

print(S)
print(L)
print(h)


Measured memory_bytes: 5700
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, maxx=0;
  std::cin >> N >> M;
  std::vector<int> X(M);
  range(i, M) std::cin >> X[i];
  sort(X.begin(), X.end());
  std::vector<int> XX(M-1);
  range(i, M-1) XX[i] = X[i+1] - X[i];
  sort(XX.begin(), XX.end());
  if(N >= M){
    std::cout << 0 << '\n';
  }else if(N == 1){
    std::cout << X[M-1] - X[0] << '\n';
  }else{
    maxx = X[M-1] - X[0];
    range(i, N-1) maxx -= XX[M-2-i];
    std::cout << maxx << '\n';
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define N 500010
#define maxi 1048576
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int n,a[N],b[N],no[maxi+10],su[N];
ll dp[maxi+10][2],ansn;
void update(int x,int y){dp[x][0]=(dp[x][0]+dp[x][1]*(su[y]-su[no[x]]))%mo;no[x]=y;}
int main(){
	read(n);
	for (int i=0;i<maxi;i++) dp[i][0]=1,no[i]=0;
	for (int i=1;i<=n;i++){
		read(a[i]);
		b[i]=b[i-1]^a[i];
		if (b[i]==0){
			su[i]=1+su[i-1];
			if (i!=n)dp[0][0]=(dp[0][0]+dp[0][0])%mo;
		}else{
			su[i]=su[i-1];
			update(b[i],i);
			dp[b[i]][1]=(dp[b[i]][1]+dp[b[i]][0])%mo;
		}
	}
	for (int i=1;i<maxi;i++) update(i,n);
	if (b[n]==0){
		for (int i=1;i<maxi;i++) ansn=(ansn+dp[i][1])%mo;
		ansn=(ansn+dp[0][0])%mo;
	}else
		ansn=dp[b[n]][0];
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 26624
fun main(args: Array<String>) {
    val num = readLine()!!.toInt()
    val list = mutableListOf(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)
    println(list[num-1])
}

Measured memory_bytes: 33472
# N = int(input())
# As = []
# ans = 0
# for i in range(N):
#     As.append(int(input()))
# if 2 in As:
#     pressed_btns = {2}
#     sagasu_btn = 1
#     while True:
#         if sagasu_btn in pressed_btns:
#             print(sagasu_btn)
#             print(pressed_btns)
#             print(-1)
#             exit(0)
#         sagasu_btn = As.index(sagasu_btn + 1)
#         pressed_btns.add(sagasu_btn)
#         ans+=1
#         if sagasu_btn == 0:
#             print(ans)
#             exit(0)

# else:
#     print(-1)

# 普通に順番にシミュレーションする．ただし，「ボタン２が永遠に光らない」場合は「すでに光ったボタンが光る時」である．
# その場合，ボタンが光る回数は合計でNを超えるので， N回試行してボタン２が光らなければ永遠にボタン２は光らない．

N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
btn = 1
for i in range(N):
    btn = As[btn-1]
    if btn == 2:
        print(i+1)
        exit(0)
print(-1)



Measured memory_bytes: 51032
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

ll modu = 1000000007;

ll posMod(ll num) {
	return (num % modu + modu) % modu;
}

ll n, k;
vl persons;

int main(){
	cin.sync_with_stdio(0);
	cin >> n >> k;
	
	persons = vl(n);
	FOR(i, 0, n) cin >> persons[i];		
	
	// position, leftCandies
	ll dp[n + 1][k + 1] = {{ 0 }};
	FOR(i, 0, n + 1) FOR(j, 0, k + 1) dp[i][j] = 0;
	
	dp[0][k] = 1;
	
	FOR(pos, 1, n + 1) {
		ll preSum[k + 1];
		preSum[0] = dp[pos - 1][0];
		
		FOR(i, 1, k + 1) {
			//cout << i << ": " << dp[pos-1][i] << endl;
			preSum[i] = preSum[i-1] + dp[pos - 1][i];
			preSum[i] %= modu;
			//cout << preSum[i] << endl;
		}
		
		
		FOR(remaining, 0, k + 1) {
			ll starting = remaining - 1;
			ll ending = min(k, remaining + persons[pos - 1]);
			//cerr << starting << " " << ending << endl;
			
			ll interval;
			if(starting < 0) interval = preSum[ending];
			else interval = posMod(preSum[ending] - preSum[starting]);
			
			dp[pos][remaining] = posMod(dp[pos][k] + interval);
		}
		
		//cerr << " ------------------------ " << endl;
	}
		
		
	cout << dp[n][0] << endl;	
		
	return 0;
}


Measured memory_bytes: 80000
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
//use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

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

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

////////////////////////////////////////////////

fn check(s:String)->bool{
    let n = s.len();
    let xs = s.chars().collect::<Vec<char>>();
        
    if xs[0] != 'A'{
        return false;
    }
    
    let mut n_c = 0;
    let mut index = 0;
    
    for i in 2..n-1{
        if xs[i] == 'C'{
            n_c+=1;
            index = i;
            
            if n_c > 1{
                return false;
            }
        }
    }
    
    if n_c != 1{
        return false;
    }
    
    for i in 1..n{
        if i == index {
            continue;
        }
        
        if !xs[i].is_lowercase(){
            return false;
        }
    }
    
    true
}

fn main(){
    let s = read_line();
    
    println!("{}", if check(s) {"AC"} else {"WA"});
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int compare( const void *, const void * );

int main( void ) {
	int i, n, a[ 10000 ] = { [ 3 ] = 99999 }, b[ 12 ];
	char bStr[ 12 ][ 10 ];

	scanf( "%d", &n );

	for ( i = n; i--; scanf( "%d", a + i ) ) ;

	qsort( a, n, sizeof(int), &compare );

	for ( i = 15; i--; )
		if ( i % 5 )
			sprintf( bStr[ i - i / 5 - 1 ], "%d%d", a[ i / 4 ], a[ i % 4 ] );
	for ( i = 12; i--; b[ i ] = atoi( bStr[ i ] ) ) ;

	qsort( b, 12, sizeof(int), &compare );

	printf( "%d\n", b[ 2 ] );

	return 0;
}

int compare( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

Measured memory_bytes: 716
import sys
import fractions
from functools import reduce

n, X = map(int, input().split())
x = list(map(int, input().split()))
y = []

if len(x) > 1:
    for i in range(1, n):
        y.append(x[i] - x[i-1])
else:
    print(abs(x[0] - X))
    sys.exit()

#gcd = reduce(lambda x, y: fractions.gcd(x, y), x)
gcd = reduce(lambda x, y: fractions.gcd(x, y), y)

temp = 10**10

for i in range(n):
    if abs(X - x[i]) < temp:
        temp = abs(X - x[i])

gcd = fractions.gcd(gcd, temp)
print(gcd)


Measured memory_bytes: 88596
n, m = map(int, input().split())
# from, to, cost
edges = [list(map(int, input().split())) for _ in range(m)]

score = [-float('inf')] * (n+1)
score[1] = 0
cnt = 0

for i in range(n):
    for frm, to, cost in edges:
        if score[to] < score[frm] + cost:
            if i == n - 1 and to == n:
                print('inf')
                exit()
            score[to] = score[frm] + cost

print(score[n])


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

using namespace std;

int main(){
  int n;
  int k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(h[i]>=k){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main(){
    int n;
    string str;
    cin >> n;
    cin >> str;
    int ans = n;
    int ctr = 0;
    for(int i=1;i<n;i++){
        if(str[i] == 'E'){
            ctr++;
        }
    }
    if(ctr < ans){
        ans = ctr;
    }
    for(int i=1;i<n;i++){
        if(str[i] == 'E'){
            ctr--;
        }
        if(str[i-1] == 'W'){
            ctr++;
        }
        if(ctr < ans){
            ans = ctr;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int X, Y, Z;
  
  cin >> X >> Y >> Z;
  
  int a = X;
  int b = Y;
  int c = Z;
  
  int d = c;
  int e = a;
  int f = b;

  
  cout << d  << " " << e << " " << f << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define VB vector<bool>
#define VPLL vector<pair<ll,ll> >
#define VVL vector<vector<ll> >
#define VVB vector<vector<bool> >
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define PI 3.141592653589793238
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str)

using namespace std;

int main() {
	ll n;
	cin >> n;
	cout << 800 * n - (n / 15)*200 << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n, S;
int r[20100];

int main() {
    while (cin >> n >> S) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> r[i];
        sort(r, r+n);
        int res = 0;
        for (int i = 0; i < n; ++i) {
            int rem = S - r[i];
            int it = upper_bound(r+i+1, r+n, rem) - r;
            res += n - it;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1220
/**
 * ******* Created on 27/10/19 5:23 PM*******
 */

import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {
        int n = reader.nextInt();
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                if(i*j ==n){
                    writer.println("Yes");
                    return;
                }
            }
        }
        writer.println("No");
    }

    public static void main(String[] args) throws IOException {
        try (Input reader = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
            new Main().run();
        }
    }

    StandardInput reader;
    PrintWriter writer;

    @Override
    public void run() {
        try {
            reader = new StandardInput();
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    interface Input extends Closeable {
        String next() throws IOException;

        default int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        default long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        default double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        default int[] readIntArray() throws IOException {
            return readIntArray(nextInt());
        }

        default int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        default long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextLong();
            }
            return array;
        }
    }

    private static class StandardInput implements Input {
        private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        private StringTokenizer stringTokenizer;

        @Override
        public void close() throws IOException {
            reader.close();
        }

        @Override
        public String next() throws IOException {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                stringTokenizer = new StringTokenizer(reader.readLine());
            }
            return stringTokenizer.nextToken();
        }
    }
}


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

int main(){
    long long n,k,x,loopcount=0;
    cin>>n>>k;
    vector<int> a(n),color(n,0),b(n);
    rep(i,n) {
        cin>>x;
        a[i]=--x;
    }
    x=0;
    while(1){
        //cout<<x<<" "<<color[x]<<endl;
        if(color[x]==1){
            break;
        }
        if(loopcount==k){
            cout<<x+1;
            return 0;
        }
        b[x]=loopcount;
        loopcount++;
        color[x]=1;
        x=a[x];
    }
    //cout<<"\n"<<loopcount<<" "<<b[x]<<" "<<x<<endl;
    k=(k-b[x])%(loopcount-b[x]);
    //cout<<k<<endl;
    for(int i=0;i<k;i++){
        x=a[x];
    }
    cout<<x+1;
    }


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


#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define DEBUG freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
//#define int long long
using namespace std;
const int N = 1e5+5;
vector<int> AdjList[N];
vector<int> dp(N, 0);
bool vis[N];

void DFS(int node) {
	vis[node] = true;
	for (auto v: AdjList[node]) {
		if (!vis[v]) DFS(v);
		dp[node] = max(dp[node], dp[v]+1);
	}
}

signed main() {
	FAST_IO;
	int n, m;
	cin >> n >> m;
	for (int i=0; i<m; i++) {
		int u, v;
		cin >> u >> v;
		AdjList[u].push_back(v);
	}

	for (int i=1; i<=n; i++) {
		if (!vis[i]) DFS(i);
	}

	int ans = INT_MIN;
	for (int i=1; i<=n; i++) ans = max(ans, dp[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int i,j,n,k,p,a[20],b[20],c[20];
int main(){
  for(cin>>n;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++)cin>>b[i];
  for(i=0;i<n-1;i++)cin>>c[i];
  for(i=0;i<n;i++){
    j=a[i];
    if(j-p==1)k+=c[p-1];
    k+=b[i];
    p=j;
  }
  cout<<k;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, m, c[300], r[10];
char s[200];

int main() {
	
	scanf("%d%d", &n, &m);
	
	r[4] = (n / 2) * (m / 2);
	r[2] = (n / 2) * (m % 2) + (m / 2) * (n % 2);
	r[1] = (n % 2) * (m % 2);
	
	FOR(i, 0, n) {
		scanf("%s", s);
		FOR(j, 0, m) c[s[j]]++;
	}
	
	FOE(i, 'a', 'z') {
		while (r[4] > 0 && c[i] >= 4) {
			r[4]--;
			c[i] -= 4;
		}
		while (r[2] > 0 && c[i] >= 2) {
			r[2]--;
			c[i] -= 2;
		}
		while (r[1] > 0 && c[i] >= 1) {
			r[1]--;
			c[i] -= 1;
		}
	}
	
	if (r[4] + r[2] + r[1] == 0) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
////////////////////////////////////////////////////////////////////
int main(){
    ll N,K;
    cin >> N;
    vector<ll> A;
    ll sum = 0;
    VSCLLD(A,N);
    REP(i,N){
        sum += A[i];
    }

    A.PB(A[0]);

    vector<ll> D;
    bool flg = true;
    REP(i,N){
        D.PB(A[i+1] - A[i]);
    }
    if ((2 * sum) % (N * (N+1)) != 0) flg = false;
    K = 2 * sum / (N * (N+1));

    REP(i,N){
        D[i] -= K;
        if (D[i] > 0) flg = false;
        if (D[i] % N != 0) flg = false;
    }

    if (flg) printf("YES\n");
    else printf("NO\n");


}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define re register
const int mod=998244353,inv2=(mod+1)/2; 
int p[(1<<18)+1],x[(1<<18)+1];
int ex(re int a,re int b)
{
	re int ans=1;
	for(;b;b>>=1,a=(long long)a*a%mod)if(b&1)ans=(long long)ans*a%mod;
	return ans;
}
void FWT(re int*a,re int n,re int op)
{
	for(re int i=1;i<=n;i++)
	{
		for(re int i1=1<<i-1,j=0;j<(1<<n);j+=1<<i)
		{
			for(re int k=j;k<j+i1;k++)
			{
				re int x=a[k],y=a[k+i1];
				a[k]=(x+y)%mod;a[k+i1]=(x-y+mod)%mod;
				if(op)a[k]=1ll*inv2*a[k]%mod,a[k+i1]=1ll*inv2*a[k+i1]%mod;
			}
		}
	}
}
int main()
{
	re int n,S=0;
	scanf("%d",&n);
	for(re int i=0;i<(1<<n);i++)
		scanf("%d",&p[i]),S=(S+p[i])%mod;
	S=ex(S,mod-2);
	for(re int i=0;i<(1<<n);i++)p[i]=(long long)p[i]*S%mod;
	p[0]=(p[0]-1+mod)%mod;
	for(re int i=1;i<(1<<n);i++)x[i]=mod-1;
	x[0]=(1<<n)-1;
	FWT(x,n,0);
	FWT(p,n,0);
	for(re int i=0;i<(1<<n);i++)x[i]=(long long)x[i]*ex(p[i],mod-2)%mod;//,printf("%d %d\n",i,p[i]);
	FWT(x,n,1);
	for(re int i=0;i<(1<<n);i++)printf("%d\n",(x[i]-x[0]+mod)%mod);
}

Measured memory_bytes: 4864
n = gets.to_i
s = gets.chomp

cw = 0
cb = 0
a = false
ans = [0, 0]

(n-1).downto(0) do |i|
    if s[i] == "#"
        cb += 1
        a = true
    elsif a
        ans = [ans[0] + cw, ans.min + cb]
        cb = 0
        cw = 1
        a = false
    else
        cw += 1
    end
end

ans = [ans[0] + cw, ans.min + cb] if a

puts ans.min

Measured memory_bytes: 2172
#include <algorithm>
#include <atcoder/all>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
using namespace atcoder;

int main() {
  int n, m;
  cin >> n >> m;
  dsu uf(n);

  // n - 1の辺が必要
  int cnt = 0;

  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (!uf.same(a, b)) {
      ++cnt;
      uf.merge(a, b);
    }
  }
  cout << n - 1 - cnt;
  return 0;
}


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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

int main() {
    int n, l, u, i;
    string s, t;
    cin >> n;

    cout << 0 << endl;
    cin >> t;
    if (t == "Vacant") {
        return 0;
    }
    l = 0;
    u = n;
    i = (u - l) / 2;

    while (1) {
        cout << i << endl;
        cin >> s;
        if (s == "Vacant") {
            return 0;
        } else if (((i - l) % 2 == 0 && s == t) ||
                   ((i - l) % 2 != 0 && s != t)) {
            l = i;
            i = l + (u - l) / 2;
            t = s;
        } else {
            u = i;
            i = l + (u - l) / 2;
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
int main(void){
	long long int nowT=0,nowA=0;
	long long int perT,perA;
	long long int zt=0,za=0;
	long long int z=0;
	int n=0;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>perT>>perA;
		if(i==0){
			nowT=perT;
			nowA=perA;
		}else {
			if(nowT%perT==0){
				zt=(long long int)nowT/perT;
			}else zt=(long long int)nowT/perT+1;
			if(nowA%perA==0){
				za=(long long int)nowA/perA;
			}else za=(long long int)nowA/perA+1;
			z=std::max(zt,za);
			nowT=perT*z;
			nowA=perA*z;
		}
	}
	std::cout<<nowA+nowT<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  int n;
  cin>>n;
  int k=n/100;
  if(n>k*100+k*10+k){
    cout<<(k+1)*100+(k+1)*10+k+1;
  }else{
    cout<<k*100+k*10+k;
  }

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    x, y = list(map(lambda x: int(x)-1, input().split()))
    edges[x].append(y)

dist = [-1]*n


def longest_path(v):
    if dist[v] != -1:
        return dist[v]
    retval = 0
    for v2 in edges[v]:
        retval = max(retval, longest_path(v2)+1)
    dist[v] = retval
    return dist[v]


ans = 0
for i in range(n):
    ans = max(ans, longest_path(i))
print(ans)

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


int main()
{   
	int n;
	cin>>n;
     int a[n],b[n],c[n],dp[n+1][3];

     	dp[0][2]=0;
        dp[0][0]=0;
        dp[0][1]=0;

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

         dp[i+1][0]=a[i]+max(dp[i][1],dp[i][2]);
         dp[i+1][1]=b[i]+max(dp[i][0],dp[i][2]);
         dp[i+1][2]=c[i]+max(dp[i][1],dp[i][0]);

      }

      cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}   

Measured memory_bytes: 2560
n,m=map(int,input().split())
ps=list(list(input().split()) for _ in range(m))

wal=[0]*n
acl=[0]*n

for p,s in ps:
    p=int(p)-1
    if s=='AC' and acl[p] ==0:
        acl[p]+=1
    elif s=='WA' and acl[p] ==0:
        wal[p]+=1

wa=0
for i,ac in enumerate(acl):
    if ac == 1:
        wa+=wal[i]    
    
print(sum(acl),wa)

Measured memory_bytes: 27460
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	ll A, B;
	cin >> A >> B;
	if((B+A)%2) cout << "IMPOSSIBLE" << endl;
	else cout << (B+A)/2 << endl;

	return 0;
}


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

#define f first
#define s second
#define pb push_back
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
const int N=505;
int n,m;
int dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;	
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin>>n;
    vector<string> A,B;
    string C={"abcdefghijklm"};
    rep(i,n){
        if(i==0){
            A.push_back("a");
            continue;
        }
        B.clear();
        for(auto j:A){
            int a=0;
            for(auto k:j) a=max(a,k-'a');
            rep(k,a+2){
                char b=C[k];
                B.push_back(j+b);
            }
        }
        A=B;
    }
    rep(i,A.size()) cout<<A[i]<<endl;
}


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

  int n;
  cin>>n;
  map<int,int>mp;
  
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    mp[x]++;
  }
  
  int count=0;
  for(auto it:mp)
  {
        if(it.first!=it.second)
        {
            if(it.second>it.first)
                count+=it.second-it.first;
            else
                count+=it.second;
        }
  }
  
  cout<<count<<"\n";
  
  
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  int ans=0;
  bool flag=1;
  int key=1;
  rep(i,0,N){
    int X; cin>>X;
    if(X==key){
      key++;
      flag=0;
    }
    else
      ans++;
  }
  if(flag)
    ans=-1;
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300005
#define MOD 1000000007
using namespace std;

int h,w,a,b,ans,f[N];

int pw(int ta,int us) {

  if(!us) return 1;
  if(us==1) return ta;
  int c=pw(ta,us/2);
  c=(1ll*c*c)%MOD;
  if(us%2) c=(1ll*c*ta)%MOD;
  return c;

}

int main() {

  scanf("%d %d %d %d",&h,&w,&a,&b);
  f[0]=1;
  for(int i=1;i<=N-4;i++) {
    f[i]=(1ll*f[i-1]*i)%MOD;
  }
  for(int i=1;i<=h-a;i++) {
    int ust1=f[i-1+b-1];
    int ust2=f[h-i+w-b-1];
    int alt1=(1ll*f[i-1]*f[b-1])%MOD;
    int alt2=(1ll*f[h-i]*f[w-b-1])%MOD;
    ans=(ans+1ll*(1ll*ust1*pw(alt1,MOD-2)%MOD)*((1ll*ust2*pw(alt2,MOD-2))%MOD))%MOD;
  }
  printf("%d",ans);

}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    static void Main()
    {
        string[] s = Console.ReadLine().Split().ToArray();
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);

        long ans = 0;

        if (k % 2 == 1)
        {
            long tmp = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % k == 0) tmp++;
            }
            ans = tmp * tmp * tmp;
        }
        else
        {
            long tmp = 0;
            long tmp2 = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % k == 0) tmp++;
                else if (i % k == k / 2) tmp2++;
            }
            ans = tmp * tmp * tmp + tmp2 * tmp2 * tmp2;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#define N 101
#define NIL -1
#define INF 10000
 
int G[N][N];
int n;
 
int prim(int );

int main() {

  int i,j,ans;
 
  scanf("%d", &n);
 
  for(i = 1;i <= n;i ++)
    {
      for(j = 1;j <= n;j ++)
	{
	  scanf("%d", &G[i][j]);
        }
    }
 
  ans = prim(1);
 
  printf("%d\n", ans);
 
  return 0;
}

int prim(int r){

  int i,u,mincost,ans=0;

  int d[N],pi[N];;

  char color[N];
 
  for(i = 1;i <= n;i ++)
    {
      d[i] = INF;
      pi[i] = NIL;
      color[i] = 'W';
    }
  
  d[r] = 0;
 
  while(1) {

    mincost = INF;

    for (i = 1;i <= n;i ++)
      {
	if (color[i] != 'B' && d[i] < mincost)
	  {
	    mincost = d[i];
	    u = i;
	  }
      }
      
    if (mincost == INF) break;
 
    color[u] = 'B';
 
    for (i = 1;i <= n;i ++)
      {
	if (G[u][i] != NIL)
	  {
	    if(color[i] != 'B' && G[u][i] < d[i])
	      {
		pi[i] = u;
		d[i] = G[u][i];
	      }
	  }
      }
  }
    
  for(i = 1;i <= n;i ++)
    {
      ans += d[i];
    }
  return ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
vector<int>E[200000];
int d[200000];
int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);E[b].push_back(a);
	}
	memset(d,-1,sizeof(d));
	d[0]=0;
	queue<int>que;
	que.push(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int v:E[p]){
			if(d[v]==-1){
				d[v]=d[p]+1;que.push(v);
			}
		}
	}
	puts(d[n-1]==2?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 13168
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> v1(n);
    for(int i=1;i<=n;i++){v1[i-1]=i;}
    for(int i=0;i<n;i++){
        if(i!=0)cout<<" ";
        cout<<v1[i];
    }
    cout<<"\n";
    while(next_permutation(v1.begin(),v1.end())){
        for(int i=0;i<n;i++){
            if(i!=0)cout<<" ";
            cout<<v1[i];
        }
        cout<<"\n";
    }





}




Measured memory_bytes: 3104
from collections import deque

N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1

dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)

print(max(dp))


Measured memory_bytes: 23064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] array = sc.nextLine().toCharArray();
		char before = array[0];

		for (char c : array) {
			if (c != before) {
				System.out.println("Yes");
				return;
			}
			before = c;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

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

	int cur = 0;
	int ans = 0;
	for (auto c : S)
	{
		if (cur == 0)
		{
			if (c == '0')
			{
				--cur;
			}
			else
			{
				++cur;
			}
		}
		else if(cur > 0)
		{
			if (c == '0')
			{
				--cur;
				ans += 2;
			}
			else
			{
				++cur;
			}
		}
		else
		{
			if (c == '0')
			{
				--cur;
			}
			else
			{
				++cur;
				ans += 2;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
using namespace	std;
#define PI 3.141592653589;

int main(){
  double r,area,circ;
  scanf("%lf",&r);
  area=r*r*PI;
  circ=2*r*PI;

  printf("%lf %lf\n",area,circ);

  return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<queue>
using namespace std;

int buil[2][103];
bool done[2][103];
int n;

#define INF 1000000000

int bfs()
{
  queue<int> q;
  q.push(0);
  q.push(0);
  q.push(0);
  q.push(1);
  q.push(0);
  q.push(0);

  while(!q.empty())
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();
    int v = q.front(); q.pop();

    while(y + 1 < n && buil[x][y + 1] && buil[x][y] == 1)
      y++;
    while(buil[x][y] == 2)
      y--;

    if(done[x][y])
      continue;

    if(y == n - 1)
      return v;

    done[x][y] = true;

    if(y + 1< n)
    {
      q.push((x + 1) % 2);
      q.push(y + 1);
      q.push(v + 1);
    }

    if(y + 2 < n)
    {
      q.push((x + 1) % 2);
      q.push(y + 2);
      q.push(v + 1);
    }
  }
  return -1;
}


int main()
{
  while(true)
  {
    for(int i = 0; i < 103; i++)
      done[0][i] = done[1][i] = false;

    cin >> n;
    if(!n)
      break;
    for(int j = 0; j < 2; j++)
    {
      for(int i = 0; i < n; i++)
        cin >> buil[j][i];
    }
    int res = bfs();
    if(res == -1)
      cout << "NA" << endl;
    else
      cout << res << endl;
  }
}

Measured memory_bytes: 1216
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	while(a > 0 && c > 0){
		a -= d;
		c -= b;
	}

	if(c <= 0) puts("Yes");
	else puts("No");

	return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

const int MN = 100010;
using D = double;
int n, m;
ll k;
D x[MN], ans[MN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    V<int> pm(n - 1);
    iota(pm.begin(), pm.end(), 0);
    cin >> m >> k;
    for (int i = 0; i < m; i++) {
        int p;
        cin >> p; p--;
        swap(pm[p], pm[p - 1]);
    }

    auto gao = [&](const V<int> &a, const V<int> &b) {
        V<int> c(n - 1);
        for (int i = 0; i < n - 1; i++) {
            c[i] = a[b[i]];
        }
        return c;
    };

    V<int> r(n - 1);
    iota(r.begin(), r.end(), 0);
    while (k) {
        if (k & 1) r = gao(r, pm);
        pm = gao(pm, pm);
        k >>= 1;
    }

    ans[0] = x[0];
    for (int i = 0; i < n - 1; i++) {
        double d = x[r[i]+1] - x[r[i]];
        ans[i+1] = ans[i] + d;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 6120