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

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h1 = s.nextInt();
		int h2 = s.nextInt();
		int k1 = s.nextInt();
		int k2 = s.nextInt();
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int d = s.nextInt();
		
		int h = 0;
		int k = 0;
		String ans;
		
		h = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
		k = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
		
		if(h>k){
			ans = "hiroshi";
		}else if(h<k){
			ans = "kenjiro";
		}else{
			ans = "even";
		}
		
		System.out.println(ans);
		
		
	}
}

Measured memory_bytes: 26164
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int L = fs.nextInt();
		double y = (double)L/3;
		BigDecimal x = BigDecimal.valueOf(y);
		BigDecimal ans = x.multiply(x);
		 ans = ans.multiply(x);

		 System.out.printf("%.12f", ans);
 
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

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

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

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

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

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

	}
	
}


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

int main() {
  char c;
  cin >> c;
 
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    
  cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int 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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin >> n >> m;
  priority_queue<ll> p;
  rep(i,n){
      ll a;cin >> a;
      p.push(a);
  }
  rep(i,m){
      ll tmp = p.top();
      p.pop();
      p.push(tmp/2);
  }
  ll ans=0;
  while(p.size()){
      ans += p.top();
      p.pop();
  }
  cout <<ans << endl;
}

Measured memory_bytes: 1400
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0, m, x, y, v;
  set<ll> se[26];
  srand(time(NULL));
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    x = -10000000000000;
    y = -1;
    for (int j = 0; j < 26; j++) {
      if (x < s[i][j] + (i + 1 - *se[j].rbegin()) * c[j] * (d - i)) {
        y = j;
        x = s[i][j] + (i + 1 - *se[j].rbegin()) * c[j] * (d - i);
      }
    }
    t[i] = y;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
  }
  for (int i = 0; i < 26; i++) {
    se[i].insert(d + 1);
  }
  for (int i = 0; i < 15000000; i++) {
    x = i % d + 1;
    y = i % 26;
    v = 0LL;
    v += s[x - 1][y] - s[x - 1][t[x - 1]];
    set<ll>::iterator it = se[t[x - 1]].find(x);
    it--;
    ll z = *se[t[x - 1]].upper_bound(x);
    v -= c[t[x - 1]] * (z - x) * (x - *it);
    it = se[y].lower_bound(x);
    it--;
    v += c[y] * (*se[y].lower_bound(x) - x) * (x - *it);
    if (v > 0LL) {
      ans += v;
      se[t[x - 1]].erase(x);
      t[x - 1] = y;
      se[y].insert(x);
    }
  }
  for (int i = 0; i < d; i++) {
    cout << t[i] + 1 << endl;
  }
}

Measured memory_bytes: 3732
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));
  $ary = array();
  for ($i = 1; $i <= $n; $i++) {
    array_push($ary, explode(" ", trim(fgets(STDIN))));
  }
  $ary_2 = array();
  for ($i = 1; $i <= $m; $i++) {
    array_push($ary_2, trim(fgets(STDIN)));
  }
  $result = 0;
  foreach ($ary as $key => $val) {
    $x = 0;
    foreach ($val as $v) {
      $result = $result + ($v * $ary_2[$x]);
      $x++;
    }
    if ($key < (count($ary)-1)) {
      print($result . "\n");
    } else {
      print $result;
    }
    $result = 0;
  }
?>

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  string s, ans;

  cin >> s;

  if(s[2] == s[3] && s[4] == s[5]){
    ans = "Yes";
  }else{
    ans = "No";
  }

  cout << ans;
  
    




  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

vector<vector<ll>> vec;
vector<ll> ans;
void dp(ll i) {
if(vec[i].size()==0) {
ans[i]=0;
  return ;
}
  ll a=0;
  for(ll x:vec[i]) {
   ll b;
    if(ans[x-1]>=0) {
b=ans[x-1];
    }
    else {
      dp(x-1);
      b=ans[x-1];
    }
    a=max(a,b);
  }
  
  ans[i]=a+1;
return ;
}

