akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll S; cin >> S;
  vector<ll> dig; while(S!=0) {dig.push_back(S%10); S/=10;}

  ll result = 0, ds = dig.size();
  rep(i,ds) {
    ll tmp = 0;
    for (int j=i; j<ds; j++) {
      if (j==i) tmp += dig[j] * pow(2,ds-(i+1));
      else tmp += dig[j] * pow(2,ds-(i+2));
    }
    result += tmp * pow(10,i);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char s[100001];

    scanf("%s", s);

    int len = strlen(s);

    int t = 0;

    for(int i = 1; i < len; i++){
        if(s[i] == s[i-1]){
            t = 1;
            printf("%d %d\n", i, i + 1);
            break;
        }
    }

    if(t == 0){
        for(int i = 0; i < len - 2; i++){
            if(s[i] == s[i + 2]){
                t = 1;
                printf("%d %d\n", i+1, i+3);
                break;
            }
        }
    }

    if(t == 0){
        printf("-1 -1\n");
    }

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  ans1(max({a,b,c})==a+b+c-max({a,b,c}));

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,H,M;
    double angle_H,angle_M,angle;
    cin >> A >> B >> H >> M;
    angle_M = 6*M;
    angle_H = 30*H + M/2.0;
    angle = angle_H - angle_M;
    if(angle<0) angle *=-1;
    double ans = A*A + B*B - 2*A*B*cos(angle*M_PI/180);
    ans = sqrt(ans);
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<string> sq(h);
    bool ans = true;
    rep(i, h) cin >> sq[i];


    rep(i, h){
        rep(j, w){
            // マス目を全探索、黒なら隣接部に黒があるかどうか確認
            if(sq[i][j] == '#'){
                if(i != 0 && sq[i-1][j] == '#') continue;
                else if(i != h-1 && sq[i+1][j] == '#') continue;
                else if(j != 0 && sq[i][j-1] == '#') continue;
                else if(j != w-1 && sq[i][j+1] == '#') continue;
                ans = false;
            }
        }
    }

    (ans) ? Yes() : No();
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
using namespace std; 
int main() 
{ 
long long int a,b,count=0; 
while(cin>>a>>b) 
{
count=log10(a+b)+1; 
cout<<count<<endl;
}
return 0; 
} 

    


Measured memory_bytes: 3364
//*** cfmasterr ***//
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	long long n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << '\n';
		return 0;
	}
	auto Count = [&](long long a, long long b) {
		long long ans = 0;
		long long x = b;
		while (a >= x) {
			ans += a / x;
			x *= b;
		}
		return ans;
	};
	long long m = n / 2;
	long long cnt2 = Count(m, 2), cnt5 = Count(m, 5);
	cnt2 += m;
	cout << min(cnt5, cnt2) << '\n';
  return 0;
}




Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

