akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
//ユークリッド
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
//階乗
ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}
//素数判定
bool prime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	ll N,Over=0,color=0;
	vector<ll>V(8,0);
	cin>>N;
	rep(i,N){
		ll t;
		cin>>t;
		if(t<400)V[0]=1;
		else if(t<800&&t>=400)V[1]=1;
		else if(t<1200&&t>=800)V[2]=1;
		else if(t<1600&&t>=1200)V[3]=1;
		else if(t<2000&&t>=1600)V[4]=1;
		else if(t<2400&&t>=2000)V[5]=1;
		else if(t<2800&&t>=2400)V[6]=1;
		else if(t<3200&&t>=2800)V[7]=1;
		else Over++;
	}
	color=count(V.begin(),V.end(),1);
	if(color==0){
		cout<<"1 "<<Over<<endl;
	}
	else{
		cout<<color<<" "<<color+Over<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;

double calc(ll mid, ll x){
    double c = pow(1.01, mid)*100;
    return pow(1.01, mid)*100LL >= x;
}

int main(){
    int n, k;
    scanf("%d%d",&n, &k);
    vector<bool> v(n+1);
    for(int i = 0; i < k ; ++i){
        int d;
        scanf("%d", &d);
        for(int i = 0; i < d ; ++i){
            int a;
            scanf("%d", &a);
            v[a] = true;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n ; ++i) if(!v[i]) cnt++;
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 3848
fun main(args: Array<String>) {
    var (N, H) = readLine()!!.split(" ").map{it.toInt()}
    var A = IntArray(N, {0})
    var B = IntArray(N, {0})
    for (i in 0..N-1) {
        var (a, b) = readLine()!!.split(" ").map{it.toInt()}
        A[i] = a
        B[i] = b
    }
    val amax = A.max()!!
    val Bsort = B.sortedDescending()
    var damage = 0
    var cnt = 0
    for (b in Bsort) {
        if (b < amax) break
        damage += b
        cnt ++
        if (damage >= H) {
            println(cnt)
            return
        }
    }
    println(cnt+(H-damage-1)/amax+1)
}


Measured memory_bytes: 56684
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

LL v[50];
LL C[51][51];
int main() {
	for(int i=0;i<51;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
	}
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	for(int i=0;i<N;i++){
		scanf("%lld",v+i);
	}
	sort(v,v+N,greater<LL>());
	int r=upper_bound(v,v+N,v[0],greater<LL>())-v;
	if(r>=A){
		printf("%lld\n",v[0]);
		LL c=0;
		for(int i=A;i<=min(r,B);i++){
			c+=C[r][i];
		}
		printf("%lld\n",c);
	}
	else{
		double s=0;
		for(int i=0;i<A;i++){
			s+=v[i];
		}
		s/=A;
		printf("%.17lf\n",s);
		int l=lower_bound(v,v+N,v[A-1],greater<LL>())-v;
		int u=upper_bound(v,v+N,v[A-1],greater<LL>())-v;
		//cerr << l << ", " << u << endl;
		//cerr << u-l << ", " << A-l << endl;
		printf("%lld\n",C[u-l][A-l]);
	}

	return 0;
}



Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
n = getN()
nums = getList()


yaku = [[] for i in range(n + 1)]

for i in range(1, n//2 + 2):
    for j in range(2, n//i + 1):
        yaku[i*j].append(i)

# print(yaku)
ans = [0 for i in range(n)]
# print(nums)
for i in range(n):
    tmp = n - i
    if ans[tmp - 1] != nums[tmp - 1]:
        ans[tmp - 1] = 1
        for y in yaku[tmp]:
            ans[y-1] = (ans[y-1] + 1) % 2
    else:
        ans[tmp - 1] = 0
    # print(tmp, ans)

# print(ans)
pr = [i + 1 for i, x in enumerate(ans) if x == 1]
# print(pr)
print(len(pr))
print(" ".join(list(map(str, pr))))



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(int i=(a); i<(b); i++)
#define PER(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;

    VV g(n,Vec(n,-1));

    rep(i,n){
        ll tmp;
        cin>>tmp;
        ll targ;
        ll st;
        rep(j,tmp){
            cin>>targ>>st;
            targ--;
            g[i][targ] = st;
        }
    }

    int m = (1<<n);


    ll ans=0;
   // dbg(g);

    rep(i,m){
        // mのビットが立っている人のみ考える
        bool ok = true;
        rep(k,n){
            rep(l,n){
                if(i & (1<<k)){
                    if(g[k][l]==0 && (i & (1<<l))){
                        ok = false;
                        break;
                    }
                    if(g[k][l]==1 && !(i & (1<<l))){
                        ok = false;
                        break;
                    }
                }
            }
            if(!ok){
                break;
            }
        }
        if(ok){
            dbg(i);
            ll cnt = 0;
            rep(k,n){
                if(i & 1<<k){
                    cnt++;
                }
            }
            ans = max(ans,cnt);
        }
    }

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


Measured memory_bytes: 256
N=int(input())

Di={"":0}

for i in range(N):
    poll=str(input())
    
    if poll in Di.keys():
        Di[poll] += 1
    else:
        Di[poll] = 1


Di=sorted(Di.items())
Di.remove(("",0))

maxvalue=0
maxkey=[]

#print(Di)
for k in Di:
    if k[1] > maxvalue:
        maxvalue=k[1]
        maxkey=[]
        maxkey.append(k[0])
    elif k[1] == maxvalue:
        maxkey.append(k[0])

for m in maxkey:
    print(m)





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

int H,W,a,N;
int A[500][500];
typedef struct com_s{
    int a,b,c,d;
}com;
vector<com> V;


int main(void){
    cin >> H >> W;
    rep(i,H)rep(j,W){
        cin >> a;
        A[i][j]=a%2;
    }
    
    N = 0;
    rep(i,H){
        rep(j,W){
            if(A[i][j]==1){
                if(j<W-1){
                    A[i][j+1] = (A[i][j+1]+1)%2; 
                    A[i][j] = 0;
                    V.push_back({i+1,j+1,i+1,j+2});
                    N++;
                }
                if(j==W-1 && i <H-1){
                    A[i][j] = 0;
                    A[i+1][j] = (A[i+1][j]+1)%2; 
                    V.push_back({i+1,j+1,i+2,j+1});
                    N++;
                }
            }
        }
    }
    cout << N << endl;
    rep(i,N){
        cout << V[i].a << " " << V[i].b << " " << V[i].c << " " << V[i].d << endl;
    }
    
}


Measured memory_bytes: 5232
n = gets.to_i
a = gets.split.map(&:to_i)
len = a.max.to_s(2).length

ans = 0
len.times do |l|
  base = 2 ** l
  n_1 = a.inject(0) { |acc, cur| acc + cur[l] }
  ans += (n - n_1) * n_1 * base
  ans %= 1000000007
end
puts ans


Measured memory_bytes: 34820
n = int(input())  #スペース抜きの複数行,１文字ずつ
A = []

for i in range(1, n + 1):
    if i % 15 == 0:
        A.append(0)
    elif i % 3 == 0:
        A.append(0)
    elif i % 5 == 0:
        A.append(0)
    else:
        A.append(i)

print(sum(A))

Measured memory_bytes: 33904
#include<stdio.h>
bool query(long long int x){
	char s[9];
	printf("? %lld\n", x);
	fflush(stdout);
	scanf("%s",s);
	return *s == 'Y';
}
void output(int x){
	printf("! %d\n",x);
	fflush(stdout);
}
int main(){
	int L = 1;
	long long int now = 1;
	for(; L <= 10; L ++){
		if(!query(now * 10))
			break;
		now *= 10;
	}
	if(L == 11){
		now = 1;
		while(!query(now * 10 - 1))
			now = now * 10;
		output((int)now);
		return 0;
	}
	int res = 0;
	for(int i=L; i>1; i--){
		int lo = 0, hi = 9;
		while(lo != hi){
			int mi = (lo + hi + 1)/2;
			bool flag = query(res * 10 + mi);
			if(flag)
				lo = mi;
			else
				hi = mi-1;
		}
		res = res * 10 + lo;
	}

	for(int i=(L==1?1:0); i<10; i++)
		if(query(res * 100LL + i * 10)){
			output(res * 10 + i);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<vector> 
#include<cmath>
#include<algorithm>
#include<functional>
#include<queue>

using namespace std;

int main()
{
    int N, K, x;   cin >> N >> K;
    std::queue<int> que;
    std::vector<int> v(K), u(10-K);
    for(int i=0; i<K; i++)  cin >> v[i];
    int j=0;
    for(int i=0; i<=9; i++){
        if(v[j] == i)   j++;
        else{
            que.push(i);
            u[i-j] = i;
            if(i >= N){
                cout << i;
                return 0;
            }
        }
    }
    int ans = 0;
    if(u[0] == 0){
        que.front();
        que.pop();
    }
    while(ans < N){
        x = que.front();
        que.pop();
        for(int i=0; i<10-K; i++){
            ans = x*10+u[i];
            if(ans >= N){
                cout << ans;
                return 0;
            }else   que.push(ans);
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int H, W, c[10][10] = {0}, A[222][222];

  std::cin >> H >> W;

  for (int i = 0; i < 10; i ++)
    for (int j = 0; j < 10; j ++)
      std::cin >> c[i][j];

  for (int k = 0; k < 10; k ++)
    for (int i = 0; i < 10; i ++)
      for (int j = 0; j < 10; j ++)
        c[i][j] = std::min(c[i][k] + c[k][j], c[i][j]);

  int s = 0;

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++) {
      std::cin >> A[i][j];

      if (A[i][j] >= 0)
        s += c[A[i][j]][1];
    }

  std::cout << s << std::endl;

  return 0;
}


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

vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数

void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = max(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}

ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return 0; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
    // に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return max(c1, c2); // 左右の子の値の min を取る
    }
}



int dp[200005];

int main(){
  ll n;
  cin>>n;
  vector<ll> h(n);
  vector<ll> a(n);
  rep(i,n)cin>>h[i];
  rep(i,n)cin>>a[i];
  N=1;
  while(N<=n)N*=2;
  value = vector<ll>(2 * N - 1, 0);
//  dp[0]=0;

  rep(i,n){
    ll temp=query(0,h[i],0,0,N);
//    cout<<temp<<endl;
    update(h[i],temp+a[i]);
  //  cout<<temp+a[i]<<endl;
  }
cout<<query(0,n+1,0,0,N);

}


Measured memory_bytes: 10296
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
 
 
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(N)]
R = [0 for i in range(N)]
T = [0 for i in range(N)]
 
for i in range(N):
    if i == 0:
        L[i] = 0
    else:
        L[i] = gcd(L[i-1], A[i-1])
for i in range(N-1, -1, -1):
    if i == N-1:
        R[i] = 0
    else:
        R[i] = gcd(R[i+1], A[i+1])
for i in range(N):
    T[i] = gcd(L[i], R[i])
 
print(max(T))

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; ++i) { scanf("%lld", &a[i]); }
  for (int i = 0; i < n; ++i) { scanf("%lld", &b[i]); }

  ll ans = 0;
  for (int bit = 0; bit < 30; ++bit) {
    ll T = (1 << bit);
    vector<ll> aa(n), bb(n);
    for (int i = 0; i < n; ++i) {
      aa[i] = a[i] % (T << 1);
      bb[i] = b[i] % (T << 1);
    }
    sort(bb.begin(), bb.end());
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += upper_bound(bb.begin(), bb.end(), 2 * T - aa[i] - 1) -
        lower_bound(bb.begin(), bb.end(), T - aa[i]);
      cnt += upper_bound(bb.begin(), bb.end(), 4 * T - aa[i] - 1) -
        lower_bound(bb.begin(), bb.end(), 3 * T - aa[i]);
    }
    ans |= (1 << bit) * (cnt % 2);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 7032
n,m=map(int,input().split())
A=[]
C=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])
for j in range(m):
  c,d=map(int,input().split())
  C.append([c,d])
for i in range(n):
  dis=10**9
  ans=0
  for j in range(m):
    if abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])<dis:
      dis=abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])
      ans=j+1
  print(ans)

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

