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

std::vector<long long> divisors(long long n) {
	std::vector<long long> ret(0), st(0);
	for (int i = 1; i <= n / i; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i < n / i) st.push_back(n / i);
		}
	}
	while (st.size()) {ret.push_back(st.back()); st.pop_back();}
	return ret;
}

bool is_prime(long long n) {
	if (n < 2) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (int i = 3; i <= n / i; i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	long long a, b;
	std::cin >> a >> b;
	std::vector<long long> v = divisors(a), w = divisors(b);
	long long ans = 1;
	for (auto i : v) {
		auto itr = lower_bound(w.begin(), w.end(), i);
		if (itr != w.end() && *itr == i && is_prime(i)) ans++;
	}
	std::cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 3724
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

info.insert(0, [0, 0, 0])
x_diff, y_diff = 0, 0

for i in range(n):
    dt = info[i+1][0] - info[i][0]
    x_diff = abs(info[i+1][1] - info[i][1])
    y_diff = abs(info[i+1][2] - info[i][2])
    if dt < x_diff + y_diff:
        print('No')
        exit()
    if dt%2 != (x_diff + y_diff)%2:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

ll N;
vector<vector<char>> S(201, vector<char>(201, 0));
vector<ll> color(201,0);
vector<ll> check(201,0);
bool nibu=1;

void dfs(ll x){
    if(check[x])return;
    check[x]++;
    for(ll i=0;i<N;i++){
        if(S[x][i]=='1'){
            if(color[i]==0){
                color[i]=-color[x];
                dfs(i);
            }
            else if(color[i]==color[x]){nibu=0;break;}
        }
    ;}
}


int main(){
    cin >> N;
    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         cin>>S[i][j]
     ;}
    ;}
    vector<vector<ll>> d(N, vector<ll>(N, INF));
    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         if(S[i][j]=='1')d[i][j]=1;
         else if(i==j)d[i][j]=0;
     ;}
    ;}

    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         for(ll k=0;k<N;k++){
             d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
         }
     ;}
    ;}


    ll ans=0;
    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         ans=max(ans,d[i][j])
     ;}
    ;}

    color[0]=1;
    dfs(0);

    if(!nibu){
        cout<<-1<<endl;return 0;
    }

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


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

typedef long long ll;
int main(){
    int n,l;
    cin >> n >> l;

    int left = l;
    int right = l + n;

    ll sum=0;
    int les = 1000;
    for( int i=left; i<right; i++){
        //cerr << abs(i) << endl;
        if( abs(les) > abs(i)) les = i;
        sum +=i;
    }
    sum -= les;
    cout << sum << endl;
    return 0;
}



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


#define long long long int

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pi;


int main() {
    std::ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int val;
        cin >> val;
        if (val % 2 == 0){
            if (val % 3 != 0 && val % 5 != 0){
                cout << "DENIED" << "\n";
                return 0;
            }
        }
    }

    cout << "APPROVED" << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 

int main(void)
{

int n;
string s;

cin>>s;

n =s.size();

bool check = true;

//first 
for(int i=0;i<n/2;i++)
{
    if(s[i]!=s[n-i-1]) check = false;
}

// //second
for(int i=0;i<=(n-1)/4;i++)
{
    if(s[i]!=s[(n-1)/2-i-1]) check =false;

}


//therd
for(int i=(n+3)/2-1;i<n;i++)
{
    if(s[i]!=s[n-i-1]) check = false;

}

if(check) cout<<"Yes"<<endl;

else cout<<"No"<<endl;


}

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

#define INF 2147483647
#define LINF 9223372036854775807

#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=true;
    ll ans=0,sum=0;

    string s,t;
    cin>>s>>t;


    rep(i , s.length()){
        if(s[i] != t[i])flag = false;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll mod = 1000000007;

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(),a.end());

  ll ai = a[n-1];
  ll aj = 0;
  auto f = [](ll n, ll x, ll y) {
    ll l = n/2;
    if (n%2 == 1) {
      if (min(abs(x-l), abs(x-l-1)) > min(abs(y-l), abs(y-l-1))) return y;
      else return x;
    } else {
      if (abs(x-l) > abs(y-l)) return y;
      else return x;
    }
  };
  rep(i, n) aj = f(ai, aj, a[i]);
  printf("%lld %lld\n", ai, aj);

  return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