int main() {
ll N,M;
  cin>>N>>M;
  ans=vector<ll>(N,-1);
  vec=vector<vector<ll>> (N,vector<ll>(0));
  for(ll i=0;i<M;i++) {
ll x,y;
    cin>>x>>y;
    vec[x-1].push_back(y);
  }
  
  for(ll i=0;i<N;i++) {
if(ans[i]>=0) {
continue;
}
    else {
 dp(i);
    }
  }
  
  ll m=0;
  for(ll i=0;i<N;i++) {
m=max(ans[i],m);
  }
  
 cout<<m<<endl;
}
  
  
  
  

Measured memory_bytes: 11200
s=input()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print('Yes')
elif s[1]==s[2] and s[2]!=s[3] and s[3]==s[0]:
  print('Yes')
elif s[0]==s[2] and s[1]!=s[2] and s[1]==s[3]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9032
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    cin >> H;

    SORT(H);
    ll ans = 0;
    REP(i, N - K) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  ll x, y;
  cin >> x >> y;
  ll idx = x, sum = 1;
  ll prev = x;
  while(idx <= y){
    idx = idx * 2;
    if(idx <= y) sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l=list(map(int ,input().split()))
ansl=[]
c=1
cnt=0
for i in range(n):
    if l[i]!=c:
        cnt+=1
    else:
        ansl.append(l[i])
        c+=1
if len(ansl)==0:
    print(-1)
else:
    print(cnt)

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

using namespace std;

int main() {
	
	int n;
	string s;
	cin >> n;
	cin >> s;
	int counter = 0;
	for (char i = '0'; i <='9' ;i++) {
		for (char j = '0'; j <= '9';j++) {
			for (char k = '0'; k <= '9';k++) {
				string tmp = "";
				tmp.push_back(i);
				tmp.push_back(j);
				tmp.push_back(k);
				
				bool ii = false;
				bool jj = false;
				bool kk = false;

				for (int m = 0; m < n; m++) {
					if (ii==false && s[m] == i) { ii = true; continue; }
					if (jj == false && ii == true && s[m] == j) { jj = true; continue; }
					if (ii == true && jj == true && s[m] == k) { counter++; break; }
				}

			}
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
int i=0;
for(auto it:v){
	if(i > 0){os << ' ';}
	os << it;
	i++;
} 
return os;
}
template<class T,class TT> ostream& operator <<(ostream &os, const map<T,TT> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
return os;
}
using ll = long long ;


int main(){
	ios::sync_with_stdio(false);
	int X,Y;cin>>X>>Y;
	map<int,int>mp;
	int ans=0;
	if(X<=3){
		ans+=4-X;
	}
	if(Y<=3)ans+=4-Y;
	if(X==1&&Y==1)ans+=4;
	cout<<ans*100000<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;
int inf = 1e9;



int main() {

  vector<int> c1(1001, 0);
  vector<int> c2(1001, 0);
  vector<int> d(1001, 0);
  int a, b;
  string s;
  while( getline(cin, s) ){
    if( s.size() == 0 ) break;
    sscanf(s.c_str(), "%d,%d", &a, &b);
    // if( a == 0 ) break;
    c1[a]++;
  }


  while( scanf("%d,%d", &a, &b) != EOF ){
    if( a == 0 ) break;
    c2[a]++;
  }

  for(int i=0; i<1001; i++){
    if( c1[i] > 0 && c2[i] > 0 ) cout << i << " " << c1[i] + c2[i] << endl;
  }

  return 0;
}




// EOF

Measured memory_bytes: 3244
/*CODE BY VIJAY MUKHIJA*/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define SMOD 998244353
#define what_is(x) cout << #x << " is " << x << endl
#define what_are(x,y) cout<< #x <<" is " << x << " "<< #y <<" is " << y <<endl
using namespace std;
lli Powerm(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m; lli t=Powerm(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
lli Power(lli a,lli b){ if(b==0) return 1; if(b==1) return a; lli t=Power(a,b/2); t=(t*t); if(b&1)t=(t*a); return t;}
lli Gcd(lli a,lli b) { if(b==0) { return a; } else { return Gcd(b,a%b); } }
lli LeftMostSetBit(lli n){ if (n == 0){return 0; } lli msb = 0; while (n != 0) {n = n / 2; msb++; } return msb; }
lli RightMostSetBit(lli n){ return __builtin_ffsl(n); }
lli llsqrt(lli x){ if(x==0 || x==1) return x; lli start=1, end=x/2, ans; while(start<=end) { lli mid=(start+end)/2; if(mid*mid==x) return mid;
else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
        lli n;
        cin>>n;
        lli a[n],b[n],c[n];
        for(lli i=0;i<n;i++)
        {
            cin>>a[i]>>b[i]>>c[i];
        }
        lli dp[3][n+1];
        dp[0][0]=0;
        dp[1][0]=0;
        dp[2][0]=0;
        for(lli i=0;i<n;i++)
        {
            dp[0][i+1]=max(a[i]+dp[1][i],a[i]+dp[2][i]);
            dp[1][i+1]=max(b[i]+dp[0][i],b[i]+dp[2][i]);
            dp[2][i+1]=max(c[i]+dp[0][i],c[i]+dp[1][i]);
        }
        cout<<max(dp[2][n],max(dp[0][n],dp[1][n]))<<endl;
    	


}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<stack>
#include<string>

using namespace std;

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

	if (S.length() <= K) {
		cout << S << endl;
		return 0;
	}
	cout << S.erase(K) << "..." << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n,k;
int main(){
    cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl b;
    rep(i,n){
        ll sum=a[i];
        b.push_back(sum);
        for(int j=i+1;j<n;j++){
            sum+=a[j];
            b.push_back(sum);
        }
    }
    sort(b.rbegin(),b.rend());
    ll cur=0;
    for(int i=40;i>=0;i--){
        ll ncur=cur+(1ll<<i);
        int cnt=0;
        rep(i,(int)b.size()){
            if((ncur&b[i])==ncur) cnt++;
        }
        if(cnt>=k) cur=ncur;
    }
    cout << cur << endl;
    return 0;
}

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

int main()
{
    int N, K, S;
    cin >> N >> K >> S;

    if (S == 1000000000)
    {
        for (int i = 1; i <= K; i++) cout << S << " ";

        for (int j = K + 1; j <= N; j++) cout << S - 1 << " ";
    }
    else
    {
        for (int i = 1; i <= K; i++) cout << S << " ";

        for (int j = K + 1; j <= N; j++) cout << 1000000000 << " ";
    }

    return 0;
}

Measured memory_bytes: 1280
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

use std::collections::HashSet;

fn main() {
    let g1: HashSet<usize> = [1, 3, 5, 7, 8, 10, 12].iter().cloned().collect();
    let g2: HashSet<usize> = [4, 6, 9, 11].iter().cloned().collect();
    let g3: HashSet<usize> = [2].iter().cloned().collect();

    let (x, y): (usize, usize);
    let mut flag = false;
    input!(x, y);

    if g1.contains(&x) {
        if g1.contains(&y) {
            flag = true;
        }
    }
    if g2.contains(&x) {
        if g2.contains(&y) {
            flag = true;
        }
    }
    if g3.contains(&x) {
        if g3.contains(&y) {
            flag = true;
        }
    }

    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
import math
a,b,x=map(int,input().split())
V=a*a*b
if V/x<2:
    X=V-x
    print(math.degrees(math.atan(2*X/(a*a*a))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define reg register
using namespace std;
typedef long long ll;
int main(){
	reg ll A,B,N,X;
	scanf("%lld%lld%lld",&A,&B,&N);
	X=min(B-1,N);
	printf("%lld\n",A*X/B-A*(X/B));
	return 0;
}

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

using namespace std;

const int MX = 100000, md = 1000000007;

char s[MX + 1];

int main() {
	int n;
	ignore = scanf("%d %s", &n, s);
	
	map<char, int> cnt;
	for (int i = 0; i < n; i++) cnt[s[i]]++;
	
	int ans = 1;
	for (auto& p : cnt) ans = ans * (p.second + 1LL) % md;
	
	printf("%d\n", (ans + md - 1) % md);
	
	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  if((n-1)%(k-1)==0)
    cout << (n-1)/(k-1) << endl;
  else
    cout << (n-1)/(k-1)+1 << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string S;
  cin >> S;
  S = S.substr(0, S.size() - 1);
  while (1) {
    if (S.size() % 2 == 0) {
      int w = S.size() / 2;
      string s1 = S.substr(0, w);
      string s2 = S.substr(w, w);
      if (s1 == s2) {
        cout << w * 2 << endl;
        return 0;
      }
    }
    S = S.substr(0, S.size() - 1);
    if (S.size() == 1) {
      cout << 1 << endl;
      return 0;
    }
  }
}

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

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

    for (int i = 0; i < min((long long)S.size(), K);i++){
        if(S[i]>= '2'){
            cout << S[i]<<endl;
            return 0;
        }
    }

    cout << '1' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cstdlib>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint h, w;
llint a[85][85], b[85][85];
llint d[85][85];
llint Zero = 13002;
bool dp[85][85][26005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> a[x][y];
		}
	}
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> b[x][y];
			d[x][y] = abs(a[x][y]-b[x][y]);
		}
	}
	
	dp[1][1][Zero+d[1][1]] = dp[1][1][Zero-d[1][1]] = true;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			for(int i = -13000; i <= 13000; i++){
				if(!dp[x][y][Zero+i]) continue;
				if(x+1 <= w){
					if(i+d[x+1][y] <= 13000) dp[x+1][y][Zero+i+d[x+1][y]] = true;
					if(i-d[x+1][y] >= -13000) dp[x+1][y][Zero+i-d[x+1][y]] = true;
				}
				if(y+1 <= h){
					if(i+d[x][y+1] <= 13000) dp[x][y+1][Zero+i+d[x][y+1]] = true;
					if(i-d[x][y+1] >= -13000) dp[x][y+1][Zero+i-d[x][y+1]] = true;
				}
			}
		}
	}
	
	llint ans = 1e18;
	for(llint i = -13000; i <= 13000; i++){
		//if(abs(i) <= 5) cout << dp[w][h][Zero+i] << endl;
		if(dp[w][h][Zero+i]) ans = min(ans, abs(i));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 174592
# coding: utf-8
import sys

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

# あえてAからループで回す場合、本当はマッチ棒の本数で先にループを回すのが良い
N, M = lr()
A = lr()
A.sort(reverse=True)
dp = [-1] * (N+1)
dp[0] = 0
match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for a in A:
    for x in range(1, N+1):
        y = match[a]
        if x - y < 0 or dp[x-y] == -1:
            continue
        dp[x] = max(dp[x], dp[x-y] * 10 + a)

answer = dp[N]
print(answer)


Measured memory_bytes: 66780
#include <stdio.h>
void bubbleSort(int *A,int N);
int cnt=0;
int main(){

  int n,a[100],i;

  scanf("%d",&n);

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

  bubbleSort(a,n);

  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",a[i]);
    }
    else {
      printf("%d ",a[i]);
    }

  }
 
  printf("%d\n",cnt);
  return 0;
  
}


void bubbleSort(int *a,int n){
  int j,flag=1,sub;

  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	sub=a[j];
	a[j]=a[j-1];
	a[j-1]=sub;
	cnt++;
	flag=1;
      }

    }
  }
}
  
      

Measured memory_bytes: 600
import math
N =int(input() )
trains = [list(map(int,input().split(" "))) for _ in range(N-1)]
for s in range(N):
    ans = 0
    spent = 0
    arrived_time = 0
    for train in trains[s:]:
        c,s,f = train
        n = max(0,math.ceil((ans-s) /f))
        wait = n * f + s - ans
        #待機時間

        ans += c + wait

    print(ans)

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

void solve() {
    int N ,M;
    cin >> N >> M;
    int ans = 0;
    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        ans += a;
    }
    int x = N - ans;
    cout << (0 <= x ? x : -1)  << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int D, G;
	int p[11], c[11];
	cin >> D >> G;
	for (int i = 0; i < D; ++i) {
		cin >> p[i] >> c[i];
	}
	int ans = INF;
	for (int bit = 0; bit < (1 << D); ++bit) {
		int sum = 0;
		int key = 0;
		for (int i = 0; i < D; ++i) {
			if (bit&(1 << i)) {
				sum += p[i] * 100 * (i + 1);
				sum += c[i];
				key += p[i];
			}
		}
		if (sum >= G) {
			ans = min(ans, key);
		}
		else {
			int S = G - sum;
			for (int i = D - 1; i >= 0; --i) {
				int x = 0;
				if (!(bit&(1 << i))) {
					for (int j = 0; j < p[i]; ++j) {
						S -= 100 * (i + 1);
						key++;
						if (S <= 0) {
							ans = min(ans, key);
							x = 1;
							break;
						}
					}
				}
				if (x == 1)break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
/**
 *   created: 21 July 2019  12:00:05
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
			cout<<"Yes";
		else
			cout<<"No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  vector<pair<pair<string, int>, int>> v;
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    string a;
    int b;
    cin >> a >> b;
    v.push_back({{a, -b}, i});
  }
  sort(v.begin(), v.end());
  for(auto x: v) cout << x.second << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	n, m := 0, 0
	_, _ = fmt.Scan(&n, &m)
	memo := make(map[int]int)
	for i := 0; i < n; i++ {
		k := 0
		_, _ = fmt.Scan(&k)
		for j := 0; j < k; j++ {
			k := 0
			_, _ = fmt.Scan(&k)
			v, ok := memo[k]
			if ok {
				memo[k] = v + 1
			} else {
				memo[k] = 1
			}
		}
	}
	count := 0
	for _, v := range memo {
		if v == n {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

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

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}
const double PI = 3.1415926535897932384626433;

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;

	rep(i,k,n+2){
		if(n+1==i){
			ans+=1;
			ans%=mod;
		}else{
			ll ma=n*(n+1)/2-(n-i)*(n-i+1)/(ll)2;
			ll mi=(i-1)*i/(ll)2;
			ans=ans+ma-mi+1;
			ans%=mod;
			//print(ma<<"      "<<mi<<"    i = "<<i);
		}

	}
	print(ans);
}


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

int main(){
	int n;
	while(cin>>n,n){
		int x=0, i=1,count=0,ans=0;
		while(x+i<=n){
			x+=i++;
			count++;
		}
		
		for(int i=2;i<=count;i++){
			if(i%2){
				if(n%i==0) ans++;

			}else{
				if(n%i == i/2) ans++;

			}
		}
		cout<<ans<<endl;


	}

	return 0;
}



Measured memory_bytes: 3112
# https://atcoder.jp/contests/abc136/tasks/abc136_c
N = int(input())
H = list( map( int, input().split()))
H.reverse()

flag = True 
before = 0
for i in range(N-1):
    n1 = H[i] + before
    n2 = H[i+1]
    if n1 >= n2:
        before = 0
    elif n1 + 1== n2:
        before = -1
    else:
        flag = False
        break

if flag:
    print( 'Yes')
else:
    print( 'No' )


Measured memory_bytes: 15020
def main():
    N,A = map(int,input().split())
    X = [int(x) for x in input().split()]
    dp = [[[0 for _ in range(2501)] for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for j in range(N):
        now = X[j]
        for k in range(N+1):
            for s in range(2501):
                if now>s:
                    dp[j+1][k][s] = dp[j][k][s]
                else:
                    dp[j+1][k][s] = dp[j][k][s] + dp[j][k-1][s-now]
    ans = 0

    for i in range(1,N+1):
        ans += dp[N][i][i*A]
    print(ans)

            

if __name__=="__main__":
    main()

Measured memory_bytes: 95068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a [] = new int[21];
		int L;

		for(a[0]=sc.nextInt(),L=sc.nextInt();a[0]!=0 || L!=0;a[0]=sc.nextInt(),L=sc.nextInt()) {
			int A [] = new int [L];
			for(int k=0;k<20;k++) {
				int temp=a[k];
				for(int i=0;i<L;i++) {
					A[i]=temp/(int)Math.pow(10,L-1-i);
					temp-=A[i]*(int)Math.pow(10,L-1-i);
				}
				for(int j=L;j>0;j--) {
					for(int i=0;i<j-1;i++) {
						if(A[i]<A[i+1]) {
							temp = A[i];
							A[i] = A[i+1];
							A[i+1] = temp;
						}
					}
				}
				int max=0;
				int min=0;
				for(int i=0;i<L;i++) {
					max+=A[i]*(int)Math.pow(10,L-1-i);
					min+=A[i]*(int)Math.pow(10,i);
				}
				a[k+1]=max-min;
			}

			int flag=0;
			for(int j=0;j<20 && flag==0 ;j++) {
				for(int i=j+1;i<=20 && flag==0 ;i++) {
					if(a[j]==a[i]) {
						System.out.printf("%d %d %d\n",j,a[i],i-j);
						flag=1;
					}
				}
			}

		}


	}
}


Measured memory_bytes: 26932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int xx = x2 - x1;
		int yy = y2 - y1;

		int x3 = x2 - yy;
		int y3 = y2 + xx;

		int x4 = x3 - xx;
		int y4 = y3 - yy;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);


	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
vector<int> d(6);
struct dice{
    int top;
    void set(){
        for(int i=0;i<6;i++){
            cin >> d.at(i);
        }
        return;
    }
    void roll(char c){
        if(c=='E'){
            top=d.at(0);
            d.at(0)=d.at(3);
            d.at(3)=d.at(5);
            d.at(5)=d.at(2);
            d.at(2)=top;//ここをtopにすることで配列の更新が行われるようになる
        }
        else if(c=='N'){
            top=d.at(0);
            d.at(0)=d.at(1);
            d.at(1)=d.at(5);
            d.at(5)=d.at(4);
            d.at(4)=top;
        }
        else if(c=='W'){
            top=d.at(0);
            d.at(0)=d.at(2);
            d.at(2)=d.at(5);
            d.at(5)=d.at(3);
            d.at(3)=top;
        }
        else if(c=='S'){
            top=d.at(0);
            d.at(0)=d.at(4);
            d.at(4)=d.at(5);
            d.at(5)=d.at(1);
            d.at(1)=top;
        }
        else if(c=='R'){
            roll('N');
            roll('W');
            roll('S');
        }
        else if(c=='L'){
            roll('N');
            roll('E');
            roll('S');
        }
        return;
    }
    void settf(int t,int f){
        int i;
        for(i=0;i<6;i++) if(d.at(i)==t) break;
        if(i==1) roll('N');
        else if(i==2) roll('W');
        else if(i==3) roll('E');
        else if(i==4) roll('S');
        else if(i==5){
            roll('N');
            roll('N');
        }
        for(i=1;i<5;i++) if(d.at(i)==f) break;
        if(i==2) roll('R');
        else if(i==3) roll('L');
        else if(i==4){
            roll('R');
            roll('R');
        }
        return;
    }
};


int main(){
    dice D;
  //  D.d={0,0,0,0,0,0};
    D.set();
    int q;
    cin >> q;
    int t,f;
    for(int i=0;i<q;i++){
     cin >> t >> f;   
     D.settf(t,f);
     cout << d.at(2) << endl;
    }
    return 0;
}


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

bool cmp(char a, char b){
	return a>b;
}

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	
	sort (s.begin(), s.end());
	sort (t.begin(), t.end(), cmp);
	
	if (s<t)
	   cout << "Yes" << endl;
	else
	   cout << "No" << endl;
	   
	return 0;
}

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

int n, l[200], ta = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n * 2; i++) {
		cin >> l[i];
	}
	sort(l, l + n * 2);
	for (int i = 0; i < n * 2; i += 2) {
		ta += l[i];
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
inline int max(int a, int b){return (a>b)? a:b;}
inline int min(int a, int b){return (a<b)? a:b;}

using namespace std;
class book{
    public:
        int price;
        vector<int> progress;
        book(void){
            price=0;
        }
        book(int ci, int n){
            price=ci;
            vector<int> default_value(n,0);
            progress=default_value;
        }
        void set_aij(int i, int v){
            progress[i]=v;
        }
};
bool book_comparator(const book& left, const book& right){
    return left.price > right.price;
}
int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    vector<book> books(n);
    for(int i=0;i<n;i++){
        int ci, t;
        cin >> ci;
        books[i]=book(ci,m);
        for(int j=0;j<m;j++){
            cin >> t;
            books[i].set_aij(j,t);
        }
    }
    sort(books.begin(),books.end(),book_comparator);
    int progress[m];
    int lowest_price=-1;
    for(int i=0;i<(1<<n);i++){
        int total_price=0;
        for(int j=0;j<m;j++){
            progress[j]=0;
        }
        for(int j=0;j<n;j++){
            int mask = (1<<j);
            if(mask&i){
                total_price+=books[j].price;
                for(int k=0;k<m;k++){
                    progress[k]+=books[j].progress[k];
                }
            }
        }
        char valid=1;
        for(int k=0;k<m;k++){
            if(progress[k]<x){
                valid=0;
                break;
            }
        }
        if(valid){
            if(lowest_price==-1){
                lowest_price=total_price;
            }else{
                lowest_price=min(total_price,lowest_price);
            }
        }
    }
    cout << lowest_price << endl;
}

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

int main(void)
{
    int N;

    cin >> N;

    long long sum = 0;
    for(int i = 1; i <= N; i++)
    {
        if( ( (i % 3) == 0) || ((i % 5) == 0) )               
        {
            ;
        }
        else
        {
            sum += i;
        }
    }

    cout << sum << endl;
    
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL a, b, c, k;

int main() {
    cin >> a >> b >> c >> k;
    if (k % 2 == 0) {
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}


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

const int N = 1e5 + 7;

long long a, b, n, h[N], ps[N];

bool chk(long long t) {
	long long res = 0;
   	for (int i = 1; i <= n; i++)
		if (h[i] >= t * b) {
			res += (h[i] - t * b) / (a - b);
			if ((h[i] - t * b) % (a - b))
				res++;
		}	
	return res <= t;
}

int main() {
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	sort (h + 1, h + n + 1);
	for (int i = n; i >= 1; i--)
		ps[i] = ps[i + 1] + h[i];
	long long l = 0, r = 1e9 + 100;
	while (r - l > 1) {
		long long md = (r + l) / 2;
		if (chk(md))
			r = md;
		else
			l = md;
	}
	cout << r;
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    ll ans = ((N - 1) * N) / 2;
    ans += ((M - 1) * M) / 2;
    cout << ans << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define maxn 2000000
using namespace std;
int k;
bool vis[maxn];
int main() {
	scanf("%d",&k);
	if(__gcd(k,10)!=1) {
        printf("-1");
	}
	else {
        if(k%7==0) k/=7;
        int d=1;
        int t=1;
        t=t%k;
        d=d%k;
        int i=1;
        while(t!=0) {
            if(vis[t]) {
                printf("-1");
                return 0;
            }
            d=(d*10)%k;
            t=(t+d)%k;
            i++;
        }
        printf("%d",i);
	}
	return 0;
}


Measured memory_bytes: 3828
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)

Measured memory_bytes: 3572
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int n)
{
	auto x = new int [n * 2];
	auto y = new int [n * 2];
	foreach (i; 0..n * 2)
	{
		readf (" %s %s", &x[i], &y[i]);
	}
	auto a = new bool [] [] (n, n);
	foreach (i; 0..n)
	{
		foreach (j; 0..n)
		{
			a[i][j] = (x[i] < x[j + n]) && (y[i] < y[j + n]);
		}
	}
	auto b = new bool [n];
	auto c = new int [n];
	c[] = -1;

	bool bipart (int v)
	{
		if (b[v])
		{
			return false;
		}
		b[v] = true;
		foreach (u; 0..n)
		{
			if (a[v][u] && (c[u] == -1 || bipart (c[u])))
			{
				c[u] = v;
				return true;
			}
		}
		return false;
	}

	int res = 0;
	foreach (v; 0..n)
	{
		b[] = false;
		res += bipart (v);
	}
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		writeln (solve (n));
	}
}


Measured memory_bytes: 256
from fractions import gcd
a,b,c,d = map(int, input().split())
def f(p):
  if a % p ==0:
    return(b//p - a//p + 1)
  else:
    return(b//p - a//p)
  
print(b-a+1 - (f(c)+f(d) - f(int(c*d/gcd(c,d)))))

Measured memory_bytes: 5088
s = input()
start = int(s[0]+s[1])
end = int(s[2]+s[3])

if 1 <= start <= 12 and 1 <= end <= 12:
    print("AMBIGUOUS")
elif 1 <= start <= 12 and (end > 12 or end == 0):
    print("MMYY")
elif (start > 12 or start == 0) and 1 <= end <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 18;

int T[maxN];
map <int, int> M;
long long S[maxN];

void solve()
{
	int n, k;
	scanf ("%d%d", &n, &k);
	FOR(i, 1, n+1)
		scanf ("%d", T+i), T[i]--;
	M[0] = 1;
	long long res = 0;
	FOR(i, 1, n+1)
	{
		S[i] = (S[i-1] + T[i]) % k;
		if (i >= k)
			M[S[i-k]]--;
		res += M[S[i]];
		M[S[i]]++;
	}
	
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 11904
from operator import mul
from functools import reduce
from collections import Counter

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N = int(input())
s_list = []
for _ in range(N):
    s = ''.join(sorted(list(input())))
    s_list.append(s)

b = 0
for i in Counter(s_list).values():
  if i==1:
    pass
  else:
    b += combinations_count(i,2)
print(b)

Measured memory_bytes: 19996
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
bool a,b,c,d;
int main(){
    cin>>s;l=s.length();
	while(l--){
	  if(s[l]=='N')a=1;
	  if(s[l]=='S')b=1;
	  if(s[l]=='E')c=1;
	  if(s[l]=='W')d=1;}
	if((a^b)||(c^d))puts("No");
	else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, c; cin >> n >> c;
  vector<vector<int>> D(c, vector<int>(c));
  vector<vector<int>> C(n, vector<int>(n));
  rep(i, c) rep(j, c) cin >> D[i][j];
  rep(i, n) rep(j, n) {
    cin >> C[i][j];
    C[i][j]--;
  }
  vector<vector<ll>> cost(3, vector<ll>(c));
  rep(i, n) rep(j, n) {
    rep(k, c) cost[(i+j)%3][k] += D[C[i][j]][k];
  }
  ll ans = longinf;
  rep(i, c) rep(j, c) rep(k, c) {
    if(i != j && i != k && j != k) {
      chmin(ans, cost[0][i]+cost[1][j]+cost[2][k]);
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 4208
# https://codeforces.com/blog/entry/71482
# https://atcoder.jp/contests/abc145/submissions/8473167

import numpy
n, t = map(int, input().split())
time = []
for i in range(n):
    x, y = map(int, input().split())
    time.append((x, y))


dp = numpy.zeros(t, dtype=int)
time.sort()
ans = 0
for a, b in time:
    ans = max(ans, dp[-1]+b)
    dp[a:] = numpy.maximum(dp[a:], dp[:-a]+b)

print(ans)

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


bool solve() {
  int H, W; cin >> H >> W;
  vector<string> A(H);
  int cnt = 0;
  for (int y = 0; y < H; y++) {
    cin >> A.at(y);
    for (int x = 0; x < W; x++) if (A.at(y).at(x) == '#') cnt++;
  }
  if (cnt != H + W - 1) return false;
  int x = 0, y = 0;

  auto chk = [&](int yy, int xx) {
    if (yy >= H) return false;
    if (xx >= W) return false;
    return A.at(yy).at(xx) == '#';
  };

  while (y != H-1 || x != W-1) {
    bool okD = chk(y+1, x);
    bool okR = chk(y, x+1);
    if (okD == okR) return false;
    if (okD) y++;
    else x++;
  }
  return true;
}


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << (solve() ? "Possible" : "Impossible") << endl;
  return 0;
}



Measured memory_bytes: 384