akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n        = Integer.parseInt(scanner.nextLine());
		String[] tmp = scanner.nextLine().split(" ");
		int[] list   = new int[n];
		int now   = 0;
		int was   = 1;
		int point = 0;
		for(int i = 0;i < n; i ++) {

			now = Integer.parseInt(tmp[i]);

			if(now == was) {
				was++;
			}else {
				point++;
			}


		}

		if(point == tmp.length) {

			System.out.println(-1);

		}else {

			System.out.println(point);

		}
	}
}

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

int main()
{
    int x, y; cin >> x >> y;

    const auto infinity = numeric_limits<int>::max() - 2;
    const auto cost = [&](const int x, const int y)
    {
        return x <= y ? y-x : infinity;
    };

    cout << min({cost(x, y), 1 + cost(-x, y), 1 + cost(x, -y), 2 + cost(-x, -y)}) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::string;

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

  auto tgt = T.substr(0, S.length());
  bool ans = tgt == S;

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include<iomanip>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  
  int n,m;
  cin >> n >> m;
  int l[m],r[m];
  int maxl=0,minr = 100000;
  rep(i,m){
    cin >> l[i] >> r[i];
    maxl = max(maxl,l[i]);
    minr = min(minr,r[i]);
  }
  if((minr - maxl) >= 0){
    cout << (minr - maxl +1);
  } else {
    cout << 0;
  }
                      
 
 return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
string data1,temp;
bool flag=true;
int main()
{
  cin>>data1;
  for(int i=0;i<data1.size();)
  {
    if((data1.substr(i,6))=="eraser")
        i+=6;
    else if(data1.substr(i,5)=="erase")
        i+=5;
    else if(data1.substr(i,7)=="dreamer"&&data1[i+7]!='a')
        i+=7;
    else if(data1.substr(i,5)=="dream")
        i+=5;
    else
    {
      flag=false;
      break;
    }
  }
  if(flag) cout<<"YES";
  else cout<<"NO";
  return 0;
}


Measured memory_bytes: 512
/**
 *    author:  tourist
 *    created: 12.12.2019 13:28:59       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  dsu d(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    d.unite(x, y);
  }
  vector<int> cnt(2);
  for (int i = 0; i < n; i++) {
    if (d.get(i) == d.get(0)) {
      ++cnt[0];
    }
    if (d.get(i) == d.get(1)) {
      ++cnt[1];
    }
  }
  int mn = min(cnt[0], cnt[1]);
  long long k = mn * 1LL * (mn - 1) / 2 + (n - mn) * 1LL * (n - mn - 1) / 2;
  cout << k - m << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL H, W;
    cin >> H >> W;
    LL h3 = H % 3 == 0 ? 0 : W;
    LL w3 = W % 3 == 0 ? 0 : H;
    LL h2 = LLONG_MAX;
    LL h2h1 = H / 2, h2h2 = H - h2h1;
    FOR(i, 1, W) {
        LL r1 = H * i, r2 = h2h1 * (W - i), r3 = h2h2 * (W - i);
        h2 = min(h2, max(r1, max(r2, r3)) - min(r1, min(r2, r3)));
    }
    LL w2 = LLONG_MAX;
    LL w2w1 = W / 2, w2w2 = W - w2w1;
    FOR(i, 1, H) {
        LL r1 = W * i, r2 = w2w1 * (H - i), r3 = w2w2 * (H - i);
        w2 = min(w2, max(r1, max(r2, r3)) - min(r1, min(r2, r3)));
    }
    cout << min(h3, min(w3, min(h2, w2))) << endl;
	
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/aising2020/tasks/aising2020_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll T;
  cin >> T;

  auto solve_case = []() {
    ll N;
    cin >> N;

    struct Camel {
      ll K, diff, min;
    };

    struct CompareCamel {
      bool operator()(Camel const& lhs, Camel const& rhs) {
        return lhs.diff > rhs.diff;
      }
    };

    V<Camel> front(0);  // L >= R
    V<Camel> back(0);   // L < R

    rep(i, N) {
      ll K, L, R;
      cin >> K >> L >> R;

      if (L >= R) {
        front.push_back({K, L - R, min(L, R)});
      } else {
        // 「後ろから何番目」に変換
        back.push_back({N - K, R - L, min(L, R)});
      }
    }

    auto solve_partial = [&](V<Camel>& camels) -> ll {
      ll res = 0;
      ll camel_ct = camels.size();
      for (auto& c : camels) res += c.min;

      map<ll, V<Camel>> k_to_camel;

      for (auto& c : camels) {
        ll k = min(c.K, camel_ct);
        k_to_camel[k].push_back(c);
      }

      priority_queue<Camel, V<Camel>, CompareCamel> q;

      rep1(i, camel_ct) {
        for (auto& c : k_to_camel[i]) q.push(c);
        while (q.size() > i) q.pop();
      }

      while (q.size()) {
        auto c = q.top();
        res += c.diff;
        q.pop();
      }

      return res;
    };

    ll res = solve_partial(front) + solve_partial(back);
    cout << res << "\n";
  };

  rep(i, T) solve_case();
}


Measured memory_bytes: 24744
#include <stdio.h>

int		main(void)
{
	long n;
	scanf("%ld", &n);
	long sum = 0;
	long i = 1;
	while (n > 0)
	{
		if (!(n % 3 == 0|| n % 5 == 0))
		{
			sum += n;
		}
		n--;
	}
	printf("%ld", sum);
	return (0);
}

Measured memory_bytes: 1732
N,Q=gets.split.map(&:to_i)
G=Array.new(N){Array.new}
(N-1).times do
  a,b=gets.split.map{|i|i.to_i-1}
  G[a]<<b
  G[b]<<a
end
n=[0]*N
Q.times do
  p,x=gets.split.map(&:to_i)
  n[p-1]+=x
end
q=[[0,0]]
until q.empty?
  cur,pre=q.shift
  G[cur].each do |nex|
    next if nex==pre
    q<<[nex,cur]
    n[nex]+=n[cur]
  end
end
puts n*" "

Measured memory_bytes: 47344
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> cells = new ArrayList<Integer>();

		for (int i = 0; i < N; i++) {
			int num = sc.nextInt();
			if (i % 2 == 0) {
				cells.add(num);
			}
		}

		int ans = (int) cells.stream().filter(x -> x % 2 == 1).count();
		System.out.println(ans);
	}
}

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


int main() {
 
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    
    string x;
    cin >> x;
    
    if (x == "Y") {
      sum++;
    }
    
  }
  
  if (sum == 0){
    cout << "Three" << endl;
  }
  
  else {
    cout << "Four" << endl;
  }
  
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli x , a , b ;
    cin >> x >> a >> b ;
    cout << (b < x ? "delicious" : (b <= a + x ? "safe" : "dangerous")) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
def abc072_c():
    from collections import Counter
 
    _ = int(input())
    a = list(map(int, input().split()))
    a_ex = []
    for num in a:
        a_ex.append(num)
        a_ex.append(num-1)
        a_ex.append(num+1)
 
    print(max(Counter(a_ex).values()))
 
 
abc072_c()

Measured memory_bytes: 27360
# coding: utf-8
import bisect
import math
#N, c, k = map(int,input().split())
N = int(input())
#T = []
A = list(map(int,input().split()))
A.sort()
A_ = sorted(A)
ans = 0
for i in range(N-1):
    A_[i+1] += A_[i]
#print(A)
#print(A_)
t=0
for i in range(N-1):
    #print(ans)
    if A_[i]*2 >= A[i+1]:
        ans += 1
    else:
        ans = 0
ans += 1
print(ans)

Measured memory_bytes: 86228
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int a[100005];
bool stone[100005];
int main()
{
//	cut here before submit 
//	freopen ("testcase.SGS", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		memset (a, 0, sizeof (a ) );
		memset (stone, false, sizeof (stone ) );
		for (int i = 1; i <= n; i++ ){
			int in;
			scanf ("%d", &in );
			stone[i] = (in == 1 ? true : false );
		} // end rep
		int right = 0;
		a[right] = 1;
		bool left = stone[1];		// 左端の色
		bool prev = stone[1];		// 直前に置いた石の色
		for (int i = 2; i <= n; i++ ){
 			if (prev == stone[i] ){
				// 連続した色の碁石の数を１つ増やす
				a[right]++;
			}else
			if (i % 2 == 0 ){		// 偶数番目に碁石を置く場合
				if (right == 0 ){
					// テーブルに置いてある碁石は一色であり
					// 新たに置く碁石の色は異なるので、
					// 現在のテーブルに置いてある碁石を、
					// 新たに置く碁石と同じ色の碁石に、全て置き換える
					a[right]++;
					left = stone[i];
				}else{
					// 直前の連続した色の碁石を、
					// 新たに置く碁石の色と同じ色に置き換える
					a[right-1] += a[right] + 1;
					right--;
				} // end if
			}else{
				// 直前に置いた碁石とは異なった色の碁石を新たに置く
				right++;
				a[right] = 1;
			} // end if
			// 直前に置いた碁石の色 = 新たに置く碁石の色
			prev = stone[i];
		} // end for

		int res = 0;
		rep (i, right+1 ){
			// 右端が白のとき、偶数番目が白
			if (!left && (i % 2 == 0 ) ){
				res += a[i];
			}else // 右端が黒のとき、奇数番目が白	
			if (left && (i % 2 != 0 ) ){
				res += a[i];
			} // end if
		} // end rep
		printf ("%d\n", res );

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <boost/format.hpp>
#include <algorithm>
#include <string>

int main(){
    std::string s;
    std::cin >> s;

    int n = s.size();
    
    std::string t(1, '0'), u(1, '1');
    for(int i = 1; i < n; ++i){
        t += std::to_string((t.at(i - 1) + 1) % 2);
        u += std::to_string((u.at(i - 1) + 1) % 2);
    }

    int tCount = 0, uCount = 0;
    for(int i = 0; i < n; ++i){
        if(s.at(i) != t.at(i)){
            ++tCount;
        }
        if(s.at(i) != u.at(i)){
            ++uCount;
        }

    }

    std::cout << std::min(tCount, uCount) << std::endl;

    return 0;
}

Measured memory_bytes: 832
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	red := make([]bool, N)
	ball := make([]int, N)
	red[0] = true
	for i := 0; i < N; i++ {
		ball[i] = 1
	}
	for m := 0; m < M; m++ {
		x := readInt() - 1
		y := readInt() - 1
		if red[x] {
			if ball[x] == 1 {
				red[x] = false
			}
			red[y] = true
		}
		ball[x]--
		ball[y]++
	}
	var ans int
	for _, t := range red {
		if t {
			ans++
		}
	}
	println(ans)
}

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


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int H, W;

    std::cin >> H >> W;

    std::unordered_set<int> skiprows;
    std::unordered_set<int> skipcols;

    char A[H][W];

    for (int i = 0; i < H; ++i) {
        bool allwhite = true;
        for (int j = 0; j < W; ++j) {
            std::cin >> A[i][j];
            if (allwhite == true && A[i][j] == '#') {
                allwhite = false;
            }
        }

        if (allwhite == true) {
            skiprows.insert(i);
        }
    }

    for (int j = 0; j < W; ++j) {
        bool allwhite = true;
        for (int i = 0; i < H; ++i) {
            if (allwhite == true && A[i][j] == '#') {
                allwhite = false;
                break;
            }
        }

        if (allwhite == true) {
            skipcols.insert(j);
        }
    }

    for (int i = 0; i < H; ++i) {
        if (skiprows.count(i) != 0) {
            continue;
        }
        for (int j = 0; j < W; ++j) {
            if (skipcols.count(j) != 0) {
                continue;
            }

            std::printf("%c", A[i][j]);
        }

        std::printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		System.out.println(A + B >= C ? "Yes" : "No");
	}
}

Measured memory_bytes: 21972
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    t = 1
    m = 10 ** 18
    for v in sorted(list(map(int, readline().split()))):
        t *= v
        if t > m:
            print(-1)
            exit()
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 86732
// abc172_b
#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 (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << 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

    string S, T;
    cin >> S >> T;
    int ans = 0;
    REP(i, S.size()){
        if (S[i] != T[i]){
            ans++;
        }
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

typedef struct UnionFindTree{
    vector<int> par;
    vector<lint> sum;

    UnionFindTree(int n){
        par.resize(n, -1);
        sum.resize(n, 0);
    }

    bool is_root(int x){
        return par[x]<0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        sum[x] += sum[y];
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int n, m, a[MAX], b[MAX];
bool used[MAX];
vector<int> G[MAX], edge;
vector<lint> x(MAX), y(MAX);
int ans = 0;

void dfs(int v, lint tmp){
    for(auto e: G[v])if(!used[e] && y[e] <= tmp){
        used[e] = true;
        ++ans;
        dfs(a[e] == v ? b[e] : a[e], tmp);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%lld", &x[i]);
    rep(i, m){
        scanf("%d%d%lld", &a[i], &b[i], &y[i]);
        --a[i]; --b[i];
        G[a[i]].push_back(i);
        G[b[i]].push_back(i);
    }

    vector<int> E(m);
    rep(i, m) E[i] = i;
    sort(E.begin(), E.end(), [&](const int &i, const int &j){return y[i] < y[j];});
    UF uf(n);
    rep(i, n) uf.sum[i] = x[i];
    for(auto e: E){
        uf.unite(a[e], b[e]);
        if(uf.sum[uf.find(a[e])] >= y[e]){
            edge.push_back(e);
        }
    }
    reverse(edge.begin(), edge.end());

    memset(used, false, sizeof(used));
    for(auto e: edge)if(!used[e]){
        dfs(a[e], y[e]);
    }

    printf("%d\n", m - ans);
}

Measured memory_bytes: 14840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextInt();
        double k = sc.nextInt();
        int times = (int) Math.ceil((n - k) / (k - 1));
        System.out.println(times + 1);
    }
}


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

using namespace std;

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

	for (unsigned int i = 0; i < N.length(); ++i) {
		if (N[i] == '9') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

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


void solve(long long A, long long B){
    cout << A * B << endl;
}

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


Measured memory_bytes: 3760
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
  int ans=0;	
  fi(i,n) {
    	cin>>a[i];
      	int c=i+1;
      if((c&1) && (a[i]&1)) ans++;
    }
  cout<<ans<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 14992
#include<stdio.h>
#include<string.h>
int main() {
	int k,m;
	char s[101];
	scanf("%d\n", &k);
	scanf("%s", s);
	m = strlen(s);
	if (k >= m) printf("%s", s);
	else {
		for (int i =k ; i <= m - 1; i++) {
			s[i] = 0;
		}
		printf("%s...", s);
	}

	return 0;
}

Measured memory_bytes: 2156
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=gets.to_i
puts l[n-1]


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int s = 0;
    rep(i, N) s ^= a[i];
    rep(i, N) a[i] ^= s;
    rep(i, N) cout << a[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3856
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 0
    for i in range(60):
        cnt = 0
        for j in a:
            if (j>>i) & 1:
                cnt += 1
        res += ((cnt*(n-cnt))*2**i) % mod
    print(res%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n, cap;
ll value[101];
ll weight[101];
ll dp[100001];

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

    cin >> n >> cap;
    for(int i=0;i<n;i++) cin >> weight[i] >> value[i];

    for(int i=0;i<=n*1000;i++) dp[i] = INF;
    dp[0] = 0;

    for( int i=0;i<n;i++ ){

        for(int j=100001-value[i];j>=0;j--){

            if( dp[j] == INF ) continue;

            dp[ j + value[i] ] = min( dp[j+value[i]], dp[j] + weight[i] );

        }

    }

    for(int j=n*1000;j>=0;j--){
        // cout << dp[j] << endl;
        if( dp[j] <= cap ){
            cout << j << endl;
            // cout << dp[j] << endl;
            break;
        }
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
const int INF = -100100100;

vector<vector<int> > dp(110,vector<int>(10010,INF));

int main(){
    int n,w;
    cin >> n>>w;
    vector<int> v(n),b(n);
    rep(i,n){
        cin >> v[i] >> b[i];
    }    
    rep(i,10010)dp[0][i] = 0;
    rep(i,n){
        rep(j,w+1){
            if(j<b[i])dp[i+1][j] =dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j-b[i]]+v[i]);
        }
    }
    // rep(i,n+1){
    //     rep(j,w+1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][w] << endl;   
    return 0;
}


Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

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

const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    ll total = 0;
    for(int i = 1;i <= n;i++){
        if(i % 3 != 0 && i % 5 != 0)total+= i;
    }
    cout << total;
}


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

int main(){
	int N,M,X;
	cin >> N >> M >> X;
	int C[N];
	int A[N][M];

	for(int i=0;i<N;i++){
		cin >> C[i];
		for(int j=0;j<M;j++){
			cin >> A[i][j];
		}
	}

	///−１
	for(int j=0;j<M;j++){
		int sum=0;
		for(int i=0;i<N;i++){
			sum+= A[i][j];
		}
		if (sum<X){
			cout << -1 << endl;
			return 0;
		}
	}
  
	int ans = 100000000;

	for(int i=1;i <=pow(2,N);i++){
		int Q[M]={0};
		bitset<12> S(i);
      	
		int ans1 = 0;
		for(int j=0;j<N;j++){
			if (S[j]==true){
				ans1 += C[j];
				for(int k = 0;k<M;k++){
					Q[k] += A[j][k];
				}
			}
		}

		sort(Q,Q+M);
		if(Q[0]>=X){
			ans = min(ans,ans1);
		}
	}

	cout << ans << endl;

}

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

int iro(int n,int x,int y){
	int dis;
	dis=min(min(x,n-x+1),min(y,n-y+1));
	dis%=3;
	if(dis==0) return 3;
	else return dis;
}

int hgx,hgy,ans[1010];
int main(){
	int N,K;
	cin>>N>>K;
	for(int i=0;i<K;i++){
		cin>>hgx>>hgy;
		ans[i]=iro(N,hgx,hgy);
	}

	for(int i=0;i<K;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if(a<=5) cout << 0;
    else if(a<=12) cout << b/2;
    else cout << b;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main() {
  char buf[10];
  int64_t num, result;
  scanf("%" PRId64, &num);
  scanf("%s", buf);
  result = (num * (buf[0] - '0') * 100) + (num * (buf[2] - '0') * 10) +(num * (buf[3] - '0') );
  result /= 100;
  printf("%" PRId64 "\n", result);
  return 0;
}

Measured memory_bytes: 1728
while True:
   d = input()
   if d == '0':
      break
   D = list(d)
   A_t = 0
   B_t = 0
   for i in range(1,len(D)):
      if D[i] == "A":
         A_t += 1
      elif D[i] == "B":
         B_t += 1
   if A_t > B_t:
      A_t += 1
   elif A_t < B_t:
      B_t += 1
   print(A_t, B_t)


Measured memory_bytes: 5560
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n, d;
    cin>>n>>d;

    int num=2*d+1;
    
    int ans=(n+num-1)/num;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
import sys

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


def main():
    n = int(input())
    a = list(map(int, readline().split()))

    a.sort(reverse=True)

    e1 = 0
    e2 = 0
    prev = 0
    
    for cur in a:
        if prev == cur:
            if e1 == 0:
                e1 = cur
            else:
                e2 = cur
                print(e1*e2)
                sys.exit()
            cur = 0
        prev = cur

    print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

ll n;
ll a, b, c, d;  
map<ll, ll> memo;

ll f(ll x){
    if(!x)  return 0;
    if(x==1) return d;
    if(memo.count(x)) return memo[x];
    ll res = LINF;
    
    //x*d<LINFの場合は更新
    if(x < LINF/d) res = x*d;
    //切り捨てしてからかけて左右を求める
    ll l2 = (x/2)*2;
    ll r2 = ((x+1)/2)*2;
    ll l3 = (x/3)*3;
    ll r3 = ((x+2)/3)*3;
    ll l5 = (x/5)*5;
    ll r5 = ((x+4)/5)*5;
    res = min(res, labs(x-l2)*d+a+f(l2/2));
    res = min(res, labs(x-r2)*d+a+f(r2/2));
    res = min(res, labs(x-l3)*d+b+f(l3/3));
    res = min(res, labs(x-r3)*d+b+f(r3/3));
    res = min(res, labs(x-l5)*d+c+f(l5/5));
    res = min(res, labs(x-r5)*d+c+f(r5/5));
    return memo[x] = res;

}




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

    int left=0, right=0, n=s.size(), res=0;
    char key[4] = {'A', 'C', 'G', 'T'};
    REP(i, n){
        int cnt=0;
        FOR(j, i, n){
            bool flag=false;
            REP(i, 4)   if(s[j]==key[i]) flag=true;
            if(!flag) break;
            cnt += 1;
        }
        res = max(res, cnt);
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[1002];
  char *w[501];
  int c[501]={0};
  int n,ml,mc=0,il=0,ic=0,i,j;
  fgets(s,1000,stdin);
  s[strlen(s)-1]=0;
  w[0]=strtok(s," ");
  ml=strlen(w[0]);//printf("%s %d\n",w[0],strlen(w[0]));
  i=1;
  while((w[i]=strtok(NULL," "))!=NULL){//
    for(j=0;j<i;j++){
      if(strcmp(w[i],w[j])==0){
	c[j]++;
	if(mc<c[j]){
	  mc=c[j];
	  ic=j;
	}
	break;
      }
    }
    if(i==j){
      n=strlen(w[i]);
      if(n>ml){
	ml=n;
	il=i;
      }
      i++;
    }
  }
  printf("%s %s\n",w[ic],w[il]);
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long N = int.Parse(s[0]);
            long M = int.Parse(s[1]);
            var dictEnergyDrink = new SortedDictionary<long,long>();

            long price, limit;
            for (int i = 0; i < N; i++)
            {
                s = Console.ReadLine().Split(' ');
                price = long.Parse(s[0]);
                limit = long.Parse(s[1]);
                if (dictEnergyDrink.ContainsKey(price))
                {
                    dictEnergyDrink[price] += limit;
                }
                else
                {
                    dictEnergyDrink.Add(price, limit);
                }
            }

            long amount = 0;
            foreach (var item in dictEnergyDrink)
            {
                if (item.Value >= M)
                {
                    amount += item.Key * M;
                    break;
                }
                else
                {
                    amount += item.Key * item.Value;
                    M -= item.Value;
                }
            }
            Console.WriteLine(amount);
        }
    }
}


Measured memory_bytes: 25188
n, m = map(int, input().split(' '))
C = []

for _ in range(m):
    s, c = map(int, input().split(' '))
    C.append((s, c))

v = False

for i in range(1000):
    m = str(i)
    if len(m) != n:
        continue
    w = True
    for s, c in C:
        if m[s - 1] != str(c):
            w = False
            break
    if not w:
        continue
    print(i)
    v = True
    break

if not v:
    print('-1')

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int hyou[][] = new int[n][3];
		for(int s=0;s<n;s++){
			for(int i=0;i<3;i++){
				hyou[s][i]=in.nextInt();
			}
		}
		int ten[] = new int[n];
		for(int i=0;i<n;i++)ten[i]=0;
		for(int s=0;s<3;s++){
			int kensa[] = new int[n];
			for(int i=0;i<n;i++){
				for(int k=i+1;k<n;k++){
					if(hyou[i][s]==hyou[k][s]){
						kensa[i]=-1;
						kensa[k]=-1;
						continue;
					}
				}
			}
			for(int k=0;k<n;k++){
				if(kensa[k]!=-1)ten[k]+=hyou[k][s];
			}
		}
		for(int i=0;i<n;i++)System.out.println(ten[i]);


	}
}

Measured memory_bytes: 20956
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

long double A, B, X;

void solve(void) {
  long double x = X / A;
  long double a, b, c;
  long double x2 = 2 * x;
  if (x2 / A > B) {
    b = 2 * B - (x2 / A);
    // cout << (A * (B + d)) / 2 << ", " << x << endl;
    c = A;
  } else {
    b = B;
    c = x2 / B;
    // cout << ((B * c) / 2) << ", " << x << endl;
  }
  a = sqrt(c * c + b * b);
  cout << setprecision(20) << 90.0 - acos(b / a) * 180.0 / 3.14159265358979 << endl;
}

int main(void) {
  cin >> A >> B >> X;
  solve();
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[20202];
int x[20202], y[20202];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(int i = 1; i <= n; i++){
		x[i] = i*20000;
		y[i] = (n-i)*20000;
	}
	
	for(int i = 1; i <= n; i++){
		y[a[i]] += i;
	}
	
	for(int i = 1; i <= n; i++){
		cout << x[i];
		if(i != n) cout << " ";
	}
	cout << endl;
	for(int i = 1; i <= n; i++){
		cout << y[i];
		if(i != n) cout << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 896
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e6+50;
const ll mod=1e9+7;
using namespace std;
ll x,y,i,j,in[nmax],f[nmax],rs;
ll pw(ll x,ll p)
{
	ll ans=1;
	while(p)
	{
		if(p&1LL)ans=(ans*x)%mod;
		x=(x*x)%mod;
		p>>=1LL;
	}
	return ans;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>x>>y;
	in[0]=f[0]=1;
	for(i=1;i<=x+y;i++)
	{
		f[i]=(f[i-1]*i)%mod;
		in[i]=pw(f[i],mod-2);
	}
	for(i=0;i<=x;i++)
	{
		j=x-i;
		if(j&1)continue;
		j/=2;
		if(2*i+j!=y)continue;
		rs=(rs+f[i+j]*in[i]%mod*in[j]%mod)%mod;
	}
	cout<<rs<<endl;
	return 0;
}


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

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

    vector<int> count(26);
    bool check=true;
    char c='a';

    for(int i=0; i<26; i++){
        for(int j=0; j<w.size(); j++){
            if(w[j]==c){
                count[i]++;
            }
        }
        c++;
    }

    for(int i=0; i<26; i++){
        if(count[i]%2!=0){
            check=false;
        }
    } 

    cout<<(check==true ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 384
a,b=list(map(int,input().split()))
a_b=""
b_a=""
for _ in range(b):
    a_b += str(a)
    
for _ in range(a):
    b_a += str(b)

if a_b[0] <= b_a[0]:
    print(a_b)
else:
    print(b_a)


Measured memory_bytes: 2940
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    const MOD: i64 = 1000000007;

    let mut m = std::collections::HashMap::new();
    for i in 2..n + 1 {
        for j in 2..i + 1 {
            if !is_prime(j) {
                continue;
            }
            if i % j != 0 {
                continue;
            }
            let mut c = 0;
            let mut temp = i;
            while temp % j == 0 {
                c += 1;
                temp /= j;
            }
            let e = m.entry(j).or_insert(0);
            *e += c;
        }
    }

    let mut ans = 1i64;
    for (_, c) in m {
        ans *= c + 1;
        ans %= MOD;
    }
    println!("{}", ans);
}

fn is_prime(n: i64) -> bool {
    let mut ok = true;
    for i in 2..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            ok = false;
            break;
        }
    }
    ok
}


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

int main() {
  int a, b, ans;
  cin >> a >> b;

  ans = (a + b) % 2;

  if(ans == 1){
    cout << (a + b) / 2 + 1 << endl; 
  }
  else {
    cout << (a + b) / 2 << endl;
  }

}

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

const int MAX_N = 100000;

int G[MAX_N];
set<int> A[MAX_N];

void assign_gid(int user_num) {
  int gid;
  queue<int> Q;

  Q.push(0);
  G[0] = gid = 0;

  while (!Q.empty()) {
    int c = Q.front(); Q.pop();

    if (G[c] == -1) G[c] = ++gid;

    for (set<int>::iterator it = A[c].begin(); it != A[c].end(); it++) {
      if (G[*it] == -1) {
        G[*it] = gid;
        Q.push(*it);
      }
    }

    if (Q.empty()) {
      for (int i = 1; i < user_num; i++) {
        if (G[i] == -1) {
          Q.push(i);
          break;
        }
      }
    }
  }
}

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

  for (int i = 0; i < n; i++) G[i] = -1;

  for (int i = 0; i < m; i++) {
    int s, d; cin >> s >> d;
    A[s].insert(d);
    A[d].insert(s);
  }

  assign_gid(n);

  int q; cin >> q;

  for (int i = 0; i < q; i++) {
    int s, d; cin >> s >> d;
    if (G[s] == G[d]) cout << "yes";
    else cout << "no";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 15728
s=[1 if i=="R" else -1 for i in input()]
count = [0 for i in range(len(s))]
for i in range(len(s)):
    c=0
    now=i
    if i>0 and s[now]==s[i-1]:
        count[pre_ot] += 1
        pre_re, pre_ot = pre_ot, pre_re
        continue
        
    while True:
       c+=1
       ne=s[now]
       nextstep=s[now+ne]
       if nextstep == ne:
           now+=ne
       else:
           break
    if (10**100-c)%2 == 0:
        count[now+ne] += 1
        pre_re = now+ne
        pre_ot = now
    else:
        count[now] += 1
        pre_re = now
        pre_ot = now+ne
print(" ".join([str(i) for i in count]))

Measured memory_bytes: 11164
#include<stdio.h>

int main(void){
    int h ,w ;
    int i ,j ;

    while(1){
        scanf("%d%d",&h ,&w);
        if(h==0 && w==0) break;

        for(i=0 ;i<h ;i++){
            printf("#");

            for(j=0 ;j<w-2 ;j++){

                if(i==0 || i==h-1){
                    printf("#");
                } else printf(".");
            }

            printf("#\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 588
from itertools import product
import numpy as np
N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(N)]
X, Y, Z = np.array(XYZ, dtype=np.int64).T

if M == 0:
    print(0)
    exit()

ans = -10 ** 18
for p in product([-1, 1], repeat=3):
    xyz = X * p[0] + Y * p[1] + Z * p[2]
    xyz.sort()
    ans = max(ans, xyz[-M:].sum())
print(ans)

Measured memory_bytes: 12532
#include <iostream>
using namespace std;
int main()
{
  int K, S, ans=0;
  cin >> K >> S;
  for(int x=0; x<=K; ++x)
  {
    for(int y=0; y<=K && S-(x+y)>=0; ++y)
    {
      if(S-(x+y) <= K)
      {
         ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256