sorted_ab=sorted(ab, key=lambda x: x[0])
ans=0
i=0
for a, b in sorted_ab:
  for _ in range(b):
    if i < m:
      ans+=a
      i+=1
    else:
      break
print(ans)

Measured memory_bytes: 29796
/*
  Contest 112
  A - Programming Education
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    if (n == 1) {
        std::cout << "Hello World" << std::endl;
    } else {
        int a = 0, b = 0;
        std::cin >> a >> b;
        std::cout << a + b << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  bool flag = true;
  for (ll i = 0; i < n; i++) {
    if (s.at(i) != s.at(n-1-i)) flag = false;
  }
  for (ll i = 0; i < (n-1)/2; i++) {
    if (s.at(i) != s.at((n-1)/2-1-i)) flag = false;
  }
  for (ll i = (n+3)/2; i < n; i++) {
    if (s.at(i-1) != s.at(n-1-(i-(n+3)/2))) flag = false;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#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 <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COM_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////
int main(){
  ll H,W,A,B,ans=0;
  cin>>H>>W>>A>>B;
  COM_init();
  
  for(ll i=B; i<W; ++i){
    ans+=COM(H-A-1+i,i)*COM(W-1-i+A-1,A-1);
    ans%=MOD;
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 50728
#include <iostream>
#include <algorithm>
#include <stdio.h>
#define ll long long
#define MAX 10000
#define NIL -1
using namespace std;

struct Node{int p,r,l;};
Node T[MAX];
int n;

void preOrder(int u){
  if(u == NIL)
    return;
  printf(" %d", u);
  preOrder(T[u].l);
  preOrder(T[u].r);
}

void postOrder(int u){
  if(u == NIL)
    return;
  postOrder(T[u].l);
  postOrder(T[u].r);
  printf(" %d", u);
}

void inOrder(int u){
  if(u == NIL)
    return;
  inOrder(T[u].l);
  printf(" %d", u);
  inOrder(T[u].r);
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(int i = 0; i < n; i++){
    int v, l, r;
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)
      T[l].p = v;
    if(r != NIL)
      T[r].p = v;
  }
  int root;
  for(int i = 0; i < n; i++)
    if(T[i].p == NIL)
      root = i;
  printf("Preorder\n");
  preOrder(root);
  printf("\n");
  printf("Inorder\n");
  inOrder(root);
  printf("\n");
  printf("Postorder\n");
  postOrder(root);
  printf("\n");
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll mypow(ll a, ll b)
{
    ll r = 1ll;
    while(b != 0){
        if(b&1) r = r * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return r;
}

ll p(ll i, ll j)
{
    ll r = 1ll;
    REP(k,j) {
        r = (r * (i - k)) % MOD;
        r = (r * mypow(k + 1, MOD - 2)) % MOD;
    }
    return r;
}

ll n, a, b, ans;

int main()
{
    cin>>n>>a>>b;
    ans += p(n, a);
    ans %= MOD;
    //debug(ans);
    ans += p(n, b);
    ans %= MOD;
    //debug(ans);
    ans = mypow(2, n) - ans - 1 + MOD;
    ans %= MOD;
    cout<<ans<<endl;

    return 0;
}


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

const double PI = acos(-1);

int main()
{
    int r;
    cin >> r;
    printf("%.20f\n", 2 * PI * r);
    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;cin>>n>>q;
    long long tree[n];//各頂点の重み
    vector<vector<int>> to(n);//それぞれどことつながっているか
    fill(tree,tree+n,0);
    bool used[n];//一度キューに突っ込まれたのは二度と見ない
    fill(used,used+n,false);
    
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p;
        long long x;cin>>p>>x;p--;
        tree[p]+=x;
    }
    queue<int> que;
    que.push(0);
    used[0]=true;
    //頂点１から下に流れるように見ていく。usedで逆流防止
    while(que.size()>0){
        int v = que.front();
        que.pop();
        bool changed = false;
        for(int i=0;i<to[v].size();i++){
            int u = to[v][i];
            if(!used[u]){
                que.push(u);
                used[u]=true;
                tree[u]+=tree[v];
                changed = true;
            }
        }
        if(!changed)continue;
    }
    for(int i=0;i<n;i++){
        cout<<tree[i]<<endl;
    }
}

Measured memory_bytes: 16500
def even_method(n)
  n/2
end

def odd_method(n)
  3*n+1
end

S = gets.to_i

num_array = []
backet = {}
i = 0
ans = 0

loop do
  i += 1
  if i == 1
    num_array << S
    backet[S.to_s] = true
  end

  if num_array.last%2 == 0
    next_num = even_method(num_array.last)
  else
    next_num = odd_method(num_array.last)
  end

  num_array << next_num
  if backet[next_num.to_s]
    ans = i+1
    break
  else
    backet[next_num.to_s] = true
  end
end

puts ans


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

int main() {
	unsigned char S;
	unsigned int N,K;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> S;

		if (i == K - 1) {
			cout << (char)(S + 0x20);
		}
		else {
			cout << S;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,M;
int A[300000],B[300000],C[300000],sum[300000];

signed main(){
    scanf("%lld",&N);
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    scanf("%lld",&M);
    for(int i=0;i<M;i++)scanf("%lld",&B[i]);
    for(int i=0;i<M;i++)scanf("%lld",&C[i]);

    sort(A,A+N);

    for(int i=0;i<N;i++){
        sum[i]=A[i]+(i?sum[i-1]:0);
    }


    for(int i=0;i<M;i++){
        int u=upper_bound(A,A+N,B[i])-A;
        int val;
        if(u==0)val=0;
        else val=sum[u-1];
        if(C[i]<=val)puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 10540
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	vector<vector<int>> num(10, vector<int>(10));
	REP(i, 10) {
		REP(j, 10) {
			cin >> num[i][j];
		}
	}
	int cnt = 0;
	REP(i, 10000) {
		int e = num[num[num[num[0][(i / 1000) % 10]][(i / 100) % 10]][(i / 10) % 10]][i % 10];
		const int newnum = i * 10 + e;
		bool check = true;
		int di = 1;
		REP(j, 5) {
			REP(k, 10) {
				if (((newnum / di) % 10) == k)
					continue;
				int copy = newnum - ((newnum / di) % 10)*di + k*di;
				if (num[num[num[num[num[0][(copy / 10000) % 10]][(copy / 1000) % 10]][(copy / 100) % 10]][(copy / 10) % 10]][copy % 10] == 0)
					check = false;
			}
			di *= 10;
		}
		di = 1;
		REP(j, 4) {
			if (((newnum / di) % 10) == ((newnum / di / 10) % 10)) {
				di *= 10;
				continue;
			}
			int copy = newnum - ((newnum / di) % 10)*di + ((newnum / di / 10) % 10)*di - ((newnum / di / 10) % 10)*di * 10 + ((newnum / di) % 10)*di * 10;
			if (num[num[num[num[num[0][(copy / 10000) % 10]][(copy / 1000) % 10]][(copy / 100) % 10]][(copy / 10) % 10]][copy % 10] == 0)
				check = false;
			di *= 10;
		}
		if (!check) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

class p
{

    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        string[] inputStr = new string[N];
        int[] alphMin = new int[26];

        for (int i = 0; i < 26; i++)
        {
            alphMin[i] = 100000000;
        }

        for (int i = 0; i < N; i++)
        {
            inputStr[i] = Console.ReadLine();
        }

        for(int i = 0; i < N; i++)
        {
            int[] alphCount = new int[26];
            for(int j = 0; j < inputStr[i].Length; j++)
            {
                alphCount[inputStr[i][j] - 'a']++;
            }
            for(int j = 0; j < 26; j++)
            {
                alphMin[j] = Math.Min(alphCount[j], alphMin[j]);
            }
        }

        for(int i = 0; i < 26; i++)
        {
            int chTemp = 'a' + i;
            while (true)
            {
                if (alphMin[i] == 0) break;
                Console.Write((char)chTemp);
                alphMin[i]--;
            }
        }
        Console.WriteLine();
    }   
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;
using namespace std;

int main(){
	int n; cin >> n;
	
	int pos = 0;
	while(pos <= n) {
		if((n - pos) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		
		pos += 4;
	}

	cout << "No" << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<pair<ll, ll>> ans;

  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  for (int i = 1; i < n - 1; ++i) {
    if (a[i] > 0) {
      ans.emplace_back(a[0], a[i]);
      a[0] -= a[i];
    } else {
      ans.emplace_back(a[n - 1], a[i]);
      a[n - 1] -= a[i];
    }
  }

  ans.emplace_back(a[n - 1], a[0]);
  cout << a[n - 1] - a[0] << endl;
  for (auto b : ans) printf("%d %d\n", b.first, b.second);
  return 0;
}

Measured memory_bytes: 6132
import sys

x = int(input())
n = 1
a = 0
b = 0


def chk(x, a, b):
    if a * a * a * a * a - b * b * b * b * b == x:
        print(a, b)
        sys.exit()


def r(x, n, a, b):
    for _ in range(n):
        a = a + 1
        # print(a, b)
        chk(x, a, b)
    return a, b


def u(x, n, a, b):
    for _ in range(n):
        b = b + 1
        # print(a, b)
        chk(x, a, b)
    return a, b


def l(x, n, a, b):
    for _ in range(n):
        a = a - 1
        # print(a, b)
        chk(x, a, b)
    return a, b


def d(x, n, a, b):
    for _ in range(n):
        b = b - 1
        # print(a, b)
        chk(x, a, b)
    return a, b


while n < 100000000:
    a, b = r(x, n, a, b)
    a, b = u(x, n, a, b)
    n = n + 1
    a, b = l(x, n, a, b)
    a, b = d(x, n, a, b)
    n = n + 1


# r1 u1 l2 d2 r3 u3 l4 d4

#    x x x x x
#      x x x x
#      x x x x
#      x x x x


Measured memory_bytes: 9264
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class Binary_Indexed_Tree():
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i):
        return self.sum_range(i, i)

    def sum(self, i):
        ret = 0
        while i:
            ret += self.data[i]
            i &= i-1
        return ret

    def sum_range(self, l, r):
        return self.sum(r)-self.sum(l-1)

n,d,a = map(int, input().split())
d *= 2
data = []
s = set()
for i in range(n):
    x,h = map(int, input().split())
    s.add(x)
    s.add(x+d)
    data.append([x,h])
data.sort()
dd = sorted(s)
ddd = {j:i for i,j in enumerate(dd)}
m = len(dd)

BIT = Binary_Indexed_Tree(m+1)
ans = 0
for x,h in data:
    i = ddd[x]
    rem = BIT.sum_range(i+1 , m+1)
    h = max(h-rem, 0)
    cnt = -(-h//a)
    ans += cnt
    BIT.add(ddd[x+d]+1, cnt*a)
print(ans)


Measured memory_bytes: 133516
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll ans=0;
  if(2*a<=b){
    ans+=a;
    b-=2*a;
    ans+=b/4;
    co(ans)
  }
  else{
    co(b/2)
  }
}

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

int main(void)
{
    int N;

    cin >> N;

    vector<int> ans(4, 0);

    for(int i = 0; i < N; ++i)
    {
        string tmp;
        cin >> tmp;
        if(tmp[0] == 'A') ++ans[0];
        if(tmp[0] == 'W') ++ans[1];
        if(tmp[0] == 'T') ++ans[2];
        if(tmp[0] == 'R') ++ans[3];

    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
        

    return 0;
}



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

int main(){
    int n,r;
    while(true){
        cin >> n >> r;
        if(n == 0 && r== 0) break;
        int k[n];
        for(int i=0; i<n; i++)k[i]=n-i;
        int a[r],b[r];
        int c[n];
        for(int i = 0;i < r; i++)cin >> a[i] >> b[i];
        for(int i = 0;i < r; i++){
            for(int j = 0;j < b[i]; j++){
                c[j] = k[a[i]+j-1];
            }
            int d[100];
            for(int j = 0;j < a[i]-1;j++){
                d[j]=k[j];
            }
            for(int j=0;j<a[i]-1;j++){
                k[j+b[i]]=d[j];
            }
            for(int j = 0;j < b[i]; j++){
                k[j] = c[j];
            }
        }
        cout << k[0] << endl;
    }
}


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

int main(void)
{
    long long int N, N_copy, N_long, tmp;
    long long int ans;
    int i, l=1;//Nは何文字か
    int j;
    scanf("%lld",&N);
    N_copy = N;
    
    N_long = 0;
    while(N > N_long){
        N_long += pow(26,l);
        l++;
        //printf("N_long = %lld\n",N_long);
    }
    l--;
    //printf("l = %d\n",l);
    l--;
    N_copy = N;
    for(i=l; i>0; i--){
        N_long -= pow(26,i+1);
        //printf("N_long = %lld\n",N_long);
        N_copy = N;
        //ans = 0;
        tmp = pow(26,i);
        //
        //printf("tmp = %lld\n",tmp);

        //何回tmpで割って大丈夫かという判断をしながらループする
        j=0;
        //printf("N-j*tmp = %lld\n",N-j*tmp);
        while(N-N_long-j*tmp > 0) {
            //printf("N-j*tmp = %lld\n",N-j*tmp);
            j++;
        }
        //printf("j = %d\n",j);
        /*
        if((N - N_long-26*tmp > 0) && N_copy/tmp > 26){
            ans = 0;
        } else {
            if(N_copy%tmp == 0){
                ans = N_copy/tmp;
                ans--;
                if(i!=1 && N-N_long-ans*tmp < 0) ans--;
            } else {
                ans = N_copy/tmp;
                if(i!=1 && N-N_long-ans*tmp < 0) ans--;
            }
        }
    */

        //printf("ans = %d\n",ans);

        if(j == 0){
            printf("z");
            N -= (26*tmp);
        } else {
            printf("%c",(char)j + 96);
            N -= (j*tmp);
        }
        
        //printf("N_copy = %lld\n",N_copy);


    }
    
    N_copy = N;
    //printf("N_copy = %lld\n",N_copy);
    if(N_copy%26 == 0){
        printf("z\n");
    } else {
        printf("%c\n",(char)N_copy%26 + 96);
    }
    
    return 0;
}

