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

bool check(std::string s){
    bool three=false,five=false,seven=false;
    for(char c : s){
        if(c == '3') three=true;
        if(c == '5') five=true;
        if(c == '7') seven=true;
    }
    return three && five && seven;
}
ll dfs(std::string s, int n){
    if(std::stol(s) > n) return 0;
    ll ans=0;
    if(check(s)) ++ans;
    std::string ss[] = {"3","5","7"};
    for(auto c : ss){
        auto t = s+c;
        ans += dfs(t,n);
    }
    return ans;
}

int main(){
    ll n; std::cin >> n;
    ll ans=dfs("0",n);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>


int main(){

  int A[1000],i,j,k,v,N;

  scanf("%d",&N);
 

  for(i = 0; i < N ;i++){
    scanf("%d",&A[i]);
  }

  
  for(k = 0; k < N ;k++){
    if(k != N-1){
    printf("%d ",A[k]);
  }
    else printf("%d\n",A[k]);
  }

  for(i = 1; i <= N-1 ;i++){
  
    v = A[i];
    j = i - 1;
   
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
  
    }

    for(k = 0; k < N ;k++){
      if(k != N-1){
	printf("%d ",A[k]);
      }

      else    printf("%d\n",A[k]);

    }

    
  }

  return 0;
}
  

    



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

    int x,y;

    cin>>x>>y;

    if(x*2>y || x*4<y || y%2){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3652
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input:Vec<String> = s.split_whitespace().map(|x| x.parse::<String>().unwrap()).collect();
    let mut v = input[0].chars().collect::<Vec<char>>();
    v.sort();
    let mut state = 0;
    let ref vv = v.into_iter().collect::<String>();
    if vv == "abc" {state = 1}
    let ans = vec!["No", "Yes"];
    println!("{}", ans[state]);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]

PY.sort(key=lambda x:x[1])
ans = []
cnt = [0] * N
for p, y, i in PY:
  ans.append(("{0:06d}".format(p)+"{0:06d}".format(cnt[p-1]+1), i))
  cnt[p-1] += 1
ans.sort(key=lambda x:x[1])
for a in ans:
  print(a[0])




Measured memory_bytes: 44488
#include <stdio.h>

int around[4][2] = {
  {0, 1},
  {1, 0},
  {0, -1},
  {-1, 0}
};

int main(){
  int h, w;  scanf("%d %d", &h, &w);
  char field[52][52];
  for(int i=0; i<h; i++)
    scanf("%s", field[i]);

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(field[i][j] == '#'){
	int flag = 1;
	for(int a=0; a<4; a++){
	  int ai = i + around[a][0];
	  int aj = j + around[a][1];
	  if(ai < 0 || ai >= h || aj < 0 || aj >= w)  continue;
	  if(field[ai][aj] == '#')  flag = 0;
	}
	if(flag){
	  printf("No\n");
	  return 0;
	}
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;
const int N = 3e5 + 6;
int n;
int h, w;
struct T {
	int l, r, v;
}a[N];
bool cmp(T x, T y) {
	return x. v > y.v;
}
int g[N], fa[N];
int Find(int x) {
	return fa[x] == x? x : fa[x] = Find(fa[x]);
}
int check(int x, int y) {
	x = Find(x), y = Find(y);
	if(x == y) {
		if(g[x]) {
			--g[x];
			return 1;
		} 
		return 0;
	}
	fa[x] = y;
	g[y] += g[x];
	if(g[y] == 0) return 0;
	--g[y];
	return 1;
}
int main() {
	n = read(), h = read(), w = read();
	for(int i = 1; i <= n; ++i) {
		a[i].l = read();
		a[i].r = read();
		a[i].v = read();
	}
	ll ans = 0;
	sort(a + 1, a + 1 + n, cmp);
	for(int i = 1; i <= h + w; ++i) fa[i] = i, g[i] = 1;
	for(int i = 1; i <= n; ++i) if(check(a[i].l, a[i].r + h)){
		ans += a[i].v;
	}
	writeln(ans);
 	return 0;
}

Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String A = scan.next();
        char[] data_A = A.toCharArray();
        String B = scan.next();
        char[] data_B = B.toCharArray();
        String C = scan.next();
        char[] data_C = C.toCharArray();
        int answer = 0;
        for (int i = 0; i < N; i++) {
            HashSet<Character> set = new HashSet<>();
            set.add(data_A[i]);
            set.add(data_B[i]);
            set.add(data_C[i]);
            if (set.size() == 1) {
                continue;
            }
            if (set.size() == 3) {
                answer += 2;
                continue;
            }
            answer += 1;
        }
        System.out.println(answer);
    }
}


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