int main() {
  int N = 4;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  sort(V.begin(), V.end());
  cout << ((V.at(0) == 1 && V.at(1) == 4 && V.at(2) == 7 && V.at(3) == 9) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
    long k, a, b, d, ans;
    scanf("%ld%ld%ld", &k, &a, &b);
d=b-a;
    if (d<=2)
        ans = k + 1;
    else {
        if (a > k - 1)
            ans = k + 1;
        else {
            ans = a;
            k -= a - 1;
            if (k % 2 == 1) {
                ans++;
                k--;
            }
            ans += d*k/2;
        }
    }
    printf("%ld\n", ans);
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  string ss,c="";
  ss=s+s;
  int i,j,n=s.size();
  for(i=0;i<n;i++){
    for(j=i;j<i+n;j++)
      c=c+ss.at(j);
    if(c==t){
      cout<<"Yes";
      break;
    }
    else if(i==n-1 && c!=t)
      cout<<"No";
    c="";
  }
    
}


Measured memory_bytes: 256
N,A,B,C = map(int, input().split(' '))
ls = [int(input()) for i in range(N)]

def dfs(n, a = 0, b = 0, c = 0, mp = 0):
    if n == N:
        if a > 0 and b > 0 and c > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) + mp
        else:
            return 9223372036854775807
    else:
        return min(
            dfs(n+1, a + ls[n], b, c, mp + (10 if a > 0 else 0)),
            dfs(n+1, a, b + ls[n], c, mp + (10 if b > 0 else 0)),
            dfs(n+1, a, b, c + ls[n], mp + (10 if c > 0 else 0)),
            dfs(n+1, a, b, c, mp),
        )