Measured memory_bytes: 2488
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  double n,d;
  cin>>n>>d;
  double hu=d*2+1;

  cout<<ceil(n/hu)<<endl;

 }



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF 1<<15
using namespace std;

int main(){
  int n,m,s,e,c;

  while(true){
    cin >> n >> m;
    if(n+m == 0)break;
    int lst[n+1][n+1];
    int Graph[n+1][n+1];
    for(int i=0;i<n+1;i++)for(int j=0;j<n+1;j++){
	lst[j][i] = i==j?0:INF;
	Graph[i][j] = INF;
      }
    for(int i=0;i<m;i++){
      cin >> s >> e >> c;
      Graph[s][e] = Graph[e][s] = lst[s][e] = lst[e][s] = c;
    }

    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)lst[i][j] = min(lst[i][j],lst[i][k]+lst[k][j]);
    int cost = lst[1][n];
    for(int k=1;k<=n;k++){
      for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
	  if(Graph[k][i] != INF &&  Graph[k][j] != INF){ //kからiとkからjの通路があるという事は連続している	  
	    cost = min(cost,lst[1][i]+lst[j][n]);
	  }
	}
      }
    }
    cout <<  cost << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    
    bool flg = false;
    int x = 0;
    int y = 0;
    
    cin >> x >> y;
    
    if(y%2 == 1){
        cout << "No" << endl;
        return 0;
    }else{
        y /= 2;
    }
    
    for(int i=0; i<=x; i++){
        if(2*i + (x-i)==y){
            flg=true;
        }
    }
    
    if(flg == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,w;
    cin>>n>>w;
    long long int val[n],wt[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    long long int a[n+1][w+1];
    for(int i=0;i<n+1;i++){
        for(int j=0;j<w+1;j++){
            if(i==0 || j==0)
            a[i][j]=0;
            else if(wt[i-1]<=j)
            a[i][j]=max(val[i-1]+a[i-1][j-wt[i-1]],a[i-1][j]);
            else
            a[i][j]=a[i-1][j];
        }
    }
    cout<<a[n][w]<<"\n";
}    

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int p=a/1000%10,q=a/100%10,r=a/10%10,s=a%10;
  if(p-q-r-s==7)cout << p << '-' << q << '-' << r << '-' << s << "=7";
  else if(p-q-r+s==7)cout << p << '-' << q << '-' << r << '+' << s << "=7";
  else if(p-q+r-s==7)cout << p << '-' << q << '+' << r << '-' << s << "=7";
  else if(p-q+r+s==7)cout << p << '-' << q << '+' << r << '+' << s << "=7";
  else if(p+q-r-s==7)cout << p << '+' << q << '-' << r << '-' << s << "=7";
  else if(p+q-r+s==7)cout << p << '+' << q << '-' << r << '+' << s << "=7";
  else if(p+q+r-s==7)cout << p << '+' << q << '+' << r << '-' << s << "=7";
  else cout << p << '+' << q << '+' << r << '+' << s << "=7";
}