using Graph = vector<vi>;

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

    vector<vi> graph(n, vi());

    rep(i, m) {
        int a, b;
        cin >> a >> b; --a; --b;

        graph[a].push_back(b);
    }

    int s = INT_MAX;
    vi ans;

    rep(i, n) {
        vi d(n, -1), p(n, -1);
        d[i] = 0;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            auto v = q.front();
            q.pop();
            for (const auto& u: graph[v]) {
                if(d[u] == -1) {
                    d[u] = d[v] + 1;
                    p[u] = v;
                    q.push(u);
                }
            }
        }

        rep(j, n) {
            if (d[j] == -1) continue;
            for (const auto& v: graph[j]) {
                if (v == i) {
                    vi path({i});
                    int pt = j;
                    while (pt != i) {
                        path.push_back(pt);
                        pt = p[pt];
                    }

                    if (s > path.size()) {
                        s = path.size();
                        ans = path;
                    }
                }
            }
        }
    }

    if (s == INT_MAX) {
        cout << -1;
    } else {
        cout << s << endl;
        for (auto x: ans) {
            cout << x + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int l,r;
	cin>>l>>r;
	int ans=2018;
	if(r-l+1<=2019) {
		for(int i=l; i<=r; i++) {
			for(int j=i+1; j<=r; j++) {
				ans=min(ans,(((i%2019)*(j%2019))%2019));
			}
		}
		cout<<ans<<endl;
	}
	else{
		cout<<0<<endl;

	}


	return 0;
}


Measured memory_bytes: 256
# abc 153
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

H = int(read().strip())

def solve(h):
    if h == 1:
        return 1
    
    new_h = int(h / 2)
    return (2 * solve(new_h)) + 1

answer = solve(H)
print(answer)

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  
  vector<int> x;
  x.push_back(0);
  for(int i = 1; i < n; i++){
    if(s.at(i - 1) != s.at(i)) x.push_back(i);
  }
  x.push_back(n);
  
  if(s.at(0) == '1'){
    if((x.size() - 1) / 2 <= k) cout << n << endl;
    else{
      x.push_back(n);
      int i = 0, ans = 0;
      while(i + 2 * k + 1 < x.size()){
        ans = max(ans, x.at(i + 2 * k + 1) - x.at(i));
        i += 2;
      }
      cout << ans << endl;
    }
  }
  else{
    if(x.size() / 2 <= k) cout << n << endl;
    else{
      x.push_back(n);
      int i = 1, ans = 0;
      while(i + 2 * k + 1 < x.size()){
        ans = max(ans, x.at(i + 2 * k + 1) - x.at(i));
        i += 2;
      }
      ans = max(ans, x.at(2 * k));
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>a>>b;
    cout<<min(n * a, b);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        String str2 = scan.next();
        int num0 = Integer.parseInt(str);
        int num1 = Integer.parseInt(str2);
        System.out.println(num0 * num1 + " " + (num0 + num1) * 2);
        scan.close();
    }
}



Measured memory_bytes: 26016
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B + C >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1000;
typedef long long LL;
using namespace std;
int father[MaxN + 5], n;
bool vis[MaxN + 5][MaxN + 5];
LL a[MaxN + 5][MaxN + 5], b[MaxN + 5][MaxN + 5];
void Init(){
	memset(vis, 0, sizeof(vis));
	memset(a, 0, sizeof(a));
	for (int i = 1; i <= n; i++) father[i] = i;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			b[i][j] = 1LL << 60;
			scanf("%lld", &a[i][j]);
			if(a[i][j] != 0) b[i][j] = a[i][j];
		}
	}
	for (int k = 1; k <= n; k++){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++) {
				b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
			}
		}
	}
}

void Solve(){
	bool ok = 1;
	int tot = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++) {
			if(a[i][j] != b[i][j] && a[i][j] != 0){
				ok = 0;
			}
		}
	}
	if(!ok){
		printf("-1\n");
		return;
	}
	LL sum = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			bool flag = 1;
			for (int k = 1; k <= n; k++){
				if(b[i][j] == b[i][k] + b[k][j]) flag = 0;
			}
			if(flag && vis[i][j] == 0 && vis[j][i] == 0) sum = sum + b[i][j], vis[i][j] = vis[j][i] = 1;
		}
	}
	printf("%lld\n", sum);
}
int main()
{
	while(~scanf("%d", &n)){
		Init();
		Solve();
	}
}

Measured memory_bytes: 14464
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
    int H,A[2000001];

       