int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    if (b == 'C') cout << 'G' << endl;
    if (b == 'G') cout << 'C' << endl;
    if (b == 'T') cout << 'A' << endl;
}

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

int main(){
	int n;cin>>n;
	string s;cin>>s;
	int c=1;
	
//	int c=1;
	int i=1;
	for(i=1;i<s.length();i++){
		if(s[i]==s[i-1]){
			continue;
		}
		else{
			c++;
		}
	}
	cout<<c<<endl;
	
	return 0;
}

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

int d,n,ans;

int main(){

 cin>>d>>n;

 if(n==100){
     ans=pow(100,d)*101;
 }
 else{
     ans=pow(100,d)*n;
 }

 cout<<ans<<endl;

 return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    string s; cin >> s;
    string ans;
    rep(i, 0, s.size()){
        if (s[i] == 'B'){
            if (ans.size()==0) continue;
            else ans.pop_back();
        }else if (s[i] == '1'){
            ans += '1';
        }else{
            ans += '0';
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

	int add = A + B;
	int sub = A - B;
	int mul = A * B;

	int ans = max(add, sub);
	ans = max(mul, ans);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
void solve(){
  string s ,t ; cin >> s >> t ;
  t.pop_back() ;
  cout << (s==t?"Yes":"No") << endl ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'




int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
     // int t;
     // cin >> t;

     // while(t--){
 		

     // }
int x;
cin >> x;
if(x >= 30){
	cout << "Yes" << endl;
}
else cout << "No" << endl;



return 0;
}




Measured memory_bytes: 3632
check_list_S = [0] * 13
check_list_H = [0] * 13
check_list_C = [0] * 13
check_list_D = [0] * 13
input_number = int(input())

for i in range(input_number):
    input_data = list(input().split())
    check_mark = str(input_data[0])
    check_number = int(input_data[1])
    if check_mark == "S":
        check_list_S[check_number-1] += 1
    elif check_mark == "H":
        check_list_H[check_number-1] += 1
    elif check_mark == "C":
        check_list_C[check_number-1] += 1
    elif check_mark == "D":
        check_list_D[check_number-1] += 1

for i in range(13):
    if check_list_S[i] == 0:
        print(f"S {i+1}")
for i in range(13):
    if check_list_H[i] == 0:
        print(f"H {i+1}")
for i in range(13):
    if check_list_C[i] == 0:
        print(f"C {i+1}")
for i in range(13):
    if check_list_D[i] == 0:
        print(f"D {i+1}")



Measured memory_bytes: 5628
# coding: utf-8
# Your code here!
S=input()
N=len(S)

l=[]*9
count=0
for i in range(2**(N-1)):
    prev=0
    for j in range(N-1):
        if i>>j&1==1:
            count+=int(S[prev:j+1])
            prev=j+1
    count+=int(S[prev:N])
print(count)            

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] dice = Console.ReadLine().Split(' ');

            char[] flow = Console.ReadLine().ToCharArray();

            var diceclass = new Dice2(int.Parse(dice[0]), int.Parse(dice[1]), int.Parse(dice[2]), int.Parse(dice[3]), int.Parse(dice[4]), int.Parse(dice[5]));

            //????§??????°??????????????????????????????
            for(int i = 0; i < flow.Length; i++)
            {
                diceclass.MoveDice(flow[i].ToString());
            }

            Console.WriteLine(diceclass.Up);
        }

    }

    class Dice2
    {
        //??????????????°
        int N = -1;
        int Under = -1;
        int E = -1;
        int W = -1;
        public int Up = -1;
        int S = -1;

        Dictionary<string, int> diceEye;


        #region ?????????????????????
        //????????????????????¨????????????????????????
        public Dice2(int up, int s, int e, int w, int n, int under)
        {
            CreateDictionary(up, s, e, w, n, under);

            Up = up;
            S = s;
            E = e;
            W = w;
            N = n;
            Under = under;
        }
        #endregion



        public void MoveDice(string direction)
        {
            //????????¨????????°???????§??????????????????????
            this.Under = this.diceEye[direction];


            //????????¨???Under?????°???????????°???????§??????????
            //??¢?????????????§??????°??????????????????(S ??? N, W ??? E)
            switch (direction)
            {
                case "S":
                    this.N = this.diceEye["Under"];
                    this.S = this.diceEye["Up"];
                    this.Up = this.diceEye["N"];
                    break;


                case "E":
                    this.W = this.diceEye["Under"];
                    this.E = this.diceEye["Up"];
                    this.Up = this.diceEye["W"];
                    break;


                case "N":
                    this.S = this.diceEye["Under"];
                    this.N = this.diceEye["Up"];
                    this.Up = this.diceEye["S"];
                    break;


                case "W":
                    this.E = this.diceEye["Under"];
                    this.W = this.diceEye["Up"];
                    this.Up = this.diceEye["E"];
                    break;
            }

            //?????£????????§??????????????????
            CreateDictionary(this.Up, this.S, this.E, this.W, this.N, this.Under);
        }


        //?????£????????§?????????????????????
        public void CreateDictionary(int up, int s, int e, int w, int n, int under)
        {
            this.diceEye = new Dictionary<string, int>();

            this.diceEye.Add("Up", up);
            this.diceEye.Add("S", s);
            this.diceEye.Add("E", e);
            this.diceEye.Add("W", w);
            this.diceEye.Add("N", n);
            this.diceEye.Add("Under", under);

        }

    }




}

