akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll x, y, z, w;
	cin >> x >> y >> z >> w;
	ll a, b, c, d;
	a = z - (w-y);
	b = w + (z-x);
	c = a - (z-x);
	d = b - (w-y);
	printf("%d %d %d %d\n", a, b, c, d);
    return 0;
}

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

int main()
{
    int n;
    cin >>n;
    int h[n];
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<int> DP(n,INT_MAX);
    DP[0] = 0;
    DP[1] = abs(h[1]-h[0]);
    for(int i = 2; i < n; i++)
    {
        DP[i] = min(DP[i-1]+abs(h[i-1]-h[i]), DP[i-2]+abs(h[i-2]-h[i]));
    }
    cout << DP[n-1];
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=1000000007;
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<char,ll> mp;
const ll MAX = 2000010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
//階乗
long long factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%mod;
}
int main(){
    COMinit();
    mp['R']=1;mp['G']=2;mp['B']=4;
    int n;
    cin>>n;
    string s;
    cin>>s;
    V<ll> d(8,0);
    ll ans=1;
    for(int i=0;i<3*n;i++){
       ll m=mp[s[i]];
       ll tmp=(7^m);
       if(d[tmp]){
           (ans*=d[tmp]%mod)%=mod;
           d[tmp]--;
           continue;
         }
        bool make=true;
          for(int j=1;j<=4;j++){
                if(j==3||m==j)continue;
                if(d[j]){
                (ans*=d[j]%mod)%=mod;
                d[j]--;
                d[j+m]++;
                make=false;
                break;
            }
          }
         if(make)d[m]++;
    }
    cout<<(ans*fac[n])%mod<<endl;
}

Measured memory_bytes: 47696
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

ll n, m, ans = 0;
vv(ll) G(51, vector<ll>(51, 0));
vector<bool> seen(51);

void	dfs(int now)
{
	seen[now] = 1;
	for (int i = 1; i <= n; ++i)
	{
		if (G[now][i] == 0)
			continue ;
		if (seen[i] == 0)
			dfs(i);
	}
}