Measured memory_bytes: 256
s = input()

flag = 0
for i in range(len(s)):
  if i%2 == 0 and s[i] == 'L':
    flag = 1
  if i%2 == 1 and s[i] == 'R':
    flag =1
    
if flag:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var A2B = new List<int>[100_000];
        for (int i = 0; i < A2B.Length; i++)
            A2B[i] = new List<int>();

        for (int i = 0; i < N; i++)
        {
            var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var (A, B) = (AB[0], AB[1]);
            A2B[A - 1].Add(B);
        }

        var pq = new PriorityQueue<int>();
        var ans = 0L;

        for (int i = 0; i < M; i++)
        {
            foreach (var item in A2B[i])
                pq.Push(item);

            if(0 < pq.Count)
                ans += pq.Pop();
        }

        WriteLine(ans);
    }
}
public class PriorityQueue<T> : IEnumerable<T>
    where T : IComparable<T>
{
    private List<T> buffer;

    public int Count { get => buffer.Count; }
    public bool IsDescending { get; }

    private int Compare(T a, T b) => IsDescending ? a.CompareTo(b) : b.CompareTo(a);

    public PriorityQueue(bool isDescending = true)
    {
        buffer = new List<T>();
        IsDescending = isDescending;
    }

    public void Push(T item)
    {
        buffer.Add(item);

        var root = 0;
        var child = buffer.Count - 1;

        while (root < child)
        {
            var parent = (child - 1) / 2;

            if (Compare(buffer[parent], buffer[child]) < 0)
                (buffer[parent], buffer[child]) = (buffer[child], buffer[parent]);

            child = parent;
        }
    }

    public T Pop()
    {
        var item = buffer[0];
        buffer[0] = buffer[^1];
        buffer.RemoveAt(buffer.Count - 1);

        var root = 0;
        var parent = root;
        var child = 1;

        while (child < buffer.Count)
        {
            if (child < buffer.Count - 1)
            {
                var leftChild = child;
                var rightChild = child + 1;

                if (Compare(buffer[leftChild], buffer[rightChild]) < 0)
                    child = rightChild;
            }

            if (Compare(buffer[parent], buffer[child]) < 0)
                (buffer[parent], buffer[child]) = (buffer[child], buffer[parent]);

            parent = child;
            child = 2 * parent + 1;
        }

        return item;
    }

    public T Peek() => buffer[0];

    public IEnumerator<T> GetEnumerator() => buffer.GetEnumerator();

    IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int total = 0;
  for (int i = A; i <= B; i++) {
    int num = i;
    int n[5];
    for (int j = 0; j < 5; j++) {
      n[j] = num % 10;
      num /= 10;
    }
    if ((n[0] == n[4])
        && (n[1] == n[3])) {
      total++;
    }
  }
  
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main() 
{
    int n, k;
    cin >> n >> k;
    int a[2010] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int cntl[2010] = {};
    int cntr[2010] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (a[i] < a[j]) cntl[i]++;
        }
        for (int j = i+1; j < n; j++)
        {
            if (a[i] < a[j]) cntr[i]++;
        }
        
    }

    ll ans = 0;
   for (int i = 0; i < n; i++)
        {
            ans = (ans + (ll)k*(2*cntl[i])/2%mod+((ll)k*(ll)(k-1)/2)%mod*(cntl[i]+cntr[i])%mod) % mod;
            //ans = (ans + k%mod*(((k-1)%mod*(cntl[i]+cntrs[i]))/2+cntl[i])%mod) % mod;
            //ans = (ans + (ll)k * cntl[i] % mod  + ((ll)k*((ll)k-1)/2) % mod * (cntl[i]+cntr[i]))%mod;
            //ans = (ans + (ll)k * cntl[i] % mod  + ((ll)k*(ll)(k-1)/2) % mod * (cntl[i]+cntr[i]))%mod;
        }
    
    
    cout << ans << "\n";
    
    
    
    
}

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

