akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/


Measured memory_bytes: 2100
a, b, k = map(int, input().split())
s, l = [], []
for i in range(k):
  if a+i == b-i:
    s.append(a+i)
    break
  else:
    s.append(a+i)
    l.append(b-i)
    if b-a-2*i == 1:
      break
for i in s:
  print(i)
for i in l[::-1]:
  print(i)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, r[200000], Max = -999999999, Min;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  Min = r[0];
  for (int i = 1; i < n; i++) {
    Max = max(r[i] - Min, Max);
    Min = min(r[i], Min);
  }
  cout << Max << '\n';
  return 0;
}



Measured memory_bytes: 3936
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, 3) {
		if (s.at(i) == s.at(i + 1)) {
			cout << "Bad" << endl; return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

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

const int INF = 1001001001;
vector<int> to[100010];
int main(){
    int n, m; cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int u : to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) cout << pre[i]+1 << endl;
}

Measured memory_bytes: 10664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll N, M;
  cin >> N >> M;
  
  ll X = (M - 2 * N) / 4;
  ll result = 0;
  for (ll x = max(0LL, X - 10); x <= max(0LL, X + 10); ++x) {
    result = max(result, min(N + x, (M - 2 * x) / 2));
  }
  
  cout << result << '\n';
  
  return 0;
}


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

using namespace std;

