akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

string pial[] = {"No", "Yes"};

int main() {
    int a, b;
    cin >> a >> b;
	string s;
	cin >> s;
	int ans = 1, pos = -1;
	for(int i = 0; i < a; i++) {
	    if(s[i] < '0' || s[i] > '9') {
	        ans = 0;
	        break;
	    }
	}
	if(s[a] != '-')
	    ans = 0;
	for(int i = a + 1; i < s.size(); i++) {
	    if(s[i] < '0' || s[i] > '9') {
	        ans = 0;
	        break;
	    }
	}
	cout << pial[ans] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110] = {};
 
void get_map();
void print_map();
void conv_map();
void print_mat();
 
int main()
{
 
  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}
 
void get_map()
{
 
  int k;
  scanf("%d", &map_max);//<100
 
  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
    {
      scanf("%d", &map[i][j]);
    }
    }
 
   
  return ;
}
 
void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      printf("%d", map[i][j]);
    }
      puts("");
    }
return ;
}
 
 
void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      mat[i][map[i][j]-1]=1;
    }
    }
  return ;
}
 
void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
    {
      printf("%d", mat[i][j]);
      if(j!=map_max-1)
        {
          printf(" ");
        }
    }
    printf("\n");
    }
}

Measured memory_bytes: 1104
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		
		System.out.println(Math.abs(a[2]-a[1]) + Math.abs(a[1]-a[0]));
	}
}

Measured memory_bytes: 23636
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
vector<vector<int>> set_pascal(int N) {
    vector<vector<int>> c(N + 1, vector<int>(N + 1, 0));

    for (int i = 0; i <= N; i++) {
        c[i][0] = 1;

        for (int j = 1; j <= i; j++) {
            c[i][j] = c[i-1][j] + c[i-1][j-1];
        }
    }

    return move(c);
}


signed main() {
    int N, K;
    cin >> N >> K;
    int odd_cnt = 0;
    int even_cnt = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0) even_cnt++;
        else odd_cnt++;
    }

    vector<vector<int>> pas = set_pascal(N);

    int ret = 1LL << even_cnt;
    int tmp = 0;
    if (K % 2 == 0) {
        for (int i = 0; i <= odd_cnt; i += 2) {
            tmp += pas[odd_cnt][i];
        }
    } else {
        for (int i = 1; i <= odd_cnt; i += 2) {
            tmp += pas[odd_cnt][i];
        }
    }

    cout << ret * tmp << endl;

    return 0;
}

Measured memory_bytes: 256
def main():

    L = input()
    mod = pow(10, 9) + 7
    n = len(L)
    prefix = 0

    pows3 = [1]
    for _ in range(n):
        pows3.append((pows3[-1] * 3) % mod)
    p2 = 1
    ans = 0
    for i in range(n):
        if L[i] == "1":
            ans += (pows3[n-1-i]*p2) % mod
            ans %= mod
            prefix += 1
            p2 *= 2
            p2 %= mod
    ans += p2
    ans %= mod
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 45552
N=int(input())
ans=0
l=len(str(N))
for i in range(l+1):
    if i!=l and i%2!=0:
        ans+=(10**i)-(10**(i-1))
    if i==l and i%2!=0:
        ans+=(N-(10**(i-1))+1)