Measured memory_bytes: 9304
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M,X;
    cin>>N>>M>>X;
    int ans1=0,ans2=0;
    REP(i,M){
        int a; cin>>a;
        if(a<X) ans1++;
        if(a>X) ans2++;
    }
    cout<<min(ans1,ans2)<<endl;

}


Measured memory_bytes: 256
from sys import stdin
from operator import itemgetter

input = stdin.readline

N, M = map(int, input().split())

AB = [[int(j) for j in input().split()] for i in range(N)]


def main():
    AB.sort(key=itemgetter(0))
    num = 0
    yen = 0
    for i in range(N):
        if M < num + AB[i][1]:
            yen += AB[i][0] * (M - num)
            break
        else:
            yen += AB[i][0] * AB[i][1]
            num += AB[i][1]
    print(yen)
    return


main()


Measured memory_bytes: 22804
N = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if(a[j] < a[minj]):
            minj = j
    hold = a[i]
    a[i] = a[minj]
    a[minj] = hold
    if(minj != i): count += 1

print(" ".join(list(map(str, a))))
print(count)

Measured memory_bytes: 7684
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	long long x;
	cin >> x;
	long long now = 100;
	for (int i = 1; ; ++i) {
		now = 1.01l * now;
		if (now >= x) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3752
from sys import stdin
from collections import defaultdict
mod = 10**9+7
N = int(stdin.readline().rstrip())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
  
ans = 1
fact = defaultdict(int)
for i in range(2,N+1):
    for j,k in factorize(i):
        fact[j] += k

for l in fact.values():
    ans *= (l+1)
    ans %= mod
print(ans%mod)

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

int main(){
                                                                     

    string s;

    int i;

    
    cin >> s;


    for( i = 0 ; i < s.size() - 1 ; i = i + 1 ){

         if( s.substr(i, 2) == "AC" ){

             cout << "Yes" << endl;

             return 0;

             }

         }


    cout << "No" << endl;


    return 0;

    }

Measured memory_bytes: 256
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def main():
    X = ri()
    K = 360 // gcd(360, X)
    print(K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],b[N];
bool flag=true;
vector<int>v;
int cal(int i)
{
    int ans=0;
    for(int j=i;j<=n;j+=i)
        ans+=b[j];
    return ans;
}
int main()
{
    int res=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=n;i>=1;i--)
    {
        int x=cal(i);
        if(x%2!=a[i]) b[i]=1,v.push_back(i);
    }
    if(!flag) printf("-1\n");
    else
    {
        printf("%d\n",v.size());
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
            printf(i==v.size()-1?"%d\n":"%d ",v[i]);
    }
}


Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<numeric>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define stop char nyaa;cin>>nyaa;