int main(){
    string str;
    priority_queue<int>PQ;
    
    while(1){
        cin>>str;
        if(str[0]=='i'){
            int key; cin>>key;
            PQ.push(key);
        }else if(str[1]=='x'){
            cout<<PQ.top()<<endl;
            PQ.pop();
        }else break;
  
    }
    return 0;
    
 
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll n, k;
    cin >> n >> k;
    if (n > k) {
        n -= n / k * k;
    }
    for (;;) {
        ll t = abs(n - k);
        if (n <= t) break;
        n = t;
    }
    ll ans = n;
    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++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a>> b;
    if(b*2 >= a) cout << 0 << endl;
    else cout << a-b*2 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
int a,b;
int t=0;

int main()
{
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        if((i/10000%10)==(i%10)&&(i/1000%10)==(i/10%10))
            t++;
    }
    printf("%d",t);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200000
int a[N];
main(){
	int n,t;
	cin>>n;
	for(int i=0;i<n-1;i++)cin>>t,a[t]++;
	for(int i=1;i<=n;i++)cout<<a[i]<<"\n";
}

Measured memory_bytes: 4344
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int A, B,C,D,ans;
	ans=0;
	cin >> A >> B>>C>>D;
	for (int i = 1; i<= A; i++){
		if (i <= B)ans += C;
		else ans += D;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(M);
    set<ll> s;
    REP(i, M){
        ll a;
        cin>>a;
        s.insert(a);
    }
    vector<ll> dp(N+1);
    dp[0] = 1;
    if(s.count(1)) dp[1]=0;
    else dp[1] = 1;
    for(ll i=2; i<=N; i++){
        if(s.count(i)) dp[i]=0;
        else dp[i] = (dp[i-1] + dp[i-2]) %MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 6528
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j]*b[j]
for i in range(n):
    print(c[i])


Measured memory_bytes: 6020
n ,m = list(map(int,input().split()))
A= list(map(int,input().split()))

S= sum(A)
count = 0
for i in range(n):
    if A[i]>=S*1/4*1/m:
        count+=1

if count>=m:
    print("Yes")
if count<m:
    print("No")





Measured memory_bytes: 3060
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;

int gcd(int n, int m) {
	if (n < m) swap(n, m);
	while (m != 0) {
		int r = n % m;
		n = m;
		m = r;
	}
	return n;
}

int main()
{
	long long N, X;
	long long x[100010];
	cin >> N >> x[0];

	N = N + 1;

	for (long long i = 1; i < N; i++) {
		cin >> x[i];
	}

	sort(x, x + N);

	for (long long i = 1; i < N; i++) {
		x[i] = x[i] - x[0];
	}
	x[0] = 0;

	long long D = x[1] - x[0];
	long long temp = D;
	for (long long i = 1; i < N; i++) {
		long long a = x[i];
		long long b = D;
		D = gcd(a, b);
	}

	cout << D;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef multiset<int> si;

void dfs(vi e[], int a[], int n, int x, int p, int maxl, int ans[], si s[]) {
    int l = 0, r = n + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;

        if (!s[mid].empty() && *s[mid].begin() < a[x]) {
            l = mid;
        } else {
            r = mid;
        }
    }
    s[l+1].insert(a[x]);

    maxl = max(maxl, l + 1);
    ans[x] = maxl;

    for (int y : e[x]) {
        if (y != p) {
            dfs(e, a, n, y, x, maxl, ans, s);
        }
    }

    s[l+1].erase(s[l+1].find(a[x]));
}

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

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    int ans[n];
    si s[n+1];
    dfs(e, a, n, 0, -1, 0, ans, s);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 59920
#include<bits/stdc++.h>
//pbds
#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 orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
ll dp[1000][100001];
int weight[1000],profit[1000];
int W,n;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
       cin>>n>>W;
     for(int i=1; i<=n; i++)
     {
         cin>>weight[i]>>profit[i];
     }
     for(int i=1; i<=n; i++)
     {
         for(int j=1; j<=W; j++)
         {
             if(weight[i]<=j)
             {
                 dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+profit[i]);
             }
             else dp[i][j]=dp[i-1][j];
         }
     }
     cout<<dp[n][W]<<endl;
}




Measured memory_bytes: 81760
#include <bits/stdc++.h>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
using namespace std;
const long long MOD = 1e9 + 7;
int N, M;
string s, t;
int dp[1001][1001];
string MAT[1001];
int value (char ch) {
    if (ch == '.') return 1;
    return 0;
}
int main() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i)
        cin >> MAT[i];
    dp[0][0] = 1;
    for (int i = 1; i  < N; ++i)
        dp[i][0] = (MAT[i][0] == '.') ? dp[i - 1][0]: 0;
    for (int j = 1; j  < M; ++j)
        dp[0][j] = (MAT[0][j] == '.') ? dp[0][j - 1]: 0;
    for (int i = 1; i < N; ++i)
        for (int j = 1; j < M; ++j) {
            if (MAT[i][j] == '#') continue;
            dp[i][j] = (value(MAT[i - 1][j]) * dp[i - 1][j] + value(MAT[i][j - 1]) * dp[i][j - 1]) % MOD;
        }
    cout << dp[N - 1][M - 1];
    return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