print(dfs(0))


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

int main(void)
{
    ll n, pat_num = 1;
    long double distance_sum = 0;
    cin >> n;
    vector<ll> x(n), y(n), p(0);
    for(ll i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i);
        p.push_back(i);
        pat_num *= (i + 1);
    }

    do {
        for(ll i = 0; i < n - 1; i++) {
            distance_sum += sqrt( ( x.at(p.at(i + 1)) - x.at(p.at(i)) ) * ( x.at(p.at(i + 1)) - x.at(p.at(i)) ) + ( y.at(p.at(i + 1)) - y.at(p.at(i)) ) * ( y.at(p.at(i + 1)) - y.at(p.at(i)) ) );
        }
    } while ( next_permutation(p.begin(), p.end()) );

    cout << fixed << setprecision(10) << distance_sum / pat_num;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << 7 << endl;
  }
  if(s == "MON"){
    cout << 6 << endl;
  }
  if(s == "TUE"){
    cout << 5 << endl;
  }
  if(s == "WED"){
    cout << 4 << endl;
  }
  if(s == "THU"){
    cout << 3 << endl;
  }
  if(s == "FRI"){
    cout << 2 << endl;
  }
  if(s == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define MAX 15000001
#define p pair<int,int>
#define speed ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)

ll pow2[15];
ll pow3[15];
//ll pow10[15];
int len;
ll ans[10];
vector<int> numbers[11];

void generate()
{
	numbers[1].push_back(3);
	numbers[1].push_back(5);
	numbers[1].push_back(7);
	for(int i=2;i<10;i++)
	{
		for(int j=0;j<numbers[i-1].size();j++)
		{
			int curr=numbers[i-1][j];
			numbers[i].push_back(curr*10 +3);
			numbers[i].push_back(curr*10 +5);
			numbers[i].push_back(curr*10 +7);
		}
	}
}
bool check(int x)
{
	//vector<int> vec;
	int a=0,b=0,c=0;
	while(x!=0)
	{
		int curr=x%10;
		if(curr==3)
			a=1;
		if(curr==5)
			b=1;
		if(curr==7)
			c=1;
		x/=10;
	}
	return a && b && c;
}

int main()
{
	int n;
	cin>>n;
	pow2[0]=pow3[0]=1;
	for(int i=0;i<15;i++)
	{
		pow3[i+1]=pow3[i]*3;
		pow2[i+1]=pow2[i]*2;
		//pow10[i+1]=pow10[i]*10;
	}
	for(int i=1;i<=10;i++)
	{
		ans[i]+=ans[i-1];
		ans[i]+=pow3[i] - 3*pow2[i] + 3;
	//	cout<<ans[i]<<endl;
	}
	len=0;
	int t=n;
	while(t!=0)
	{
		len++;
		t/=10;
	}
	//cout<<len;
	int res=0;
	res=ans[len-1];
	if(len>=3)
	{
		generate();
		for(int i=0;i<numbers[len].size();i++)
		{
			int num=numbers[len][i];
			if(num<= n && check(num))
				res++;
		}
	}
	cout<<res;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s,mae,ato;
    int q;
    cin>>s>>q;
    bool normal=true;
    for (int i = 0; i < q; i++)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            normal=!normal;
        }
        else
        {
            int f;
            char c;
            cin>>f>>c;
            if((normal && f==1) || (!normal && f==2))
            {
                mae+=c;
            }
            else
            {
                ato+=c;
            }
        }
    }
    string ans;
    reverse(all(mae));
    ans=mae+s+ato;

    if(!normal)
    {
        reverse(all(ans));
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int blc[51][51];
int dp[51][51];

int solve(int h,int w){
    REP(i,h){
        REP(j,w){
            if(i==0&&j==0)continue;
            else if(i==0)dp[i][j]=dp[i][j-1]+blc[i][j];
            else if(j==0)dp[i][j]=dp[i-1][j]+blc[i][j];
            else dp[i][j]=min(dp[i-1][j],dp[i][j-1])+blc[i][j];
        }
    }
    return dp[h-1][w-1];
}

int main(){
    int h,w;
    cin >> h >> w;
    char b;
    REP(i,h){
        REP(j,w){
            cin >> b;
            blc[i][j]=b-'0';
        }
    }
    dp[0][0]=0;

    int ans=solve(h,w);
    cout << ans << endl;

}



Measured memory_bytes: 3124
A,B,M = map(int, input().split(' '))
priceA = list(map(int, input().split(' ')))
priceB = list(map(int, input().split(' ')))
minPrice = min(priceA) + min(priceB)

for i in range(M):
    ai,bi,discount = list(map(int, input().split(' ')))
    sum = (priceA[ai-1] + priceB[bi-1] - discount)
    if minPrice > sum:
      minPrice = sum
else:      
    print(minPrice)

Measured memory_bytes: 18736
/* Author: Jason L.(int3xccATgmailDOTcom), Mon Sep  4 00:29:19 CST 2017 */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pll = pair<ll, ll>; using dd = long double;
//=========================================================================
namespace {
static bool constexpr dbg =
#ifdef INT3XCC_DEBUG
        1;
#else
        0;
#endif
#define Dprintf(fmt, ...) do{if(dbg) printf(fmt, ##__VA_ARGS__);}while(0)
#define REP0(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
//=========================================================================
ll constexpr N = 1.1e5;
ll n, d[N];
//=========================================================================
void init() {
    cin>>n; REP1(i, n) cin>>d[i];
}
void solve() {
    ll res = 0, cnt = 0;
    REP1(i, n) {
        if (d[i] == i) ++cnt;
        else {
            res += (cnt+1)/2;
            cnt = 0;
        }
    }
    res += (cnt+1)/2;
    cout<<res;
}}
//=========================================================================
int main() {
    if (!dbg) { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
    cout<<fixed<<setprecision(20); init(); solve(); return 0;
}


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int a, b; cin >> a >> b;
    set<int> ans = {1, 2, 3};
    ans.erase(a);
    ans.erase(b);
    cout << *ans.begin();
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e9)

bool check(int n, vector<int> d){
	while(n>0){
		for(int i=0; i<d.size(); i++){
			if(n%10==d[i]) return false;
		}
		n/=10;
	}
	return true;
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> d;
	d.resize(k);
	for(int i=0; i<k; i++){
		cin >> d[i];
	}
	for(int i=n; ; i++){
		if(check(i, d)){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;
cin >> n;
int p;
int m=INF;
int ans=0;
rep(i,n){
    cin >> p;
    if(chmin(m,p))ans++;
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  map<int,ll> d;
  int s = 0;
  d[0]++;
  rep(i,n) {
    int a;
    cin >> a;
    s = (s+a)%m;
    d[s]++;
  }
  ll ans = 0;
  for(auto i:d) ans += i.second*(i.second-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int w,h,n;
  cin >> w >> h >> n;
  int x[n],y[n],a[n];
  int minx = 0;
  int maxx = w;
  int miny = 0;
  int maxy = h;
  
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> a[i];
    if(a[i] == 1) minx = max(minx,x[i]);   
    if(a[i] == 2) maxx = min(maxx,x[i]);
    if(a[i] == 3) miny = max(miny,y[i]);
    if(a[i] == 4) maxy = min(maxy,y[i]);
    }
  if((maxx - minx) > 0 && (maxy - miny) > 0) {
    cout << (maxx - minx) * (maxy - miny) << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

using namespace std;

int main(){

	double l, r, s;
	long long int a, b, c;

	cin>> a >> b >> c;

	if ((c - a - b)*(c - a - b) > 4*a*b && 0<c-a-b) cout << "Yes" << endl;
	else cout << "No" << endl;



}


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

int main() {
	int N; cin >> N;
	long long H; cin >> H;
	long long A[100010], B[100010];

	for (int i = 0; i < N; i++)cin >> A[i] >> B[i];
	
	sort(A, A + N, greater<long long>());
	sort(B, B + N, greater<long long>());
	
	long long sum = 0;
	long long cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[0] > B[i]) continue;
		sum += B[i]; cnt++;
		if (sum >= H) { cout << i + 1 << endl; return 0; }
	}

	if ((H - sum) % A[0] == 0)cout << (H - sum) / A[0] + cnt << endl;
	else cout << (H - sum) / A[0] + 1 + cnt << endl;
	

	return 0;
}

Measured memory_bytes: 1792
#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>;

int main(void){
    int N;
    string C;
    cin >> N >> C;
    int w=0, r=0;
    rep(i, N) if(C.at(i) == 'R') r++;
    int ans = max(w, r);

    for(int i=0;i<N;i++){
        if(C.at(i) == 'W') w++;
        else r--;
        ans = min(ans, max(w, r));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), mi, ma;
    rep(i, n){
        cin >> a[i] >> b[i];
        mi.push_back(a[i]);
        ma.push_back(b[i]);
    }
    sort(all(mi)); sort(all(ma));
    if(n % 2 == 1){
        ll c = mi[n/2], d = ma[n/2];
        cout << d-c+1 << endl;
    }
    else{
        ll p = n/2;
        ll c = (mi[p] + mi[p-1]);
        ll d = (ma[p] + ma[p-1]);
        cout << d-c+1 << endl; 
    }
}

Measured memory_bytes: 9684
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main(){

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)
		cout << a * b << endl;
	else
		cout << c * d << endl;

	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    set<int>st;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        st.insert(a);
    }
    if(st.size()==n)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 9600
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         SET(m)                      memset(m, 1,sizeof m)
#define         RESET(m)                    memset(m,0,sizeof m)
#define         mp(a,b)                     make_pair(a,WWb)
#define         mod                         1000000007
#define         INF                         1e17
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

ll a[200005];
int main(){
    ll n,k;
    sfl(n),sfl(k);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
    }   
    sort(a+1,a+n+1);
    ll i=n;
    while(i>=1 and k){
        i--;
        k--;
    }
    ll ans=0;
    while(i>=1){
        ans += a[i];
        i--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int main(){
	IOS;
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<< '\n';
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M,Q = map(int,input().split())

com = [[0] * 502 for i in range(502)]

for _ in range(M):
    L,R = map(int,input().split())
    com[L][R] += 1

for i in range(502):
    for j in range(1,502):
        com[i][j] += com[i][j-1]

for _ in range(Q):
    p,q = map(int,input().split())
    ans = 0
    for i in range(p,q+1):
        ans += com[i][q]
    print(ans)


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	if(n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,Q,A[100001];
	ll K;
	ll pt[100001];
	scan(N>>K>>Q);
	rep(i,N) pt[i]=K-Q;
	rep(i,Q){
		scan(A[i]);
		A[i]--;
		pt[A[i]]++;
	}
	rep(i,N){
		if(pt[i]>0) prin("Yes");
		else prin("No");
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<long long> ww;
vector<vector<long long>> wc;
long long best;

void solve(long long step, long long w, long long v) {
	if (step == ww.size()) {
		best = max(best, v);
	}
	else {
		long long i;
		solve(step + 1, w, v);
		for (i = 0; (i < wc[step].size()) && ((i + 1) * ww[step] <= w); i++) {
			solve(step + 1, w - (i + 1) * ww[step], v + wc[step][i]);
		}
	}
}

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

	long long n, www, i, j, k, w, v, m, x;
	map<long long, vector<long long>> ct;
	cin >> n >> www;
	for (i = 0; i < n; i++) {
		cin >> w >> v;
		if (ct.find(w) == ct.end()) ct[w] = { v };
		else ct[w].push_back(v);
	}

	for (auto p : ct) {
		ww.push_back(p.first);
		wc.push_back(p.second);
		x = wc.size() - 1;
		sort(wc[x].rbegin(), wc[x].rend());
		for (i = 1; i <= wc[x].size() - 1; i++) wc[x][i] += wc[x][i - 1];
	}

	best = 0;
	solve(0, www, 0);

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, 0, N) cin >> H[i];
    int ans = 0;
    int now_ans = 0;
    rep(i, 0, N - 1) {
        if (H[i] >= H[i + 1]) now_ans++;
        else {
            ans = max(ans, now_ans);
            now_ans = 0;
        }
    }
    ans = max(ans, now_ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


ll dp[305][305][305];

int main() {

	string s;
	cin >> s;
	ll m;
	cin >> m;

	VLL v;
	int cnt = 0;
	REP(i, s.size()) {
		if (s[i] == '0') {
			v.push_back(cnt);
			cnt = 0;
		}
		else cnt++;
	}
	if (cnt != 0) {
		v.push_back(cnt);
	}



	while (v.size() != 0 && v.back() == 0)v.pop_back();

	int n = v.size();
	if (v.size() <= 1) {
		cout << 1 << endl;
		return 0;
	}

	reverse(ALL(v));

	//vector<map<pair<int, int>, ll>> dp(305);

	REP(i, min(m + 1, v[0] + 1)) {
		dp[0][i][i] = 1;
	}


	int max_m = 0;
	REP(i, n)max_m += v[i];

	FOR(i, 1, n - 1) {
		//cout << i << endl;
		REP(j, max_m + 1)REP(k, max_m + 1) {
			ll cnt = dp[i - 1][j][k];
			ll mi = max(0LL, v[i] - max(0LL, m - k));
			FOR(l, mi, v[i] + j + 1) {
				int o = j + v[i] - l;
				int kk = k + max(0LL, v[i] - l);
				dp[i][o][kk] += cnt;
				dp[i][o][kk] %= mod;
			}

		}
	}
	ll sum = 0;

	REP(i, 305)REP(j, 305) {
		sum += dp[n - 2][i][j];
		sum %= mod;
	}
	cout << sum << endl;



}

Measured memory_bytes: 57900
from collections import deque

h,w = map(int,input().split())
s = [list(input()) for j in range(h)]
path = [[[]for i in range(w)]for j in range(h)]
sg = []
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        else:
            sg.append((i,j))
        if j != w-1 and s[i][j+1] == '.':
            path[i][j].append((i,j+1))
        if i != h-1 and s[i+1][j] == '.':
            path[i][j].append((i+1,j))
        if j != 0 and s[i][j-1] == '.':
            path[i][j].append((i,j-1))
        if i != 0 and s[i-1][j] == '.':
            path[i][j].append((i-1,j))
que = deque([])
ans = 0
for x,y in sg:
    passed = [[0 for ii in range(w)] for jj in range(h)]
    que = deque([])
    que.append((x,y))
    depth = [[-1 for ii in range(w)] for jj in range(h)]
    depth[x][y] = 0
    while len(que) > 0:
        vx,vy = que.popleft()
        d = depth[vx][vy]
        for wx,wy in path[vx][vy]:
            if depth[wx][wy] > -1:
                continue
            depth[wx][wy] = d + 1
            que.append((wx,wy))
        ans = max(ans,d)
print(ans)

        


Measured memory_bytes: 3436
import math
from functools import reduce

K = int(input())
sum = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            sum += gcd(a, b, c)

print(sum)

Measured memory_bytes: 69756
#include <bits/stdc++.h>
using namespace std;
#define int long long
//int arr[1e6][1e6];
#define data pair<int,int>

inline double dist(int x1, int y1, int x2, int y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

signed main() {
    map<int,int> mp;
    mp[0] = 1;
    mp[1] = 1;
    mp[2] = 2;
    mp[3] = 6;
    mp[4] = 24;
    mp[5] = 120;
    mp[6] = 720;
    mp[7] = 5040;
    mp[8] = 40320;
    map<int,vector<double>>mp2;
    int n;
    cin>>n;
    vector <data> vec;
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        vec.push_back(make_pair(x,y));
    }
    
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            mp2[i].push_back(dist(vec[i].first,vec[i].second,vec[j].first,vec[j].second));
        }
    }
    vec.erase(vec.begin(),vec.end());
    double ans = 0;
    int mul = 0;
    for(auto i:mp2){
        //cout<<i.first+1<<"->";
        for(auto k:i.second){
            //cout<<k<<" ";
            ans += k;
            ++mul;
        }
        //cout<<endl;
    }
    //cout<<setprecision(10)<<ans<<" "<<mul<<endl;
    //fixed();
    double hehe = (double)((2*ans)/(n));
    cout<<setprecision(10)<<hehe<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char X,Y;
	scanf("%s", &X);
	scanf("%s", &Y);
	if ((int)X > (int)Y)printf(">");
	else if ((int)X < (int)Y)printf("<");
	else printf("=");

}

Measured memory_bytes: 128
s = input()
ACGT = ["A", "C", "G", "T"]
temp = 0

long_record = 0
for car in s:
  if car in ACGT:
    temp += 1
  else:
    if long_record < temp:
      long_record = temp
    temp = 0
print(max(long_record, temp))

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

const int N = 2020;

long long dp[N][N];
pair<int,int> a[N];

signed main(){
    int n;
    scanf("%lld", &n);
    for(int i = 1;i<=n;i++){
        int x;
        scanf("%lld", &x);
        a[i] = pair<int,int>(-x,i);
    }
    sort(a+1,a+n+1);
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            if(i == 0) dp[i][j] = 0;
            else dp[i][j] = -1;
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j = 0;j<i;j++){
            int x = i-1-j, y = j;
            dp[x+1][y] = max(dp[x+1][y],dp[x][y]-(a[i].first)*abs(a[i].second-(x+1)));
            dp[x][y+1] = max(dp[x][y+1],dp[x][y]-(a[i].first)*abs(a[i].second-(n-y)));
        }
    }
    long long ans = -1;
    for(int i = 0;i<=n;i++){
        ans=max(ans,dp[n-i][i]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 35748
//
//

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int n,l;

  cin >> n >> l;

  vector<string> s(n);
  
  for(auto &str : s){
    cin >> str;
  }

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

  string result = "";

  for(auto str : s){
    result += str;
  }
  
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
program sum_of_large_numbers
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, k, i
  integer(8) :: x = 0, l = -1, r
  read(*,*) n, k
  r = n
  do i = 1, n+1
    if (i >= k) x = modulo(x+r-l,md)
    l = l+i
    r = r+(n-i)
  end do
  write(*,'(i0)') x
end program sum_of_large_numbers

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  cout << count(all(s),'1') << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

li pow(li a,int n){
  li ans=1;
  while(n){
    if(n%2) {
      ans*=a;
      if(df)print("*",a,ans);
      ans%=MOD;
    }
    (a*=a)%=MOD;
    n/=2;
  }
  return ans;
}


int main(){
  int n,k; cin >>n >>k;
  vector<li> v(k+1);
  rep(i,k+1) v[i]=i;

  auto f=
    [&](int a){
      int s=a*2;
      while(s<=k){
        v[s]-=v[a];
        s+=a;
      }
    };

  if(df)print(pow(10,10));

  li ans=0;
  repa(i,1,k+1){
    (ans+=pow(k/i,n)*v[i]%MOD)%=MOD;
    f(i);
  }
  if(df)print(v);
  print(ans);
}


Measured memory_bytes: 3984
#include <stdio.h>
#include <string.h>


int main(void)

{	
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a==b){
		printf("Draw\n");
	} else if(a==1){
		printf("Alice\n");
	} else if(b==1){
		printf("Bob\n");
	} else if(a>b){
		printf("Alice\n");
	} else {
		printf("Bob\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int min(int,int);

int main(){
  int i,j,l,k,n,p[101],m[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}

int min(int i,int j){
  int k;
  if(i<j){
    return i;
  }
  return j;
}



Measured memory_bytes: 2052
#include <stdio.h>

int main(void)
{
	int loan;
	int n;
	
	loan = 100000;
	scanf("%d", &n);
	
	while (n){
		loan += (loan * 0.05);
		
		if (loan % 1000){
			loan += 1000;
		}
		
		loan /= 1000;
		loan *= 1000;
		
		n--;
	}
	
	printf("%d\n", loan);
	
	return (0);
}

Measured memory_bytes: 1020
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, M, H[2000], W[2000];
int h[2000000], w[2000000];

int main(void) {
  while(cin >> N >> M, N && M) {
    H[0] = W[0] = 0;
    REP(i, 1, N + 1) cin >> H[i];
    REP(i, 1, M + 1) cin >> W[i];
    REP(i, 0, N + 1) H[i + 1] += H[i];
    REP(i, 0, M + 1) W[i + 1] += W[i];

    REP(i, 0, 2000000) h[i] = w[i] = 0;
    REP(i, 0, N + 1) REP(j, i + 1, N + 1) h[H[j] - H[i]]++;
    REP(i, 0, M + 1) REP(j, i + 1, M + 1) w[W[j] - W[i]]++;

    int ans = 0;
    REP(i, 1, 2000000) ans += h[i] * w[i];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 18708