int		main(void)
{
	cin >> n >> m;

	vector<pair<ll, ll>> P;
	for (ll i = 0; i < m; ++i)
	{
		ll a, b;
		cin >> a >> b;
		P.push_back({a, b});
		G[a][b] = true;
		G[b][a] = true;
	}
	ll size = P.size();
	for (int i = 0; i < size; ++i)
	{
		ll p1 = P[i].first;
		ll p2 = P[i].second;
		G[p1][p2] = false;
		G[p2][p1] = false;
		seen.assign(51, false);
		dfs(1);
		int j;
		for (j = 1; seen[j] && j <= n; ++j)
			;
		if (j == n+1)
			++ans;
		G[p1][p2] = true;
		G[p2][p1] = true;
	}
	cout << m - ans << endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b;
ll ans;
ll f[100005];
int main(void){
    cin>>a>>b;
    f[0]=1;
    for(int i=1;i<100005;i++){
        f[i]=f[i-1]*i%1000000007;
    }
    if(a==b){
        cout<<2*f[a]*f[b]%1000000007<<endl;
    }else if(abs(a-b)==1){
        cout<<f[a]*f[b]%1000000007<<endl;
    }else{
        cout<<0<<endl;
    }
    
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>

int const MAXN=300;
int N;
double dp[MAXN+1][MAXN+1][MAXN+1];

double calc(int x1, int x2, int x3) {
  if(dp[x1][x2][x3] >= 0.0) return dp[x1][x2][x3];
  double v = 0.0+N;
  if(x1 > 0) v += calc(x1-1, x2, x3)*x1;
  if(x2 > 0) v += calc(x1+1, x2-1, x3)*x2;
  if(x3 > 0) v += calc(x1, x2+1, x3-1)*x3;
  v /= 0.0+x1+x2+x3;
  return dp[x1][x2][x3] = v;
}

int main() {
  std::cin >> N;
  int x1 = 0, x2 = 0, x3 = 0;
  for(int i = 0; i < N; ++i) {
    int a;
    std::cin >> a;
    if(a == 1) ++x1;
    if(a == 2) ++x2;
    if(a == 3) ++x3;
  }
  for(int i1 = 0; i1 <= x1+x2+x3; ++i1) for(int i2 = 0; i2 <= x2+x3; ++i2) for(int i3 = 0; i3 <= x3; ++i3) {
    dp[i1][i2][i3] = -1.0;
  }
  dp[0][0][0] = 0.0;
  printf("%.10f\n", calc(x1, x2, x3));
  return 0;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int inf = 1e9;
#define MAXN 1009
#define UNVISITED -1
#define EXPLORED -2
#define VISITED -3

int vis[MAXN], parent[MAXN];
vector<int> adjList[MAXN];
vector<pii> be;

void graphCheck(int u) { // DFS for checking graph edge properties
	vis[u] = EXPLORED;
	
	for (int j = 0, v; j < (int)adjList[u].size(); j++) {
		v = adjList[u][j];
		if (vis[v] == UNVISITED) {
			//printf(" Tree Edge (%d, %d)\n", u, v);
			parent[v] = u; // parent of this children is me
			graphCheck(v);
		}
		else if (vis[v] == EXPLORED) {
			//printf(" Back Edge (%d, %d) (Cycle)\n", u, v);
			be.push_back( {u, v});
		}
		//else if (vis[v] == VISITED)
			//printf(" Forward/Cross Edge (%d, %d)\n", u, v);
	}
	vis[u] = VISITED;
}

int main() {
    //cin.sync_with_stdio(0); cin.tie(0);
    //cin.exceptions(cin.failbit);
    int n, m;
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        adjList[a].push_back(b);
    }
    iota(parent, parent + n, 0);
    memset(vis, -1, sizeof vis);
    //be = {-1, -1};
    rep(i, 0, n){
        if (vis[i]==UNVISITED)
            graphCheck(i);
    }

    if (sz(be) == 0){
        cout << -1 << '\n';
        return 0;
    }
    int res = inf;
    vi ans;
    trav(b, be){
        vi dist(n, inf); dist[b.second] = 0;
        queue<int> q; q.push(b.second);
        vi p(n);
        p[b.second] = b.second;
        while(!q.empty()){
            int u = q.front(); q.pop();
            trav(a, adjList[u]){
                if (dist[a] == inf){
                    dist[a] = dist[u] + 1;
                    p[a] = u;
                    q.push(a);
                }
            }
        }
        if (dist[b.first] < res){
            ans.clear();
            int u = b.first;
            while (u != p[u]){
                ans.push_back(u);
                u = p[u];
            }
            ans.push_back(u);
            res = dist[b.first] + 1;
        }
        
    }
    cout << res << '\n';
    trav(a, ans) cout << a + 1 << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1000000007;
Int modpow(Int x, Int y)
{
    if (y == 0) return 1;
    if (y % 2) return modpow(x, y-1) * x % MOD;
    return modpow(x*x % MOD, y/2);
}
Int modinv(Int x)
{
    return modpow(x, MOD-2);
}
Int modfact(Int x)
{
    Int ans = 1;
    for (int i = 1; i <= x; i++) (ans *= i) %= MOD;
    return ans;
}
Int fact[1001], dp[1001][1001];
int main()
{
    Int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    fact[0] = 1;
    for (int i = 1; i <= N; i++) fact[i] = fact[i-1] * i % MOD;
    for (int i = 0; i <= N; i++) dp[0][i] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            dp[i][j] = dp[i][j-1];
            if (A <= j && j <= B) {
                for (int k = C; k <= D && j*k <= i; k++) {
                    dp[i][j] += modinv(modpow(fact[j], k) * fact[k] % MOD) * dp[i-j*k][j-1];
                    dp[i][j] %= MOD;
                }
            }
        }
    }
    cout << fact[N] * dp[N][N] % MOD << '\n';
    return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

const int N = 111111;

int par[N];
vector<int> ch[N];
int ch_size[N];

int dfs(int v) {
  int sz = 1;
  for (size_t i = 0; i < ch[v].size(); i++) {
    sz += dfs(ch[v][i]);
  }
  return ch_size[v] = sz;
}

int es, ei[N], ed[N], ep[N];
vector<int> e[N];
int dd[N];

int dec(int v, int k = 0, int d = 0) {
  int idx = -1;
  int tk = k;
  ei[v] = tk;
  dd[v] = e[tk].size();
  e[tk].push_back(v);
  ed[tk] = d;
  for (int i = 0; i < int(ch[v].size()); i++) {
    if (idx == -1 || ch_size[ch[v][idx]] < ch_size[ch[v][i]]) {
      idx = i;
    }
  }

  if (idx >= 0) k = dec(ch[v][idx], tk, d);
  
  for (int i = 0; i < int(ch[v].size()); i++) {
    if (i != idx) {
      ep[k+1] = tk;
      k = dec(ch[v][i], k+1, d+1);
    }
  }

  return k;
}

struct path {
  int i, a, b;
  path() {}
  path(int i, int a, int b) :
      i(i), a(a), b(b) {}
};
vector<path> pathset(int u, int v) {
  vector<path> ps, qs;
  int aa = ei[u];
  int bb = ei[v];

  while (aa != bb) {
    // printf("%d %d %d %d\n", u, v, aa, bb);
    if (ed[aa] > ed[bb]) {
      ps.push_back({aa, 0, dd[u]+1});
      u = par[e[aa][0]];
      aa = ep[aa];
    } else {
      qs.push_back({bb, 0, dd[v]+1});
      v = par[e[bb][0]];
      bb = ep[bb];
    }
  }
  ps.push_back({aa, min(dd[u], dd[v]), max(dd[u], dd[v])+1});

  reverse(qs.begin(), qs.end());
  copy(qs.begin(), qs.end(), back_inserter(ps));
  return ps;
}

int a[N], b[N];

int main(void) {
  int n, q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int k; scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int c; scanf("%d", &c);
      par[c] = i;
      ch[i].push_back(c);
    }
  }

  dfs(0);
  es = dec(0)+1;

  /*
  for (int i = 0; i < es; i++) {
    printf("%3d(%d, %d): ", i, ed[i], ep[i]);
    for (int j = 0; j < int(e[i].size()); j++) {
      printf("%d(%d) ", e[i][j], dd[e[i][j]]);
    }
    puts("");
  }
  */

  scanf("%d", &q);
  for (int ii = 0; ii < q; ii++) {
    int u, v;
    scanf("%d%d", &u, &v);
    auto ps = pathset(u, v);

    /*
    for (int k = 0; k < int(ps.size()); k++) {
      printf("[%d](%d, %d, %d) ", ed[ps[k].i], ps[k].i, ps[k].a, ps[k].b);
    }
    puts("");
    */
        
    int md = -1;
    for (int k = 0; k < int(ps.size()); k++) {
      if (md < 0 || ed[ps[md].i] > ed[ps[k].i]) {
        md = k;
      }
    }
    printf("%d\n", e[ps[md].i][ps[md].a]);
  }
  
  return 0;
}

