akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

void evaluate(const int *input,int *output);

int main()
{
	while(1)
	{
		int input[5],output[5];
		bool end=false;
		for(int i=0;i<5;i++)
		{
			std::cin>>input[i];
			if(input[i]==0){end=true;break;}
		}
		if(end)break;
		evaluate(input,output);
		for(int i=0;i<5;i++)
		{
			std::cout<<output[i]<<std::endl;
		}
	}
}

void evaluate(const int *input,int *output)
{
	int used[3]={0};
	for(int i=0;i<5;i++)
	{
		used[input[i]-1]=1;
	}
	
	int sum=0;
	for(int i=0;i<3;i++){sum+=used[i];}
	
	if(sum==2)
	{
		int hand;
		int win,lose;
		int j=0;
		for(int i=0;i<3;i++)
		{
			if(used[i]==0)
			{
				hand=i+1;
			}
		}
		switch(hand)
		{
		case 1:
			win=2;
			lose=3;
			break;
		case 2:
			win=3;
			lose=1;
			break;
		case 3:
			win=1;
			lose=2;
			break;
		}
		for(int i=0;i<5;i++)
		{
			if(input[i]==win)
			{
				output[i]=1;
			}
			else if(input[i]==lose)
			{
				output[i]=2;
			}
		}
	}
	else
	{
		for(int i=0;i<5;i++)
		{
			output[i]=3;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>

using namespace std;

const int MAXN = 400 + 100;

int n;
long long s[MAXN];
map<long long, int> cnt;

long long get_ind(int x0, int x1, int x2, int x3)
{
	return (x0) | (x1 << 10) | (x2 << 20) | ((long long)x3 << 30);
}

int get_dig(long long s, int k)
{
	return (s >> (10 * k)) & 1023;
}

void add(long long s, int v)
{
	for(int i = 0; i < 4; i++)
		cnt[s] += v, s = (s >> 10) | ((s & 1023) << 30);
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x0, x1, x2, x3;
		cin >> x0 >> x1 >> x2 >> x3;
		s[i] = get_ind(x0, x1, x2, x3);
		add(s[i], 1);
	}

	long long ans = 0;
	for(int i = 1; i <= n; i++)
	{
		add(s[i], -1);
		for(int j = i + 1; j <= n; j++)
		{
			add(s[j], -1);
			for(int k = 0; k < 4; k++)
			{
				long long t[4] = {
					get_ind(get_dig(s[j], k), get_dig(s[j], (k + 3) % 4), get_dig(s[i], 1), get_dig(s[i], 0)),
					get_ind(get_dig(s[j], (k + 3) % 4), get_dig(s[j], (k + 2) % 4), get_dig(s[i], 2), get_dig(s[i], 1)),
					get_ind(get_dig(s[j], (k + 2) % 4), get_dig(s[j], (k + 1) % 4), get_dig(s[i], 3), get_dig(s[i], 2)),
					get_ind(get_dig(s[j], (k + 1) % 4), get_dig(s[j], k), get_dig(s[i], 0), get_dig(s[i], 3))
				};
				long long tmp = 1;
				for(int l = 0; l < 4; l++)
					if(cnt.find(t[l]) == cnt.end())
					{
						tmp = 0; break;
					}
				if(!tmp) continue;
				for(int l = 0; l < 4; l++)
					tmp *= cnt[t[l]], add(t[l], -1);
				for(int l = 0; l < 4; l++)
					add(t[l], 1);
				ans += tmp;
			}
			add(s[j], 1);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, a[1010], min = 10000000;
    while (true) {
        cin >> n;
        if (n == 0) break;
        else {
            for (int i = 0; i < n; i++) cin >> a[i];
            sort(a, a + n);
            for (int i = 0; i < n - 1; i++) {
                if (a[i + 1] - a[i] < min) min = a[i + 1] - a[i];
            }
            cout << min << endl;
            min = 10000000;
        }
    } 
    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
int main(){
	ll n;
	cin>>n;
	ll k=ceil((db)100*n/108);
	if((k*108/100)==n) cout<<k<<endl;
	else cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int S=in.nextInt();
			if((n|S)==0)
				return;
			int a[]=new int[n];
			int[] r = new int[101];
			while(n--!=0)r[in.nextInt()]++;
			int res = 0;
			for(int i=1;i<101;i++)for(int j=i;j<101;j++){
				if(S<i+j){
					if(i==j)res+=r[i]*(r[i]-1)/2;
					else res+=r[i]*r[j];
				}
			}
			System.out.println(res);
		}
	}
}

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


int main()
{

  int r, c;
  cin>>r>>c;

  char a[r+1][c+1];
  for(int i = 1; i<=r; i++)
  {
    for(int j = 1; j<=c; j++)
    {
      cin>>a[i][j];
    }
  }


  //int a2[2*r][c];
  for(int i = 1; i<=2*r; i++)
  {
    for(int j = 1; j<=c; j++)
    {
      cout<<a[(i+1)/2][j];
    }
    cout<<endl;
  }
  return 0;

}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    long[] A = sc.nextLongList(N);
    
    Arrays.sort(A);

    int ret = 1;
    long now = A[0];
    for (int i = 1; i < N; i ++) {
      if (now * 2 >= A[i]) {
        ret ++;
      } else {
        ret = 1;
      }
      now += A[i];
    }
    System.out.println(ret);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

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

int main(void){
   int n,x,count;
   while(true){
      cin >> n >> x;
      if ((n == 0) && (x == 0)){
         break;
      }
      count = 0;
      for (int i = 1; i <= n; i++){
         for (int j = i + 1; j <= n; j++){
            for (int k = j + 1; k <= n; k++){
               if (i + j + k == x){
                  count += 1;
               }
            }
         }
      }
      cout << count << endl;
   }
}



Measured memory_bytes: 3076
let n = read_int () in
let rec loop i =
    if i = n then true else
        let a = Scanf.scanf " %d" (fun a -> a) in
        if a mod 2 = 0 && (a mod 3 <> 0 && a mod 5 <> 0) then false
        else loop (i + 1)
in
(if loop 0 then "APPROVED" else "DENIED") |> print_endline

Measured memory_bytes: 2432
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,d,x;

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

    itn c = 0;
    rep(i,0,n){
        int a;
        IN a;
        for(int i = 1; i <= d; i += a)c ++;
    }
    P(c + x);
    
	return  0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println(
            br.lines().skip(1)
                .map(s -> Stream.of(s.split(" "))
                    .mapToInt(Integer::parseInt)
                    .sorted()
                    .toArray())
                .map(i -> Math.pow(i[0], 2) + Math.pow(i[1],2) == Math.pow(i[2], 2))
                .map(b -> b ? "YES" : "NO")
                .collect(joining("\n")));
    }
}

Measured memory_bytes: 31836
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextInt();
        long W = sc.nextInt();

        if (H == 1 || W == 1) {
            System.out.println(1);
            return;
        }

        if (H % 2 == 0 || W % 2 == 0) {
            System.out.println(H * W / 2);
        } else{
            System.out.println(H * W / 2 + 1);
        }

        return;
    }

}