#define I inline void 

using namespace std ; 

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

const int N = 100 + 7 ; 

// How interesting!

int n; 

multiset<ll> mu ;

int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in", "r" , stdin) ;
	cin >> n; 

	vector< ll > neg ; 

	for(int i = 0 ;i < n;i++){
		ll x ; 
		cin >> x; 
		mu.insert(x); 
	}
	vector<pair<ll,ll> > ans ; 

	while(mu . size() > 2){
		ll st = (*mu.begin()) ; 
		auto it = mu.rbegin() ; it--; 
		ll en = (*it) ; 
		if(en < 0)
			break ;
		ans.push_back({st , en}) ; 
		mu.erase(mu.find(st)) ; 
		mu.erase(mu.find(en)) ; 
		mu.insert(st - en) ; 
	}

	while(mu . size() > 1){
		ll st = (*mu.begin()) ; 
		ll en = (*mu.rbegin()) ; 
		ans.push_back({en , st}) ; 
		mu.erase(mu.find(st)) ; 
		mu.erase(mu.find(en)) ; 
		mu.insert(en - st) ; 
	}

	ll out = (*mu.begin()) ; 

	cout<< out <<"\n" ;
	for(auto u : ans){
		cout<< u.first <<" " << u.second <<"\n" ; 
	} 
	return 0 ; 
}