int main(){
	ll n;
	cin>>n;
	ll a[100010];
	ll cnt=0;
	ll ct=0;
	ll c=0;
	rep(i,0,n){
		cin>>a[i];
		if(a[i]%4==0)cnt++;
		else if(a[i]%2==0)ct++;
		else c++;
	}
	if(cnt<c){
		if(cnt+1==c&&cnt+c==n){
			cout<<"Yes"<<endl;
			return 0;
		}
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <valarray>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int size = 0, ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if ((s[i] == 'A' || s[i] == 'C') || (s[i] == 'G' || s[i] == 'T')) {
			size++;
		}
		else {
			ans = max(ans, size);
			size = 0;
		}
	}
	ans = max(ans, size);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll bin(ll a, ll b) {
	//a%=m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a; //mod
        a = a * a; //mod
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll fact(ll x)
{
  ll res=1;
  for(ll i=1;i<=x;i++)
    res=(res*i)%mod;

  return res;
}

ll bcof(ll x,ll y) //x choose y
{
  return fact(x)*bin(fact(x-y)*fact(y)%mod,mod-2)%mod;
}

ll lmod(string n,ll x)
{
	
	ll res=0;
	for(ll i=0;i<n.length();++i)
	{
		res=(res*10+(int)n[i]-'0')%x;
	}
	return res;
}
bool ispal(string s,int l,int r)
{
	string t=s;
	for(int i=l,j=r;i<=r;++i)
	{
		if(s[i]!=s[j])
			return false;
		else
			{
				--j;
			}
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double l;
    cin>>l;
    double ans=pow(l/3,3);
    cout<<fixed<<setprecision(8)<<ans<<endl;
	
}

Measured memory_bytes: 512
import scala.math._

object Main {
	def calc(n:Int):List[Int] = {
		def calc(i:Int, n:Int):List[Int] = {
			if (i > sqrt(n)) List(n)
			else if (n%i == 0) i :: calc(i, n/i)
			else calc(i+1, n)
		}
		calc(2, n)
	}
	
	def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		val n = sc.nextInt
		
		println(n+": "+calc(n).mkString(" "))
	}
}

Measured memory_bytes: 45128
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
  int num;
  cin >> num;
  
  int blackBoardSuuti[400];
  int temp;
  for(int i = 0; i < num; i++ ) 
  {
    cin >> temp;
    blackBoardSuuti[i] = temp;
  }
  
  auto count = 0;
  bool flag = true;
  while ( flag ) 
  {
    for( int i = 0; i < num; i++ )
    {
      if( blackBoardSuuti[i] % 2 == 1 )
      {
        flag = false;
        break;
      }
      blackBoardSuuti[i] /= 2;
    }
    if( flag == true )
    {
      count++;
    }
  }
 
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
  int a, b, c, d, e, k;
  
  cin >> a >> b >> c >> d >> e >> k;
  
  if (e-a>k){
    printf(":(\n");
  }else {
    printf("Yay!\n");
  }
  return 0;
}

Measured memory_bytes: 256
mod = 998244353

n,s = map(int, input().split())
al = list(map(int, input().split()))

dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    a = al[i]
    for j in range(s+1):
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] %= mod

        if j+a<=s:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= mod

print(dp[n][s])

Measured memory_bytes: 139524
#include<bits/stdc++.h>
using namespace std;
int n;
long long INF = 1e18+5;

long long sum(vector<int> &a, int l, int r)
{
    long long result = 0;
    for (int i = l; i <= r; ++i) {
        result += a[i];
    }
    return result;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;

    if(a <= 8 && b <= 8)
        cout <<"Yay!";
    else
        cout <<":(";
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

static int c[51];

 int main(void)
{
	int  n,m,i;
	int  a, b;

	i_cin2(n, m);

	for (i = 0; i < m; i++) {
		i_cin2(a, b); 
		a--; b--;
		c[a]++; c[b]++;
	}

	for (i = 0; i < n; i++) 
		i_cout(c[i]);

 return 0;

}


// 93-C
//int main(void) {
//	int a, b, c;
//	int i,x, y, z, m, cnt = 0;
//	
//	i_cin3(a, b, c); 
//
//	x=abs(a-b);
//	y=abs(a-c);
//	z=abs(b-c);
//
//	m = _max(_max(x,y), z);
//	cnt = m / 2 + 1;
//	i_cout(cnt);
//	return 0;
//}



//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> A(N), B(N);
  REP(i, N) {
    A[i] = nextInt();
    B[i] = nextInt();
  }
  vector<pair<ll, int>> v(N);
  REP(i, N) v[i] = {A[i] + B[i], i};
  sort(ALL(v));
  reverse(ALL(v));
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      ans += A[v[i].second];
    } else {
      ans -= B[v[i].second];
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>

int main(){
  int flag=0;
  std::string s;
  std::cin >> s;

  if(s.find("a")==std::string::npos){
    flag++;
  }

  if(s.find("b")==std::string::npos){
    flag++;
  }

  if(s.find("c")==std::string::npos){
    flag++;
  }

  if(flag==0){
    std::cout << "Yes";
  }else{
    std::cout << "No";
  }

  return 0;
}
      

 
      


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans;
//整数値の入力
int a,b,c;
cin >> a>>b>>c;

if(a+b>=c){ans=b+c;}
else{ans=a+b+b+1;}

//回答
cout << ans << endl;
return 0;
}

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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;


