akhauriyash/Code-Regression huggingface dataset:
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		long mod = (long)1e9+7;
		int n = reader.ni();
		int k = reader.ni();
		long res = 0;
		for (long i=1; i<=n+1; i++) {
			long min_val = (0 + i-1) * i / 2;
			long max_val = (n-i+1 + n) * i / 2;
			// System.out.println("i = " + i + ", min_val = " + min_val + ", max_val = " + max_val);
			if (i >= k) {
				// System.out.println("i = " + i + ", min_val = " + min_val + ", max_val = " + max_val);
				res += max_val - min_val + 1;
				res %= mod;
			}
		}
		out.println(res);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32940
#include<stdio.h>
#include<math.h>

int main(void){
    long long int n;
    int i=0 ,mod =27;
    char s[10000];
  	char mozi[26];
  	for(int j =0;j<26;j++){
      mozi[j] = j+97;
      //printf("%c",mozi[j]);
      
    }
    scanf("%lld",&n);
    do{
      	n--;
        s[i] = mozi[n%26];
        n /= 26;
      	
        i++;
    }while(n>0);
    for(i>=0;i--;){
        printf("%c",s[i]);
    }
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count5 = 0;
	int count7 = 0;
	if (a == 5) {
		count5++;
	}
	if (a == 7) {
		count7++;
	}
	if (b == 5) {
		count5++;
	}
	if (b== 7) {
		count7++;
	}
	if (c == 5) {
		count5++;
	}
	if (c == 7) {
		count7++;
	}
	if (count5 == 2 && count7 == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define maxn 2005
#define mod 1000000007
vector<int>g[maxn];
int n,k,m,f;

void dfs(int v,int p,int dist){
	if(dist>k/2)m++;
	for(int u:g[v]){
		if(u-p){
			dfs(u,v,dist+1);
		}
	}
}

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

	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g[v].pb(u);
		g[u].pb(v);
	}

	int ans=mod;
	if(k%2==0){
		for(int i=1;i<=n;i++){
			m=0;
			dfs(i,0,0);
			ans=min(ans,m);
		}
	}
	else{
		for(int i=1;i<=n;i++){
			for(int j:g[i]){
				m=0;
				dfs(i,j,0);
				dfs(j,i,0);
				ans=min(ans,m);
			}
		}
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 512
import sys
import bisect

input = sys.stdin.readline

N, M = list(map(int,input().split()))
LRC = [list(map(int,input().split())) for i in range(M)]
LRC.sort()

INF = 100100100100100100
dist = [INF]*N
dist[0] = 0

for li, ri, ci in LRC:
	td = dist[li-1]+ci
	ti = bisect.bisect(dist,dist[li-1]+ci)
	ti = min(ti,ri+1)
	for i in range(ti,ri):
		dist[i] = td

ans = dist[-1]
if ans==INF: ans = -1

print(ans)

Measured memory_bytes: 62172
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//https://codeforces.com/contest/1215/problem/A
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}


int main()
{
    FAST();
    ll int n,m;
    cin>>n;
 for(ll int i=1;i<=n;i++)
 {
     int cnt=0;
     int sq=sqrt(i);
     for(int j=1;j<=sq;j++)
     {
         for(int k=1;k<=sq;k++)
         {
             for(int l=1;l<=sq;l++)
             {
                 ll res=l*l+j*j+k*k+l*j+j*k+k*l;
                 if(res==i)cnt++;
                 if(res>i)break;
             }
         }
     }
     cout<<cnt<<endl;
 }
}




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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 300007;
const int MOD = 998244353;

int n, a, b;
LL K;
LL frac[MAXN], rf[MAXN];

void init ();
void input ();
void work ();



int add ( int x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
	return x;
}

void addv ( int &x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
}

int sub ( int x, int y )
{
	x -= y;
	if ( x < 0 ) x += MOD;
	return x;
}

void subv ( int &x, int y )
{
	x -= y;
	if ( x < 0 ) x += MOD;
}

int qpow ( int a, int b )
{
	LL base = a, ans = 1;
	while ( b ) {
		if ( b & 1 ) ( ans *= base ) %= MOD;
		( base *= base ) %= MOD;
		b >>= 1;
	}
	return SC ( int, ans );
}

int C ( int n, int m )
{
	return SC ( int, frac[n] * rf[m] % MOD * rf[n - m] % MOD );
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );

	frac[0] = 1;
	lp ( i, 1, MAXN ) frac[i] = frac[i - 1] * i % MOD;
	rf[MAXN - 1] = qpow ( frac[MAXN - 1], MOD - 2 );
	lpdi ( i, MAXN - 2, 0 ) rf[i] = rf[i + 1] * ( i + 1 ) % MOD;
}