print(ans)

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define MAX_N 364364
#define fi first
#define sc second
int N;
P B[MAX_N];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%lld%lld",&B[i].fi,&B[i].sc);
	}
	sort(B,B+N);
	int ans=0;
	priority_queue<P,vector<P>,greater<P> >que;
	ll sum=0;
	for(int i=0;i<N;i++){
		sum+=B[i].fi;
		que.push(P(B[i].sc,B[i].fi));
		while(!que.empty()&&(ll)que.size()*que.top().fi<sum){
			sum-=que.top().sc;
			que.pop();
		}
		ans=max(ans,(int)que.size());
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16804
GRID = []
for _ in range(3):
    GRID.append([int(c) for c in input().split()])

def diff(row):
    min_num = min(row)
    return list(map(lambda c: c - min_num, row))

def main():
    ans = None
    prev = None
    while GRID:
        row = GRID.pop()
        curr = diff(row)
        if prev is None:
            prev = curr[:] # deep copy
        if curr != prev:
            ans = "No"
            break
    if ans is None:
        ans = "Yes"
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (b <= a && k != 0){
		b *= 2;
		k -= 1;
	}
	while (c <= b && k != 0){
		c *= 2;
		k -= 1;
	}
	if (c > b && b > a) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

int main() {
  int n,m,ans = 0;
  cin >> n >> m;
  vector<vector<bool>>data(n,vector<bool>(n,false));
  vector<pair<int,int>>hasi(m);
  for(int i = 0;i < m;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    hasi[i] = pair<int,int>(a,b);
    data[a][b] = true;
    data[b][a] = true;
  }
  queue<int>que;
  for(int i = 0;i < m;i++){
    vector<bool>seen(n,false);
    seen[0] = true;
    bool tf = false;
    if(data[hasi[i].first][hasi[i].second]){
      data[hasi[i].first][hasi[i].second] = false;
      data[hasi[i].second][hasi[i].first] = false;
      tf = true;
    }
    for(int j = 0;j < n;j++) if(data[0][j]){
      que.push(j);
      seen[j] = true;
    }
    while(!que.empty()){
      int v = que.front();
      que.pop();
      for(int j = 0;j < n;j++){
        if(data[v][j] && !seen[j]){
          que.push(j);
          seen[j] = true;
        }
      }
    }
    bool flag = false;
    for(int j = 0;j < n;j++) if(!seen[j]) flag = true;
    if(flag) ans++;
    if(tf){
      data[hasi[i].first][hasi[i].second] = true;
      data[hasi[i].second][hasi[i].first] = true;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static class DoublyLinkedList<T> {
        class Node<T> {
            T value;
            Node<T> prev;
            Node<T> next;
        }

        final Node<T> nil;

        DoublyLinkedList() {
            nil = new Node<T>();
            nil.prev = nil;
            nil.next = nil;
        }

        void insert(T x) {
            Node<T> n = new Node<>();
            n.value = x;
            n.prev = nil;
            n.next = nil.next;
            nil.next.prev = n;
            nil.next = n;
        }

        void delete(T x) {
            Node<T> c = nil.next;
            while (c != nil) {
                if (c.value.equals(x)) {
                    // find
                    delete(c);
                    return;
                }
                c = c.next;
            }
        }

        void deleteFirst() {
            delete(nil.next);
        }

        void deleteLast() {
            delete(nil.prev);
        }

        void delete(Node<T> n) {
            if (n == nil) return;
            n.prev.next = n.next;
            n.next.prev = n.prev;
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder();
            Node<T> c = nil.next;
            boolean append = false;
            while (c != nil) {
                if (append) {
                    sb.append(" ");
                }
                sb.append(c.value);
                c = c.next;
                append = true;
            }
            return sb.toString();
        }

    }

    public static void main(String[] args) throws IOException {
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(sc.readLine());
        DoublyLinkedList<Integer> list = new DoublyLinkedList<>();
        for (int i = 0; i < n; i++) {
            String[] command = sc.readLine().split(" ");
            switch (command[0]) {
                case "insert":
                    list.insert(Integer.parseInt(command[1]));
                    break;
                case "delete":
                    list.delete(Integer.parseInt(command[1]));
                    break;
                case "deleteFirst":
                    list.deleteFirst();
                    break;
                case "deleteLast":
                    list.deleteLast();
                    break;
            }
        }
        System.out.println(list);
    }
}


Measured memory_bytes: 212216
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 1000 + 5;
int a[N];

int main(){
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a,a+n);
	int sum = 0;
	for(int i = 0; i < k; i++)
		sum += a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        int max;
        int min;

        int r0 = Integer.parseInt(scanner.next());
        int r1 = Integer.parseInt(scanner.next());
        max = r1 - r0;
        min = Math.min(r1, r0);

        for (int i = 2; i < n; i++) {
            int ri = Integer.parseInt(scanner.next());
            if (ri - min > max) {
                max = ri - min;
            }
            min = Math.min(ri, min);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 70648
from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n, m = MI()
to = defaultdict(list)
# dp[u][v] uを根としたときのサブツリーvの値
dp = {}

def dfs(u=0, pu=-1):
    res = 1
    for v in to[u]:
        if v == pu: continue
        res *= dfs(v, u) + 1
        res %= m
    if pu != -1: dp[(pu,u)] = res
    return res

def main():
    for _ in range(n - 1):
        x, y = map(int1, input().split())
        to[x].append(y)
        to[y].append(x)
    dfs()
    # bfsでdfsとは逆向きのdpを完成させる
    que = deque()
    que.append([0, -1])
    while que:
        u, pu = que.popleft()
        tn = len(to[u])
        # 累積積のための配列
        ll = [0] * tn
        rr = [0] * tn
        # uのサブツリーの値+1を入れる
        for i, v in enumerate(to[u]):
            ll[i] = rr[i] = dp[(u,v)] + 1
        # 左右から累積積を作る
        for i in range(1, tn):
            ll[i] = (ll[i - 1] * ll[i]) % m
            rr[tn - 1 - i] = (rr[tn - i] * rr[tn - 1 - i]) % m
        # 配列の最初or最後のために最後に1を追加
        ll += [1]
        rr += [1]
        # uの子vを根とみたときのサブツリーuの値を求める
        for i, v in enumerate(to[u]):
            if v == pu: continue
            dp[(v,u)] = (ll[i - 1] * rr[i + 1]) % m
            que.append([v, u])
    # p2D(dp)
    # 各頂点について答えを出す
    for u in range(n):
        ans = 1
        for v in to[u]:
            ans = (ans * (dp[(u,v)] + 1)) % m
        print(ans)

main()


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int[] n = new int[9];
            char[] list = sc.nextLine().toCharArray();
            for (int i : list) {
                n[i - '1']++;
            }
            List<Integer> result = new ArrayList<>();

            for (int i = 0; i < 9; i++) {
                next: for (int j = 0; j < 9; j++) {
                    if (n[i] < 4 && (n[j] >= 2 || n[i] >= 1)) {
                        int[] temp = n.clone();
                        temp[i]++;
                        temp[j] -= 2;
                        for (int k = 0; k < 7; k++) {
                            process(temp, k, 1);
                            process(temp, k, 2);
                            if (temp[k] % 3 != 0) {
                                continue next;
                            }
                        }
                        if (temp[7] % 3 == 0) {
                            result.add(i + 1);
                            break;
                        }
                    }
                }
            }
            if (result.isEmpty()) {
                System.out.println(0);
            } else {
                for (int i = 0; i < result.size(); i++) {
                    System.out.print(result.get(i) + (i < result.size() - 1 ? " " : "\n"));
                }
            }
        }
    }

    static void process(int[] a, int p, int n) {
        if (a[p] % 3 == n && a[p + 1] >= n && a[p + 2] >= n) {
            a[p] -= n;
            a[p + 1] -= n;
            a[p + 2] -= n;
        }
    }
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 50;
ll n;
string s[MAX_N];
map<char, ll> counter[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> s[i];

  REP(i, n){
    REP(j, s[i].size()){
      char x = s[i][j];
      counter[i][x]++;
    }
  }
  map<char, ll> ans;
  REP(j, 26){
    ll temp = INF;
    REP(i, n) chmin(temp, counter[i]['a' + j]);
    ans['a' + j] = temp;
  }
  REP(j, 26){
    REP(k, ans['a' + j]) printf("%c", 'a' + j);
  }
  cout << endl;


}


Measured memory_bytes: 384
import java.util.*

val dx = listOf(0, 1, 0, -1)
val dy = listOf(-1, 0, 1, 0)

fun main() {
  val (H, W) = readInts()
  val (Ch, Cw) = readInts().map { it - 1 }
  val (Dh, Dw) = readInts().map { it - 1 }
  val S = (1..H).map { readString() }

  val dist = Array(H) { Array(W) { Int.MAX_VALUE } }
  val deque = LinkedList<Pair<Int, Int>>()
  dist[Ch][Cw] = 0
  deque.add(Ch to Cw)
  while (deque.isNotEmpty()) {
    val (py, px) = deque.removeFirst()
    if (py to px == Dh to Dw) break
    // 通常移動
    for (i in 0..3) {
      val y = py + dy[i]
      val x = px + dx[i]
      if (y < 0 || y >= H || x < 0 || x >= W) continue
      if (S[y][x] == '#') continue
      val cost = dist[py][px] + 0
      if (dist[y][x] <= cost) continue
      dist[y][x] = cost
      deque.addFirst(y to x) // 先頭
    }
    // ワープ移動
    for (dy in -2..2) {
      for (dx in -2..2) {
        val y = py + dy
        val x = px + dx
        if (y < 0 || y >= H || x < 0 || x >= W) continue
        if (S[y][x] == '#') continue
        val cost = dist[py][px] + 1
        if (dist[y][x] <= cost) continue
        dist[y][x] = cost
        deque.addLast(y to x) // 後ろ
      }
    }
  }
  println(dist[Dh][Dw].let { if (it == Int.MAX_VALUE) -1 else it })
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 87744
#include <stdio.h>
int main(void)
{
  int stay_days,change_days,price1,price2,price;
  char str[16];
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&stay_days);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&change_days);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&price1);
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&price2);
  if(stay_days <= change_days)
  {
    price = stay_days * price1;
  }
  else
  {
    price = change_days * price1 + (stay_days - change_days) * price2;
  }
  printf("%d\n",price);
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 0; i < n; i++) cin >> a[i+1];
    vector<int> b(n+1);
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i+i; j <= n; j += i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        if (b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        if (i+1 == ans.size()) cout << ans[i] << endl;
        else cout << ans[i] << ' ';
    }
    return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