//keta,Nより小さい,51?3の回数
ll dp[19][2][5];



void solve() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<int> d(m + q), a(m + q), b(m + q);
	rep(i, m + q) {
		cin >> d[i] >> a[i] >> b[i];
		--a[i]; --b[i];
	}
	vector<int> ord(m + q);
	iota(ord.begin(), ord.end(), 0);
	sort(ord.begin(), ord.end(), [&](int x, int y) {
		if (d[x] == d[y])return x > y;
		return d[x] < d[y];
	});
	set<pair<int, int>> st;
	rep(i, n + 2) {
		st.insert({ i - 1,i-1 });
	}vector<string> ans(q);
	for (auto i : ord) {
		if (i >= m) {
			if (a[i] > b[i])ans[i - m] = "Yes";
			else {
				auto itr = st.lower_bound({ a[i],a[i] });
				if (itr->first > a[i])--itr;
				if (itr->second >= b[i])ans[i - m] = "Yes";
				else ans[i - m] = "No";
			}
		}
		else {
			auto itr = st.lower_bound({ a[i],a[i] });
			if (itr->first > a[i])--itr;
			int l = itr->first;
			int r = b[i];
			while (itr->second < b[i]) {
				r = itr->second;
				itr = st.erase(itr);
			}
			r = itr->second;
			itr = st.erase(itr);
			st.insert({ l,r });
		}
	}
	rep(i, q) {
		cout << ans[i] << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	stop
	return 0;
}


Measured memory_bytes: 12948
import sys
import math

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, X = lr()
total = A * A * B
if X >= total / 2:
    Y = total - X # 空の容積
    # A ** 3 * tan(θ) / 2 = Y
    # tan(θ) = 2 * Y / A ** 3 
    answer = math.atan(2*Y / A**3)
else:
    # A * B * B / (tan(θ) * 2) = X
    # tan(θ) = A * B * B / (X * 2)
    answer = math.atan(A*B*B / (X*2))

print(math.degrees(answer))


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

int main() {

	long A,B,K;
  	cin >> A >> B >> K;
  
	if ( A <= K ){
      K -= A;
      A = 0;
      if ( B <= K ){
        B = 0;
      }else{
        B -= K;
      }
    }else{
      A -= K;
    }

	cout << A << " " << B << endl;
 
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++) 
#define ford(i, a, b) for(int i = a; i >= b; i--) 
#define endl "\n"
#define scv(a, b, c) #a#b#c
#define com(a,b) a ## b

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 3e3 + 1;
const ll MOD = 998244353;
const ll oo = 1e18 + 7;
const int BASE = 10000;

class solve {
public: 
    solve() {
        int n;
        string s;
        cin >> n >> s;
        cout << ((n < 3200) ? "red" : s);
    }
};

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(1);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve kAN;
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i,j,N,ans=0;
    cin >> N;
    for(i=0;i<26;i++){
        for(j=0;j<15;j++){
        if(N == 4*i+7*j) {
            ans++;
            break;
        }   
        }
    }
    if(ans == 0){
        cout << "No" << endl;
    }
    else{cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] m = new int[n];
    for (int i = 0; i < n; i++) {
      m[i] = sc.nextInt();
    }
    int min = m[0];
    int sum = m[0];
    for (int i = 1; i < n; i++) {
      if (min > m[i]) {
        min = m[i];
      }
      sum += m[i];
    }
    System.out.println(n + (x - sum) / min);
  }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1 && b != 1) {
    cout << "Alice";
  } else if (a != 1 && b == 1) {
    cout << "Bob";
  } else if(a>b) {
    cout << "Alice";
  } else if (a<b) {
    cout << "Bob";
  } else {
    cout << "Draw";
  }
}

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