void input ()
{
	// input method

	cin >> n >> a >> b >> K;
}

void work ()
{
	// main work

	int ans = 0;
	lpi ( i, 0, n ) {
		LL rem = K - SC ( LL, a ) * i;
		if ( rem >= 0 && rem % b == 0 && rem / b <= n ) {
			int j = rem / b;
			addv ( ans, SC ( LL, C ( n, i ) ) * C ( n, j ) % MOD );
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
N = int(input())
A = [(int(x), i+1) for i, x in enumerate(input().split())]

def test(N, A):
    answer = 0
    for a0, i0 in A:
        for a1, i1 in A:
            if a1 + a0 == abs(i1 - i0):
                answer += 1
    return answer // 2

def solve(N, A):
    memo0 = {}
    memo1 = {}
    for a, n in A:
        k = - (a+n)
        if k not in memo0:
            memo0[k] = 0
        memo0[k]+=1
        k = n-a
        if k not in memo1:
            memo1[k] = 0
        memo1[k]+=1
    #print(f"{memo0=}")
    #print(f"{memo1=}")
    answer = 0
    for a, n in A:
        k = a - n
        if k in memo0:
            answer += memo0[k]
        k = a + n
        if k in memo1:
            answer += memo1[k]

    return answer // 2

#print(test(N, A))
print(solve(N, A))




Measured memory_bytes: 76032
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int L[n];

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

    int count=0;

    for(int i=0;i<n-2;i++){
        for(int f=i+1;f<n-1;f++){
            for(int g=f+1;g<n;g++){
                if(L[i]!=L[f]&&L[f]!=L[g]&&L[g]!=L[i]){
                    if(L[i]<L[f]+L[g]&&L[f]<L[g]+L[i]&&L[g]<L[f]+L[i]){
                        count++;
                    }
                }
            }
        }
    }

    printf("%d\n",count);
}

Measured memory_bytes: 1732
#!/usr/bin/env python3
import sys
import numpy as np


def solve(A: int, B: int):
    print(A*B)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 1e5 + 5;
typedef long long ll;
int n;
int a[maxn], b[maxn], c[maxn];

ll xiao(int k)
{
	ll l = 0, r = n - 1, mid;
	while(l < r)
	{
		mid = (l + r) / 2;
		if(a[mid] < b[k])
			l = mid + 1;
		else
			r = mid;
	}
	if(a[l] >= b[k])
		l--;
	return l;
}

ll da(int k)
{
	ll l = 0, r = n - 1, mid;
	while(l < r)
	{
		mid = (l + r) / 2;
		if(c[mid] > b[k])
		{
			r = mid;
		}
		else
			l = mid + 1;
	}
	if(c[l] <= b[k])
		l++;
	return l;
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]); 
	for(int i = 0; i < n; i++)
		scanf("%d", &b[i]); 
	for(int i = 0; i < n; i++)
		scanf("%d", &c[i]);
	sort(a, a + n), sort(b, b + n), sort(c, c + n);
	//int k;
	//scanf("%d", &k);
	//printf("%d\n", da(k));
	ll sum = 0;
	for(int i = 0; i < n; i++)
	{
		ll a = xiao(i);
		ll b = da(i);
		//cout << a << ' ' << b << endl;
		sum += (a + 1) * (n - b); 
	} 
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1916
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <complex>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

typedef complex<double> P;

int main(){
  while(const int n = getInt()){
    vector<P>   pos(n);
    vector<double> v(n);

    REP(i,n){
      const int x = getInt();
      const int y = getInt();
      v[i] = getInt();
      pos[i] = P(x, y);
    }

    const double r = 0.98;
    P p(0, 0);

    auto calc = [&](P p){
      auto mx = make_pair(0.0, 0);
      REP(i,n) mx = max(mx, make_pair(abs(p - pos[i]) / v[i], i));
      return mx;
    };

    for(double d = 100; d > 1e-8; d *= r){
      auto mx = calc(p).second;
      p += (pos[mx] - p) / abs(pos[mx] - p) * d;
    }

    printf("%.8f\n", calc(p).first);
  }

  return 0;
}

Measured memory_bytes: 1088
s = int(input())

ax = 10 ** 9
by = 10 ** 9

bx_x_ay = ax * by - s

q, r = divmod(bx_x_ay, 10 ** 9)
by -= q
bx = 1
ay = r

ans = (0, 0) + (ax, ay) + (bx, by)
print(*ans)

# print(abs(ax * by - bx * ay))

# 三角形の面積 := s / 2 = abs(a.x * b.y - b.x * a.y) / 2
# 三角形の面積 := s / 2 = abs((a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y)) / 2


Measured memory_bytes: 2940
#include <algorithm>
#include <deque>
#include <iostream>
#include <string>

using namespace std;

constexpr static int MAXN = 1e6;

int n, k;
string s;

int main() {
    cin >> n >> k >> s;

    if (n == 1) {
        cout << ('A' + (s[0] - 'A' + k) % 2) << endl;
        return 0;
    }

    deque <int> d;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && s[j] == s[i])
            j++;
        d.push_back(j - i);
        i = j;
    }

    bool isA = (s[0] == 'A');
    for (int i = 0; i < k; i++) {
        if (d.size() == n)
            i += ((k - i - 1) / 2) * 2;
        /*
        cout << (isA ? 'A' : 'B');
        for (int len : d)
            cout << " " << len;
        cout << endl;
        */
        if (isA) {
            if (d.front() > 1) {
                // AA... -> BA...
                d.front()--;
                d.push_front(1);
            }
            else {
                // AB... -> BB...
                d.pop_front();
                d.front()++;
            }
            isA = false;
        }
        else {
            // B^m A^n ... -> A^{m-1} B^n ... A
            d.front()--;
            if (d.size() % 2 == 0)
                d.push_back(1);
            else
                d.back()++;

            if (d.front() == 0)
                d.pop_front();
            else
                isA = true;
        }
    }

    int add = (isA ? 0 : 1);
    for (int len : d) {
        cout << string(len, 'A' + add);
        add = 1 - add;
    }
    cout << endl;
}