Measured memory_bytes: 23252
N = int(input())
A = list(map(int, input().split()))
swap_counter = 0
for i in range(N):
    min_temp = i
    for j in range(i, N, 1):
        if A[j] < A[min_temp]:
            min_temp = j
    if i < min_temp:
        A[i], A[min_temp] = A[min_temp], A[i]
        swap_counter += 1
A_str = [str(a) for a in A]
result = ' '.join(A_str)
print(result)
print(swap_counter)


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int prefix[200005];
const int mod = 2019;
unordered_map<int, int> cnt;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s; cin>>s;
    int n = s.length();
    prefix[n-1] = s[n-1]-'0';
    int ans = 0;
    cnt[0]++;
    cnt[prefix[n-1]]++;
    int mul = 10;
    for(int i = n-2; i >= 0; i--){
        prefix[i] = (mul*(s[i]-'0')+prefix[i+1])%mod;
        ans += cnt[prefix[i]];
        cnt[prefix[i]]++;
        mul = (mul*10)%mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4476
N, M = map(int, input().split())

class UnionFind():

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

uf = UnionFind(N)
for i in range(M):
    X, Y, Z = map(int, input().split())
    uf.union(X-1, Y-1)
print(len(uf.roots()))


Measured memory_bytes: 7856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

    if (N == 0) {
        cout << X;
        exit(0);
    }

    int d = 200;
    rep(d, N) {
        bool mflag = false;
        bool pflag = false;
        rep(i, N) {
            if (p[i] == X - d) mflag = true;
            if (p[i] == X + d) pflag = true;
        }
        if (mflag == false) {
            cout << X - d;
            exit(0);
        }
        if (pflag == false) {
            cout << X + d;
            exit(0);
        }
    }
    cout << X - N;
}