int main() {
    input;
    int n, m;
    cin >> n >> m;
    cout << (n * m);
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;

string MCXI ="ixcm";

int main(int argc, char const *argv[])
{
	string s1,s2;
	int n;
	string ans;

	int d1,d2;

	int temp,f;

	cin>>n;

	for(int i1=0;i1<n;i1++){
		cin>>s1>>s2;

		temp=1;
		d1=0;
		for(int i2=0;i2<s1.size();i2++){
			f=MCXI.find(s1[i2]);
			if(f!=-1) {
				d1+=temp*pow(10,f);
				temp=1;
			}
			else temp=s1[i2]-48;
		}

		temp=1;
		d2=0;
		for(int i2=0;i2<s2.size();i2++){
			f=MCXI.find(s2[i2]);
			if(f!=-1) {
				d2+=temp*pow(10,f);
				temp=1;
			}
			else temp=s2[i2]-48;
		}


		d1+=d2;
		f=0;
		ans="";
		while(d1!=0){
			if(d1%10!=0){
				ans+=MCXI[f];
				if(d1%10!=1){
					ans+=(d1%10+48);
				}
			}
			d1=d1/10;
			f++;

		}
		reverse(ans.begin(), ans.end());
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if (n % 2 == 0) cout << n;
    else cout << 2 * n;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
S = list(input())

for i,q in enumerate(S):
    if q == 'A':
        S[i] = 'T'
    elif q == 'T':
        S[i] = 'A'
    elif q == 'G':
        S[i] = 'C'
    else:
        S[i] = 'G'
print("".join(S))        

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  scanf("%d",&n);
  int a[n],i,sum=0,j;
  for(i=0;i<n;++i)
      scanf("%d",&a[i]);
      
    for(i=0;i<n;++i)
       {
           for(j=i+1;j<n;++j)
              {
                  sum+=a[i]*a[j];
              }
       }
       
       printf("%d",sum);
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    cout << max(0,(b-(a-c))) << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n, a[105];
	float sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		sum = sum + a[i];
	}
	float avg ;
	avg = sum / n;
	float pre;
	float ans = 100;
	int wa;
	for (int i = 0; i < n; i++) {
		pre = a[i] - avg;
		if (pre < 0)pre = -pre;
		if (ans > pre) { ans = pre; wa = i; }
	}
	cout << wa << endl;
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

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

    double ans = 0.0;

    if (n < b) {
        MSG(floor(((double) a * n / (double) b) - a * floor((double) n / b)))
    } else {
        MSG(floor(((double) a * (b - 1) / (double) b) - a * floor((double) (b - 1) / b)))
    }
}


Measured memory_bytes: 3816
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int trans[26];
void makelist(int a,int b){
for(int i=0;i<26;i++){
trans[i]=(a*i+b)%26;
}
}
string translate(string s){
for(int i=0;i<s.size();i++){
if(s[i]>='a' && s[i]<='z'){
s[i]=trans[s[i]-'a']+'a';
}
}
return s;
}
int main(){
//a!=2,13 **
int n;
cin>>n;
cin.ignore();
for(int count=0;count<n;count++){
string s;
getline(cin,s);
string tmp=s;
int a=0,b=100;
while(s.find("that")==string::npos && s.find("this")== string::npos){
b++;
if(b>=26){
b=0;
a++;
}
while(a%2==0||a%13==0)a++;
makelist(a,b);
s=translate(tmp);
//cout<<s<<endl;
}
cout<<s<<endl;
}
}

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

int main(void) {
	int N, M, C;
	int B[20];
	int A[20];

	cin >> N >> M >> C;
	for (int i = 0; i < M; ++i)
		cin >> B[i];
	int ans = 0;
	for (int j = 0; j < N; ++j) {
		for (int i = 0; i < M; ++i)
			cin >> A[i];
		int val = 0;
		for (int i = 0; i < M; ++i)
			val += A[i] * B[i];
		val += C;
		if (val > 0)
			++ans;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

const int max_time = 1e5;

int main() {
    int N, C; cin >> N >> C;
    
    vector<vector<int>> P(C, vector<int>(max_time + 2, 0));
    REP(i, 0, N) {
        int s, t, c; cin >> s >> t >> c; c--;
        P[c][s]++;
        P[c][t + 1]--;
    }

    REP(i, 0, C) {
        REP(j, 1, max_time + 1) {
            P[i][j] += P[i][j - 1];
        }
    }

    int ans = 0;
    REP(i, 1, max_time + 1) {
        int cnt = 0;
        REP(j, 0, C) {
            if (P[j][i]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15388
function Main(input) {
    input = input.split("\n");
  	var count = 0;
  	for(var i=0; i<3; i++){
    	if(input[0][i] == input[1][i]){
        	count++;
        }
    }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;

int main(){
	IOS;
int n,m;
cin>>n>>m;
cout<<n*(n-1)/2+m*(m-1)/2;
}

Measured memory_bytes: 3680
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    point = list(map(int, readline().split()))
    T = readline().strip()

    T = T.translate(str.maketrans('rsp', '012'))
    T = list(map(int, T))

    ans = 0
    for i in range(K):
        vec = T[i::K]
        M = len(vec)

        dp = [[0] * 3 for _ in range(M + 1)]
        for j in range(M):
            for k in range(3):
                dp[j + 1][k] = max(dp[j][(k + 1) % 3], dp[j][(k + 2) % 3])
                if (k + 1) % 3 == vec[j]:
                    dp[j + 1][k] += point[k]
        ans += max(dp[M])

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 23980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int i = kb.nextInt();
		int j = kb.nextInt();
		int count = 0;
		int price = 0;
		while (count < i) {
			count += 1;
			price += 500;
		}
		if (price >= j)
			System.out.println("Yes");
		else
			System.out.println("No");
		kb.close();
	}

}


Measured memory_bytes: 21712
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, A, B = LI()
    X = A ^ B
    if bin(X).count('1') % 2 == 0:
        print('No')
        return 0
    print('Yes')
    # 入れ替えなきゃいけない桁
    m = []
    s = []
    for i in range(N):
        if (X // (2 ** i)) % 2:
            m.append(i)
        else:
            s.append(i)
    ans = [0] * (2 ** N)
    def get(se, ms):
        if len(ms) > 2:
            return get(ms[1:2] + se, ms[2:]) + ms[0:1] + get(ms[2:] + se, ms[1:2])
        elif len(ms) == 1:
            return get(se, []) + ms[0:1] + get(se, [])
        if len(se) == 0:
            return []
        return get(se[1:], []) + se[0:1] + get(se[1:], [])
    swap = get(s, m)
    ans = [A]
    for sw in swap:
        ans.append(ans[-1] ^ (2 ** sw))
    print(*ans)

    return 0

main()

Measured memory_bytes: 12852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define EPS 1e-10
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, pii> pdii;

int N;
double PX[200], PY[200], PZ[200], VX[200], VY[200], VZ[200], R[200], VR[200];

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> PX[i] >> PY[i] >> PZ[i] >> VX[i] >> VY[i] >> VZ[i] >> R[i] >> VR[i];
    vector<pdii> vec;
    REP(i, 0, N) vec.push_back(pdii((double) R[i] / VR[i], pii(i, -1)));
    REP(i, 0, N) REP(j, i + 1, N) {
      double px = PX[i] - PX[j], py = PY[i] - PY[j], pz = PZ[i] - PZ[j], r = R[i] + R[j];
      double vx = VX[i] - VX[j], vy = VY[i] - VY[j], vz = VZ[i] - VZ[j], vr = VR[i] + VR[j];
      double a = vx * vx + vy * vy + vz * vz - vr * vr;
      double b = px * vx + py * vy + pz * vz + r * vr;
      double c = px * px + py * py + pz * pz - r * r;
      double d = b * b - a * c;
      if(d >= 0 && a > 0) {
        double t1 = (-b - sqrt(d)) / a;
        if(t1 > EPS) vec.push_back(pdii(t1, pii(i, j)));
      }
    }
    sort(vec.begin(), vec.end());
    bool b[200];
    REP(i, 0, N) b[i] = false;
    double ans[200];
    REP(i, 0, vec.size()) {
      double t = vec[i].first;
      int x = vec[i].second.first, y = vec[i].second.second;
      if(y == -1) {
        if(!b[x]) b[x] = true, ans[x] = t;
      } else {
        if(!b[x] && !b[y]) b[x] = b[y] = true, ans[x] = ans[y] = t;
      }
    }
    REP(i, 0, N) printf("%.10lf\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int goal=2001;
		int a[] = new int[2];
		int b[]=new int[2];
		for(int i=0;i<2;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<2;i++) {
			b[i]=sc.nextInt();
		}
		for(int i=0;i<2;i++) {
			for(int j=0;j<2;j++) {
				int num =a[i] + b[j];
				if(goal>num) {
					goal=num;
				}
			}
		}
		System.out.println(goal);
	}
}

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

int main() {
  string s;
  cin>>s;
  if(s=="RRR") cout<<"3"<<endl;
  else if(s=="RRS" or s=="SRR") cout<<"2"<<endl;
  else if(s=="RSS" or s=="SRS" or s=="SSR" or s=="RSR") cout<<"1"<<endl;
  else cout<<"0"<<endl;

}

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


def solve(N: int):
    ans = [i for i in range(1, N + 1)[::-1] if math.log2(i) % 1 == 0]
    print(ans[0])
    return


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

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bool ans = false;
    int j=1;
    for(int i=0;i<n;i++){
        if(a[i]==1){
            ans = true;
        }
        if(a[i]==j){
            j++;
        }

    }
    if(ans){
        cout << n-(j-1) << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
N, K = map(int,input().split())
cost= input().split()
cost = [int(i) for i in cost]
ans_list = [0]*N
ans_list[1] = abs(cost[0] - cost[1])

for i in range(2,N):
    compare = []
    for j in range(1,K+1):
        if i-j >=0:
            compare.append(ans_list[i-j] + abs(cost[i-j]-cost[i]))
    ans_list[i] = min(compare)
print(ans_list.pop())


Measured memory_bytes: 52576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll cnt=0;
pair<vector<ll>,vector<ll>> prime(ll n) {
    vector<ll> p,e;
    ll m=n;
    for (ll i=2;i*i<=n;i++) {
        if (m%i!=0) continue;
        int c=0;
        while (m%i==0) c++, m/=i;
        p.push_back(i);
        e.push_back(c);
        cnt++;
    }
    if (m>1) {
        p.push_back(m);
        e.push_back(1);
        cnt++;
    }
    return make_pair(p,e);
}
int main(){
  ll n,p;
  cin >> n>>p;
  pair <vector<ll>,vector<ll>> v=prime(p);
  ll ans=1;
  for(ll i=0;i<cnt;i++) {
    if(v.second[i]>=n){
      ll k=v.second[i]/n,p=1;
      for(ll j=0;j<k;j++) p*=v.first[i];
      ans*=p;
    }
  }
 cout <<ans<<endl;
  }


Measured memory_bytes: 256
N,W = map(int,input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  w,v = map(int,input().split())
  for j in range(W+1):
    dp[i+1][j] = max(dp[i+1][j],dp[i][j])
    if j+w<=W:
      dp[i+1][j+w] = max(dp[i][j]+v,dp[i+1][j+w])
print(max(dp[N]))

Measured memory_bytes: 120172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define PI acos(-1.0)
#define LL long long
#define MAX 0x3fffffff
using namespace std;

int n, a;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int f = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0)f = 0;
		}
	}
	if (f)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

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

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

	int n;
	cin >> n;
	array<int, 3> dp = {0, 0, 0};
	for(int i = 0; i < n; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		array<int, 3> next;
		next[0] = max(dp[1], dp[2]) + a;
		next[1] = max(dp[0], dp[2]) + b;
		next[2] = max(dp[0], dp[1]) + c;
		dp = next;
	}

	cout << max(dp[0], max(dp[1], dp[2])) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 int main() {
     string S, T;
     int num = 0, i;
     cin >> S >> T;
 
     for(i = 0; i < 3; i++){
         if(S.at(i) == T.at(i)) num++;
     }
 
     cout << num << endl;
 }
 


Measured memory_bytes: 256
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())
D,X = map(int,input().split())

A = []
for i in range(N):
    b =int( input())
    A.append(b)

res = 0
for i in range(100):
    for j in range(N):
        if i*A[j]+1 <= D:
            res+=1

print(res+X)



Measured memory_bytes: 12484