/**
 * Created by hwzheng on 2017/3/26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] R = new int[n];
        for (int i = 0; i < n; i++){
            R[i] = scanner.nextInt();
        }
        System.out.println(maxProfit(R));
    }

    public static int maxProfit(int[] R){
        int maxv = R[1] - R[0];
        int minv = R[0];
        for (int i = 1; i < R.length; i++){
            maxv = Math.max(R[i]-minv,maxv);
            minv = Math.min(R[i],minv);
        }
        return maxv;
    }
}

Measured memory_bytes: 101304
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      ab: [(usize, usize); n],
      cd: [(usize, usize); n],
   }
   let mut dot = vec![((0, 0), 0); 2 * n];
   for i in 0..n {
      dot[i] = (ab[i], 0);
      dot[n + i] = (cd[i], 1);
   }
   dot.sort();

   let mut ans = 0;
   let mut red = vec![2 * n];
   for &((x, y), c) in dot.iter() {
      if c == 0 {
         red.push(y);
         red.sort();
      } else if !(red[0] > y) {
         let p = red.upper_bound(&y);
         red.remove(p - 1);
         ans += 1;
      }
   }
   println!("{}", ans);
}

/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
   fn lower_bound(&self, x: &T) -> usize;
   fn upper_bound(&self, x: &T) -> usize;
}
#[allow(dead_code)]
impl<T: Ord> BinarySearch<T> for [T] {
   fn lower_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            std::cmp::Ordering::Less => {
               low = mid + 1;
            }
            std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
   fn upper_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
               low = mid + 1;
            }
            std::cmp::Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
}


Measured memory_bytes: 2172
void main()
{
    int n = readln.chomp.to!int;
    int h = readln.chomp.to!int;
    int w = readln.chomp.to!int;

    writeln((n - h + 1) * (n - w + 1));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

inline int read()
{
    char c = getchar(); int f = 1, x = 0;
    while( c < '0' || c>'9' ) { if(c == '-') f = -1;  c = getchar(); }
    while( c >= '0'&&c<='9' ) { x = x * 10 + c - '0'; c = getchar(); }
    return f * x;
}

int n, k; 

vector <int> s[110000]; 

int main()
{
	n = read(); 
	
	int temp = 1, k = 2; 
	
	while( temp < n ) 
		temp += k, k ++;
	
	if( temp != n ) {
		printf( "No\n" ); return 0; 
	}
	
	printf( "Yes\n%d\n", k ); 
	
	int x = 1, y = 2;
	for( int i = 1; i <= n; i ++ )
	{
		s[x].push_back( i ); 
		s[y].push_back( i ); 
		
		y ++; if( y > k ) x ++, y = x + 1;
	}
	
	vector <int> :: iterator it; 
	for( int i = 1; i <= k; i ++ )
	{
		printf( "%d ", s[i].size() ); 
		for( it = s[i].begin(); it != s[i].end(); it ++ )
			printf( "%d ", *it ); printf( "\n" ); 
	}
	
	return 0; 
} 

Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    char ch;
	    String inputed;
		try {
			inputed = br.readLine();
		     for(int i = 0; i < inputed.length(); i++){
	             ch = inputed.charAt(i);

	             if(Character.isUpperCase(ch)){
	                 System.out.print(Character.toLowerCase(ch));
	             }else if(Character.isLowerCase(ch)){
	                 System.out.print(Character.toUpperCase(ch));
	             }else{
	                 System.out.print((char)ch);
	             }
	         }
		     System.out.printf("\n");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 25100
#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
int n,num,p[35],c[35],ans;
inline void R(int&x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pow(int x,int k)
{
	int sum=1;
	for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) sum=1LL*sum*x%mod;
	return sum;
}
void dfs(int x,int v)
{
	if(x>num)
	{
		int num=9LL*pow(10,v-1)%mod;
		if(v<=9&&num<n/v); else R(ans,((num-(n/v)+1)%mod+mod)%mod);
		return;
	}	
	for(int i=0;i<=c[x];++i) dfs(x+1,v),v*=p[x];
}
int exgcd(int a,int b,int&x,int&y)
{
	if(!b){x=1;y=0;return a;}
	int c=exgcd(b,a%b,y,x);
	y-=a/b*x;return c;
}
inline int D(int x,int y){return (x+1000000000LL*y)/y-1000000000;}
inline int U(int x,int y){return (x+1000000000LL*y+y-1)/y-1000000000;}
int Solve(int a,int b,int c,int ux,int uy)
{
	int x,y,g=exgcd(a,b,x,y);
	if(c%g) return 0;
	x*=c/g;y*=c/g;a/=g;b/=g;
	int t=x/b;x-=t*b;y+=t*a;
	if(x<=0)
	{
		int t=(-x)/b+1;
		x+=t*b;y-=t*a;	
	}
	int l=max(0,U(y-uy,a)),r=min((ux-x)/b,D(y-1,a));
	if(l<=r) return r-l+1; else return 0;
}
int main()
{
	scanf("%d",&n);int t=n;
	for(int i=2;i<=10000;++i) if(t%i==0)
	{
		p[++num]=i;
		while(t%i==0) t/=i,++c[num];
	}
	if(t>1) p[++num]=t,c[num]=1;dfs(1,1);
	for(int l=1;l<10;++l)
		for(int r=l+1,mid=0;r<10&&mid+l+r<=n;mid=min(mid+9LL*r*pow(10,r-1),(long long)1e9),++r)
			R(ans,Solve(l,r,n-mid,9*pow(10,l-1),9*pow(10,r-1)));
	for(int i=9,last;i<=n;i=last+1)
	{
		last=n/(n/i);
		if(1LL*i*i<=n)
		{
			int A=n/i,B=n%i;//l=0,r=n,mid,res=0;
		/*	while(l<=r)
			{
				mid=l+r>>1;
				if(A-mid>B+1LL*mid*i) res=mid,l=mid+1;
				else r=mid-1;
			}*/
		//	A-res>B+res*i
		//	A-B>res*(i+1)
			R(ans,(A-B-1)/(i+1)-(B==0)+1);
		}
		else if(n%(n/i)) R(ans,1);
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
/**
 *  Square Route (Problem D, Practice Contest for Japan Domestic, 2007-06-24)
 *  by Kenji Inoue, 2007-06-28
 **/