Measured memory_bytes: 9996
import java.util.*

class LucasIterator {
    var L0: Long = 2
    var L1: Long = 1
    var count = 0

    operator fun hasNext(): Boolean = true
    operator fun next() : Long {
        if (count==0) {
            count++
            return L0
        } else if (count==1) {
            count++
            return L1
        }
        val tmp = L1
        L1 = L1 + L0
        L0 = tmp
        count++
        return L1
    }
}

fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val N = cin.nextInt()

    val iter = LucasIterator()
    var ans: Long = 0
    for (i in 1..N+1) {
        ans = iter.next()
    }
    println(ans)
}

Measured memory_bytes: 31136
import sys

n, q = [int(i) for i in sys.stdin.readline().split()]
graph = {i: [] for i in range(n)}
ct = [0 for i in range(n)]
for i in range(n - 1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

for i in range(q):
    p, x = [int(i) for i in sys.stdin.readline().split()]
    p -= 1
    ct[p] += x
already = {0}
stack = [(0, ct[0], -1)]
res = [0 for i in range(n)]
while len(stack) > 0:
    cur, cost, _from = stack.pop(-1)
    res[cur] = cost
    for _next in graph[cur]:
        if _next == _from:
            continue
        next_cost = ct[_next]
        stack.append((_next, cost + next_cost, cur))
        already.add(cur)
print(" ".join([str(r) for r in res]))


Measured memory_bytes: 126988
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return (a*b)//gcd(a,b)

def solve():
    N,M = map(int, input().split())
    S = input()
    T = input()
    gcd_NM = gcd(N,M)
    lcm_NM = (N*M)//gcd_NM
    S_diff = N // gcd_NM
    T_diff = M // gcd_NM
    
    i = 0
    possible = True
    while S_diff*i < N and T_diff*i < M:
        if S[S_diff*i] != T[T_diff*i]:
            possible = False
        i += 1
        
    print(lcm_NM if possible else -1)
    
solve()

Measured memory_bytes: 5716
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans = 0
for i,j in zip(a,a[1:]):
    ans += b[i-1]
    if j == i + 1:
        ans += c[i-1]
print(ans + b[a[-1]-1])

Measured memory_bytes: 3064
#include <stdio.h> 
 #define _USE_MATH_DEFINES 
 #include <math.h> 
 
 
 int main(){ 
     int a, b, angle; 
     double s, l, h; 
 
 
     scanf("%d %d %d", &a, &b, &angle); 
     // sin(), cos(), tan()は角度がラジアン 
     // 度数法からラジアン法への変換：角度(ラジアン)＝角度(度数)*π/180 
     // 定数としてπを使うには：math.hのdefineを利用する。 
     // 参考：dandelion's log » VC++でM_PIが使えなかった理由判明 http://www.atinfinity.info/blog/archives/14 
     h=b*sin(angle*M_PI/180.0); 
     s=a*h/2; 
     l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0))); 
     printf("%f\n", s); 
     printf("%f\n", l); 
     printf("%f\n", h); 
 
 
     return 0; 
 } 



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