Measured memory_bytes: 18944
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse
l1 = 0
l2 = 0
pre = 0
a.each do |x|
  if pre == 0
    pre = x
    next
  elsif pre == x
    if l1 == 0
      l1 = x
    else
      l2 = x
      break
    end
    pre = 0
    next
  end

  pre = x
end
puts l1 * l2

Measured memory_bytes: 10112
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H, W;
	string S[110];
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int i = -1; i <= H; i++) {
		//cout << i << endl;
		if (i == -1 || i == H) {
			for (int j = -1; j <= W; j++) cout << '#';
		}
		else {
			cout << '#' << S[i] << '#';
		}
		cout << endl;
	}
}

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

int main() {
    string s;
    cin >> s;
    map<char,int> m;
    rep(i,s.size()) {
        m[s[i]]++;
    }
    for(auto p : m) {
        if(p.second%2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[4];
  REP(i,4){
    a[i] = n%10;
    n /= 10;
  }
  
  if(a[0]==a[1] && a[1]==a[2]){
    cout<<"Yes"<<endl;
  }else if(a[1]==a[2] && a[2]==a[3]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	ll n;
	cin >> n;
	vector<ll> p(n);
	for(int i=0;i<n;i++) cin >> p[i];

	int a,b,c;
	int ans(0);
	for(int i=0;i<n-2;i++){
		a = p[i];
		b = p[i+1];
		c = p[i+2];
		if(a < b && b < c) ans ++;
		else if(c < b && b < a) ans ++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
typedef unsigned long ul;
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 0)
	{
		std::cout << "Even\n";
	}
	else
	{
		std::cout << "Odd\n";
	}
}

Measured memory_bytes: 888
N = int(input())
count, A, B, BA = 0, 0, 0, 0
for _ in range(N):
    s = input()
    count += s.count('AB')
    B += s[0] == 'B' and s[-1] != 'A'
    A += s[-1] == 'A' and s[0] != 'B'
    BA += s[0] == 'B' and s[-1] == 'A'
    #print(s, A,B,BA, 'count', count)

if BA == 0 :
    tmp = min(A,B)
else:
    if A + B > 0:
        tmp = BA + min(A,B)
    else:
        tmp = BA - 1
print(count + tmp)


Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(S);
    unordered_map<char,int> m;
    rep(i,S.length())m[S[i]]++;
    int variationCount = 0,irregalLengthCount=0;
    for(auto i:m){
        variationCount++;
        if(i.second!=2) irregalLengthCount++;
    }
    if(variationCount==2 && irregalLengthCount == 0) cout << "Yes" << nn;
    else cout << "No" << nn;
    return 0;
}

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

int main(){
	int min_d, min_i, min_i2, N, K, *A, count = 0;
	char num[10];
	scanf("%d %d", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++){
		scanf("%s", num);
		A[i] = atoi(num);
	}
	min_d = 1;
	for (int i = 0; i < N; i++){
		if (1 == A[i]){
			min_i = i;
			break;
		}
	}

	min_i2 = min_i;
	while (min_i>0){
		if (min_i - (K-1) <= 0){
			if(min_i2+abs(min_i-(K-1))<=N-1)min_i2+=abs(min_i-(K-1));
			else min_i2 = N - 1;
			count++;
			break;
		}
		min_i -= K-1;
		count++;
	}
	while (min_i2 < N-1){
		if (min_i2 + K-1 >= N-1){
			count++;
			break;
		}
		min_i2 += K-1;
		count++;
	}
	printf("%d", count);
	free(A);
	return 0;
}


Measured memory_bytes: 512
#%%

n, h, w = map(int, input().split())
a = [0] * n
b = [0] * n
ans = 0

for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] >= h and b[i] >= w:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
struct node{int from, to, dis;};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int num = 0, m = N;
    while(m){
    	m /= 2;
    	num++;
    }
    int n = num;

    vector<vector<pair<int,int> > > v(n);
    for(int i=0;i<n-1;i++){
    	v[i].emplace_back(i+1, 0);
    	v[i].emplace_back(i+1, 1<<i);
    }
    vector<int> de;
    for(int i=0;i<20;i++){
    	de.pb(1 << i);
    }
    num = (1 << (n-1));
    while(N > num){
    	m = N - num;
    	int id = upper_bound(be(de), m) - de.begin() - 1;
    	v[id].emplace_back(n-1, num);
    	num += de[id];
    }
    vector<node> ans;
    for(int i=0;i<n;i++){
    	for(auto& j: v[i]){
    		ans.push_back({i + 1, j.first + 1, j.second});
    	}
    }
    cout << n << " " << ans.size() << endl;
    for(auto & i: ans){
    	cout << i.from << " " << i.to << " " << i.dis << endl;
    }
    return 0;
}


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