Measured memory_bytes: 1540
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if (x[i]-x[i-1])*a>=b:
        ans+=b
    else:
        ans+=(x[i]-x[i-1])*a
print(ans)

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

typedef long long ll;

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

int main() { 
    int N, D_1, D_2, count = 0, status = 0;
    cin >> N;
    rep(i, N) {
        cin >> D_1 >> D_2;
        if (D_1 == D_2) {
            ++count;
        } else {
            count = 0;
        }
        if (count == 3) {
            status = 1;
        }
    }
    if (status == 1) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" <<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 3652
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int N,K,R,S,P; string T;

int winc(char c){ return c=='r'?'p':c=='s'?'r':'s'; }
int winp(char c){ return c=='r'?P:c=='s'?R:S; }

int main(){
	cin>>N>>K>>R>>S>>P>>T;
	vector<string> G(K); rp(i, 0, N) G[i%K] += T[i];
	int ans = 0;
	for(auto s:G){
		int n = s.size();
		pair<char,int> dp[n+1];
		dp[0].first = '-';
		dp[0].second = 0;
		rp(i, 0, n){
			if(dp[i].first == winc(s[i])){
				dp[i+1].first = s[i+1];//not overlap with the next value.
				dp[i+1].second = dp[i].second;
			}
			else{
				dp[i+1].first = winc(s[i]);//win
				dp[i+1].second += dp[i].second + winp(s[i]);
			}
		}
		ans += dp[n].second;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rep1(i,n) for (ll i = 1; i <= (n); ++i)
#define rrep(i,n) for (ll i = (n)-1; i >=0; --i)
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define dame { puts("-1"); return 0;}
#define show(x) cerr<<#x<<" = "<<x<<endl;

using namespace std;
using ll = long long;
using ld = long double;
using pl = pair<ll, ll>;

typedef vector<ll> vl;
typedef vector<pl> vp;
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; }


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

ll LINF = 1000000000000000000;

int main() {
  ll n;
  cin >> n;

  ll m = n;
  map<ll, ll> mp;
  bool flug = false;
  for(int i=2;i<=1000000; i++){
    while(m%i==0){
      m /= i;
      mp[i]++;
    }
  }

  if(m>1) mp[m]++;
  
  ll ans = 0;
  for(auto x:mp){
    //show(x.fi);
    //show(x.se);
    ll ind = 1;
    ll l=x.se;
    ll S = ind*(ind+1)/2;
    while(S<=l){
      ind++;
      S = ind*(ind+1)/2;
    }
    show(ind-1);
    
    ans += ind-1;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6236
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, H;
  cin >> N >> H;
  vector<ll> A(N), B(N);
  REP(i, 0, N) cin >> A[i] >> B[i];

  sort(B.begin(), B.end());

  vector<ll> sum(N + 1, 0);
  REP(i, 0, N) sum[i + 1] = sum[i] + B[i];

  ll ans = INF;
  REP(i, 0, N + 1) if(sum[N] - sum[i] >= H) ans = min(ans, N - i);
  REP(i, 0, N) {
    ll j = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
    ll s = sum[N] - sum[j];
    ll p = (N - j) + (H - s >= 0 ? (H - s + A[i] - 1) / A[i] : 0);
    ans = min(ans, p);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import itertools

N = int(input())
ans = 0

for i in range(3, len(str(N)) + 1):
    cand = list(map(lambda x: "".join(x), itertools.product("357", repeat=i)))
    for c in cand:
        if int(c) > N:
            continue
        elif all(c.count(s) > 0 for s in "357"):
            ans += 1

print(ans)


Measured memory_bytes: 4980
while True:
    line=input().rstrip().split()
    h=int(line[0])
    w=int(line[1])
    if h==0 and w==0:
        break
    else:
        for i in range(h):
            for j in range(w):
                if i%2==0:
                    if j%2==0:
                        print("#",end='')
                    else:
                        print(".",end='')
                else:
                    if j%2==0:
                        print(".",end='')
                    else:
                        print("#",end='')
            print()
        print()


Measured memory_bytes: 7008
#include <iostream>
#include <algorithm>
#include <vector>

bool all_div(std::vector<int>& V) {
    for (auto itr=V.begin(); itr!=V.end(); itr++) {
        if (*itr % 2 != 0)
            return false;
        *itr /= 2;
    }
    return true;
}

int main() {
    int N, temp;
    std::cin >> N;
    
    std::vector<int> A; 
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        A.push_back(temp);
    }
    
    int ans = 0;
    for (ans = 0; ans<32; ++ans) {
        if (!all_div(A))
            break;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int n, k;
int isok[11];

bool chk(int T)
{
	while(T)
	{
		int tt=T%10;
		if(isok[tt]) return false;
		T/=10;
	}
	return true;
}

int main(void)
{
	int i, x;
	cin>>n>>k;
	for(i=1 ; i<=k ; i++)
	{
		cin>>x; isok[x]=1;
	}
	for(i=n ; ; i++)
	{
		if(chk(i))
		{
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int ans = 0;
	int len = y+2*z;
	while (len <= x) {
		len += y + z;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

    ll n;
    cin >> n;
    vector<ll> a(n+1, 0);

    ll ans = 0;
    for(ll i = 1; i <= n; ++i) {
        for(ll j = i; j <= n; j+=i) {
            ++a[j];
        }
    }
    for(ll i = 1; i <= n; ++i) {
        ans += i*a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 81292
#!/usr/bin/env python3
import sys


def solve(N: int):
    sum = 0
    for i in range(1,N+1):
        if i % 3 != 0 and i % 5 != 0:
            sum += i
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67344
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int N = 32769;

int main(void){
    vi sq(N);
    for(int i = 0; i * i < N; i++){
        sq[i * i] = 1;
    }

    for(int n, res; cin >> n, n; cout << res << endl){
        res = 0;

        for(int i = 0; i * i <= n; i++){
            if(sq[i * i] == 0) continue;
            for(int j = i; i * i + j * j <= n; j++){
                if(sq[j * j] == 0) continue;
                for(int k = j; i * i + j * j + k * k <= n; k++){
                    if(sq[k * k] == 0) continue;
                    int last = n - i * i - j * j - k * k;
                    if(last < k * k) break;

                    if(sq[last]){
                        res++;
                    }
                }
            }
        }
    }

	return 0;
}

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

int main () {
  string str1 , str2  ;
  cin >> str1 >> str2 ;
  int ans = 0 ;
  if(str1[0] == str2[0]) ans++ ;
  if(str1[1] == str2[1]) ans++ ;
  if(str1[2] == str2[2]) ans++ ;
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,c=0,m,x;
    cin>>n>>m;
    vector<ll>v,u;
    for(ll i=0;i<m;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    u.push_back(n+v[0]-v[m-1]);
    for(ll i=0;i+1<m;i++)
    {
        u.push_back(v[i+1]-v[i]);
    }
    sort(u.begin(),u.end());
    for(ll i=0;i<u.size()-1;i++)
    {
        c+=u[i];
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 5872
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
key = False
for CX in range(101):
    for CY in range(101):
        ans = True
        H = -1
        for x, y, h in xyh:
            if h > 0:
                tmp = h + abs(x - CX) + abs(y - CY)
                if H == -1:
                    H = tmp
                else:
                    if H != tmp:
                        H = -2
                        break

        if H == -2:
            continue

        for x, y, h in xyh:
            if h == 0:
                dist = abs(x - CX) + abs(y - CY)
                if H > dist:
                    H = -2
                    break
                
        if H == -2:
            continue
        
        print(CX, CY, H)
        key = True
        break
        
    if key:
        break

                

Measured memory_bytes: 3064
from collections import Counter

n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]
"""
c = 0
c1 =  0
p = sorted(q)

for i in range(n):
	if p[i] == p[i+1]:
		c+=1
	else:
		
		if c>0:
			for j in range(c+1):
				c1+=j
				
		c=0
"""
count_by_kw = Counter()

for i in range(n):
	count_by_kw[q[i]] += 1
ans = 0
for kw, count in count_by_kw.most_common():

	ans += count*(count-1) /2

print(int(ans))


Measured memory_bytes: 31588
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	//多角形の包含関係
    int contains(Point2D[] plist,Point2D p){
   	boolean isin = false;
   	int n = plist.length;
   	for(int i = 0;i < n;i++){
   		Point2D a = sub(plist[i],p);
   		Point2D b = sub(plist[(i+1) % n ], p);
   		if(a.getY() > b.getY()){
   			Point2D temp = (Point2D) a.clone();a = b;
   			b = temp;
   		}
   		if(a.getY() <= 0 && 0 < b.getY()){
   			if(cross(a,b) < 0) isin =! isin;
   		}
   		if(cross(a,b) == 0 && dot(a,b) <= 0)return 0;
   	}
   	return isin ? 1 : -1;
    }
    //点と点の差
    Point2D sub(Point2D p1,Point2D p2){
   	 return new Point2D.Double(p1.getX()-p2.getX(),p1.getY()-p2.getY());
    }
    //内積
    double dot(Point2D p1,Point2D p2){
   	 return p1.getX()*p2.getX()+p1.getY()*p2.getY();
    }
    //外積
    double cross(Point2D p1,Point2D p2){
   	 return p1.getX()*p2.getY()-p1.getY()*p2.getX();
    }
	void doIt() { 
		int n = sc.nextInt();
		for(int k = 0;k < n;k++){
			for(int i = 0;i < 3;i++){
				Point2D xy[] = new Point2D.Double [3];
				for(int j = 0;i < 3;i++){
					xy[i] = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
				}
				Point2D xyk = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
				Point2D xys = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
				if(contains(xy,xyk) == contains(xy,xys)){
					System.out.println("NG");
				}else{
					System.out.println("OK");
				}
			}
		}
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve (int i, int m) {
    if (m==0) return 1;
    if (i>=n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return  res;
}

int main() {
    int q, M, i;

    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int ans[100];
int esc[8]={0,1,2,3,5,7,8,9};
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)break;
	int top=0;
	while(true){
		ans[top]=n%8;
		n/=8;
		if(n==0)break;
		top++;
	}
	for(int i=top;i>=0;i--)cout<<esc[ans[i]];
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    import collections
    cnter = collections.Counter(S)
    for k in ["AC", "WA", "TLE", "RE"]:
        cnt = 0 if k not in cnter else cnter[k]
        print("{} x {}".format(k, cnt))
    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 16404
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

ll sum(ll X) {
  ll res = 0;
  while (X) {
    res += X % 10;
    X /= 10;
  }
  return res;
}

signed main() {
  ll N;
  cin >> N;

  ll ans = sum(N);
  string S = to_string(N);
  rep(i, len(S)) {
    if (i == 0)
      S[i]--;
    else
      S[i] = '9';
  }
  chmax(ans, sum(stoll(S)));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  cout <<  n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x, y, res = 0, A, B, N;
int main(void){
    // Your code here!
    cin >> N >> A >> B;
    for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
            for (int c = 0; c < 10; c++) {
                for (int d = 0; d < 10; d++) {
                    x = a + b + c + d;
                    y = a * 1000 + b * 100 + c * 10 + d;
                    if (A <= x && x <= B && y <= N) res += y;
                }
            }
        }
    }
    if (N == 10000 && A == 1) res += 10000;
    cout << res << endl;
}


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

#include <vector>

#include <functional>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int c, d, sum;
    bool flag = false;

    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 101; j++)
        {
            sum = 4 * i + 7 * j;
            if (sum == N)
                flag = true;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;



int main() {
  int n; cin>>n;
  cout<<(10000-n)%1000;
}


/* きょむ〜 */


Measured memory_bytes: 3632
import copy
N, M = map(int, input().split())
INF = 2 ** 63 - 1
d = [[INF for i in range(N+1)] for j in range(N+1)]
for i in range(N+1):
    d[i][i] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c

d_original = copy.deepcopy(d)

for k in range(1, N+1):
    for j in range(1, N+1):
        for i in range(1, N+1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if d_original[i][j] != INF and d[i][j] != d_original[i][j]:
            ans += 1
print(ans)


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N){
        cin >> p[i];
    }
    int ans = 0;
    rep(i, N){
        if(p[i] == i + 1 && i < N - 1){
            swap(p[i], p[i + 1]);
            ans ++;
        }
        if(p[i] == i + 1 && i == N - 1){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef unsigned long long ull;
#define MAX_N 100000
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int A[MAX_N];
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];

	ull cnt = 0;
	for(int i=0; i<N; i++){
		cnt += A[i] / 2;
		A[i] = A[i] % 2;
		if(i != N-1 && A[i] && A[i+1]){
			cnt++;
			A[i+1]--;
		}
	}
	cout << cnt << endl;

	return 0;
}


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

int main() {
  int w, h, n, x, y, a; cin >> w >> h >> n;
  int max_x = w, max_y = h, min_x = 0, min_y = 0;

  for(int i = 0; i < n; i++) {
    cin >> x >> y >> a;
    switch(a) {
      case 1: min_x = max(min_x, x); break;
      case 2: max_x = min(max_x, x); break;
      case 3: min_y = max(min_y, y); break;
      case 4: max_y = min(max_y, y); break;
    }
  }
  int s = max_x - min_x, t = max_y - min_y;
  cout << (s > 0 && t > 0 ? s*t : 0) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		double  tri_a = scanner.nextDouble();
		double  tri_b = scanner.nextDouble();
		double  angle = scanner.nextDouble();
		double area = 0.f;
		double lap = 0.f;
		double high = 0.f;
		double  tri_a_w;
		double  tri_b_w;
		double  tri_c,tri_c_w;
		
		//ラジアン変換
		double rad = Math.toRadians(angle);
		double cos_angle = Math.cos(rad);
		double sin_angle = Math.sin(rad);
		
		//2辺を二乗しておく
		tri_a_w = tri_a * tri_a;
		tri_b_w = tri_b * tri_b;
		
		//余弦定理を使って3辺目を出す
		tri_c_w = tri_a_w + tri_b_w - ( tri_a * tri_b * 2 )*cos_angle ;
		tri_c = Math.sqrt( tri_c_w );
		
		//面積
		area = tri_a * tri_b * sin_angle * 0.5;
		
		//周
		lap = tri_a + tri_b + tri_c;
		
		//高さ
		high = ( area / tri_a )* 2; 
		
		System.out.println(area);
		System.out.println(lap);
		System.out.println(high);
		
		scanner.close();
	}
}


Measured memory_bytes: 27952
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a<=b*c){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[]) {
  string s;
  int cnt_0 = 0, cnt_1 = 0;
  int ans;
  cin >> s;
 
  // 0101...
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      if ('0' != s[i]) cnt_0++;
    } else {
      if ('1' != s[i]) cnt_0++;
    }
  }
 
  // 1010...
  for (int j = 0; j < s.size(); ++j) {
    if (j % 2 == 0) {
      if ('1' != s[j]) cnt_1++;
    } else {
      if ('0' != s[j]) cnt_1++;
    }
  }
 
  ans = min(cnt_0, cnt_1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ans=1000000000;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,cnt=0;
    cin>>a;
    while(a>1&&a%2==0){
      a/=2;
      cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
  return(0);
}


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

int main() {
  int n;cin>>n;
  vector<int> ans(n+1);
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int cnt=x*x+y*y+z*z+x*y+y*z+z*x;
        if(cnt<=n)ans[cnt]++;
      }
    }
  }
  for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> vec(H);

  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < H + 2; i++) {
    
    cout << '#';
    
    if (i == 0 || i == H + 1) {
      
      for (int j = 0; j < W; j++) {
        cout << '#';
      }
    } else {
       cout << vec.at(i - 1);
    }
    cout << '#' << endl;
  }
}

Measured memory_bytes: 256
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for m in range(1<<~-r):
  t=0
  for s in d:
   c=bin(m^s).count('1')
   t+=c if c>r//2 else r-c
  if a<t:a=t
 print(a)


Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int w,h,n;
  cin>>w>>h>>n;
  bool table[109][109];
  rep(i,h) rep(j,w) table[i][j]=true;
  rep(i,n){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
      rep(i,h) rep(j,x)
        table[i][j]=false;
    }
    if(a==2){
      rep(i,h) for(int j=x;j<=w;++j)
        table[i][j]=false;
    }
    if(a==3){
      rep(i,y) rep(j,w)
        table[i][j]=false;
    }
    if(a==4){
      for(int i=y;i<=h;++i) rep(j,w)
        table[i][j]=false;
    }
  }
  /*rep(i,h){
    rep(j,w){
      cout<<table[i][j];
    }
    cout<<endl;
  }*/
  
  int ans=0;
  rep(i,h) rep(j,w)
    if(table[i][j]) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N;cin >> N;
  string W[100];
  bool flg = true;
  for(int i = 0;i < N;++i)
    cin >> W[i];
  for(int i = 0;i < N;++i){
    for(int j = 0;j < N;++j){
      if(i != j){
        if(W[i] == W[j])
          flg = false;
      }
    }
  }

  for(int i = 0;i < N-1;++i){
    if(W[i].at(W[i].length()-1) != W[i + 1].at(0))
      flg = false;
  }
  cout << ((flg) ? "Yes" : "No");
}


Measured memory_bytes: 256
def is_possible(A):
    if A[0] != 0:
        return False
    for i in range(1, len(A)):
        if A[i-1] < A[i] - 1:
            return False
    return True

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    if not is_possible(A):
        print(-1)
        return
    B = reversed(A)
    ans = 0
    i = N-1
    while i >= 0:
        if A[i] > 0:
            x = A[i]
            ans += x
            while i >= 0 and x > 0 and A[i] == x:
                i -= 1
                x -= 1
        else:
            i -= 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 11052
def main():
	import itertools
	n = int(input())
	l = [list(map(int,input().split())) for i in range(n)]
	l_jun = []
	dis_l = []
	ans_pre = []

	# print(l)

	for i in itertools.permutations(range(n),n):
		l_jun.append(i)
	# print(l_jun)

	for i in range(len(l_jun)):
		# print("組み合わせ番号 = {}".format(i))
		#順列の数だけ回す
		# print("--- i = {} ---".format(i))
		# print("l_jun[i] = {}".format(l_jun[i]))
		for t in range(n-1):
			# print("l_jun[i][t] = {}".format(l_jun[i][t]))
			# print("l_jun[i][t+1] = {}".format(l_jun[i][t+1]))
			# print("l[ l_jun[i][t] ] = {}".format(l[ l_jun[i][t] ]))
			# print("l[ l_jun[i][t+1] ] = {}".format(l[ l_jun[i][t+1] ]))
			dis_x = (( int(l[ l_jun[i][t] ][0])-int(l[ l_jun[i][t+1] ][0]) )**2)
			dis_y = (( int(l[ l_jun[i][t] ][1]) - int(l[ l_jun[i][t+1] ][1]) )**2)
			# print('dis_x = {}'.format(dis_x))
			# print("dis_y = {}".format(dis_y))
			dis = (dis_x+dis_y)**.5
			ans_pre.append(dis)
			# print(ans_pre)
			# x_dis = ( (int(l[ l_jun[i][t][0] ])- int(l[l_jun[i][t+1][0]]))**2 + (int(l[ l_jun[i][t][1] ]) - int(l[ l_jun[i][t+1][1] ]) )**2)**0.5
			# print("dis = {}".format(dis))
	print(sum(ans_pre)/len(l_jun))




if __name__ == '__main__':
	main()

Measured memory_bytes: 64624
import bisect
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    ans = 0
    for b in B:
        upper = bisect.bisect_left(A, b)
        bottom = N - bisect.bisect_right(C, b)
        ans += upper * bottom

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  for(int i=a-1;i<max(c,d)-1;i++)
  {
    if(s[i]=='#' && s[i+1]=='#')
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(d<c && (s[d-2]=='#' || s[d]=='#'))
  {
    int t=d-1;
    while(t>=b-1)
    {
      if(s[t+1]=='.' && s[t]=='.' && s[t-1]=='.' )
      {    
        cout<<"Yes"<<endl;
        return 0;
      }
      t--;
    }
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    string S; cin >> S;
    ll K; cin >> K;

    char ans;
    if (K == 1) ans = S[0];
    else { // K >= 2
        int pos = -1;
        REP(i,S.size()) {
            if (S[i]!='1') {
                pos = i;
                break;
            }
        }

        if (pos < 0 || K-1 < pos) ans = '1';
        else ans = S[pos];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256