int main(){
  int N,M;
  cin >> N >> M;
  priority_queue<int> index;
  rep(i,N){
    int x;
    cin >> x;
    index.push(x);
  }

  while(M > 0){
    int b = index.top();
    index.pop();
    b /= 2;
    index.push(b);
    M--;
  }

  int64_t sum = 0;
  rep(i,N){
    sum += index.top();
    index.pop();
  }

  cout << sum << endl;
}


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

ll g(ll x, ll y) {
    return (y+1) * y * x / 2;
}

int main() {

    int n;
    cin >> n;

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += g(i, n/i);
    }

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

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
int main() {
	int a,b;
	while(~scanf("%d%d",&a,&b)) {
		if(a%3==0||b%3==0||(a+b)%3==0) puts("Possible");
		else puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 128
//Triangle

#include<stdio.h>
#include<math.h>

int main(void){
    double a,b, angle;
    double c;
    double rad;
    double s, l, height;
    
    scanf("%lf", &a);
    scanf("%lf", &b);
    scanf("%lf", &angle);
    
    //convert angle to radian
    rad = (angle / 180) * M_PI;
    
    //c is a edge
    c = sqrt(a*a + b*b - 2*a*b * cos(rad));
    
    // height base on a
    height = b * sin(rad);
    
    //area
    s = (a * height) / 2;
    
    //circumference
    l = a + b + c;
    
    printf("%lf\n", s);
    printf("%lf\n", l);
    printf("%lf\n", height);
    
    return 0;
}

Measured memory_bytes: 648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long H = GetLong();
		long W = GetLong();
		var a = new long[H, W];
		for(long i = 0; i < H; i++)
		{
			for(long j = 0; j < W; j++)
			{
				a[i, j] = GetLong();
			}
		}

		var ans = new List<string>();
		for(long i = 0; i < H; i++)
		{
			for(long j = 0; j < W - 1; j++)
			{
				if(a[i, j] % 2 == 1)
				{
					a[i, j]--;
					a[i, j + 1]++;
					ans.Add($"{i + 1} {j + 1} {i + 1} {j + 2}");
				}
			}
		}

		for(long i = 0; i < H - 1; i++)
		{
			if(a[i, W - 1] % 2 == 1)
			{
				a[i, W - 1]--;
				a[i + 1, W - 1]++;
				ans.Add($"{i + 1} {W} {i + 2} {W}");
			}
		}

		WriteLine(ans.Count);
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 53636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
typedef long long int ll;
using   namespace std;
#define ALL(a) ((a).begin(),(a).end())
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

    ll N,M;
    ll A,B,ans=1e12;
    string S;



int main() {
    cin>>N;
    EREP(i,N-1){
        string s,t;
        s=to_string(i),t=to_string(N-i);
        ll temp=0;
        for(auto x:s)
            temp+=x-'0';
        for(auto x:t)
            temp+=x-'0';
        ans=min(ans,temp);
    }
    cout<<ans;
}


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

const long long MOD = 998244353;

void solve(long long A, long long B, long long C, long long D){
    long long dp[C+1][D+1] = {};
    dp[A][B] = 1;
    for (long long b = B + 1; b <= D; b++) {
        dp[A][b] = (dp[A][b - 1]) * A % MOD;
    }
    for (long long a = A + 1; a <= C; a++) {
        dp[a][B] = (dp[a - 1][B]) * B % MOD;
    }
    for (long long a = A + 1; a <= C; a++) {
        for (long long b = B + 1; b <= D; b++) {
            dp[a][b] = (
                dp[a][b-1] * a + dp[a-1][b] * b - dp[a-1][b-1] * (a - 1) * (b - 1)
            ) % MOD;
        }
    }
    // for (long long a = 0; a <= C; a++) {
    //     for (long long b = 0; b <= D; b++) {
    //         cout << dp[a][b] << " ";
    //     }
    //     cout << endl;
    // }
    cout << (dp[C][D] + MOD) % MOD << endl;
}

// 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)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 74040