int main(){
	int m,f,r;
	while(1){
		cin>>m>>f>>r;
		if(m == -1 && f == -1 && r == -1)break;
		if(m == -1 || f == -1){
			cout<<"F"<<endl;
		}else if(m + f >= 80){
			cout<<"A"<<endl;
		}else if(m + f >= 65 && m + f < 80){
			cout<<"B"<<endl;
		}else if(m + f >= 50 && m + f < 65){
			cout<<"C"<<endl;
		}else if(m + f >= 30 && m + f < 50 && r >= 50){
			cout<<"C"<<endl;
		}else if(m + f >= 30 && m + f < 50){
			cout<<"D"<<endl;
		}else if(m + f < 30){
			cout<<"F"<<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3092
W,H,x,y,r=map(int,input().split())
#x,y=float(x,y)

if x-r<0:
    print("No")
elif x+r>W:
    print("No")
elif W<=x:
    print("No")
elif H<=y:
    print("No")
elif x<=0:
    print("No")
elif y<=0:
    print("No")
else:
    print("Yes")


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    rep(i, n) cin >> x[i] >> y[i] >> z[i];
    vector<ll> sum(n);
    ll ans = 0;
    rep(mask, 8) {
        int xm = mask>>0 & 1 ? 1 : -1;
        int ym = mask>>1 & 1 ? 1 : -1;
        int zm = mask>>2 & 1 ? 1 : -1;

        rep(i, n) sum[i] = x[i] * xm + y[i] * ym + z[i] * zm;
        sort(sum.begin(), sum.end(), greater<ll>());
        ll tmpAns = 0;
        rep(i, m) tmpAns += sum[i];
        ans = max(ans, tmpAns);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
def main():
    from collections import Counter

    n, k, *a = map(int, open(0).read().split())
    c = Counter(a)
    v = len(c)
    l = list(c.values())
    l.sort()
    ans = sum(l[:v - k])
    print(ans)


if __name__ == '__main__':
    main()


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  VVI xs(3, VI(3));
  cin >> xs;

  bool ok = false;
  VI as(3), bs(3);
  REP(a1,101) REP(a2,101) REP(a3,101){
	as[0] = a1;
	as[1] = a2;
	as[2] = a3;
	REP(k,3) bs[k] = xs[0][k] - as[0];

	ok = true;
	REP(k,3) if(bs[k] < 0 || 100 < bs[k]) ok = false;
	REP(y,3) REP(x,3){
	  if(xs[y][x] != as[y] + bs[x]){
		ok = false;
	  }
	}
	if(ok){
	  cout << "Yes" << endl;
	  return 0;
	}
  }

  cout << ("No") << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
N=int(input())
def f(x):
    if x==0:
        return "0"
    if x%2==1:
        return f((1-x)//2)+"1"
    else:
        return f((-x)//2)+'0'
if N==0:
    print('0')
    sys.exit()
print(f(N)[1:])

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

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

long long N;


void func(long long cur, int use, long long &counter){
	if (cur > N) return;
	if (use == 0b111) ++counter;

	func(cur*10 + 7, use|0b001, counter);

	func(cur*10 + 5, use|0b010, counter);

	func(cur*10 + 3, use|0b100, counter);

}

int main(){
	cin >> N;
	long long res = 0;
	func(0, 0, res);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {      
      int n = int.Parse(Console.ReadLine());
      List<long> L = new List<long>();
      L.Add(2);
      L.Add(1);
      for (int i=2;i<=n;i++)
      {
        L.Add(L[i-2]+L[i-1]);
      }
      Console.WriteLine(L[n]);
    }
}


Measured memory_bytes: 27688
n = int(input())
a = list(map(int, input().split())) + [-1]

min_money = 0
ans = 1000
i = 0
while i < n:
    stock = 0
    rest = 0
    for k in range(i, n):
        if a[k] < a[k + 1]:
            min_money = a[k]
            stock = ans // a[k]
            rest = ans % a[k]
            i = k
            break
    
    if stock != 0:
        temp = stock * a[i+1]
        for k in range(i, n):
            if temp <= a[i+1] * stock:
                ans = a[i+1] * stock
    ans += rest
    i += 1

print(ans)

Measured memory_bytes: 9092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string O, E;
    cin >> O >> E;
    int n;

    rep(i, E.length())
    {
        cout << O[i] << E[i];
    }
    if (O.length() > E.length())
    {
        cout << O[O.length() - 1];
    }
    cout << endl;
    return 0;
}


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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
string s,t,u;

string s1,s2;

unordered_map<string,LL> mp;
 
LL ret=0;

int main(){
  cin>>n>>s;
  t=s.substr(0,n);
  u=s.substr(n,2*n);
  
  REP(i,1<<n){
    s1="";
    s2="";
    REP(j,n){
      if((i>>j)%2)
	s1=t[j]+s1;
      else
	s2=t[j]+s2;
    }
    mp[s1+" "+s2]++;
  }

  reverse(u.begin(),u.end());
  
  REP(i,1<<n){
    s1="";
    s2="";
    REP(j,n){
      if((i>>j)%2)
	s1=u[j]+s1;
      else
	s2=u[j]+s2;
    }
    ret+=mp[s1+" "+s2];
  }
      
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 72308
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a,b,c,d;
	cin >> a;
	cin >> b;
	cin >> c;
	
	d.push_back(a[0]);
	d.push_back(b[1]);
	d.push_back(c[2]);
	cout <<d<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define SS size()
#define PB push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
  int a, b, c, k; cin >> a >> b >> c >> k; 
  int x = max(a, max(b,c));
  cout << (a + b + c + (x<<k)-x) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        long[] l = new long[2];
        l[0] = sc.nextLong();
        l[1] = sc.nextLong();
        long ans =  l[0] * l[1];
        long[] s = new long[3];
        for (int i = 0; i < 2; i++) {
            for (int j = 1; j <= l[i]; j++) {
                s[0]=(long)j*l[abs(1-i)];
                s[1]=(l[i]-(long)j)/2*l[abs(1-i)];
                s[2]=l[0]*l[1]-s[0]-s[1];
                Arrays.sort(s);
                ans=min(ans,s[2]-s[0]);
                s[0]=(long)j*l[abs(1-i)];
                s[1]=l[abs(1-i)]/2*(l[i]-(long)j);
                s[2]=l[0]*l[1]-s[0]-s[1];
                Arrays.sort(s);
                ans=min(s[2]-s[0],ans);
            }
        }
        out.println(ans);
    }
    static long sum(long[] a){
        long t=0;
        for (long k:a)t+=k;
        return t;
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define N 1005
using namespace std;
char ans[N][N];
inline int read()  
{  
    int x=0,f=1;char s=getchar();  
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s<='9'&&s>='0'){x=x*10+s-'0';s=getchar();}  
    return x*f;  
}  
int main() 
{ 
	int n=read(),m=read(),a=read(),b=read();
	memset(ans,'.',sizeof(ans));
	for(int i=1;i<=n;i++)ans[i][m+1]='\0';
	if(n&1) 
	{
		int j=1;
		while(a&&j+1<=m) 
		{
			ans[n][j]='<';
			ans[n][j+1]='>';
			j+=2;
			a--;
		}
	}
	if(m&1) 
	{
		int i=n;
		while(b&&i>1)
		{
			ans[i-1][m]='^';
			ans[i][m]='v';
			i-=2;
			b--;
		}
	}
	for(int i=n/2;i>=1;i--)
		for(int j=1;j<=m/2;j++) 
		{
			int x=i*2-1,y=j*2-1;
			if(n%2==1&&m%2==1&&a==1&&b==1&&i==1&&j==m/2) 
			{
				ans[x][y]='^';
				ans[x+1][y]='v';
				b--;
				ans[x][y+1]='<';
				ans[x][y+2]='>';
				a--;
			}
			if(a&&b<2) 
			{
				ans[x][y]='<';
				ans[x][y+1]='>';
				a--;
				if(a)
				{
					ans[x+1][y]='<';
					ans[x+1][y+1]='>';
					a--;
				}
			}else if(b) 
			{
				ans[x][y]='^';
				ans[x+1][y]='v';
				b--;
				if(b)
				{
					ans[x][y+1]='^';
					ans[x+1][y+1]='v';
					b--;
				}
			}
		}
	if(a||b)puts("NO");else
	{
		puts("YES");
		for(int i=1;i<=n;i++)puts(ans[i]+1);
	}
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int a[3][n] , dp[3][n] ;

	memset(dp, 0, sizeof(dp));
	memset(a, 0, sizeof(a));

	for(int i = 0; i< n; ++i ) {
		cin >> a[0][i] >> a[1][i] >> a[2][i];
	}
	dp[0][0] = a[0][0] ;
	dp[1][0] = a[1][0] ;
	dp[2][0] = a[2][0] ;

	for(int i = 1; i < n; ++i ) {

		dp[0][i] = max( dp[0][i-1] , max( dp[1][i-1] + a[0][i] , dp[2][i-1] + a[0][i] ) ) ;
		dp[1][i] = max( dp[1][i-1] , max( dp[0][i-1] + a[1][i] , dp[2][i-1] + a[1][i] ) ) ;
		dp[2][i] = max( dp[2][i-1] , max( dp[0][i-1] + a[2][i] , dp[1][i-1] + a[2][i] ) ) ;

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

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 500;

ll dp[MAX_N][2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l,k;
    cin >> l >> k;
    dp[1][0] = 1,dp[k][0] = 1;
    rep(i,l){
        dp[i+1][1] += dp[i][0];
        dp[i+k][0] += dp[i][1];
        dp[i+1][0] += dp[i][1];
    }
    ll ans = 0;
    srep(i,1,l+1){
        ans += dp[i][0];
    }
    cout << ans << "\n";
    return 0;
}

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

int main ()
{
    int c[4] = {};
    for (int i = 0; i < 6;++i) {
        int tmp;
        cin >> tmp;
        c[tmp - 1]++;
    }
    if (max(max(c[0],c[1]),max(c[2],c[3])) > 2) cout << "NO";
    else cout << "YES";
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int ans=0;
	for(int i=1;i<=n;i+=2)
	{
		int dv=0;
		for(int j=1;j<=i;j++)
			dv+=(i%j==0);
		if(dv==8) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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 ll INF = 1LL << 60;
const ll mod = 1000000007;


const int MAX_N = 110;
const int MAX_V = 100100;

ll N;
ll W, weight[MAX_N], value[MAX_N];

ll dp[MAX_N][MAX_V];
//dp[i][j]=i-1番目の品物から価値の条件を達成するように選んだ時の重さの総和の最小値。

int main(){
	//乱数srand((unsigned)time(NULL));
	
	//入力
	cin>>N>>W;
	rep(i,N)cin>>weight[i]>>value[i];
	
	rep(i,MAX_N)rep(j,MAX_V) dp[i][j]=INF;
	
	dp[0][0]=0;
	
	//dpテーブル埋め
	rep(i,N){
		rep(j,MAX_V){
			if(j-value[i]>=0){
				chmin(dp[i+1][j],dp[i][j-value[i]]+weight[i]);
			}
			
			chmin(dp[i+1][j],dp[i][j]);
		}
	}
	
	ll res=0;
	
	rep(i,MAX_V){
		if(dp[N][i]<=W) res=i;
	}
	//dp[i][j]の値がW以下のjの最大値（ここでjは価値の総和の最大値）
	cout<<res<<endl;
}

Measured memory_bytes: 86272
# include <iostream>
# include <vector>
# include <cmath>


using namespace std;


vector<int> ps = {1};


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

    for (int i=1; pow(6, i) <= n; ++i) {
        if (pow(6, i) > n) continue;
        ps.push_back(pow(6, i));
    }
    for (int i=1; pow(9, i) <= n; ++i) {
        if (pow(9, i) > n) continue;
        ps.push_back(pow(9, i));
    }
    sort(ps.begin(), ps.end());

    vector<int> dp(n+1);
    fill(dp.begin(), dp.end(), 1e8);
    dp[0] = 0;  // to withdraw 0 yen, it requires 0 operation

    for (int i=0; i<=n; ++i) {
        for (int p: ps) {
            if (i >= p) {
                dp[i] = min(dp[i], dp[i-p]+1);
            }
        }
    }

    cout << dp[n] << endl;
}



Measured memory_bytes: 640
s = gets.chomp
vis = Array.new(26, false)
s.each_char{|c|
    vis[c.ord - 'a'.ord] = true
  }
(0..25).each do |i|
  if !vis[i]
    puts (i + 'a'.ord).chr
    exit
  end
end

puts "None"

Measured memory_bytes: 1916
def main():
    N, K = map(int, input().split())
    M_max = (N-1) * (N-2) // 2
    if K > M_max:
        print(-1)
        exit()
    M = N - 1 + (M_max - K)
    print(M)
    M_cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            M_cnt += 1
            u = i + 1
            v = j + 1
            print(u, v)
            if M_cnt == M:
                exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 3608
CHARACTER(10) S
CHARACTER(10) ANSWER
INTEGER MOJI
READ*,S
MOJI=0
ANSWER=""
DO I=1,LEN_TRIM(S)
	IF (S(I:I) /= "B") THEN
    	ANSWER=TRIM(ANSWER)//S(I:I)
        MOJI=MOJI+1
    ELSE
    	IF(MOJI /= 0)THEN
        ANSWER=ANSWER(:MOJI-1)
    	MOJI=MOJI-1
    	ENDIF
    ENDIF
END DO
PRINT"(A)",TRIM(ANSWER)
END

Measured memory_bytes: 640
N=int(input())
P=[(0,0,0)]
for i in range(N):
	t,x,y=map(int,input().split())
	P.append((t,x,y))

T=[0]*N
dist=[0]*N

for i in range(N):
	T[i]=P[i+1][0]-P[i][0]
	dist[i]=abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])

ans=1
for i in range(N):
	if dist[i]>T[i]:
		ans=0
	else:
		m=T[i]-dist[i]
		if m%2==0:
			pass
		else:
			ans=0
	if ans==0:
		break
print("Yes" if ans==1 else "No")

Measured memory_bytes: 25780
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline())

    abc = [chr(i) for i in range(ord("a"),ord("z")+1)]

    x=1
    y=0
    keta=0
    s=0
    while 1:
        x*=26
        y+=x
        keta+=1
        if n <= y:
            s=y-x+1
            break
    to=n-s
    ans=""
    for i in range(keta):
        ans=abc[to%26]+ans
        to=to//26

    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 15988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main(void) {
  int q;
  cin >> q;
  vi a(100009,0);
  rep(i,100001){
    if(i%2==0)continue;
    if(IsPrime(i) && IsPrime((i+1)/2)) a[i]++;
  }
  vi s(100009,0);
  rep(i,100001)s[i+1] = s[i] + a[i];
  rep(i,q){
    int k,l;
    cin >> k >> l;
    cout << s[l+1]-s[k] << endl;
  }
    
}




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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);

    int n, l;
    cin >> n >> l;

    int flavors[n+1];
    flavors[0] = 0;
    int sum_n = 0;

    int menor = 100000000;
    for(int i = 1; i <= n; i++) {
        flavors[i] = l + i - 1;
        sum_n += flavors[i];
        if(abs(flavors[i]) < abs(menor)) menor = flavors[i];
    }
    cout << sum_n - menor << endl;

}


Measured memory_bytes: 256
a, b = map(int, input().split())

#上のコードが正しいか確かめるためにプリントしてみる↓
#一つ一つ確かめるの大事
#print(a)
#print(b)

#2.目的通りの計算をする
# ex: 2つの整数AとBno掛け算をやる
answer = a * b

#3.計算の結果を出力する
print(answer)

Measured memory_bytes: 9028
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){

    string s;
    cin >> s;

    int count = 0;
    
    for(int i = 0; i < s.size(); ++i){

        if(s[i] == 'A'){
            ++count;
            if(i != 0)count = 10;

        }else if(s[i] == 'C'){

            ++count;
            if(i == 1 || i == s.size()-1)count = 10;

        }else if(s[i] < 'a')count = 10;

}

    if(count == 2)cout << "AC" << endl;
    else cout << "WA" << endl; 

    return 0;

}

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
ll n , m ,k;
ll a[200005],b[200005];
int main()
{
    fast();
    n=D();m=D();k=D();
    for(int i=1;i<=n;++i){
        a[i]=a[i-1]+lD();
    }
    for(int i=1;i<=m;++i){
        b[i]=b[i-1]+lD();
    }
    int ans=0;
    for(int i=0;i<=n;++i){
        int l =1, r = m ,indx=0;
        while(l<=r){
            int mid=(l+r)/2;
            if(b[mid]+a[i]<=k){
              ans=max(ans,i+mid);
                l=mid+1;
            }else {
             r=mid-1;
            }
        }
    }
        int i=1,c=0;
        while(k>=a[i]&&i<=n){
            c++;
          i++;
        }

    cout<<max(ans,c)<<endl;
}


Measured memory_bytes: 6736
S = input().strip()
A = [0 for _ in range(len(S))]
A[-1] = int(S[-1])%3
for i in range(2,len(S)+1):
    A[-i] = (A[-i+1]+int(S[-i]))%3
B = [0 for _ in range(len(S))]
B[-1] = int(S[-1])%673
a = 1
for i in range(2,len(S)+1):
    a = (a*10)%673
    B[-i] = (int(S[-i])*a+B[-i+1])%673
C = {}
for i in range(len(S)):
    a = A[i]
    b = B[i]
    if (a,b) not in C:
        C[(a,b)] = 0
    C[(a,b)] += 1
if (0,0) in C:
    C[(0,0)] += 1
cnt = 0
for c in C:
    n = C[c]
    cnt += (n*(n-1))//2
print(cnt)

Measured memory_bytes: 83552
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    long long n;
    long long a[100005];
    int check = 1;
    int ch = 1;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        if (a[i] == 0){
            check = 0;
        }
        if (abs(a[i]) > 1000000000000000000){
            ch = 0;
        }
    }
    
    if (check == 0){
        cout << 0 << endl;
    }
    else if (ch == 0){
        cout << -1 << endl;
    }
    else {
        long long ans = 1;
        long double sta = 1000000000000000000;
        for (int i = 0;i < n;i++){
            sta = sta/a[i];
            if (sta < 1){
                check = -1;
                break;
            }
            ans *= a[i];
        }
        if (check == -1){
            cout << -1 << endl;
        }
        else {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e4+10;
int num[maxx];
int main() {
	int n,x;
	scanf("%d%d",&x,&n);
	memset(num,0,sizeof(num));
	rep(i,0,n){
		int a;
		scanf("%d",&a);
		num[a]++;
	}

	int a=101,b=0;
	for(int i=x;i<101;i++){
		if(num[i]==0){
			a=i;
			break;
		}
	}
	
	for(int i=x;i>0;i--){
		if(num[i]==0){
			b=i;
			break;
		}
	}
	if(a-x<x-b){
		printf("%d",a);
	}else if(a-x>=x-b){
		printf("%d",b);
	}
} 

Measured memory_bytes: 3824
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b; 
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
	int h, w; 
	cin >> h >> w;
  	vector<string> s(h);
  	int count = 0; // 道の数
  	rep(i,h){
    	cin >> s[i];
      	rep(j,w){
        	if(s[i][j] == '.') count++;
        }
    }
  	// s[i][j] = '.' -> 道; s[i][j] = '#' -> 壁
 	vvi dist(h, vector<int>(w,-1)); // -1 だったらまだ見ていない
  	dist[0][0] = 0;
  	queue<P> q;
	q.push(P(0,0));

  	int dx[] = {1, -1, 0, 0};
  	int dy[] = {0, 0, 1, -1};
  	int xnow, ynow, xtemp, ytemp;
  	  
  	while(!q.empty()){
      	xnow = q.front().first;
      	ynow = q.front().second;
      	q.pop();
     	rep(i,4){
      		xtemp = xnow + dx[i];
      		ytemp = ynow + dy[i];
      		if(0<=xtemp && xtemp<h && 0 <= ytemp && ytemp<w 
           	   && s[xtemp][ytemp] == '.' && dist[xtemp][ytemp] == -1){
        		q.push(P(xtemp, ytemp));
          		dist[xtemp][ytemp] = dist[xnow][ynow] + 1;
            }
        }
	}
	/*
  	rep(i,h){
    	rep(j,w){
        	cout << dist[i][j] << " " ;
        }
      	cout << endl;
    }
	*/
  	if(dist[h-1][w-1] == -1) cout << -1 << endl;
  	else cout << count - dist[h-1][w-1] - 1 << endl;
    return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(M)]
BC.sort(key=lambda k: k[1], reverse=True)
l = []

for Bi, Ci in BC:
    l += [Ci]*min(Bi, N-len(l))

A.sort()
l.sort(reverse=True)

for i in range(min(N, len(l))):
    if A[i]<l[i]:
        A[i] = l[i]
    else:
        break

print(sum(A))

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */



int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}


int main(){
  string s;
  cin >> s;
  int64_t score = 0;
  rep(i,s.size()){
    if(i % 2 == 0){
      if(s.at(i) == 'p'){
        score--;
      }
    }else{
      if(s.at(i) == 'g'){
        score++;
      }
    }
  }
  cout << score << endl;
      
      
}

Measured memory_bytes: 512