akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

long long M, r[2], c[2];

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    while (cin >> M >> r[0] >> r[1] >> c[0] >> c[1]) {
        long long x = 0;
        for (int it = 0; it < 2; ++it) {
            long long mul = c[it] * 100;
            long long add = (mul + r[it] - 1) / r[it];
            x += add;
        }
        if (x > M) cout << -1 << endl;
        else cout << M - x << endl;
    }
    return 0;
}


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

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine().Trim().Split().Select(e => int.Parse(e)).ToArray();
    var n = input[0];
    var k = input[1];

    var ans = k * Math.Pow(k-1, n-1);
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int x;

    cin>>x;

    cout<<(x/500)*1000+((x%500)/5)*5<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll N;
    cin >> N;
    ll ans = N-1;
    if (N % 2 == 0) {
        ans = min(ans, N/2-1+1);
    }
    // bool found = false;
    for(ll i = 3; i*i <= N; i+=1) {
        if (N % i == 0) {
            ans = min(ans, (i-1)+((N/i)-1));
            // found = true;
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main(){
    int a, b, c; cin >> a >> b >> c;
    bool fg = true;
    if(a%b== 0 && c != 0) fg = false;
    else{
        if(c%__gcd(a,b)!=0)fg = false;
    }
    if(fg) cout << "YES" << ln;
    else cout << "NO" << ln; 
    
}



Measured memory_bytes: 256
from math import gcd

input_num = int(input())

sum = 0

for a in range(1, input_num+1):
    for b in range(1, input_num+1):
        if gcd(a, b) == 1:  
            sum += 1 * input_num
            continue
        for c in range(1, input_num+1):
            if gcd(b, c) == 1:
                sum += 1
            else: 
                sum = sum + gcd(gcd(a, b), c)

print(sum)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010], m[1000005];
int main()
{
    ll t,n,i,j,k,l,r,mn=0, mx=1;
    sl(n);
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        sl(a[i]); m[a[i]]++;
    }

    ll f =0;
    for(int i=0; i<n; i++)
    {
        f=0;
        if(m[a[i]]>1) continue;
        for(ll j=1; j*j<=a[i]; j++)
        {

            if(a[i]%j==0)
            {
                if(m[j]>0 && j!=a[i]) f=1;

                ll p=a[i]/j;
                if(m[p]>0 && p!=a[i]) f=1;
            }
        }
        //cout<<a[i]<<" "<<f<<endl;
        if(f==0) cnt++;
    }
  cout<<cnt;
}


Measured memory_bytes: 13004
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

pii edge[maxn];
int father[maxn], rankk[maxn], n;
ll siz[maxn];

void init()
{
    for(int i = 0; i <= n; i++) father[i] = i, rankk[i] = 0, siz[i] = 1LL;
}

int query(int id)
{
    return father[id] == id ? id : query(father[id]);
}

void merge(int a, int b)
{
    int fathera = query(a);
    int fatherb = query(b);
    if(fathera != fatherb)
    {
        if(rankk[fathera] > rankk[fatherb])
        {
            siz[fathera] += siz[fatherb];
            father[fatherb] = fathera;
        }
        else
        {
            siz[fatherb] += siz[fathera];
            father[fathera] = fatherb;
            if(rankk[fathera] == rankk[fatherb])    rankk[fatherb]++;
        }
    }
}