#include <iostream>
#include <map>

using namespace std;

int main() {
  int h[1501], w[1501];

  int N, M;
  while (cin >> N >> M, (N || M)) {
    for (int i=0; i<N; i++) {
      int t; cin >> t; h[i] = t;
    }
    for (int i=0; i<M; i++) {
      int t; cin >> t; w[i] = t;
    }

    map<int, int> V, H;
    for (int i=0; i<N; i++) {
      int len = 0;
      for (int j=i; j<N; j++) {
        len += h[j];
        V[len]++;
      }
    }
    for (int i=0; i<M; i++) {
      int len = 0;
      for (int j=i; j<M; j++) {
        len += w[j];
        H[len]++;
      }
    }

    int count = 0;
    for (map<int, int>::iterator it = V.begin(); it != V.end(); it++) {
      int key = it->first;
      count += V[key] * H[key];
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 21000
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

def max(a, b)
  return a > b ? a : b
end

N, h_list = gets_n_and_i_list      
INF = Float::INFINITY

dp = Array.new(N, INF)
dp[0] = 0
dp[1] = (h_list[1] - h_list[0]).abs

1.upto(N-2) do |i|
  n1 = (h_list[i + 1] - h_list[i]).abs + dp[i]
  n2 = (h_list[i + 1] - h_list[i - 1]).abs + dp[i - 1]
  dp[i + 1] = min(n1, n2)
end

puts dp.last

Measured memory_bytes: 11516
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> v;
    for(int i = 1;i <= sqrt(m);i++)
    {
        if(m % i == 0)
        {
            v.push_back(i);
            v.push_back(m / i);
        }
    }
    sort(v.begin(),v.end(),greater<int>());
    for(int i = 0;i < v.size();i++)
    {
        if(v[i] <= m / n)
        {
            cout << v[i];
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3F3F3F3F3F3F3F3Fll
#define maxn 
using namespace std;

int len[60], N;
long long c[60], dp[2][60][30];
char S[2][60][30];

bool isPalindrome(char *s, char *t) {
	for(; s < t; ++s, --t) if(*s != *t) return false;
	return true;
}

long long dfs(const int &n, const int &l, const bool &f) {
	long long &ret = dp[f][n][l];
	if(ret != -1) return ret;
	const int &r = len[n] - 1;
	if(isPalindrome(S[f][n] + l, S[f][n] + r)) return ret = 0;
	ret = INF;
	for(int i = 1; i <= N; ++i) {
		if(r - l + 1 <= len[i]) {
			bool valid = true;
			for(int j = 0; j <= r - l; ++j) {
				if(S[f][n][j + l] != S[!f][i][j]) {
					valid = false;
					break;
				}
			}
			if(valid) ret = min(ret, c[i] + dfs(i, r - l + 1, !f));
		} else {
			bool valid = true;
			for(int j = 0; j < len[i]; ++j) {
				if(S[f][n][j + l] != S[!f][i][j]) {
					valid = false;
					break;
				}
			}
			if(valid) ret = min(ret, c[i] + dfs(n, l + len[i], f));
		}
	}
	return ret;
}

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i) {
		scanf("%s%lld", S[0][i], c + i);
		len[i] = strlen(S[0][i]);
		strcpy(S[1][i], S[0][i]);
		reverse(S[1][i], S[1][i] + len[i]);
	}
	long long Ans = INF;
	memset(dp, 0xFF, sizeof dp);
	for(int i = 1; i <= N; ++i) Ans = min(Ans, c[i] + dfs(i, 0, false));
	printf("%lld\n", Ans == INF ? -1 : Ans);
	return 0;
}



Measured memory_bytes: 3824
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int (t); cin>>(t);while((t)--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

lli dist[2005][2005]={0};
lli n,x,y;

vector<long long int> adj[110000];
 
void edge (long long int x, long long int y)
{
	adj[x].push_back(y);
	adj[y].push_back(x);
}
 
long long int bfs (int u)
{
	queue<long long int> q;
	bool visited[110000]={0};
	
	q.push(u);
	visited[u]=1;
	dist[u][u]=0;
 
	while (!q.empty())
	{
		long long int f= q.front();
		q.pop();
 
		for (auto i = adj[f].begin() ; i!=adj[f].end() ; i++)
		{
			if (visited[*i]==0)
			{
				q.push(*i);
				visited[*i]=1;
				dist[u][*i]=dist[u][f]+1;
			}
		}
	}
}

int main (void)
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif

	cin>>n>>x>>y;

	ref(i,1,n-1)
		edge(i,i+1);
	
	edge(x,y);

	ref(i,1,n)
		bfs(i);

	lli hash[2100]={0};

	ref(i,1,n)
		ref(j,i+1,n)
			hash[dist[i][j]]++;
	
	ref(i,1,n-1)
		cout<<hash[i]<<endl;

	return 0;
}

Measured memory_bytes: 34304
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

	string S;
	cin>>S;

	int a = ((S[0] - '0') * 10) + (S[1] - '0');
	int b = ((S[2] - '0') * 10) + (S[3] - '0');
	bool f=true, s=true;

	dbg(a);
	dbg(b);

	//YYMM
	if(b<1||b>12){
		f = false;
	}

	//YYMM
	if(a<1||a>12){
		s = false;
	}

	if(f&&s){
		cout << "AMBIGUOUS" << endl;
		return 0;
	}

	if(f){
		cout << "YYMM" << endl;
		return 0;
	}

	if(s){
		cout << "MMYY" << endl;
		return 0;
	}

	cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    string s;
    cin >> s;
    size_t i0 = s.find('A');
    size_t i1 = s.rfind('Z');
    cout << i1 - i0 + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int A[220];
    int N;

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

    bool check = false;

    int count = 0;

    while (true)
    {
        for (int i = 0; i < N; i++)
        {

            if (A[i] % 2 == 0)
            {
                A[i] = A[i] / 2;
            }
            else
            {
                check = true;
            }
        }
        if (check)
        {
            break;
        }
        else
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    map<int, ll> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        m[a[i]]++;
    }
    ll t = 0;
    for(auto&& i : m){
        t += (i.second * (i.second - 1)) / 2;
    }
    for(int i = 0; i < n; i++){
        ll x = m[a[i]];
        cout << t - (x * (x - 1)) / 2 + ((x - 1) * (x - 2)) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 10240
#include<iostream>

using namespace std;

int main(){
    int a ,b;
    cin >> a >> b;
    if ( a < b ) {
    cout <<"a < b"<< endl;
    }  if ( a > b ) { 
    cout <<"a > b"<< endl;
    }  if ( a == b ) {
    cout <<"a == b"  << endl;
    }
}

 



Measured memory_bytes: 3120
A,B,H,M= map(int,input().split())
import numpy as np
h = (60*H)+M
kakudo = abs(0.5*h - 6*h)%360
kakudo = np.radians(kakudo)
C =( A**2+B**2-2*A*B*np.cos(kakudo))**0.5
print(C)

Measured memory_bytes: 27200
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        int max = 0;
        int ans = 0;
        for(int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
            ans += p[i];
            if(max < p[i]) max = p[i];
        }
        ans -= max/2;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);
int main(){
  int n;cin>>n;
  vector<bool> a(n, false);
  vector<bool> b(n, false);
  for(int i=0;i<n;i++){
  	int t;cin>>t;
    if(t==0)a[i]=false;
    else a[i]=true;
  }
  vector<int> ans;
  for(int i=n;i>=1;i--){
    int sum=0;
  	for(int j=1;j*i<=n;j++){
      sum += (int)b[j*i-1];
    }
    if((sum+(int)a[i-1])%2==1){
      b[i-1]=true;
      ans.push_back(i);
    }else{
      b[i-1]=false;
    }
  }
  int m=(int)ans.size();
  cout<<m<<endl;
  for(int i=0;i<m;i++){
  	if(i!=m-1)cout<<ans[i]<<" ";
    else cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int n,count=0,tmp,a;
  cin >> n;
  vector<int> p;
  for(int i=0;i<n;i++){
    cin >> a;
    p.push_back(a);
  }


  for(int i=1;i<n;i++){
    for(int j=0;j<=i;j++){
      tmp=p[i];
      p[i]=p[j];
      p[j]=tmp;
      if(is_sorted(p.begin(),p.end())){
        count=1;
        break;
      }
      tmp=p[i];
      p[i]=p[j];
      p[j]=tmp;
    }
  }


  if(count==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

int main() {
  int N,D,X;
  cin >> N >> D >> X;
  
  vector<int> A(N);
  
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  
  int sum = 0;
  int a;
  
  for (int i = 0; i < N; i++) {
    a = 1;
    
    while (a * A.at(i) + 1 <= D) {
      sum++;
      a++;
    }
    
  }
  
  cout << N + sum + X << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc167/tasks/abc167_a
#include <bits/stdc++.h>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s , res ;
  cin >> s >> res ;
  s += res[res.size() - 1 ] ;
  if(s == res) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 50005
#define MAX_M 25

int n, m;
int D[MAX_M];
int dp[MAX_N];

int main(void) {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &D[i]);
	}
	sort(D, D + m, std::greater<int>());
	dp[0] = 0;
	int i, j;
	for (i = 1; i <= n; i++) {
		dp[i] = INT_MAX;
		// 限制条件里有硬币一定包含1, 所以下面的循环一定会终止
		for (j = 0; j < m; j++) {
			if (i >= D[j])
				dp[i] = min(dp[i - D[j]] + 1, dp[i]);
		}
	}

	printf("%d\n", dp[n]);
}


Measured memory_bytes: 3448
/* Accepted. */
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
#define MAXN 100006
int n , m;
int X[MAXN] , d[MAXN] , S;
int main() {
	//freopen( "input","r",stdin );
	cin >> m >> n;
	if( n <= m ) return puts("0"),0;
	for( int i = 1 ; i <= n ; ++ i ) 
		scanf("%d",&X[i]);
	sort( X + 1 , X + 1 + n );
	for( int i = 1 ; i <= n ; ++ i ) d[i] = i != 1 ? X[i] - X[i-1] : -0x3f3f3f3f;
	S = X[n] - X[1];
	sort( d + 1 , d + 1 + n );
	for( int i = 0 ; i < m-1 ; ++ i )
		S -= d[n-i];
	cout << S;
}//qwq



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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>p(n);
  for(int i=0;i<n;i++) cin>>p[i];
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<k;i++) ans+=p[i];
  cout<<ans<<endl;
}

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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, n) for(int i = 0; i < n; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

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

    map<string, int> M;

    int N;
    cin >> N;
    rep(i, N){
        string s;
        cin >> s;
        if(M.count(s) == 0){
            M[s] = 1;
        }
    }

    cout << M.size() << endl;

    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 2003;
const ll lmod = 1e9+7;

int main(){
  string s; cin >> s; int N = s.size();
  cout << ((N%2==0 ^ s[0]==s[N-1]) ? "Second" : "First") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define INF 1e+18
#define int long long
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

signed main(){
	int n,m,c,a,b,dd,sum = 0,mi = INF;
	int d[100000];
	bool used[100000];
	vector<edge> G[100000];
	priority_queue<P,vector<P>,greater<P> > que;
	cin >> n >> m >> c;
	for(int i = 1;i < n;i++) d[i] = INF;
	for(int i = 0;i < m;i++){
		cin >> a >> b >> dd;
		G[a - 1].push_back({b - 1,dd});
		G[b - 1].push_back({a - 1,dd});
		sum += dd;
	}
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.top();que.pop();
		if(d[p.second] < p.first) continue;
		used[p.second] = true;
		for(int i = 0;i < G[p.second].size();i++){
			if(used[G[p.second][i].to]) sum -= G[p.second][i].cost;
		}
		mi = min(mi,d[p.second] * c + sum);
		for(int i = 0;i < G[p.second].size();i++){
			edge e = G[p.second][i];
			if(d[e.to] > d[p.second] + e.cost){
				d[e.to] = d[p.second] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 17448
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=2e5+10;
const int mod=1e9+7;
#define PI 3.1415927
int main()
{
	double a,b,x,teg=0,s,t;
	cin>>a>>b>>x;
	if(x>a*a*b/2){
		x=a*a*b-x;
		double s=((x*2)/(a*a));
		double t=sqrt(a*a+s*s);
		teg=(asin(s/t)*180/PI);
	}else if(x==a*a*b/2){
		teg=45;
	}else {
		double s=(x*2/(a*b));
		double t=sqrt(b*b+s*s);
		teg=(asin(b/t)*180/PI);
	}
	printf("%.10f\n",teg);
	return 0;
} 

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

int a[2];

int main() {
    a[0]=1;
    while (a[0]+a[1]!=0) {
        cin >> a[0] >> a[1];
        sort (a , a+2);
        if (a[0]+a[1]!=0) cout << a[0] << " " << a[1] << endl;
    }
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		long[] X = new long[N];
		long[] Y = new long[N];
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		
		int count = 0;
		for (int i = 0; i < N; i++) {
			double Z = Math.sqrt(X[i] * X[i] + Y[i] * Y[i]);
			if (Z <= D) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 62740
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h,a;
    cin>>h>>a;
    int sum=0;
    for(int i=0;i<a;i++)
    {
        int ip;
        cin>>ip;
        sum+=ip;
    }

    if(sum>=h)
    {
        cout<<"Yes"<<"\n";
    }
    else
    {
        cout<<"No"<<"\n";
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int INF = (1LL << 31) - 1;
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketMin;
  vector<bool> lazyFlag;
  vector<int> lazyUpdate;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, INF);
    bucketMin.assign(K, INF);
    lazyFlag.assign(K, false);
    lazyUpdate.assign(K, 0);
  }
  void eval(int k) {
    if (lazyFlag[k]) {
      lazyFlag[k] = false;
      for (int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
        data[i] = lazyUpdate[k];
      }
    }
  }
  // [s, t)
  void update(int s, int t, int x) {
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucketMin[k] = x;
        lazyFlag[k] = true;
        lazyUpdate[k] = x;
      } else {
        eval(k);
        for (int i = max(s, l); i < min(t, r); ++i) {
          data[i] = x;
        }
        int &minVal = bucketMin[k] = INF;
        for (int i = l; i < r; ++i) {
          minVal = min(minVal, data[i]);
        }
      }
    }
  }
  // [s, t)
  int find(int s, int t) {
    int minVal = INF;
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        minVal = min(minVal, bucketMin[k]);
      } else {
        eval(k);
        for (int i = max(s, l); i < min(t, r); ++i) {
          minVal = min(minVal, data[i]);
        }
      }
    }
    return minVal;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  SqrtDecomposition sd(n);
  FOR(i,0,q) {
    int f;
    cin >> f;
    if(f) {
      int s,t;
      cin >> s >> t;
      cout << sd.find(s, t+1) << endl;
    } else {
      int s,t,x;
      cin >> s >> t >> x;
      sd.update(s,t+1,x);
    }
  }
}


Measured memory_bytes: 3344
N = int(input())
a= int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())

min_i = -1
min_kazu = 10**20
for i, p in enumerate([a, b, c, d, e]):
    if p < min_kazu:
        min_kazu = p
        min_i = i

nokori = 5-min_i
if N%min_kazu == 0:
    print(4+N//min_kazu)
else:
    print(5+N//min_kazu)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  int a, b, c;
  int tr = 0, rtr = 0, actr = 0, obtr = 0;
  bool end = false;
  while(cin >> a >> b >> c){
    if(a + b <= c || b + c <= a || c + a <= b) break;
    tr++;
    int arr[3] = {a, b, c};
    sort(arr, arr + 3);
    if(arr[0] * arr[0] + arr[1] * arr[1] == arr[2] * arr[2]) rtr++;
    else if(arr[0] * arr[0] + arr[1] * arr[1] > arr[2] * arr[2]) actr++;
    else obtr++;
  }
  printf("%d %d %d %d\n", tr, rtr, actr, obtr);
  return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  if (m / 2 <= n) {
    cout << m / 2 << "\n";
  } else {
    cout << n + (m - 2 * n) / 4 << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

    int i,j,k,l,n;
    scanf("%d", &n);

    for(i=1;i<=n;i++){

        scanf("%d %d %d", &j, &k, &l);
        if((j*j)==(k*k)+(l*l))printf("YES\n");
        else if((k*k)== (j*j)+(l*l))printf("YES\n");
        else if((l*l)==(j*j)+(k*k))printf("YES\n");
        else printf("NO\n");

    }

    return 0;


}

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

using i64 = int64_t;

bool is_ascending(const vector<int> &v){
    bool res = true;
    for(int i=0;i<(int)v.size()-1;++i){
        if(v[i] > v[i+1])res = false;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int p;
        cin >> p;
        v.push_back(p);
    }
    bool flag = is_ascending(v);
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            auto vv = v;
            swap(vv[i], vv[j]);
            if(is_ascending(vv)){
                flag = true;
                break;
            }
        }
        if(flag)break;
    }
    cout << (flag ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct edge{int to, cost;};

int N;
vector<edge> G[111111];
int res[111111];
bool visited[111111];

void rec(int v, int color){
	visited[v] = true;
	res[v] = color;
	for(int i = 0; i < G[v].size(); i++){
		if(visited[G[v][i].to]) continue;
		if(G[v][i].cost % 2 == 0){
			rec(G[v][i].to, color);
		}else{
			rec(G[v][i].to, (color + 1) % 2);
		}
	}
	return ;
}

int main(){
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back((edge){v, w});
		G[v].push_back((edge){u, w});
	}
	fill(visited, visited + N, false);
	rec(0, 0);
	for(int i = 0; i < N; i++){
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 8704