int main(){

 int k,s;
 int ans = 0;
 cin >> k >> s;

 for(int i = 0; i <= k; i++){
   for(int j = 0; j <= k; j++){
     int need = s - i - j;
     if(need >= 0 && need <= k){
       ans++;
     }
   }
 }

cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int s[200][200],r[200][200],t[200],a[200],b[200],c[200],d[200];
int main(void)
{
	int m,n,i,k,h,x;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++) scanf("%d",&t[i]);
	for(i=0;i<m;i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for(i=0;i<n;i++){
		for(k=0;k<m;k++) s[i][k]=0;
	}
	for(i=0;i<n;i++){
		d[i]=0;
		for(k=0;k<m;k++){
			if(a[k]<=t[i]&&t[i]<=b[k]){
				r[i][d[i]]=c[k];
				d[i]++;
			}
			
		}
	}
	for(i=1;i<n;i++){
		for(k=0;k<d[i];k++){
			for(h=0;h<d[i-1];h++){

				if(s[i][k]<abs(r[i][k]-r[i-1][h])+s[i-1][h]){
					s[i][k]=abs(r[i][k]-r[i-1][h])+s[i-1][h];
				}			
			}
		}
	}
	x=0;
	for(i=0;i<d[n-1];i++){
		if(x<s[n-1][i]) x=s[n-1][i];
	}
	printf("%d\n",x);
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<vector<ll>> F(N, vector<ll>(10));
    vector<vector<ll>> P(N, vector<ll>(11));

    REP(i, N){
        REP(j, 10){
            cin >> F[i][j];
        }
    }

    REP(i, N){
        REP(j, 11){
            cin >> P[i][j];
        }
    }

    ll n = 10;
    ll ans = -1*INF;
    for (ll bit = 0; bit < (1<<n); ++bit){

        // 一つも選択しない場合はなし
        if(bit == 0) continue;

        // Cを数えていく
        vector<ll> C(N, 0);
        for (ll i = 0; i < n; ++i) {
            if (bit & (1<<i)){
                REP(j, N){
                    C[j] += F[j][i];
                }
            }
        }
        ll temp = 0;
        
        // この選択での値を保存
        REP(j, N){
            temp += P[j][C[j]];
        }

        ans = max(ans, temp);
        
    }
    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 < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, W;
  cin >> n >> W;
  vector <int> w(n + 1);
  vector <ll> v(n + 1);
  REP1(i, n) {
	cin >> w[i] >> v[i];
  }
  vector <vector <ll> > dp(n + 1, vector <ll>(W + 1, 0));
  REP1(i, n) {
	REP1(j, W) {
	  dp[i][j] = dp[i - 1][j];
	  if (j - w[i] >= 0) {
		  dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
  }
  ll ans = 0;
  REP1(j, W) {
	ans = max(ans, dp[n][j]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{ 
    int n; 
    cin>>n; 
    string s; 
    cin>>s; 

    int64_t r=0,g=0,b=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='R') 
            r++; 
        else if(s.at(i)=='G') 
            g++; 
        else//B 
            b++; 
    }

    int64_t cnt=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int k=2*j-i;
            if(k>j&&k<n&&s.at(i)!=s.at(j)&&s.at(i)!=s.at(k)&&s.at(j)!=s.at(k))
                cnt++;
        }
    }

    cout<<r*b*g-cnt<<endl; 

return 0; 
} 


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

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

  int ans = 1;

  for (int i = 2; i * i <= N; i++) {
    for (int j = i * i; j <= N; j *= i) {
      ans = max(ans, j);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int m[55][55][55][55];

int main() {
    while (true){
        memset(m, 0, sizeof(m));
    int w,h;
    cin >> w >> h;
    if (w==0 && h==0) break;
    vector<vector<int>> a(w+2,vector<int>(h+2,1)),b(w+2,vector<int>(h+2,1));
    queue<pair<pp,pp>> q;
    pair<pp,pp> v;
    rep(i,h){
        string s,ss;
        cin >> s >> ss;
        rep(j,w){
            if (s[j]=='.') a[1+j][1+i]=0;
            if (ss[w-1-j]=='.') b[1+j][1+i]=0;
            if (s[j]=='L') {
                a[1+j][1+i]=0;
                v.first.first=1+j;
                v.first.second=1+i;
            }
            if (ss[w-1-j]=='R') {
                b[1+j][1+i]=0;
                v.second.first=1+j;
                v.second.second=1+i;
            }
            if (s[j]=='%') a[1+j][1+i]=2;
            if (ss[w-1-j]=='%') b[1+j][1+i]=2;
        }}
        q.push(v);
        m[v.first.first][v.first.second][v.second.first][v.second.second]=1;
        vector<int> dx={0,0,1,-1},dy={1,-1,0,0};
        bool u=true;
        while(!q.empty()){
            int d=q.front().first.first,f=q.front().first.second,g=q.front().second.first,h=q.front().second.second;
            q.pop();
            rep(i,4){
                int x1=d,x2=g,y1=f,y2=h;
                if (a[d+dx[i]][f+dy[i]]!=1) {x1=d+dx[i];y1=f+dy[i];}
                if (b[g+dx[i]][h+dy[i]]!=1) {x2=g+dx[i];y2=h+dy[i];}
                v.first.first=x1;v.first.second=y1;v.second.first=x2;v.second.second=y2;
                if (m[x1][y1][x2][y2]==1) continue;
                m[x1][y1][x2][y2]=1;
                if (a[x1][y1]==2 && b[x2][y2]==2){
                    cout << "Yes" << endl;
                    u=false;
                }
                else if (a[x1][y1]==2 || b[x2][y2]==2) continue;
                q.push(v);
            }
    }
    if (u) cout << "No" << endl;
    }
}




Measured memory_bytes: 39632
#include<stdio.h>
#define gc() getchar()
int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}
int main()
{
	int n,a,b;
	n = in();
	printf("%d", (n / 500) * 1000 + (n % 500 / 5) * 5);
}

Measured memory_bytes: 128
<?php
$X = trim(fgets(STDIN));
$ans =1;
for($i=2;$i<=$X;$i++){

  $calc = $i;
  while($calc<=$X){
  $calc = $calc * $i;
    if($calc>$X){
      break;
    }elseif($ans<$calc) {
      $ans = $calc;
    }
}

}

echo $ans;

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int magic[7][7]={
	{18,17,16,14,12,11,9},
	{17,15,14,12,10,9,7},
	{16,14,13,11,9,8,6},
	{14,12,11,9,7,6,4},
	{12,10,9,7,5,4,2},
	{11,9,8,6,4,3,1},
	{9,7,6,4,2,1,0}
};
bool solve(string s){
	rep(i,1<<19){
		int a[19];
		rep(j,19) a[j]=(i>>j)&1;
		int b[7]={};
		rep(j,7){
			rep(k,7){
				if(a[magic[j][k]]) b[j]+=(1<<k);
			}
			b[j]=s[b[j]]-'0';
		}
		int c=0;
		rep(k,7){
			if(b[k]) c+=(1<<k);
		}
		c=s[c]-'0';
		if(b[3]!=c) return false;
	}
	return true;
}
int main(){
	while(true){
		string s;
		cin>>s;
		if(s[0]=='#') break;
		if(solve(s)) puts("yes");
		else puts("no");
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, x;
    cin >> n >> x;

    int ans = 1;
    int tmp = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        tmp += l;
        if (tmp <= x) {
            ans++;
        }
    }

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

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    int k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    pair<int, int> range;
    vector<pair<int, int> > zeros;
    
    for (int i = 0; i < n; i++) {
        if (s[i]=='0') {
            range.first = i;
            range.second = i;
            for (int j = i+1; j < n; j++) {
                if (s[j]=='0') {
                    range.second = j;
                } else {
                    break;
                }
            }
            zeros.push_back(range);
            i = range.second;
        }
    }
    
    int ans = 0;
    if (zeros.size()<=k) {
        ans = n;
    } else {
        ans = zeros[k].first;
        for (int i = 1; i < zeros.size()-k-1; i++) {
            ans = max(ans, zeros[i+(k+1)].first - zeros[i].second - 1);
        }
        ans = max(ans, (n-1) - zeros[zeros.size()-1-k].second);
    }
    
    cout << ans;
    
    
    
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int n,m,A[130],B[130],p2[130];
int fir[20],dis[260],nxt[260],id=1;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int f1[1<<15|1],f2[1<<15|1],E[1<<15|1];
void DP(int S,int*F){
	F[1<<S]=1;
	for(int i=0;i<1<<n;++i){
		if(~(i>>S)&1)continue;
		if(i==(1<<S))continue;
		for(int j=(i-1)&i;j;j=(j-1)&i)F[i]=(F[i]+1ll*p2[E[i^j]]*F[j])%mod;
		F[i]=(p2[E[i]]-F[i]+mod)%mod;
	}
}
int main(){
	p2[0]=1;for(int i=1;i<130;++i)p2[i]=2*p2[i-1]%mod;
	n=gi(),m=gi();int a,b;
	for(int i=1;i<=m;++i)a=gi(),b=gi(),++E[(1<<a-1)|(1<<b-1)];
	for(int i=1;i<1<<n;i<<=1)
		for(int j=0;j<1<<n;++j)
			if(~j&i)E[j|i]+=E[j];
	DP(0,f1),DP(1,f2);
	int ans=0,U=(1<<n)-1;
	for(int i=0;i<1<<n;++i){
		if(!f1[i])continue;
		int _=U^i;
		for(int j=_;j;j=(j-1)&_){
			if(!f2[j])continue;
			if(E[i|j]-E[i]-E[j])continue;
			ans=(ans+1ll*f1[i]*f2[j]%mod*p2[E[U^i^j]])%mod;
		}
	}
	printf("%d\n",(p2[m]-ans+mod)%mod);
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    
    if (st == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (st == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (st == "Rainy") {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    vector<int> x(5);
    rep(i, 5) cin >> x[i];

    rep(i, 5) {
        if (x[i] != i + 1) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
n,k = map(int,input().split())
A = list(map(int,input().split()))
dic1 = {(0,0):1}
for i in range(n):
    dic2 = {(0,0):0}
    for (total,num),amount in dic1.items():
        if (total,num) in dic2:
            dic2[(total,num)] += amount
        else:
            dic2[(total,num)] = amount
        if (total+A[i],num+1) in dic2:
            dic2[(total+A[i],num+1)] += amount
        else:
            dic2[(total+A[i],num+1)] = amount
    
    dic1 = dic2

ans = 0
for i in range(1,n+1):
    if (i*k,i) in dic1:
        ans += dic1[(i*k,i)]

print(ans)

Measured memory_bytes: 10360
#include <stdio.h>

#define int64 long long

int64 floor(int64 xx, int64 bb)
{
  return (xx / bb);
}

int main()
{
  int64 aa, bb, nn;
  scanf("%lld %lld %lld", &aa, &bb, &nn);
  int64 ans;
  if(bb > nn)
  {
    ans = floor(aa * nn, bb) - aa * floor(nn, bb);
  }
  else if(bb == nn)
  {
    ans = floor(aa * (nn - 1), bb) - aa * floor((nn - 1), bb);
  }
  else
  {
    int64 tmp = nn / bb;
    ans = floor(aa * (tmp * bb - 1), bb) - aa * floor((tmp * bb - 1), bb);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1680
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
string S; cin >> S;
int cnt = 0;
rep(i,S.size() - 1){
if(S[i] != S[i+1]){
    cnt++;
}
}
cout << cnt << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

class Data{
public:
    int n,p,y,id;
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    vector<Data> data(M);
    REP(i,M){
        data[i].n = i;
        cin>>data[i].p>>data[i].y;
    }
    sort(ALL(data), [](const Data& a, const Data& b){
            if(a.p == b.p){
                return a.y < b.y;
            }
            else{
                return a.p < b.p;
            }
            });

    int x = 1;
    int pre_p = -1;
    REP(i,M){
        if(data[i].p == pre_p){
            x++;
        }else{
            x = 1;
        }
        data[i].id = x;
        pre_p = data[i].p;
    }

    sort(ALL(data), [](const Data& a, const Data& b){return a.n < b.n;});
    REP(i,M){
        printf("%06d%06d\n", data[i].p, data[i].id);
    }
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;

   ll n,k ;
   cin>>n>>k ;

   ll dp[k+1] ;
   dp[k]=1 ;

   for(ll i=k-1;i>=1;i--)
   {
       ll x=k/i ;
       dp[i]=power(x,n) ;
       for(ll j=2*i;j<=k;j+=i)
       {
           dp[i]-=dp[j] ;
           dp[i]%=maa ;
           dp[i]+=maa ;
           dp[i]%=maa ;
       }
   }
   ll ans=0 ;
   for(ll i=1;i<=k;i++)
   {
       ans+=(dp[i]*i)%maa ;
       ans%=maa ;
   }
   cout<<ans ;





}



Measured memory_bytes: 4400
//#include<bits/stdc++.h>
#include<iostream>
 
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios::base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//using ll = long long;
 
template<typename T>
inline T Abs(T a){return a < 0 ? -a : a; }
template<typename T>
inline T Max(T a, T b){return a < b ? b : a; }
template<typename T>
inline T Min(T a, T b){return a > b ? b : a; }
 
using namespace std;
 
int main(){
    //fast()
    
    string b1, b2; cin >> b1 >> b2;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if(b1 == u) a--;
    else b--;
    cout << a << ' ' << b << '\n';
    return 0;
}

Measured memory_bytes: 256
def solve():
    n = int(input())
    a = list(map(int,input().split()))
    direction = 0 # 0なら未定　－１なら減少，１なら増加
    cnt = 1
    for i in range(1,n):
        if (a[i]-a[i-1])*direction<0:
            cnt+=1
            direction = 0
        else:
            if direction==0:
                direction = a[i]-a[i-1]
    print(cnt)
if __name__ == "__main__":
    solve()

Measured memory_bytes: 15020
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int x=0;
	string w;
	cin >> w;
	for(const auto& c : w){
		x^=c;
	}
	if(x){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}


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

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define pb push_back

int main(){
	int n;
	cin>>n;
	forsn(i, 1, n+1){
		int ot=n;
		vector<int> v;
		forn(j, i){
			int hago=i-j;
			if (hago<=ot){
				v.pb(hago);
				ot-=hago;
			}
		}
		if(ot==0){
			forn(si, v.size()){
				cout<<v[si]<<endl;
			}
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
char ca;
ll  c, d = 0, e, i, j, k, h, w, a[55][55] = {}, b[55][55] = {},o,p;
queue<i_i> q;

bool dft(int s, int t, int u) {
	if (a[s][t] == 0)return false;
	if (b[s][t] != 0)return false;
	b[s][t] = u + 1;
	return true;
}



int main() {
	cin >> h >> w;
	for(j=1;j<=h;j++)
		for (i = 1; i <= w; i++) {
			cin >> ca;
			if (ca == '.') {
				a[i][j] = 1;
				d++;
			}
			else
				a[i][j] = 0;
		}
	q.push(make_pair(1, 1));
	b[1][1] = 1;

	while (q.size() != 0) {
		o = q.front().first;
		p = q.front().second;
		if (dft(o + 1, p, b[o][p]))
			q.push(make_pair(o + 1, p));
		if (dft(o, p+1, b[o][p]))
			q.push(make_pair(o, p+1));
		if (dft(o -1, p, b[o][p]))
			q.push(make_pair(o - 1, p));
		if (dft(o, p-1, b[o][p]))
			q.push(make_pair(o, p-1));
		q.pop();
	}

	if (b[w][h] == 0)cout << -1;
	else cout << (d - b[w][h]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A, B, C;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];

    vector<ll> D;
    D.reserve(1000*1000);
    REP(i, X) {
        REP(j, Y) {
            D.push_back(A[i] + B[j]);
        }
    }
    sort(ALL(D));
    reverse(ALL(D));

    vector<ll> ans;
    ans.reserve(K*1000);
    REP(i, K) {
        REP(j, Z) {
            ans.push_back(D[i]+C[j]);
        }
    }
    sort(ALL(ans));
    reverse(ALL(ans));
    REP(i, K) cout << ans[i] << LF;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  for(int i = 1; i <= n; ++i) {
    if(a[i-1] == 1) {
      int r = n-i;
      int l = i-1;
      int ans = INF;
      for(int j = 0; j < k; ++j) {
        int nr = max(0, r-j);
        int nl = max(0, l-(k-j-1));
        int tmp = ceil((double)nr/(k-1)) + ceil((double)nl/(k-1)) + 1;
        chmin(ans, tmp);
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int a[101010];

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	LL nowprice = 2;
	LL ans = a[0] - 1;
	for (int i = 1; i < n; i++) {
		if (nowprice == a[i]) {
			nowprice++;
		}
		else if (nowprice < a[i]) {
			ans += (a[i] - 1) / nowprice;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
N,M=map(int,input().split())

dp=[0]*(N+1)
dp[0]=1
for _ in range(M):
    a=int(input())
    dp[a]=-1

for i in range(1,N+1):
    if dp[i]==-1:
        continue
    if dp[i-1]!=-1:
        dp[i]+=dp[i-1]
    if i>1 and dp[i-2]!=-1:
        dp[i]+=dp[i-2]

if dp[-1]==-1:
    print(0)
else:
    print(dp[-1]%(10**9+7))


Measured memory_bytes: 468380
import numpy as np
 
N, M = (list(map(int, input().split())))
a = np.array([0]*M)
b = np.array([0]*M)
for i in range(M):
  a[i], b[i] = (input().split())
ans = M
for i in range(M):
  C = set()
  D = set()
  count = 0
  while(True):
    for j in range(M):
      if not i == j:
        if(count == 0):
          C.add(a[j]) 
          C.add(b[j])
          count += 1  
        if a[j] in C or b[j] in C:
          C.add(a[j])
          C.add(b[j])
    if(C == D):
      break
    else:
      D = C.union(D)
  if(len(C) == N):
    ans -= 1
print(ans)

Measured memory_bytes: 12424
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
const int N = 2e5 + 10;
int A[N];
int n, d;
long long ans;
int fa[N];
struct node
{
    int x, y;
    long long v;
    node(int X = 0, int Y = 0, long long V = 0)
    {
        x = X;
        y = Y;
        v = V;
    }
};
vector<node>edge;
bool operator<(const node &a, const node &b)
{
    return a.v < b.v;
}
long long G(int x)
{
    return A[x] + (long long)x * d;
}
long long F(int x)
{
    return A[x] - (long long)x * d;
}
void work(int l, int r)
{
    if (l == r)
    {
        return;
    }
    if (l + 1 == r)
    {
        edge.push_back(node(l, r, F(l) + G(r)));
        return;
    }
    int F_min = l, G_min = r;
    int mid = (l + r) / 2;
    for (int i = l ; i<= mid ; i ++)
        if (F(F_min) > F(i))
            F_min = i;
    for (int i = mid + 1 ; i<= r ; i ++)
        if (G(G_min) > G(i))
            G_min = i;
    for (int i = l ; i <= mid; i ++)
        edge.push_back(node(i, G_min, F(i) + G(G_min)));
    for (int i = mid + 1 ; i <= r; i ++)
        edge.push_back(node(F_min, i, F(F_min) + G(i)));
    work(l, mid);
    work(mid + 1, r);
}
int getfa(int x)
{
    return x == fa[x] ? x : fa[x] = getfa(fa[x]);
}
int main()
{
    scanf("%d %d", &n, &d);
    for (int i =  1; i <= n ; i ++)
        scanf("%d", &A[i]), fa[i] = i;
    work(1, n);
    sort(edge.begin(), edge.end());
    for (auto u:edge)
        if (getfa(u.x) != getfa(u.y))
        {
            ans += u.v;
            fa[getfa(u.x)] = getfa(u.y);
        }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 69344
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    vector<vector<int> > dist(N, vector<int>(N, 1<<29));
    REP(i, R){
        cin >> r[i];
        r[i]--;
    }
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        dist[a][b] = dist[b][a] = c;
    }
    REP(i, N)dist[i][i] = 0;
    REP(k, N)REP(i, N)REP(j, N)dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    sort(ALL(r));
    int res = 1<<30;
    do{
        int tmp = 0;
        REP(i, R-1)tmp += dist[r[i]][r[i+1]];
        res = min(res, tmp);
    }while(next_permutation(ALL(r)));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
using System;

class Program
{
    static void Main(String[] args)
    {
        string w = Console.ReadLine();
        w += '\t';
        int[] abc = new int[26];

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

        for(int i = 0; w[i] != '\t'; i++)
        {
            abc[w[i] - 'a']++;
        }

        for(int i = 0; i < 26; i++)
        {
            if (abc[i] % 2 != 0)
            {
                Console.WriteLine("No");
                break;
            }
            else if (i == 25) Console.WriteLine("Yes");
        }

    }
}


Measured memory_bytes: 2648
#[test]
fn check_solve() {
    println!("input:\n0\noutput:\n{}\n", solve("0\n"));
    println!("input:\n1\noutput:\n{}\n", solve("1\n"));
    println!("input:\n2\noutput:\n{}\n", solve("2\n"));
    println!("input:\n3\noutput:\n{}\n", solve("3\n"));
    println!(
        "input:\n1234567894848\noutput:\n{}\n",
        solve("1234567894848\n")
    );
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let k: usize = sc.read();
    let n: usize = 50;
    let mut a: Vec<_> = (k / n..n + k / n).collect();
    for i in 0..k % n {
        a[i] += n + 1;
    }
    for i in 0..n {
        a[i] -= k % n;
    }
    let mut ret = String::new();
    use std::fmt::Write;
    writeln!(&mut ret, "{}", n).unwrap();
    for i in 0..n {
        write!(&mut ret, "{} ", a[i]).unwrap();
    }
    ret.pop();
    ret.push('\n');
    ret
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))

flag=0
gu=0  #偶数の数
for i in range(0,N):
    if A[i]%2==0:  #偶数ならば
        gu+=1
        if A[i]%3==0 or A[i]%5==0:
            flag+=1
            
        else:
            continue
    
    else:
        continue

if flag==gu:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
  int a,b,i;
  int max;
  scanf("%d %d",&a,&b);
  for(i=0;i<=1;i++){
  if(a>=b){
    max+=a;
  a--;}
  else{ max+=b;
       b--;}}
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.weight = [0]*N

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            p = self.root(self.parent[x])
            self.weight[x] += self.weight[self.parent[x]]
            self.parent[x] = p
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y, w):
        w-=self.getWeight(x)
        w+=self.getWeight(y)
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.weight[x] = self.weight[y]+w
            return
    def getWeight(self,x):
      x-=1
      self.root(x)
      return(self.weight[x])
N,M=map(int,input().split())
G=unionFind(N)
LRD=[tuple(map(int,input().split())) for i in range(M)]
for l,r,d in LRD:
  #print(G.parent)
  #print(G.weight)
  if G.same(l,r):
    if G.getWeight(r)-G.getWeight(l) == d:
      continue
    else:
      #print(G.parent)
      #print(G.weight)
      print("No")
      exit(0)
  else:
    G.unite(r,l,d)

print("Yes")

Measured memory_bytes: 40208
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}



int main()
{
  int N,M,Q;
  cin >> N >> M >> Q;
  int A[N][N];
  int B[N][N];
  REP(i,0,N){
    REP(j,0,N){
      A[i][j] = 0;
      B[i][j] = 0;
    }
  }
  REP(i,0,M){
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    A[r][l] += 1;
  }
  REP(i,0,N){

    REP(j,0,N){
      if(j==0){
        B[i][j] = A[i][j];
      }else{
        B[i][j] = B[i][j - 1] + A[i][j];
        
      }

    }
  
  }

  REP(i,0,Q){
    int p, q;
    cin >> p >> q;
    p--;
    

    ll ans = 0;
    REP(i, 0, q)
    {

      if (p == 0)
      {
        ans += B[i][N - 1];

      }
      else
      {
        ans += B[i][N - 1] - B[i][p - 1];
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 2816
n=int(input())
A=list(map(int,input().split()))
ans=0
mod=10**9+7
s=[0 for _ in range(n+1)]

for i in range(n):
    s[i+1]=(s[i]+A[i]%mod)%mod

for k in range(1,n):
    ans=(ans+(s[k]*(A[k]%mod))%mod)%mod
print(ans)

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int A, B, K;
  cin >> A >> B >> K;
  int cnt = 0;
  for(int i = min(A, B); i >= 0; i--){
    if(A % i == 0 && B % i == 0){
      cnt++;
      if(cnt == K){
        cout << i <<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

struct mint {
    ll x;
    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 {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=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 {mint res(*this); return res/=a;}
};

const int cmax = 2010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

ll com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    mint ret=fac[n]*finv[k]*finv[n-k];
    return ret.x;
}

int main() {
	int n, k;
	cin >> n >> k;
	com_init();
	for(int i = 1; i <= k; i++) {
		mint ans = com(n - k + 1, i) * com(k - 1, i - 1);
		cout << ans.x << endl;
	}
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll>asum(n+1),bsum(m+1);
    asum[0]=0;bsum[0]=0;
    rep(i,n){
        ll A; cin>>A;
        asum[i+1]=asum[i]+A;
    }
    rep(i,m){
        ll B; cin>>B;
        bsum[i+1]=bsum[i]+B;
    }
    ll ans=0;
    ll mx=0;
    for(int i=0;i<=n;i++){
        ll K=k-asum[i];
        if(K<0)break;
        for(int j=m;0<=j;j--){
            if(K-bsum[j]<0)continue;
            else{
                m=j;
                mx=j;
                break;
            }
        }
        ans=max(ans,i+mx);   
    }
    cout<<ans<<endl;


}














































































Measured memory_bytes: 6404