Measured memory_bytes: 3628
n = int(input())
import math
ans = float('Inf')
sq = int(math.sqrt(n)) + 1
for i in range(1, sq):
    #print(i, n // i)
    if n % i != 0:
        continue
    #print(i, n // i)
    ans = min(ans, max(len(str(i)), len(str(n // i))))
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            long[] dp = new long[N + 1];
            for(var i = 0; i <= N; i++)
            {
                dp[i] = i;
            }

            for(var i = 0; i <= N; i++)
            {
                for(var j = 1; i - Pow(6, j) >= 0; j++)
                {
                    dp[i] = Min(dp[i], dp[i - (int)Pow(6, j)] + 1);
                }

                for(var j = 1; i - Pow(9, j) >= 0; j++)
                {
                    dp[i] = Min(dp[i], dp[i - (int)Pow(9, j)] + 1);
                }
            }

            Console.WriteLine(dp[N]);


            //Console.Out.Flush();
        }

        

    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 11616
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



//jizenn tesuto sagyou
int main() {
	char S[101], T[101], tmp;
	scanf("%s%s", &S, &T);
	for (int i = 0; i < strlen(S) - 1; i++) {
		for (int j = i + 1; j < strlen(S); j++) {
			if (S[i] > S[j]) {
				tmp = S[i];
				S[i] = S[j];
				S[j] = tmp;
			}
		}
	}
	for (int i = 0; i < strlen(T) - 1; i++) {
		for (int j = i + 1; j < strlen(T); j++) {
			if (T[i] < T[j]) {
				tmp = T[i];
				T[i] = T[j];
				T[j] = tmp;
			}
		}
	}
	if (strcmp(S, T) < 0) {
		puts("Yes");
	}
	else {
		puts("No");
	}



#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
s = input()

ans = True
if s[0] is not "A":
  ans = False
if s[1] is "C" or s[-1] is "C":
  ans = False
if "C" not in s:
  ans = False
if s.count("C") > 1 or s.count("A") > 1:
  ans = False
for c in s:
  if c is not "A" and c is not "C" and c.isupper():
    ans = False

if ans == True:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string s,t;

int main(){
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t){
        out("Yes");
    }
    else{
        out("No");
    }
}


Measured memory_bytes: 256
s=input()
l,r=0,len(s)-1
cnt=0
while l<r:
    if s[r]!=s[l]:
        cnt +=1
        if s[l]=="x":l +=1
        elif s[r]=="x":r -=1
        else:print(-1);exit()
    else:
        r -=1
        l +=1
print(cnt)

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


int main() {

  int64_t a,b,c;
  cin>>a>>b>>c;


  int64_t cnt=0;

  if(a==b&&b==c&&a%2!=0){
    cnt=0;
  }
  else if(a==b&&b==c){
    cnt=-1;
  }
  else{
    while(1){
      if(a%2!=0||b%2!=0||c%2!=0)
        break;

      int64_t wk_a=a,wk_b=b,wk_c=c;

      a=wk_b/2+wk_c/2;
      b=wk_a/2+wk_c/2;
      c=wk_b/2+wk_a/2;

      cnt++;
    }
  }

  cout<<cnt<<endl;

  return 0;
}

/*
//最初
A;
B;
C;
//1回目
A=B/2+C/2
B=A/2+C/2
C=A/2+B/2
A,B,C全部同じだったら//無限回繰り返す。
A=A
B=A
C=A
//2回目
A=A/4+C/4+A/4+B/4=A/2+C/4+B/4;
B=B/4+C/4+A/4+B/4=B/2+C/4+A/4;
C=A/4+C/4+B/4+C/4=C/2+A/4+B/4;
//3回目
A=(B/4+C/8+A/8)+(C/4+A/8+B/8)=A/4+3B/8+3C/8;
B=(C/4+A/8+B/8)+(A/4+C/8+B/8)=B/4+3A/8+3C/8;
C=(B/4+C/8+A/8)+(A/4+C/8+B/8)=C/4+3B/8+3A/8;
//4回目
A=(B/8+3A/16+3C/16)+(C/8+3B/16+3A/16) =3A/8+5B/16+5C/16;
B=(A/8+3B/16+3C/16)+(C/8+3B/16+3A/16) =3B/8+5A/16+5C/16;
C=(A/8+3B/16+3C/16)+(B/8+3A/16+3C/16) =3C/8+5B/16+5A/16;
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int ans[55];
    for(int i = 0;i<n;i++){
        scanf("%d",&ans[i]);
    }
    sort(ans,ans+n);
    int result = 0;
    for (int i = n-1;i>=n-m;i--){
        result+=ans[i];
    }
    cout<<result<<endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll mp[333333];
ll hist[333333];

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

	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n){
		ll a;cin >> a;
		mp[a]++;
		hist[mp[a]]++;
	}

	REP(i, 333333 - 1)hist[i+1] += hist[i];

	for(int i = 1;i <= n;i++){
		ll now = hist[n/i];
		while(hist[now/i] != now){
			now = hist[now/i];
		}
		cout << now / i << "\n";
	}

	return 0;
}


Measured memory_bytes: 8192
r=input().strip().split()
N=int(r[0])
a=int(r[1])
z=input().strip().split()
s=0
for p in range (a):
    s+=(1+int(z[p]))/2
maximum=s

for j in range (0,N-a):
  s-=(1+int(z[j]))/2
  s+=(1+int(z[j+a]))/2
  if s>maximum:
    maximum=s

print(maximum)

Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
 
const double DEG = 90.0 / acos(0.0);
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int a, b;
  double x;
  cin >> a >> b >> x;
  x = 2*x / (double)a;
  int vol = a*b;
  if(x <= vol) {
    double h = x/(double)b;
    printf("%.8lf\n", 90 - atan2(h, b)*DEG);
  } else {
    double t = x/(double)a - b;
    printf("%.8lf\n", 90 - atan2(a, b-t)*DEG);
  }
 
  return 0;
}

Measured memory_bytes: 512
def main():
    """
    """
    N, M, Q = map(int, input().split())
    L, R = zip(*(
        map(int, input().split())
        for _ in range(M)
    ))
    p, q = zip(*(
        map(int, input().split())
        for _ in range(Q)
    ))

    # answers = f(N, M, Q, L, R, p, q)
    # experiment(N, M, Q, L, R, p, q)
    # answers = TLE(N, M, Q, L, R, p, q)
    answers = editorial_2(N, M, Q, L, R, p, q)
    for ans in answers:
        print(ans)


def editorial_2(N, M, Q, L, R, p, q):
    """
    ２次元累積和のライブラリを持っておくとよいらしい
        確かに実装ミスりそう
    """
    t = [[0] * (N+1) for _ in range(N+1)]
    for l, r in zip(L, R):
        t[l][r] += 1

    # 二次元累積和
    # 積分画像と同じ
    for l in range(1, N+1):
        for r in range(1, N+1):
            t[l][r] += t[l][r-1]
    for l in range(1, N+1):
        for r in range(1, N+1):
            t[l][r] += t[l-1][r]

    answers = []
    for l, r in zip(p, q):
        ans = 0
        ans += t[r][r]
        ans -= t[l-1][r]
        ans -= t[r][l-1]
        ans += t[l-1][l-1]

        answers.append(ans)

    return answers


def editorial_1(N, M, Q, L, R, p, q):
    # Lごとの累積和
    t1 = [[0] * (N+1) for _ in range(N+1)]
    t2 = [[0] * (N+1) for _ in range(N+1)]
    # LRの組合せ, N<=500より間に合う
    for l, r in zip(L, R):
        t1[l][r] += 1

    for l in range(1, N+1):
        for r in range(1, N+1):
            t2[l][r] = t2[l][r-1] + t1[l][r]

    answers = []
    for _p, _q in zip(p, q):
        ans = 0
        for l in range(_p, _q+1):
            ans += t2[l][_q] - t2[l][_p-1]

        answers.append(ans)

    return answers


def TLE(N, M, Q, L, R, p, q):
    """
    10^5 * 10^5
    """
    answers = []
    for _p, _q in zip(p, q):
        ans = 0
        for left, right in zip(L, R):
            if _p <= left and right <= _q:
                ans += 1

        answers.append(ans)

    return answers


if __name__ == '__main__':
    main()


Measured memory_bytes: 105248
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();  //number_of_cards
      int r = sc.nextInt();  //number_of_cutting
      if(n==0&&r==0)break;

      int[] deck = new int[n];
      int[] temp = new int[n];
      for(int i=0;i<n;i++){
        deck[i] = n-i;
      } //assign_numbers_to_each_cards_in_descending order

      for(int i=0;i<r;i++){  //do_cutting
        int p = sc.nextInt();
        int c = sc.nextInt();
        System.arraycopy(deck,p-1,temp,0,c);
        System.arraycopy(deck,0,deck,c,p-1);
        System.arraycopy(temp,0,deck,0,c);
      }

      System.out.println(deck[0]);
    } //end_of_while
  }
}

Measured memory_bytes: 36400
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

typedef tree<
        pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1e7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/

const ll N = 1e17;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin>>n;
    vector<ll> a(n+1);
    for (int i = 0; i<=n; i++) cin>>a[i];
    if (a[0]>=1)
    {
        if (n==0 && a[0]==1) {cout<<1; return 0;}
        else {cout<<-1; return 0;}
    }

    if (n==0)
    {
        if (a[0]==1) {cout<<1; return 0;}
        else {cout<<-1; return 0;}
    }

    vector<ll> minn(n+1), maxx(n+1);
    minn[0] = 1;
    maxx[0] = 1;
    for (int i = 1; i<=n; i++)
    {
        minn[i] = max(a[i], minn[i-1] - a[i-1]);
        maxx[i] = min(N, 2*(maxx[i-1] - a[i-1]));
        if (minn[i]>maxx[i]) {cout<<-1; return 0;}
    }

    ll res = 0;

    if (a[n]>maxx[n]||a[n]<minn[n]) {cout<<-1; return 0;}
    ll cur = a[n];
    res+=cur;
    for (int i = n-1; i>=0; i--)
    {
        cur = min(maxx[i], cur+a[i]);
        res+=cur;
    }
    cout<<res;

}



Measured memory_bytes: 5572
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r


import sys
# sys.stdin = open('input.txt')

s = list(map(int, input().split()))
p1 = Point(s[0], s[1])
p2 = Point(s[2], s[3])
segment = Segment(p1, p2)

q = int(input())
for i in range(q):
    x, y = map(int, input().split())
    p = Point(x, y)
    ans = project(segment, p)
    print(ans)


Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=len(s);
    ll now=1;
    vector<vector<ll> > dp(n+1,vector<ll>(13,0));
    dp[0][0]=1;
    rep(i,n){
      if(s[i]=='?') rep(j,10)rep(k,13)(dp[i+1][(10*k+j)%13]+=dp[i][k])%=mod;
      else rep(k,13)(dp[i+1][(10*k+(s[i]-'0'))%13]+=dp[i][k])%=mod;
    }
    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 13648
#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); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;

ll dp[55][55][2505];

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

int N,A;
cin >> N >> A;
vl x(N);
rep(i,N) cin >> x[i];

dp[0][0][0] = 1;
rep(i,N)rep(j,N)rep(k,2500){
    dp[i+1][j][k] += dp[i][j][k];
    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
}
ll ans = 0;
rrep(i, N) {
    ans += dp[N][i][i*A];
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 54528
N = int(input())
num_list = [int(i) for i in input().split(' ')]

even_counter = 0
for n in range(N):
  if num_list[n]%2 != 0:
    print('0')
    break
  else:
    even_counter += 1
  
  if even_counter == N:
    min_counter = float('inf')
    for i in range(N):
          num =  num_list[i]
          counter = 0
          while num%2 == 0:
            counter += 1
            num //= 2
          if counter <= min_counter:
            min_counter = counter
      
    print(min_counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n;
P p[214514];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i].first;
		p[i].second = i;
	}
	sort(p, p + n);
	set<int>st;
	st.insert(-1); st.insert(n);
	int ans = 0;
	rep(i, n) {
		auto it1 = st.lower_bound(p[i].second);
		auto it2 = it1;
		it1--;
		ans += (p[i].second - *it1) * (*it2 - p[i].second) * p[i].first;
		st.insert(p[i].second);
	}
	cout << ans << endl;
}

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



 string S;
 int ans=0;
 int r, D, x2000;

 int main () {
      cin >> r >> D >> x2000;
      
       for(int i=0;i<10;i++){
           cout << r*x2000-D << endl;
           x2000 = r * x2000 - D;
       }
 }


Measured memory_bytes: 256
//辞書順最小を求めるので、1個前の状態を覚えるやり方では
//00[0], 10[0]のような場合に上手くいかない。よって、後ろから計算し、前から復元する方法を取る。
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

string s[2];
int Next[2][2][4002];	//Next[i][j][k] = 文字iを, s[j][k]から検索したときに、最初に現れる場所
int dp[4002][4002];		//dp[i][j] = s[0][i], s[1][j]から検索を始めるときの、non-common-subseqenceの最小の長さ
						//終端位置はs[i].length()（最後の文字を取った直後）ではなくて
						//s[i].length() + 1（見つからなかった直後）であることに注意.

int main() {
	int i, j, k;
	
	cin >> s[0] >> s[1];
	int n = s[0].length();
	int m = s[1].length();
	
	rep(i, 2) {
		rep(j, 2) {
			Next[i][j][s[j].length() + 1] = s[j].length();
			Next[i][j][s[j].length()] = s[j].length();
			rrep(k, s[j].length()) {
				if (s[j][k] == (char)('0' + i)) {
					Next[i][j][k] = k;
				}
				else {
					Next[i][j][k] = Next[i][j][k + 1];
				}
			}
		}
	}
	
	rep(i, n + 2) rep(j, m + 2) dp[i][j] = 1e+9;
	
	dp[n + 1][m + 1] = 0;
	rrep(i, n + 2) {
		rrep(j, m + 2) {
			rep(k, 2) {	//文字kを追加
				int iter1 = Next[k][0][i] + 1;
				int iter2 = Next[k][1][j] + 1;
				chmin(dp[i][j], dp[iter1][iter2] + 1);
			}
		}
	}
	
	//dp[0][0]に最小の長さが入っている。ここからは復元。
	int iter1 = 0;
	int iter2 = 0;
	string ans;
	
	while (iter1 < n + 1 || iter2 < m + 1) {
		rep(i, 2) {	//dp[iter1][iter2] -> 文字iを追加 を仮定してみる
			int it1 = Next[i][0][iter1] + 1;
			int it2 = Next[i][1][iter2] + 1;
			if (dp[iter1][iter2] == dp[it1][it2] + 1) {
				break;
			}
		}
		assert(i < 2);
		ans += (char)(i + '0');
		iter1 = Next[i][0][iter1] + 1;
		iter2 = Next[i][1][iter2] + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 65784
def main():
    N = int(input())

    orda = ord('a')
    ans = ''
    
    while N:
        N -= 1
        N, Nmod = divmod(N, 26)
        ans = chr(orda + Nmod) + ans

    print(ans)


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 9168
#include <iostream>
#include <queue>
using namespace std;
 
void dfs(int cur);
int df[100][2]={};
bool dc[100]={};
bool adj[100][100]={};//初期化を忘れない
int n,u,v,k;
int t = 1;
queue<int> q;
 
int main(){
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> u >> k;
    for (int j=0; j<k; j++){
      cin >> v;
      adj[u-1][v-1] = true;
    }
  }
   
  //探索は一回で終わるとは限らない　グラフは非連結の場合もある？
  for (int i=0; i<n; i++){
    if (dc[i] != true)
      dfs(i);
  }
   
   
  for (int i=0; i<n; i++)
    cout << i+1 << " " << df[i][0] << " " << df[i][1] << endl;
 
}
 
void dfs(int cur){
  dc[cur] = true;
  df[cur][0] = t;
  t += 1;
  for (int i=0; i<n; i++){
    if (adj[cur][i] && !dc[i]){
      dfs(i);
    }
  }
  df[cur][1] = t; 
  t += 1;
}

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

int main(){
  int N; cin >> N;
  long a[N],b[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  
  sort(b, b+N);
  long mid1, mid2;
  mid1 = b[N/2-1];
  mid2 = b[N/2];
  
  for(int i=0; i<N; i++){
    if(a[i]<=mid1){cout << mid2;}
	else{cout << mid1;}
    if(i!=N-1){cout << endl;}
  }
  
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
typedef long long int ll;
#define pi 3.1415926535897932384626433832795
using namespace std;


int main() {
	
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	
  

    long double hour_angle = 0.5 * (h * 60 + m);  
    long double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    long double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle); 
    
    long double side=a*a+b*b-(2*a*b*cos((angle*pi)/180.0));
    cout<<fixed<<setprecision(20)<<sqrt(side)<<"\n";
    
  
    
	

	
	return 0;
}


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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m,c;
    
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int&i:b)cin>>i;
    
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0; i<n; i++){
        for(int&j:a[i]) cin>>j;
    }
    int ans=0;
    for(int i=0; i<n; i++){
        int val=c;
        for(int j=0; j<m; j++){
            val+=a[i][j]*b[j];
        }
        ans+=val>0;
    }
    cout<<ans;
    
}

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

ll n, m;
vector<vector<ll>> net;
vector<pair<ll, ll>> rule;

map<pair<ll, ll>, set<ll>> e2r;

void search(ll cur, ll parent, vector<ll>& state){
    REP(i, rule.size()){
        if(rule.at(i).first == cur || rule.at(i).second == cur){
            state.at(i)++;
        }
    }

    for(ll nxt : net.at(cur)){
        if(nxt == parent){ continue; }
        vector<ll> tmp = state;
        search(nxt, cur, state);
        REP(i, tmp.size()){
            if(tmp.at(i) + 1 == state.at(i)){
                e2r[{cur, nxt}].insert(i);
            }
        }
    }
}

int main(){
    cin >> n;
    net.resize(n);
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).push_back(b);
        net.at(b).push_back(a);
    }

    cin >> m;
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        rule.emplace_back(a, b);
    }

    vector<ll> state(rule.size(), 0);
    search(0, -1, state);

    ll ans = 0;
    REP(s, (1LL << m)){
        vector<bool> use(m, false);
        REP(j, m){
            if((s >> j) & 1){
                use.at(j) = true;
            }
        }

        ll ne = 0;
        for(auto it = e2r.begin(); it != e2r.end(); ++it){
            for(ll ri : it->second){
                if(use.at(ri)){
                    ne++;
                    break;
                }
            }
        }

        const ll tmp = 1LL << (n - 1 - ne);
        if(accumulate(use.begin(), use.end(), 0) % 2 == 1){
            ans -= tmp;
        }else{
            ans += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=1e5+5,M=N*60;

typedef long long LL;

int n,K,L[M],R[M],tot,rt,a[N],b[N],s;

LL T[M],ans,fl,fr;

bool tag[M];

char c;

int read()
{
    int x=0,sig=1;
    for (c=getchar();c<'0' || c>'9';c=getchar()) if (c=='-') sig=-1;
    for (;c>='0' && c<='9';c=getchar()) x=x*10+c-48;
    return x*sig;
}

void push_down(int x)
{
	if (!tag[x]) return;
	tag[L[x]]=1; T[L[x]]=T[0]; tag[R[x]]=1; T[R[x]]=T[0];
	tag[x]=0;
}

void Ins(int l,int r,int g,LL v,int &x)
{
	if (!x) x=++tot;else push_down(x);
	if (l==r)
	{
		T[x]=min(v,T[x]); return;
	}
	int mid=l+r>>1;
	if (g<=mid) Ins(l,mid,g,v,L[x]);else Ins(mid+1,r,g,v,R[x]);
	T[x]=min(T[L[x]],T[R[x]]);
}

void Del(int l,int r,int a,int b,int x)
{
	if (!x) return;
	if (l==a && r==b)
	{
		tag[x]=1; T[x]=T[0]; return;
	}
	push_down(x);
	int mid=l+r>>1;
	if (b<=mid) Del(l,mid,a,b,L[x]);else if (a>mid) Del(mid+1,r,a,b,R[x]);else
	{
		Del(l,mid,a,mid,L[x]); Del(mid+1,r,mid+1,b,R[x]);
	}
	T[x]=min(T[L[x]],T[R[x]]);
}

LL getmin(int l,int r,int a,int b,int x)
{
	if (!x || l==a && r==b) return T[x];
	push_down(x);
	int mid=l+r>>1;
	if (b<=mid) return getmin(l,mid,a,b,L[x]);
	if (a>mid) return getmin(mid+1,r,a,b,R[x]);
	return min(getmin(l,mid,a,mid,L[x]),getmin(mid+1,r,mid+1,b,R[x]));
}

void getans(int l,int r,int x)
{
	if (!x) return;
	if (l==r)
	{
		ans=min(ans,T[x]+l); return;
	}
	push_down(x);
	int mid=l+r>>1;
	getans(l,mid,L[x]); getans(mid+1,r,R[x]);
}

int main()
{
	memset(T,127,sizeof(T));
	n=read(); K=read();
	Ins(0,K-1,0,0,rt);
	for (int i=1,l,r;i<=n;i++)
	{
		a[i]=read(); b[i]=read();
		r=s;
		s=((s-2*a[i])%K+K)%K;
		l=s;
		if (b[i]==2)
		{
			l=K-1; r=0;
		}else if (a[i]*2>K)
		{
			printf("-1\n"); return 0;
		}
		Ins(0,K-1,l,-l,rt); Ins(0,K-1,r,-r,rt);
	}
	s=0;
	for (int i=1,l,r;i<=n;i++)
	{
		r=s;
		s=((s-2*a[i])%K+K)%K;
		l=s;
		if (b[i]==2)
		{
			l=K-1; r=0;
		}
		fl=fr=T[0];
		fl=min(getmin(0,K-1,0,l,rt),getmin(0,K-1,l,K-1,rt)+K);
		fr=min(getmin(0,K-1,0,r,rt),getmin(0,K-1,r,K-1,rt)+K);
		Ins(0,K-1,l,fl,rt); Ins(0,K-1,r,fr,rt);
		if (l<r)
		{
			if (l+1<=r-1) Del(0,K-1,l+1,r-1,rt);
		}else
		{
			if (l+1<K) Del(0,K-1,l+1,K-1,rt);
			if (r>0) Del(0,K-1,0,r-1,rt);
		}
	}
	ans=T[0];
	getans(0,K-1,rt);
	if (ans==T[0]) printf("-1\n");else
	{
		for (int i=1;i<=n;i++) ans+=a[i]*2;
		printf("%lld\n",ans);
	}
    return 0;
}

Measured memory_bytes: 65024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 int i = 0;
 string y; 
 bool hasYellow = false;
  
  while (i < N) {
  	cin >> y;
    if (y == "Y") {
      hasYellow = true;
    }
    i++;
  }
  if (hasYellow) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
 
}


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

int main() {
  int N;
  int num = 0;
  cin >> N;
 
  rep(i, N)
  {
    int l, r;
    cin >> l >> r;
    num += r - l + 1;
  }
  cout << num << endl;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b;
    char op;

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

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        op = sc.next().charAt(0);
        b = sc.nextInt();
        solve();
    }

    void solve() {
        if (op == '+') {
            System.out.println(a + b);
        } else {
            System.out.println(a - b);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int x,n;
  cin>>x>>n;
  int p;
  set<int> s;
  rep(i,n){
    cin>>p;
    s.insert(p);
  }
  int i=0;
  int ans;
  while(1){
    int now=x+i;
    int nl=x-i;
    if(s.find(nl)==s.end()){
      ans=nl;
      break;
    }
    if(s.find(now)==s.end()){
      ans=now;
      break;
    }
    i++;
  }
  
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3632