ll ans[maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int m;
    scanf("%d%d", &n, &m);
    init();

    ll answer = 1LL * n * (n - 1) / 2;
    for(int i = 1; i <= m; i++) scanf("%d%d", &edge[i].first, &edge[i].second);
    for(int i = m; i >= 1; i--)
    {
        ans[i] = answer;
        int a = edge[i].first;
        int b = edge[i].second;
        int fathera = query(a);
        int fatherb = query(b);
        if(fathera == fatherb)  continue;
        answer += 1LL * siz[fathera] * (siz[fathera] - 1) / 2;
        answer += 1LL * siz[fatherb] * (siz[fatherb] - 1) / 2;
        answer -= 1LL * (siz[fathera] + siz[fatherb]) * (siz[fathera] + siz[fatherb] - 1) / 2;
        merge(a, b);
    }

    for(int i = 1; i <= m; i++) printf("%lld\n", ans[i]);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;


/*
  let's try computer shogi!!!
 */

long int N;

int main(){
  cin >> N;
  if(N%2==0){
    cerr<<"even"<<endl;
    cout<<N<<" "<<N<<" "<<N/2<<endl;
  }else{
    for(int i=1;i<3500;++i){
      for(int j=1;j<3500;++j){
	if(4*i*j-N*(i+j) <=0 ){continue;}
	if((N*i*j)%(4*i*j-N*(i+j))==0){
	  cout<<i<<" "<<j<<" "<<(N*i*j)/(4*i*j-N*(i+j))<<endl;
	  return 0;
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    vector<int> v1(n+1),v2(n+1),v3(n);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v1[i];
    for(int i=1;i<=n;i++)
        cin>>v2[i];
        for(int i=1;i<n;i++)
        cin>>v3[i];
    for(int i=1;i<=n;i++)
    {
        c+=v2[v1[i]];
        if(v1[i]==1+v1[i-1])
        {
            c+=v3[v1[i-1]];

        }

            //cout<<c<<endl;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

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

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


    long long int ans = pow(3, N);
    long long int odd = 1;
    for( int i = 0; i < N; ++i ){
        if( A[i]%2 == 0 ) odd *= 2;
    }


    cout << ans-odd << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

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

    string max_s = "zyxwvutsrqponmlkjihgfedcba";

    if(S == max_s){
        pr(-1);return 0;
    }

    if(S.length() == 26){
        auto s = S;
        next_permutation(ALL(S));
        string ans;
        for (int i = 0; i < 26; i++)
        {
            ans += S[i];
            if(S[i] != s[i]) break;
        }
        
        pr(ans);
    }else{
        int ok[26] = {};
        for (size_t i = 0; i < S.length(); i++)
        {
            ok[S[i]-'a'] = 1;
        }
        for (size_t i = 0; i < 26; i++)
        {
            if(ok[i] != 1){
                S += ('a'+i);
                break;
            }
        }
        pr(S);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
int n,m,dp[1<<12],maxstate;
int main(){
	scanf("%d%d",&n,&m);
	maxstate=(1<<n)-1;
	for(register int i=1;i<=maxstate;i++)	dp[i]=INT_MAX;
	for(register int i=1;i<=m;i++){
		int a,b,c,now=0;
		scanf("%d%d",&a,&b);
		for(register int j=1;j<=b;j++){
			scanf("%d",&c),now|=(1<<(c-1));
		}
		for(register int j=maxstate;j>=0;j--)	if(dp[j]!=INT_MAX) dp[j|now]=min(dp[j]+a,dp[j|now]);
	}
	if(dp[maxstate]==INT_MAX)	printf("-1");
	else printf("%d",dp[maxstate]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	long long a,b,x,w;
	cin>>a>>b>>x;
	
	if(a==0)
	{
		w=(b/x)+1;
	}
	else
	{
		w=(b/x)-(a-1)/x;
	}
	cout<<w;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }

class fenwick_tree {
  vector<int> a;
public:
  fenwick_tree(int n) : a(n+1) {}
  void add(int i, int x) {
    int n = ::size(a) - 1;
    for (; i <= n; i += i & -i)
      a[i] += x;
  }
  int psum(int i) const {
    int r = 0;
    for (; i > 0; i -= i & -i)
      r += a[i];
    return r;
  }
};

signed main() {
  const int n = rint();
  const int q = rint();
  // b_i = a_i - a_{i-1} (conventionally a_0 = 0)
  // a_n = sum(i = 1, ..., n) b_i
  // b_s = a_s - a_{s-1} += x
  // b_{t+1} = a_{t+1} - a_t += -x
  fenwick_tree ft(n);
  dotimes(i, q) {
    if (rint())
      wint(ft.psum(rint()));
    else {
      const int s = rint();
      const int t = rint();
      const int x = rint();
      ft.add(s, x);
      if (t < n)
        ft.add(t+1, -x);
    }
  }
  return 0;
}



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

// colours
#define RESET   "\033[0m"
#define BLACK   "\033[30m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
#define YELLOW  "\033[33m"
#define BLUE    "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN    "\033[36m"
#define WHITE   "\033[37m"

// debugging : values of variables
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << YELLOW << "debug statement : " << *it << " = " << a << RESET << endl;
    err(++it, args...);
} 

void testCase(){
    long long a, b, x;
    cin>>a>>b>>x;
    long long val = 0;
    long long n = (x+1)/b;
    if(n != 0)
        val = max(val, (a*(n*b-1))/b - (n-1)*a);
    else 
        val = max(val, a*x/b);
    cout<<val<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
 
int main()
{
    int n,ans=0;
    cin>>n;
 
    ll arr[n];
 
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        ans=ans^arr[i];
    }
 
    for(int i=0;i<n;i++)
    {
        int b=ans^arr[i];
        cout<<b<<" ";
    }
 
    return 0;
}

Measured memory_bytes: 5124
#include<iostream>
#include<vector>
using namespace std;
typedef vector<int> data;
vector<data> ans;
void make(data d, int n){
	if(n == 0){
		ans.push_back(d);
		return;
	}
	for(int i = 1;i <= n;i++){
		if(d.size() > 0 && i > d.back()) continue;
		data t(d);
		t.push_back(i);
		make(t, n - i);
	}
}
int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		make(data(), n);
		for(int i = ans.size() - 1;i >= 0;i--){
			for(int j = 0;j < ans[i].size();j++){
				cout << ans[i][j];
				if(j != ans[i].size() - 1) cout << ' ';
			}
			cout << endl;
		}
		ans.clear();
	}
	return 0;
}

Measured memory_bytes: 1796
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        vlli f(1e4+1,0);
        fra(i,1,1e2){
            fra(j,1,1e2){
                fra(x,1,1e2){
                    int s=i*i+i*j+i*x+j*x+j*j+x*x;
                    if(s<=1e4) f[s]++;
                }
            }
        }
        read(n);
        fra(i,1,n+1){
            cout << f[i] << '\n';
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  map<string, int> score;
  for(string x: a) {
    if (score.count(x)) {
      score[x]++;
    }
    else {
      score[x] = 1;
    }
  }
  int ans = 0;
  for (string x: a) {
    if (score[x] > ans) {
      ans = score[x];
    }
  }
  for (auto p :score) {
    if (p.second == ans) {
      cout << p.first <<endl;
    }
  }
  
}


Measured memory_bytes: 26752
#include <stdio.h>


int main()
{
	int n;

	scanf("%d",&n);

	long long sum = 0;

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

		scanf("%d%d",&x,&y);

		sum += (y - x + 1);
	}

	printf("%lld\n",sum);


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <list>
using namespace std;
static const int MAX = 10000;
static const int INFTY = 1 << 29;

vector<int> g[MAX];
list<int> out;
bool v[MAX];
int n;
int deg[MAX];

void bfs(int s)
{
	queue<int> q;
	q.push(s);
	v[s] = true;

	while (!q.empty()) {
		int u = q.front(); q.pop();
		out.push_back(u);

		for (int i = 0; i < g[u].size(); i++) {
			int w = g[u][i];
			deg[w]--;
			if (deg[w] == 0 && !v[w]) {
				v[w] = true;
				q.push(w);
			}
		}
	}
}

void tsort()
{
	for (int i = 0; i < n; i++) {
		deg[i] = 0;
	}

	for (int u = 0; u < n; u++) {
		for (int i = 0; i < g[u].size(); i++) {
			int w = g[u][i];
			deg[w]++;
		}
	}

	for (int u = 0; u < n; u++) {
		if (deg[u] == 0 && !v[u]) bfs(u);
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
		cout << *it << endl;
	}
}

int main()
{
	int s, t, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) v[i] = false;

	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		g[s].push_back(t);
	}

	tsort();

	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            String[] s = in.readLine().split(" ");
            double a = Double.parseDouble(s[0]);
            double b = Double.parseDouble(s[1]);
            double C = Math.toRadians(Double.parseDouble(s[2]));

            double S = 0.5*a*b*Math.sin(C);
            double c = Math.sqrt(a*a+b*b-2*a*b*Math.cos(C));
            double L = a + b + c;
            double h = 2*S/a;
            System.out.printf("%.8f\n", S);
            System.out.printf("%.8f\n", L);
            System.out.printf("%.8f\n", h);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24932
#! -*- coding:utf-8 -*-
n = int(input())
data = list(input().split())
data = [int(i) for i in data]

for i in range(n):
    print('node ',i+1,':',sep = '',end = '')
    print(' key = ',data[i],',',sep = '',end = '')

    if i != 0:
        print(' parent key = ',data[(i-1)//2],',',sep = '',end = '')
    
    if 2*i + 1 >= 0 and 2*i + 1 < n:
        print(' left key = ',data[2*i+1],',',sep = '',end = '')
    if 2*(i+1) >= 0 and 2*(i+1) < n:
        print(' right key = ',data[2*(i+1)],',',sep = '',end = '')

    print(' ')

Measured memory_bytes: 7764
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);

    while (1) {
        int N;
        cin >> N;

        if (N == 0) {
            break;
        }

        // 誰が誰の個人情報を知っているか
        bitset<101> has_privacy[100];

        for (int i=0; i<N; ++i) {
            int M;
            cin >> M;
            for (int j=0; j<M; ++j) {
                int p;
                cin >> p;
                has_privacy[i].set(p, 1);
            }
        }

        int K;
        cin >> K;

        bitset<101> leaked_list;
        for (int i=0; i<K; ++i) {
            int l;
            cin >> l;
            leaked_list.set(l, 1);
        }

        int ans = -1;
        for (int i=0; i<N; ++i) {
            if ((has_privacy[i] & leaked_list) == leaked_list) {
                if (ans == -1) {
                    ans = i + 1;
                } else {
                    ans = -1;
                    break;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

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

  ll g = gcd(a, b);
  vector<pair<ll, int>> fact;
  for (ll i = 2; i * i <= g; ++i) {
    int cnt = 0;
    while (g % i == 0) {
      g /= i;
      ++cnt;
    }
    if (cnt != 0) fact.push_back({i, cnt});
  }
  if (g != 1) fact.push_back({g, 1});

  int ans = 1;
  ans += fact.size();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int function(int n,int s,int a);
int main(void){
  int n,s;
  int a;
  int ans;
  while(1){
    scanf("%d %d",&n,&s);
    if(n==0&&s==0){
      break;
    }else{
      ans=0;
      if(n==1){
	if(s>=0&&s<=9){
	  ans=1;
	}
      }else{
	for(a=9;a>=0;a--){
	  //printf("///%d %d %d\n",n-1,s-a,a);
	  ans+=function(n-1,s-a,a);
	}
      }
      printf("%d\n",ans);
    }
  }
  return 0;
}

int function(int n,int s,int a){
  int answer=0;
  int i;
  int d,min,max;
  if(n==1){
    if(s>=0&&s<=a-1){
      //printf("/%d %d %d\n",n,s,a);
      answer++;
    }
  }else{
    min=n*(n-1)/2; max=n*(2*a-n-1)/2;
    if(min<=s&&max>=s){
      if(s>a-1){
	d=a-1;
      }else{
	d=s;
      }
      for(i=d;i>=0;i--){
	//printf("%d %d %d\n",n-1,s-i,i);
	answer+=function(n-1,s-i,i);
      }
    }
  }
  return answer;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int INM = 114514;

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

    int A[m], B[m];
    for(int i = 0; i < m; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    int ans = 0;
    for(int c = 0; c < m; c++){
        int G[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j) G[i][j] = 0;
                else G[i][j] = 1e9;
            }
        }

        for(int i = 0; i < m; i++){
            if(i == c);
            else{
                G[A[i]][B[i]] = 1;
                G[B[i]][A[i]] = 1;
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
                }
            }
        }
        bool f = false;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < n; j++){
                if(G[i][j] == 1e9){
                    f = true;
                    ans++;
                    break;
                }
            }
            if(f) break;
        }

        /*-check--
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << G[i][j] << " ";
            }
            cout << endl;
        }
        cout << "-----------------------------------------------" << endl;
        --------*/

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int p[N];
   for(int i=0; i<N; ++i)
      std::cin >> p[i];

   int count = 0;
   bool flag = false;
   for(int i=0; i<N; ++i){
      if(i+1==p[i]){
	 if(flag) flag = false;
	 else{
	    ++count;
	    flag = true;
	 }
      }else flag = false;
   }
   std::cout << count << std::endl;
   return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define st stack<ll>
#define v vector<ll>
#define s set<ll>
#define p pair<ll,ll>
#define mp map<char,ll>
#define us unordered_set<ll>
#define pq priority_queue<ll>
#define q queue<ll>
#define pb push_back
#define forn(i,n) for(ll i=0;i<n;i++)
#define pf push_front
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	boost;
	ll n;
	cin>>n;
	ll s1=n%10;
	
	
	
	if(s1==2||s1==4||s1==5||s1==7||s1==9)
	{
		cout<<"hon"<<endl;
	}
	else if(s1==0||s1==1||s1==6||s1==8)
	{
		cout<<"pon"<<endl;
	}
	else
	{
		cout<<"bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int h[2],m[2];
	int k;
	rep(i,2){
		cin>>h[i]>>m[i];
	}
	cin>>k;
	int mins=(h[1]-h[0]-1)*60+(60-m[0])+m[1];
	cout<<mins-k<<endl;
}

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


Measured memory_bytes: 3652
n = int(input())

def shave(n):
    if n < 2:
        return []
    else:
        n_root = int(n**0.5)
        candidate = [i for i in range(3, n+1, 2)]
        for i in range(3, n_root+2, 2):
            candidate = [j for j in candidate if j == i or j % i != 0]
        candidate = [2] + candidate
        return candidate

for i in shave(10**5+10):
    if i >= n:
        print(i)
        break

Measured memory_bytes: 47212
#include<bits/stdc++.h>
#define INF 1001001001

struct card{
    std::string str;
    int num;
};

int partition(std::vector<card>& A, int p, int r){
    card tmp;
    int x = A[r].num;
    int i = p - 1;
    for(int j = p; j < r; j++){
        if(A[j].num <= x){
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i+1;
}

void quickSort(std::vector<card>& A, int p, int r){
    if(p < r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

void merge(std::vector<card>&A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    std::vector<card> L(n1+1);
    std::vector<card> R(n2+1);
    for(int i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1].num = INF;
    R[n2].num = INF;
    int i = 0;
    int j = 0;

    for(int k = left; k < right; k++){
        if(L[i].num <= R[j].num){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
    
}

void mergeSort(std::vector<card>&A, int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}



int main(void){
    int n;
    bool flag = true;
    std::cin >> n;
    std::vector<card> A(n), B(n);
    char str;
    int num;
    
    for(int i = 0; i < n; i++){
        std::cin >> str >> num;
        A[i].str = str;
        A[i].num = num;
    }
    
    B = A;

    quickSort(A, 0, n-1);
    mergeSort(B, 0, n);
    for(int i = 0; i < n; i++){
        if(A[i].str != B[i].str){
            std::cout << "Not stable" << std::endl;
            flag = !flag;
            break;
        }
    }
    if(flag){
        std::cout << "Stable" << std::endl;
    }

    
    for(int i = 0; i < n; i++){
        std::cout << A[i].str << " " << A[i].num << std::endl;
    }
    
    
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int H, W, K;
llong dp[101][8] = {};

bool check_amidakuji_bar(int bit) {
    for (int check_bit = 0; check_bit < (1 << (W - 1 - 1)); ++ check_bit) {
        if ((bit & (1 << check_bit)) && (bit & (1 << (check_bit + 1)))) return false;
    }

    return true;
}

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            for (int bit = 0; bit < (1 << (W - 1)); ++bit) {
                if (check_amidakuji_bar(bit)) {
                    if (w < W - 1 && (bit & (1 << w))) dp[h + 1][w + 1] = (dp[h + 1][w + 1] + dp[h][w]) % MOD;
                    else if (w - 1 >= 0 && (bit & (1 << (w - 1)))) dp[h + 1][w - 1] = (dp[h + 1][w - 1] + dp[h][w]) % MOD;
                    else dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % MOD;
                }
            }
        }
    }

    cout << dp[H][K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N, K int

	fmt.Scan(&N, &K)
	D := make([]int, K)
	for i := range D {
		fmt.Scan(&D[i])
	}
	for i := 0; i < N*10; i++ {
		ok := true
		for _, num := range strconv.Itoa(i) {
			for _, d := range D {
				if num == rune(d+'0') {
					ok = false
				}
			}
		}
		if ok && i >= N {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define CONTAINS(x, y) (x.find(y)!=x.end()) //x<T1,T2>, T1 y
#define getPair(x) MP(x->first,x->second)

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
int a,b,c;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    //cout<<setw(4)<<setfill('0')<<"hoge"<<endl;
    cin>>a>>b>>c;

        vector<int> vec;
        vec.push_back(a);
        vec.push_back(b);
        vec.push_back(c);
        sort(vec.begin(),vec.end());
        if(vec[2]==vec[1]+vec[0]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int a, b;
  cin >> a >> b;
  int ans = a - 1;
  if (b >= a)
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

	int N, K;
	int A[100100], B[100100];
	while (cin >> N >> K) {
		for (int i=0; i<N; i++)
			cin >> A[i];

		if (N <= K) {
			cout << abs(A[0] - A[N-1]) << '\n';
			continue;
		}

		B[0] = 0;
		for (int i=1; i<K; i++) {
			B[i] = 1e9;
			for (int j=0; j<i; j++)
				B[i] = min(B[i], B[j] + abs(A[i] - A[j]));
		}
		for (int i=K; i<N; i++) {
			B[i] = 1e9;
			for (int j=1; j<=K; j++)
				B[i] = min(B[i], B[i-j] + abs(A[i-j] - A[i]));
		}

		cout << B[N-1] << '\n';
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        int L = scan.nextInt();
        int R = scan.nextInt();
        int d = scan.nextInt();

        int out = 0;

        for (int i=L; i <= R; i++){
            if (i % d == 0){
                out ++;
            }
        }
        System.out.println(out);
    }
}


Measured memory_bytes: 35592
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    elif b == 0:
        print(n)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    if f == 0:
        print(a * d + g)
    else:
        print(a * d + a)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3060
#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)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,p;
    string s;
    in>>n>>p>>s;
    if(p==2||p==5){
        ll ans{};
        fr(i,n){
            if((s[i]-'0')%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    int tmp{1};
    ll ans{};
    vector<int> V(n+1),v(p);
    fr(i,n){
        V[i+1]=V[i]*10+s[i]-'0';
        V[i+1]%=p;
    }
    ifr(i,n+1){
        ans+=v[(V[i]*tmp)%p]++;
        tmp*=10;
        tmp%=p;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1428
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i = 2; i <= n; i++) {
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  
    trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 608
import math


def main():
    nvertices, nedges, s = map(int, input().split())
    edges = []
    for i in range(nedges):
        u, v, w = map(int, input().split())
        edges.append((u, v, w))

    INF = float('inf')
    weights = [INF] * nvertices
    weights[s] = 0
    for i in range(nvertices - 1):
        for u, v, w in edges:
            if weights[v] > weights[u] + w:
                weights[v] = weights[u] + w

    for u, v, w in edges:
        if weights[v] > weights[u] + w:
            print("NEGATIVE CYCLE")
            return

    for w in weights:
        if math.isinf(w):
            print("INF")
        else:
            print(w)


main()

Measured memory_bytes: 8276
import sys
from collections import Counter

sa = input()
sb = input()
sc = input()

turn = 'a'

while True:
    if turn == 'a':
        turn = sa[0]
        sa = sa[1:]
    elif turn == 'b':
        turn = sb[0]
        sb = sb[1:]
    elif turn =='c':
        turn = sc[0]
        sc = sc[1:]
    if len(sa) == 0 and turn == 'a':
        print('A')
        sys.exit()
    elif len(sb) == 0 and turn == 'b':
        print('B')
        sys.exit()
    elif len(sc) == 0 and turn == 'c':
        print('C')
        sys.exit()


Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int n,m;
	cin >> n >> m;
	cout << (ceil(n * 1.0 / m)) <<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int x,y;

  while(1){
    cin >> x >> y;
    if(x==0 && y==0)  break;
    if(x<y)  cout << x << ' ' << y << endl;
    else  cout << y << ' ' << x << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string s;
	string t = "CODEFESTIVAL2016";
	char c;
	int ans = 0;
	cin>>s;
	for(int i=0;i<16;i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 256
N=int(input())
S=input()
T=input()
dup=0
for d in range(N+1):
  # print(d)
  flag=True
  for i in range(N-d):
    
    if T[i]!=S[d+i]:
      # print(T[i],S[d+i])
      flag=False
      break
  if flag:
    dup=N-d
    break
print(2*N-dup)


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

int main() {
  ll N;
  cin >> N;
  ll A, B;
  cin >> A >> B;
  ll gap = B - A;
  
  if (gap%2 == 0) {
    cout << gap/2 << endl;
  }
  
  else if (gap%2 == 1) {
    ll side = min((A - 1), (N - B));
    ll mg = 1 + gap / 2;
    cout << side + mg << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> D;
    for (int i = 0; i < K; i++) {
        int t;
        cin >> t;
        D.push_back(t);
    }
    while (1) {
        string N_str = to_string(N);
        bool ok = true;
        for (int i = 0; i < N_str.length(); i++) {
            for (int j = 0; j < K; j++) {
                if ((int)(N_str[i] - '0') == D[j]) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) break;
        N++;
    }
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
ar = list(map(int,input().split(" ")))
k = 0
g = 0
f = 0
for r in ar:
    if r % 4 == 0:
        f += 1
    elif r % 2 == 0:
        g += 1
    else:
        k += 1
if k - f > 1:
    print("No")
elif k - f == 1:
    if g == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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


int main()
{
    double n;
    cin>>n;
    if((int)n%2==0)cout<<fixed<<setprecision(10)<<(n/2)/n<<endl;
    else {
        double p = (int)n/2+1;
        cout<<fixed<<setprecision(10)<<(p/n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

int main(){
    ll n;
    cin >> n;
    cout << n * n << endl;
}

Measured memory_bytes: 256
import sys
a=sys.stdin
while 1:
 if'0\n'==a.readline():break
 s=list(map(int,a.readline().split()))
 c=0
 while 1:
  t=s;s=[t.count(e)for e in t]
  if t==s:break
  c+=1
 print(c);print(*s)


Measured memory_bytes: 5720
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

cout << K * (int)pow(K - 1, N - 1) << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.
// map[]は対数時間．unordered_map[]は一定時間．


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = n*(n+1)*(n+2)/6 - k*(k-1)*(3*n-2*k+4)/6 + n - k + 2;
  cout << ans%1000000007 << endl;
}


Measured memory_bytes: 3632
N,M=map(int,input().split())
Qnum=[0]*M
rslt=[" "]*M
Pnum=[0]*N #問題当たりのペナルティの数
Flag=[0]*N
ACnum=0
for i in range(M):
    Qnum[i],rslt[i]=input().split()
    Qnum[i]=int(Qnum[i])
    if Flag[Qnum[i]-1]==0:
        if rslt[i]=="AC":
            Flag[Qnum[i]-1]=1
            ACnum+=1
        else:
            Pnum[Qnum[i]-1]+=1

for j in range(N):
    if Flag[j]==0:
        Pnum[j]=0
print(ACnum,sum(Pnum))


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

int main() {
  int N, K;
  int Z = 1;// N;試行回数, K;任意の数 Z;電光掲示板上の数字
  cin >> N >> K;
  int A;//A思考：Addition (N - A)B試行：Mulitiplication
  for (int i = 0; i < N ; i ++){
    if ( K < Z ){
      Z += K;
    }
    else if (K >= Z ){
      Z *= 2;
    }
  }
  cout << Z << endl;
}


Measured memory_bytes: 384
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    int n;
    cin >> n;
    VI a(n), b(n);
    FOR (i, 0, n)
        cin >> a[i] >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n%2 == 1) {
        assert(b[n/2] - a[n/2] >= 0);
        cout << b[n/2] - a[n/2] + 1 << "\n";
    } else {
        assert((b[n/2] + b[n/2-1])/(float)2 - (a[n/2] + a[n/2-1])/(float)2 >= 0);
        cout << b[n/2] + b[n/2-1] - a[n/2] - a[n/2-1] + 1 << "\n";
    }
}



Measured memory_bytes: 4784