int main(){

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
		
	return 0;
}

Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DPairCards {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,x;
        in>>n>>m;
        vector<int> y(100001),z(m),w(m);
        fr(i,n) in>>x,++y[x];
        Fr(i,100000) z[i%m]+=y[i],w[i%m]+=y[i]/2;
        int ans=z[0]/2;
        if((m&1)==0) ans+=z[m/2]/2;
        Fr(i,(m-1)/2){
            int k=min(z[i],z[m-i]);
            ans+=k;
            z[i]-=k;z[m-i]-=k;
            ans+=min(z[i]/2,w[i]);
            ans+=min(z[m-i]/2,w[m-i]);
        }
        out<<ans<<endl;
    }
};

int main() {
    DPairCards solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int isKaibun(string s) {
    int n = s.size();
    int ret = true;

    for(int i = 0; i < n / 2; i++) {
        //cout << s[i] << s[n - i - 1] << endl;
        if(s[i] != s[n - i - 1]) {
            ret = false;
            break;
        }
    }

    return ret;
}

int main() {
    string s;

    cin >> s;
    int n = (int)s.size();
    string ret = "";
    string fir = "";
    string sec = "";
    for(int i = 0; i < n / 2; i++) {
        fir.push_back(s[i]);
        sec.push_back(s[n / 2 + (n & 1) + i]);
    }

    if(fir != sec) {
        ret = "No";
    } else {
        if(isKaibun(fir) == true) {
            ret = "Yes";
        } else {
            ret = "No";
        }

    }

    cout << ret << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 土 10/27 21:08:25 2018

# Usage
#
"""
def get():
    return [int(i) for i in input().split(' ')]

def emurate_process(takahashi, aoki, mode):
    if mode == 't':
        hero = takahashi
        opposite = aoki
    else:
        hero = aoki
        opposite = takahashi

    if hero % 2 == 1:
        hero -= 1
    watasu = hero // 2
    hero = watasu
    opposite += watasu

    if mode == 't':
        return hero, opposite
    else:
        return opposite, hero


def solve(A,B,K):
    for i in range(K):
        if i % 2 == 0:  # takahashi is hero.
            A, B = emurate_process(A, B, 't')
        elif i % 2 == 1:  # aoki is hero.
            A, B = emurate_process(A, B, 'a')

    print('{} {}'.format(int(A),int(B)))

if __name__ == '__main__':
    solve(*get())



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
auto getPrimes(int lim) {
    vector<bool> flags(lim + 1, true);
    flags[0] = flags[1] = false;

    for (int i = 2; i <= lim; i++) {
        if (flags[i]) {
            for (int j = 2 * i; j <= lim; j += i) {
                flags[j] = false;
            }
        }
    }

    vector<int> primes;

    for (int i = 0; i <= lim; i++) {
        if (flags[i]) {
            primes.push_back(i);
        }
    }

    return primes;

}
class Solve{
public:
    int N;
    void input(){
        cin >> N;

    }
    void solve(){
        input();
        vector<int> primes = getPrimes(334334);
        vector<int> ans;
        for(auto e : primes){
            if(ans.size() >= N){
                break;
            }
            if(e % 5 == 1){
                ans.push_back(e);
            }
        }
        for(int i = 0; i < ans.size(); ++i){
            cout << ans[i];
            if(i == ans.size() - 1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
vector<ll> p[200005],c[200005];
int main(){
    int o;cin>>o;
    while(o--){
        ll n,ans=0;cin>>n;
        priority_queue<ll,vector<ll>,greater<ll>> q;
        for(int i=1;i<=n;i++){
            p[i].clear();c[i].clear();
        }
        for(ll i=1;i<=n;i++){
            ll k,l,r;cin>>k>>l>>r;
            if(l>r) p[k].push_back(l-r),ans+=r;
            if(l<r) c[n-k].push_back(r-l),ans+=l;
            if(l==r) ans+=l;
        }
        for(int i=1;i<=n;i++){
            for(auto j:p[i]){
                q.push(j);
            }
            while(q.size()>i){
                q.pop();
            }
        }
        while(q.size()){
            ans+=q.top();q.pop();
        }
        for(int i=1;i<=n;i++){
            for(auto j:c[i]){
                q.push(j);
            }
            while(q.size()>i){
                q.pop();
            }
        }
        while(q.size()){
            ans+=q.top();q.pop();
        }
        cout<<ans<<endl;
    }
}

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

constexpr int intHalf = 1073741823; // 2^30 - 1 > 10^9

int main()
{
	int n;
	cin >> n;
	vector<int> hls(n);
	for (auto& h : hls)cin >> h;
	vector<int> cost_dp(n);
	cost_dp[0] = 0;
	cost_dp[1] = abs(hls[1] - hls[0]);
	if (n == 2) {
		cout << cost_dp[1] << endl;
		return 0;
	}

	for (int i = 2; i < n; ++i) {
		cost_dp[i] = min(cost_dp[i - 1] + abs(hls[i] - hls[i - 1]),
			cost_dp[i - 2] + abs(hls[i] - hls[i - 2]));
	}

	cout << cost_dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
arr=[b,c,d]
for i in range(8):
    x=i
    m=a
    k=''
    for j in range(3):
        if x&1:
            m+=arr[j]
            k+='+'
        else:
            m-=arr[j]
            k+='-'
        x=x>>1
    if m==7:
        print (s[0]+k[0]+s[1]+k[1]+s[2]+k[2]+s[3]+'='+'7')
        break

Measured memory_bytes: 9220
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if p[i] == i+1:
        if i == n-1:
            ans += 1
        else:
            p[i],p[i+1], = p[i+1],p[i]
            ans += 1
print(ans)

Measured memory_bytes: 20588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;

namespace abc165_a
{
  class Program
  {
    static void Main(string[] args)
    {
      var K = CIn.ReadInt();
      var A = CIn.ReadInt();
      var B = CIn.ReadInt();

      var ans = Enumerable.Range(A, B - A + 1).Any(e => e % K == 0);

      Console.WriteLine(ans ? "OK" : "NG");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 28348
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;

using ci = const int;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair <int,int>;
using pcc = pair <char,char>;
using pll = pair <ll,ll>;
using pss = pair <string,string>;
using vi = vector <int>;
using vb = vector <bool>;
using vpii = vector <pii>;
using vll = vector <ll>;
using vii = vi::iterator;

#define INF (0x3f3f3f3f)
#define MOD 1000000007
#define mt make_tuple
#define all(c) c.begin(), c.end()
#define ms(name,val) memset(name, val, sizeof (name))
#define np nullptr
// inline functions



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

    string s;
    cin >> s;

    for (int t1 = 1; t1 < 4; ++t1)
    {
        if (s[t1] == s[t1-1])
        {
            cout << "Bad\n";
            return 0;
        }
    }

    cout << "Good\n";

























































    return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int N; cin >> N;
	vector<string> S(N); rep(i, 0, N) { cin >> S[i]; }
	int A = 0, Un = 0;
	rep(i, 0, N) {
		if (S[i] == "A")A++;
		if (S[i] == "Un")Un++;
		if (A < Un) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (A != Un) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int a,l,x;

    while(cin >> a >> l >> x){
        double s1,s2,tmp;
        
        tmp = (double)(a + l * 2) / 2;
        s1 = sqrt(tmp*(tmp-a)*(tmp-l)*(tmp-l));
        
        tmp = (double)(l + l + x) / 2;
        s2 = sqrt(tmp*(tmp-l)*(tmp-(double)(l+x)/2)*(tmp-(double)(l+x)/2));

        printf("%.9f\n", s1+s2*2);
    }
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 100005;

int n,S,cur;
int x[MAXN];
int que[MAXN];

ll ans;
ll p[MAXN];

int main()
{
	scanf("%d%d",&n,&S);
	for (int i = 1;i <= n;i++)
		scanf("%d%lld",&x[i],&p[i]);
	int l = 1,r = n;
	while (x[l] < S && x[r] > S)
	{
		if (p[l] < p[r])
		{
			p[r] += p[l];
			que[++cur] = l++;
		}
		else
		{
			p[l] += p[r];
			que[++cur] = r--;
		}
	}
	while (l <= r && x[l] < S)
		que[++cur] = l++;
	while (l <= r && x[r] > S)
		que[++cur] = r--;
	x[0] = S;
	reverse(que + 1,que + n + 1);
	for (int i = 1;i <= n;i++)
		ans += abs(x[que[i]] - x[que[i - 1]]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1920
H,W,N = map(int,input().split())

from collections import defaultdict
L = defaultdict(int)

for i in range(N):
    a,b = map(int,input().split())
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            if a+p < 2 or b+q < 2 or a+p >H-1 or b+q >W-1:
                continue
            L[(a+p-1,b+q-1)] += 1
            
ans = [0]*10
for v in L.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2) - sum(ans)

for i in range(10):
    print(ans[i])


Measured memory_bytes: 181592
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int x;
    cin >> x;

    REP(N, x, 1010101){
        int ans = 1;
        for(int i=2; i*i<=N; i++){
            if(N%i == 0){
                ans = 0;
                break;
            }
        }
        if(ans){
            cout << N << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if ( a == b && b == c){
    cout << 1 << endl;
  } else if ( a == b || b == c || c == a ){
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate

N = int(input())
A = [int(i) for i in input().split()]

acc = []

for i in accumulate(A):
    acc.append(i)

ans = 0
d = defaultdict(int)


for n in acc:
    ans += d[n] + (n == 0)
    d[n] += 1


print(int(ans))


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

int N;
int L[50];

bool check(int x,int y){
  map<int,bool> visited;
  queue<int> Q;
  Q.push(0);
  visited[0]=true;
  while(!Q.empty()){
    int p=Q.front();
    Q.pop();
    if(p==N)return true;
    int sum=0;
    for(int to=p+1;to<=N;to++){
      if(p==0 && to==N)continue;
      sum+=L[to-1];
      if(sum<x || y<sum)continue;
      if( !visited[to] ){
        visited[to]=true;
        Q.push(to);
      }
    }
  }
  return false;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  for(int i=0;i<=1000;i++){
    for(int j=1;j<=25000;j++){
      if( check(j,i+j) ){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

int getans(int sum, int amax, int rest) {
	if (sum < rest)return 0;
	if (sum > rest*amax)return 0;
	if (rest == 1) {
		if (1 <= sum&&sum <= amax)return 1;
	}
	int ans = 0;
	for (int i = 1; i <= amax; ++i) {
		ans += getans(sum - i, i - 1, rest - 1);
	}
	return ans;
}

int main() {
	while (1) {
		int N, K, S; cin >> N >> K >> S;
		if (!N)break;
		int ans(getans(S, N, K));
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (auto &a_i : a) cin >> a_i;

    ll x0 = 0;
    for (int i = 0; i < n; ++i) {
        if (i & 1) x0 -= a[i];
        else x0 += a[i];
    }

    ll prev = x0;
    for (int i = 0; i < n; ++i) {
        cout << prev << " \n"[i == n - 1];
        prev = 2 * a[i] - prev;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
    int R, C, n;
    cin >> R >> C >> n;
    rep(i,n) {
        int r, c, v;
        cin >> r >> c >> v;
        a[r-1][c-1] = v;
    }

    rep(i,R)rep(j,C) {
        for (int k = 2; k >= 0; k--) {
            chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
        }
        rep(k,4) {
            chmax(dp[i+1][j][0], dp[i][j][k]);
            chmax(dp[i][j+1][k], dp[i][j][k]);
        }
    }

    ll ans = 0;
    rep(k,4) chmax(ans, dp[R-1][C-1][k]);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 710;
bool g[MAX_N][MAX_N];

int N;
bool marked[MAX_N];
int color[MAX_N];


bool ng;

void dfs(int v, int c) {
  if (marked[v]) {
    if (color[v] != c) ng = true;
    return;
  }
  marked[v] = true;
  color[v] = c;
  REP(u, N) if (u != v && !g[u][v]) {
    dfs(u, 3-c);
  }
}

bool dp[MAX_N][MAX_N];

int main2() {
  CLR(g, 0);
  CLR(marked, 0);

  N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a][b] = true;
    g[b][a] = true;
  }

  ng = false;
  vector<pair<int,int>> v;
  REP(i, N) if (!marked[i]) {
    CLR(color, 0);
    dfs(i, 1);
    v.push_back( { count(color, color+N, 1), count(color, color+N, 2) } );
  }
  // pv(ALL(v));
  CLR(dp, 0);
  dp[0][0] = 1;
  REP(i, v.size()) {
    int a = v[i].first;
    for (int j = N; j - a >= 0; j--) {
      if (dp[i][j-a]) dp[i+1][j] = true;
    }

    a = v[i].second;
    for (int j = N; j - a >= 0; j--) {
      if (dp[i][j-a]) dp[i+1][j] = true;
    }
    
  }
  // pv (dp[v.size()], dp[v.size()] + N + 1);

  const int INF = 1001001001;
  int ans = INF;
  for (int i = 1; i < N; i++) {
    if (dp[v.size()][i]) {
      int a = i;
      int b = N-i;
      chmin(ans, a*(a-1)/2 + b*(b-1)/2);
    }
  }
  if (ans == INF) ans = -1;
  if (ng) ans = -1;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<double, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v, int idx)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        if (i == idx)
        {
            cout << "[" << v[i] << "]"
                 << " \n"[i == sz - 1];
            continue;
        }
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct Node
{
    Node *right;
    Node *left;
    Node *par;
    int key;

    Node(int v) : key(v)
    {
        right = left = par = NULL;
    }
};

struct BinarySearchTree
{
    Node *root;
    BinarySearchTree()
    {
        root = NULL;
    }
    void insert(int z)
    {
        insert(new Node(z));
    }
    void insert(Node *z)
    {
        Node *y = NULL, *x = root;
        while (x != NULL)
        {
            y = x;
            if (z->key < x->key)
            {
                x = x->left;
            }
            else
            {
                x = x->right;
            }
        }
        z->par = y;

        if (y == NULL)
        {
            root = z;
        }
        else if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
    void preorder(Node *cur)
    {
        if (cur == NULL)
            return;
        cout << " " << cur->key;
        preorder(cur->left);
        preorder(cur->right);
    }
    void inorder(Node *cur)
    {
        if (cur == NULL)
            return;
        inorder(cur->left);
        cout << " " << cur->key;
        inorder(cur->right);
    }
    void print()
    {
        inorder(root);
        cout<<endl;
        preorder(root);
        cout<<endl;
    }
};

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

    int m;
    cin >> m;
    BinarySearchTree bst = BinarySearchTree();
    for (int i = 0; i < m; i++)
    {
        string s;
        cin >> s;
        if (s == "insert")
        {
            int key;
            cin >> key;
            bst.insert(key);
        }
        else
        {
            bst.print();
        }
    }
}


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

long long gcd(long long a,long long b) {
  if(b == 0) return a;
  else return gcd(b,a%b);
}

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

  long long g = gcd(A,B);
  long long num = 1;
  // cout << g << endl;
  
  long long G = g;
  for(int i = 2;i <= sqrt(g);i++) {
    if(G % i == 0) {
      num++;
      while(G % i == 0) {
        G /= i;
      }
    }
  }

  if(G==1) cout << num << endl;
  else cout << num+1 << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC122 C

n,q = map(int,input().split())
s = input()
t = [0 for _ in range(n+1)]

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] =='AC' else 0)

for _ in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])


Measured memory_bytes: 51104
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int studentNum,tmp = 0;
	double SD,D = 0.0,ave = 0.0;
	vector<int> score;
	cout.precision(15);

	while (cin >> studentNum&&studentNum) {

		for (int i = 0; i < studentNum; i++)
		{
			cin >> tmp;
			ave += tmp;
			score.push_back(tmp);
		}

		ave /= studentNum;

		for (int i = 0; i < studentNum; i++) D += pow((score[i] - ave), 2);
		SD = sqrt(D / (double)studentNum);
		
		cout << SD << endl;

		D = 0.0;
		ave = 0;
		SD = 0;
		score.clear();
	}

    return 0;
}

Measured memory_bytes: 1288