akhauriyash/Code-Regression huggingface dataset:
S = input()

if S[0] == "A":
  if S[2:-1].count('C') == 1:
    index_c = S.find("C")
    S = S[1:index_c] + S[index_c+1:]
    if S.islower():
      print("AC")
    else:
      print("WA")
  else:
    print("WA")
else:
  print("WA")

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

int main() {
  int n;
  while (cin >> n, n) {
    int d[n], ans = 0;
    rep(i, n) cin >> d[i];
    for (int i = 1; i < n; i++)
      for (int j = 0; j < n - i; j++)
        if (d[j] > d[j + 1]) {
          swap(d[j], d[j + 1]);
          ans++;
        }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
a, b, m = map(int,input().split())
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))

ans = min(ai)+min(bi)
for k in range(m):
    ak, bk, mk = map(int,input().split())
    ansk = ai[ak-1]+bi[bk-1]-mk
    if ansk<ans:
        ans = ansk
print(ans)

Measured memory_bytes: 18736
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int  d[N];

void bfs(int s)  {
  queue<int> q;
  q.push(s);
  for (int i = 0; i< n; i++)  {
    d[i] = INFTY;
  }
  d[s] = 0;
  int u;
  while (!q.empty())  {
    u = q.front(); q.pop();
    for (int v = 0; v < n; v++)  {
      if (M[u][v] == 0)
        continue;
      if (d[v] != INFTY)
        continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for (int i = 0; i < n; i++)  {
    cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;
  cin >> n;
  for (int i = 0; i < n; i++)  {
    for (int j = 0; j < n; j++)  {
      M[i][j] = 0;
    }
  }
  
  for (int i = 0; i < n; i++)  {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++)  {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    int d = a / b;
    int r = a % b;
    double f = 1.0 * a / b;
    // cout << d << " " << r << " " << f << endl;
    printf("%d %d %f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 3200
s=input()
if (s[0]=="A") and (s[2:-1].count("C")==1) and ("C" not in s[:2]) and (s[-1] != "C"):
  s=s[1:]
  s=s.replace("C","")
  if s==s.lower():
    print("AC")
  else:
    print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    
    return 0;
}


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


int main(void) {
  string a, b;
  cin >> a >> b;

  if (a.length() > b.length()) {
    cout << "GREATER" << endl;
  } else if (a.length() < b.length()) {
    cout << "LESS" << endl;
  } else if (a.length() == b.length()) {
    int i = 0;
    while (i < a.length()) {
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        break;
      } else if (a[i] < b[i]) {
        cout << "LESS" << endl;
        break;
      }
      ++i;
    }
    if (i == a.length()) {
      cout << "EQUAL" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


long long int dp[102][100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    int n,w;
    cin>>n>>w;
    long long int v[n],wt[n];
    for(int i=0;i<n;i++)
    {
    	cin>>wt[i]>>v[i];
    }
    long long int ans = 0;
    for(int i=0;i<n;i++)
    {
    	for(int j=w;j>=0;j--)
  		{
  			if(j>=wt[i])
  			{
  				dp[i+1][j-wt[i]] = max(dp[i+1][j-wt[i]], dp[i][j]+v[i]);
  			}
  			dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
  			ans = max(ans,dp[i+1][j]);

  		}
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    int n, unused;
    cin >> n >> unused;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ma[n+1]; ma[n] = -1;
    int res = 0;
    for (int i = n-1; i >= 0; i--) {
        res = max(res, ma[i+1]-a[i]);
        ma[i] = max(ma[i+1], a[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (res == ma[i+1]-a[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int n;
cin>>n;
bool f=false;
while(n!=0){
    int re=n%10;
     if(re==7) f=true;
    n=n/10;
}
if(f) printf("Yes\n");
else
    printf("No\n");
return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define SIZE 100
using namespace std;
using ll = long long int;

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

  // input
  ll n, k;
  cin >> n >> k;
  deque<ll> dq;
  for (size_t _ = 0; _ < n; _++) {
    ll vi;
    cin >> vi;
    dq.push_back(vi);
  }

  ll ans = 0;
  for (size_t a = 0; a <= k; a++) {
    for (size_t b = 0; b <= k - a; b++) {
      deque<ll> d = dq; // 宝石の deque
      vector<ll> pq; // 持つ宝石
      const int n_cnt = k - a - b;

      // 左から a 個取る
      for (size_t _ = 0; _ < a; _++) {
        if (!d.empty()) {
          ll v = d.front();
          d.pop_front();
          pq.push_back(v);
        }
      }

      // 右から b 個取る
      for (size_t _ = 0; _ < b; _++) {
        if (!d.empty()) {
          ll v = d.back();
          d.pop_back();
          pq.push_back(v);
        }
      }

      sort(pq.begin(), pq.end(), greater<ll>());
      
      for (size_t cnt = 0; cnt <= n_cnt; cnt++) {
        auto p = pq;

        // 持ってる宝石を小さい方から cnt 個捨てた場合の
        // 持ってる宝石の価値の合計を計算する
        ll sum = 0;
        for (int i = 0; i < max(0, (int)(p.size() - cnt)); i++)
        {
          sum += p[i];
        }
        ans = max(ans, sum);
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

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


int main(void) {
	int N;
	scanf("%d", &N);
	
	int sum = 0;
	int a = N;

	while (N > 0) {
		sum += N % 10;
		N /= 10;
	}
	
	
	if (a%sum == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}

		return 0;
}



Measured memory_bytes: 128
/*
 * atcoder/abc096_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int H, W;
bool G[60][60] = {0};

void solve() {
  cin >> H >> W;
  char c;
  bool allWhite = true;
  loop(y,0,H) {
    loop(x,0,W) {
      cin >> c;
      G[y][x] = (c=='#');
      allWhite &= !G[y][x];
    }
  }
  if (allWhite) {
    cout << "Yes" << endl;
    return;
  }
  loop(y,0,H) loop(x,0,W) {
    if (!G[y][x]) continue;
    bool ok = false;
    loop(dy,-1,2) loop(dx,-1,2) {
      if (dy+dx==0) continue;
      if (dy != 0 and dx != 0) continue;
      int y2 = y + dy, x2 = x + dx;
      if (x2 < 0 or W <= x2 or y2 < 0 or H <= y2) continue;
      // if (G[y2][x2]) cout << x << " " << y << " " << dx << " " << dy << endl;
      ok |= G[y2][x2];
    }
    if (!ok) {
      cout << "No" << endl;
      return;
    }
  }

  cout << "Yes" << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>b(n,0);
  vector<int>p(m);
  for(int i = 0;i < m;i++){
    int k;
    cin >> k;
    for(int j = 0;j < k;j++){
      int s;
      cin >> s;
      s--;
      b[i] |= (1<<s);
    }
  }
  for(int i = 0;i < m;i++) cin >> p[i];
  long long ans = 0;
  for (int bit = 0; bit < (1<<n); ++bit){
    for(int i = 0;i < m;i++){
      int c = 0;
      for(int j = 0;j < n;j++){
        if(b[i] & (1<<j) && bit & (1<<j)) c++;
      }
      if(c%2 != p[i]) break;
      if(i == m-1) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
field = []
for i in range(3):
    field += list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
hit = [0 for i in range(9)]
for i in b:
    if i in field:
        #hit.append(field.index(i))
        hit[field.index(i)] += 1

if hit[0] == hit[1] == hit[2] == 1:
    print('Yes')
elif hit[3] == hit[4] == hit[5] == 1:
    print('Yes')
elif hit[6] == hit[7] == hit[8] == 1:
    print('Yes')
elif hit[0] == hit[3] == hit[6] == 1:
    print('Yes')
elif hit[1] == hit[4] == hit[7] == 1:
    print('Yes')
elif hit[2] == hit[5] == hit[8] == 1:
    print('Yes')
elif hit[0] == hit[4] == hit[8] == 1:
    print('Yes')
elif hit[2] == hit[4] == hit[6] == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
N=int(input())
dp=[0]*(N+1)
def f(n):
    p=0
    q=0
    m=n
    while n>=1:
        n//=9
        p+=1
    while m>=1:
        m//=6
        q+=1
    s=[]
    for i in range(p):
        s.append(9**i)
    for j in range(q):    
        s.append(6**j)
    s.pop(0)    
    return s
for i in range(1,N+1):
    dp[i]=dp[i-1]+1
    for j in f(i):
        dp[i]=min(dp[i-j]+1,dp[i])
print(dp[N])        
        

Measured memory_bytes: 3828
H, N = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
# A = A.sort!.reverse!
# https://www.sejuku.net/blog/19219
# while 0 < H do
#   H -= A
#   if 
#     puts "Yes"
#   else
#     puts "No"
#   end
# end
# array.inject(:+) #配列の要素をすべて足す
if H <= A.inject(:+)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8708
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n),r(n),l(n);
  rep(i,n){
    cin>>a[i];
    r[i]=i-a[i];
    l[i]=a[i]+i;
  }
  ll ans=0;
  map<ll,int>mp;
  for(int i=n-1;i>=0;i--){
    ans+=mp[l[i]];
    mp[r[i]]++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 28128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		if (st.count(t))
		{
			cout << "NO";
			return 0;
		}
		st.insert(t);
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll fact[100010];
void make_fact(ll p){
  fact[0]=fact[1]=1;
  for(ll i=2;i<=p;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
int main(){
  ll n,m;cin>>n>>m;
  if(abs(n-m)>1){
    prin(0);
    return 0;
  }
  make_fact(max(n,m));
  ll res;
  if(n==m) res=(fact[n]*fact[m]*2)%MOD;
  else res=(fact[n]*fact[m])%MOD;
    
  prin(res);


  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    int n;cin>>n;
    int count=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n) count=1;
        }
    }
    if(count==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){

    int n;
    cin >> n;
    vector<vector<int>> abc(n,vector<int>(3));
    REP(i,n)cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    static const int tenum =  110000;
    ll dp[tenum][3];

    REP(i,n){
        REP(j,3){
            REP(k,3){
                if(j != k)chmax(dp[i + 1][k],dp[i][j] + abc[i][k]);
            }
        }
    }
    
    ll ans = 0;
    REP(i,3)chmax(ans,dp[n][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11220
N,K=map(int,input().split())
answer=0
#条件はa,b,cが全てKの倍数か全てがmod(K/2)で後者はKが偶数の時のみ。
x_1=N//K#条件1　Kの倍数の数
if (N//K)*K+K//2>N:
  x_2=N//K
else:
  x_2=N//K+1
if K%2==0:
  answer=x_1**3+x_2**3
else:
  answer=x_1**3
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int a[200010];
  string s;
  cin >> n;
  m = ceil(n/1000.0);
  m *= 1000;
  cout << m-n << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>

using namespace std;

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

    pair<int, int> segs[M];
    for (int i = 0; i < M; i++) {
        cin >> segs[i].second >> segs[i].first;
    }

    sort(segs, segs + M);

    int ans = 0, trim = -1;
    for (int i = 0; i < M; i++) {
        if (segs[i].second > trim) {
            ans++;
            trim = segs[i].first - 1;
        }
    }

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long> vect(n);
  // storing in vector
  for (int i = 0; i < n; i++)
    cin >> vect[i];
   vector<long> l(n+1,0),r(n+1,0);
  // base initialization
  l[1] = vect[0];
  r[n-1] = vect[n-1];
  // finding gcd (from right and left side)
  for(int i = 1; i < n; i++){
   	l[i+1] = __gcd(l[i],vect[i]);
    r[n-i-1] = __gcd(r[n-i],vect[n-i-1]);
  }

  int maxi = 0;
  int temp;
  for (int i = 1; i < n+1; i++){
  	temp = __gcd(l[i-1], r[i]);
    (temp > maxi)? maxi = temp : maxi = maxi;
    // cout << maxi <<'\n'
  }
  cout << maxi << '\n';

	return 0;
}


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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll n; cin >> n;
	string s = "";
	while(n > 0){
		n--;
		int tmp = n % 26;
		char a = 'a';
		a += tmp;
		s = a + s;
		n /= 26;
	}
	cout << s << endl;
} 

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		sc.close();

		int ans = 0;

		for (int i = 0; i < N; i++)
			for (int j = 1; j <= D; j += A[i])
				ans++;
		ans += X;

		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		char c = sc.next().charAt(0);
		
		// 計算
		char result = (char)(c + 1);
		
		// 出力
		System.out.println(result);
	}
	
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define mkp make_pair
typedef long long ll;
using namespace std;

ll L,A,B,M;

ll MOD=1000000007;

typedef vector<ll> vec;//ll?
typedef vector<vec> mat;

mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++){
    for(int k=0;k<B.size();k++){
      for(int j=0;j<B[0].size();j++){
        C[i][j]=(C[i][j]+A[i][k]*B[k][j]%MOD)%MOD;
      }
    }
  }
  return C;
}

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++){
    B[i][i]=1;
  }
  while(n>0){
    if(n&1) B=mul(B,A);
    A=mul(A,A);
    n=(n>>1);
  }
  return B;
}



int digit(ll val){
    if(val==0) return 0;
    else return (1+digit(val/10));
}

int main(){
  cin>>L>>A>>B>>M;
  MOD=M;

  ll ans=0;
  ll ten[20]={};
  ten[0]=1;
  for(int i=1;i<=18;i++) ten[i]=ten[i-1]*10%MOD;

  ll start=0;
  while(start<L){
    ll ng=L;
    ll ok=start;
    ll nowdigit=digit(A+B*start);

    while(ng-ok>1){
      ll mid=(ng+ok)/2;
      if(digit(A+B*mid)==nowdigit) ok=mid;
      else ng=mid; 
    }
    
    mat C(3,vec(3));
    C[0][0]=ten[nowdigit];
    C[0][1]=1;
    C[0][2]=0;
    C[1][0]=0;
    C[1][1]=1;
    C[1][2]=B%MOD;
    C[2][0]=0;
    C[2][1]=0;
    C[2][2]=1;
    C=pow(C,(ok-start+1));

    mat D(3,vec(1));
    D[0][0]=ans;
    D[1][0]=(A+B*start)%MOD;
    D[2][0]=1;
    D=mul(C,D);

    ans=D[0][0];
    ans=(ans+MOD)%MOD;
    start=ok+1;
  }

  cout<<ans<<endl;


  return 0;
}


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

typedef long long ll;
typedef long double ld;

int br[200005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    for(int i=2; i<=n; i++){
        int x;
        cin >> x;
        br[x]++;
    }
    for(int i=1; i<=n; i++){
        cout << br[i] << "\n";
    }
    return 0;
}


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


int main() {

	int count = 0, count_max = 0;
	int tmp;
	int i;

	int N;
	

	cin >> N;
	long int a[N], a_max, a_min;
	
	for ( i = 0; i < N; i++)
	{
		cin >> a[i];

		if (i == 0)
		{
			a_min = a[i];
			a_max = a[i];
		}
		else
		{
			if (a[i] < a_min)
			{
				a_min = a[i];
			}
			else if(a[i] > a_max)
			{
				a_max = a[i];
			}
			
			
		}
	
	}
	
	long int a_out = a_max-a_min;
		
		cout << a_out << endl;
		
	
	
}

Measured memory_bytes: 3636
#include<stdio.h>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else if (a == b) {
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

ll N,M,cnt=0;
ll par[100010],r[100010];

void init(ll n){
    for(ll i=0;i<n;i++){
        par[i]=i;
        r[i]=0;
    }
}
ll root(ll x){
    if(par[x]==x) return x;
    else return par[x]=root(par[x]);
}
bool same(ll x,ll y){
    return root(x)==root(y);
}
void unite(ll x,ll y){
    x=root(x);
    y=root(y);
    if(x==y) return;
    if(r[x]<r[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(r[x]==r[y]) r[x]++;
    }
}

int main(){
    cin>>N>>M;
    init(N);
    vector<ll> p(N),x(M),y(M);
    for(ll i=0;i<N;i++) cin>>p[i];
    for(ll i=0;i<M;i++) cin>>x[i]>>y[i];

    for(ll i=0;i<M;i++) unite(x[i],y[i]);
    for(ll i=0;i<N;i++){
        if(same(i+1,p[i])) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  int ans1 = 0;
  rep(i, s.size()) {
    if(i % 2 && s[i] == '1')
      ans1++;
    else if(i % 2 == 0 && s[i] == '0')
      ans1++;
  }
  cout << min(ans1, (int)s.size() - ans1) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
      long long q(1);//cin>>q;
  while(q--){
    long long n,m,k(0),tot(0);string s,p;cin>>n;
   int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
      sort(arr,arr+n);
    for(int i=0;i<n-2;i++){
      for(int j=i+1;j<n-1;j++){
        if(arr[j]!=arr[i]){
          for(int f=j+1;f<n;f++){
            if(arr[f]!=arr[j]){
              if(arr[f]<arr[i]+arr[j])
                tot++;
            }
          }
        }
      }
    }
    cout<<tot<<endl;
  }
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H1 = scan.nextInt();
        int M1 = scan.nextInt();
        int H2 = scan.nextInt();
        int M2 = scan.nextInt();
        int K = scan.nextInt();
        int start = H1 * 60 + M1;
        int end = H2 * 60 + M2 - K;
        int ans = end - start;
        System.out.println(ans);
    }
    private int pow(int base, int count) {
        if (count == 0) {
            return 1;
        }
        if (count % 2 == 1) {
            return base * pow(base, count - 1);
        }
        int t = pow(base, count / 2);
        return t * t;
    }
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略
 
int main(){
  int ans=0;
  string s;
  cin >> s;
  int end = s.length();
  rep(i,end){
    string s_a = s.substr(0,s.length()/2);
    string s_b = s.substr(s.length()/2,s.length());
    if(s_a == s_b &&i>0){
      cout << s.length() <<endl;
      return 0;
    }
    else {
      s.pop_back();
    }
  }

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

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

void omji(char* a,char* b,char* c){
    char x = *a;
    char y = *b;
    char z = *c;
    x = toupper(x);
    y = toupper(y);
    z = toupper(z);
    char d = (char)x;
    char e = (char)y;
    char f = (char)z;
    cout << x << y << z;
}

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    omji(&a[0],&b[0],&c[0]);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();

            if (N[0] == N[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
H, A = map(int, input().split())

if H%A == 0 :
  print (H//A)
else :
  print ((H//A) + 1)






Measured memory_bytes: 3564
def main():
  INIT = 100
  
  query = []
  ans = []
  while True:
    q = int(input())
    if q == 0:
      break
    query.append(q)
  MAX = max(query)
  
  table = [INIT] * (MAX + 1)
  table[0] = 0
  all_item = [i * (i + 1) * (i + 2) // 6 for i in range(1, 181)]
  odd_item = [i for i in all_item if i % 2]
  eve_item = [i for i in all_item if not i % 2]
  
  for v in odd_item:
    for j in range(v, MAX + 1):
      tjv = table[j - v]
      if table[j] > tjv + 1:
        table[j] = tjv + 1
  
  for q in query:
    ans.append(table[q])
  
  for v in eve_item:
    for j in range(v, MAX + 1):
      tjv = table[j - v]
      if table[j] > tjv + 1:
        table[j] = tjv + 1
  
  for i, q in enumerate(query):
    print(table[q], ans[i])

main()


Measured memory_bytes: 13148
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(input())
m=int(input())
huga=[]
for i in range(m):
  huga.append(input())
ans=[]
ans.append(0)
for i in range(len(hoge)):
  ans.append(hoge.count(hoge[i])-huga.count(hoge[i]))

print(max(ans))

Measured memory_bytes: 3064
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, d = map(int, input().split())
    ans = 0
    while ans * (2 * d + 1) < n:
        ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
using std::vector;
#include<string>
using std::string;
#include<set>
using std::set;
#include<map>
using std::map;
#include<unordered_map>
#include<queue>
#include<tuple>
using std::get;
using std::pair;
using std::tuple;
#include<iostream>
#include<sstream>
#include<iomanip>
using lnt = long long int;
using unt = unsigned long long int;
using ust = unsigned;
using dou = double;
using P = std::pair<int,int>;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define ALL(x)        std::begin(x),std::end(x)
#define DTRL(x,y)     do{auto&x_(x),&y_(y);if(x_!=y_)return x_<y_;}while(0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%lld",&(x))
#define RII64(x,y) scanf("%lld%lld",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;

int main(){
    int A,B;
    std::cin >> A >> B;
    int ans = 0;
    for(int i=0;i<2;++i){
        if(A>B){
            ans+= A--;
        }else{
            ans+= B--;
        }
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int ar[1000000]={0};
  int n;
  cin>>n;
  for(int i=1;i<n;i++)
  {
    int temp;
    cin>>temp;
    ++ar[temp];
  }
  for(int i=1;i<=n;i++)
  {
    printf("%d\n",ar[i]);
  }
}

Measured memory_bytes: 7584
import heapq

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

node = [[] for i in range(N+1)]
for i in range(M):
  a, b = map(int, input().split())
  node[a].append(b)
  node[b].append(a)
#

gw = [0]*(N+1)
gw[1] = 1
ng=1
hq = []
heapq.heapify(hq) 
heapq.heappush(hq,(0,1))
while hq:
  c, n = heapq.heappop(hq)
  for i in node[n]:
    if gw[i] == 0:
      gw[i] = n
      ng += 1
      heapq.heappush(hq,(c+1,i))
#
if ng < N:
  print("No")
else:
  print("Yes")
  for i in range(2,N+1):
    print(gw[i])
#


Measured memory_bytes: 37796
#include <stdio.h>
int main(void){
    while(1){
        char x[1000]={'0'};
        int i, sum=0;
        
        scanf("%s", x);
        
        if(x[0]=='0') break;
        
        for(i=0; x[i]!='\0'; i++)
        sum += x[i] - '0';
        
        printf("%d\n", sum);
    }    
    return 0;
    
}


Measured memory_bytes: 2024
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string s;
	cin >> s;
	rep(i,s.length()){
		if(i%2 != 0) continue;
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 512
import numpy as np

N = int(input())

T,A = map(int,input().split())

def getTemp(T,h):
  return T - (h * 0.006)

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx + 1

lst = list(map(int,input().split()))
anslist = []

for i in lst:
  tmp = getTemp(T,i)
  anslist.append(tmp)

print(int(getNearestValue(anslist,A)))
  

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n;
PII in[N];
pair <int, PII> cur[N];
long long has = 0;

long long gcd(long long a, long long b){
	if(b == 0)
		return a;
	return gcd(b, a % b);
}

bool cmp(int a, int b, int c, int d){
	return 1LL * a * d > 1LL * b * c;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d %d", &in[i].st, &in[i].nd);
		if(in[i].st < in[i].nd)
			has += in[i].nd - in[i].st;
		cur[i] = {max(in[i].st, in[i].nd), in[i]};
	}
	
	if(has == 0){
		puts("0 1");
		exit(0);
	}
	
	int x = 0, a = 0, b = 1;
	sort(cur + 1, cur + n + 1);
	
	for(int i = 1; i <= n; ++i){
		if(cur[i].st <= has){
			has -= cur[i].st;
			++x;
			continue;
		}
		
		break;
	}
	
	if(has == 0){
		int d = __gcd(x, n);
		printf("%d %d\n", x / d, n / d);
		return 0;
	}
	
	for(int i = 1; i <= n; ++i){
		int tmp = has;
		if(i <= x)
			tmp += cur[i].st - cur[x + 1].st;
		
		if(tmp <= 0)	
			continue;

		int ox = 0, oy = 1;
		if(cur[i].nd.st < cur[i].nd.nd)
			ox = tmp, oy = cur[i].nd.nd;
		else{
			if(tmp <= cur[i].nd.st - cur[i].nd.nd)
				continue;
			
			ox = tmp - cur[i].nd.st + cur[i].nd.nd;
			oy = cur[i].nd.nd;
		}

		if(cmp(ox, oy, a, b))
			a = ox, b = oy;
	}
	
	
	
	long long up = 1LL * x * b + a;
	long long down = 1LL * n * b;
	long long d = gcd(up, down);
	
	printf("%lld %lld\n", up / d, down / d);
	return 0;
}

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

int A, B;

int main()
{
  cin >> A >> B;

  int a = ceil(A / 0.08);
  // int a_ = -((-A - 1) / 0.08) - 1;

  int b = ceil(B / 0.1);
  // int b_ = -((-B - 1) / 0.1) - 1;

  int lb = max(a, b);
  // int ub = min(a_, b_);

  int A_, B_;
  A_ = lb * 0.08;
  B_ = lb * 0.1;

  if (A_ == A && B_ == B)
  {
    cout << lb << endl;
  }
  else
  {
    cout << -1 << endl;
  }

  // if (lb <= ub)
  // {
  //   cout << lb << endl;
  // }
  // else
  // {
  //   cout << -1 << endl;
  // }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll n,m;
    cin >> n >> m;
    ll p,q;
    p = n*2;
    q = m*2;
    ll cnt = 0;
    while(1){
        ll x = min(p,n);
        q -= x;
        if(p<=0||q<=0){
            break;
        }
        cnt++;
        ll y = (q+1)/2;
        p -= y;
        if(p<=0||q<=0){
            break;
        }
        cnt++;
    }
    ll ans = 0;
    p = n*2;
    q = m*2;
    while(1){
        ll x = (p+1)/2;
        q -= x;
        if(p<=0||q<=0){
            break;
        }
        ans++;
        ll y = min(q,m);
        p -= y;
        if(p<=0||q<=0){
            break;
        }
        ans++;
    }
    cout << min(ans,cnt) << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,l,r) for(int i=l;i<r;i++)
using ll = long long;
const int inf=2e9+10;
const ll MOD=1e9+7;
const ll INF=9e18+10;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int main(){
        string s;
        cin>>s;
        if(s[2]==s[3]&&s[4]==s[5])printf("Yes\n");
        else printf("No\n");
        return 0;
}
                    

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define N 200000
int n;
string st;
int a[N], b[N];
int solve()
{
    for (int i = 1; i < n; ++ i) a[i + 1] = a[i - 1] ^ a[i] ^ b[i];
    if (a[n] == a[0] && !(a[1] ^ a[n - 1] ^ a[0] ^ b[0]))
    {
        for (int i = 0; i < n; ++ i) cout << (!a[i]? 'S': 'W');
        return 1;
    }
    return 0;
}
int main()
{
    cin >> n >> st;
    for (int i = 0; i < n; ++ i) b[i] = (st[i] == 'o'? 0: 1);
    a[0] = 0; a[1] = 0; if (solve()) return 0;
    a[0] = 0; a[1] = 1; if (solve()) return 0;
    a[0] = 1; a[1] = 0; if (solve()) return 0;
    a[0] = 1; a[1] = 1; if (solve()) return 0;
    cout << -1;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll N;
	cin >> N;
	if(N == 1) {
		cout << 0 << endl;
		return 0;
	}
	map<int, int> mp;
	int p = (int)sqrt(N);
	vector<bool> is_prime(p+1);
	rep(i,p+1) is_prime[i] = true;
	vector<int> P;
	for(int i=2; i<=p; i++) {
		if(is_prime[i]) {
			for (int j=2*i; j<=p; j+=i) {
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	for(auto k : P) {
		while(N % k == 0) {
			N /= k;
			mp[k]++;
		}
	}
	ll ans = 0;
	if(N != 1) ans += 1;
	for(auto k : mp) {
		//cout << k.first << " " << k.second << endl;
	}
	if(mp.size() == 0) {
		cout << 1 << endl;
		return 0;
	}
	for(auto k : mp) {
		if(k.second == 0) continue;
		int cnt = 1;
		int tmp = k.second;
		while(cnt <= tmp) {
			//cout << cnt << " " << tmp << endl;
			tmp -= cnt;
			cnt++;
			ans++;
		}
	}
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include<math.h>
using namespace std;
int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double D = sqrt((x2 - x1)* (x2 - x1) + (y2 - y1) * (y2 - y1));
cout << fixed <<D << endl;
        return 0;
    }
                   

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


void solve(long long N, std::string A, std::string B, std::string C){
  long long count = 0;
  for(long long i = 0; i < N; i++) {
    vector<long long> tab({A[i], B[i], C[i]});
    sort(tab.begin(), tab.end());

    tab.erase(unique(tab.begin(), tab.end()), tab.end());
    count += (tab.size()-1);
  }

  cout << count << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::string A;
  std::cin >> A;
  std::string B;
  std::cin >> B;
  std::string C;
  std::cin >> C;
    solve(N, A, B, C);
    return 0;
}


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

namespace my {
template <typename T>
void input_vec(vector<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_vec" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_set" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(a) )

bool isPrime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////////////////////////////

int main() {
  const ll M = 1e9 + 7;
  int n;
  cin >> n;
  vector<ll> a;
  my::input_vec(a, n);

  ll sum = 0;
  vector<ll> psum;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
    psum.push_back(sum);
  }
  // cout << sum << endl;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a.at(i) % M) * ((sum - psum.at(i)) % M);
    ans %= M;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7940
N = int(input())
A = list(map(int, input().split()))
A1 = list(filter(lambda x: x % 2 == 0, A))
A2 = list(filter(lambda x: x % 3 == 0 or x % 5 == 0, A1))
if len(A1) == len(A2):
    print('APPROVED')
else:
    print('DENIED')

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

int cmpf(const void *x, const void *y){
	return (*(int*)x-*(int*)y);
}

int main(){
	int *a,N;
	scanf("%d",&N);
        a=malloc(sizeof(int)*N);
	for(int i=0;i<N;i++) scanf("%d",&a[i]);
	qsort(a,N,sizeof(int),cmpf);
	double mid=(double)a[N-1]/2;
	int malim=N-2,milim=0;
	while(malim-milim>1)
	{
		int now=(malim+milim)/2;
		if(a[now]>mid){ malim=now; }
		else if(a[now+1]<mid){ milim=now+1; }
		else{
			malim=now+1;
			milim=now;
		}
	}
	printf("%d %d",a[N-1],((mid-(double)a[milim])<((double)a[malim]-mid)?a[milim]:a[malim]));
	return 0;
}


Measured memory_bytes: 892
from fractions import gcd
N = int(input())
a = [int(x) for x in input().split()]
g = a[0]
for i in range(1,N):
  g = gcd(g,a[i])
ans = 0
while True:
  if g % 2 == 1:
    break
  ans += 1
  g= g // 2
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
long long n;
int x, m;

int nxt(int a) {
	return (long long) a * a % m;
}

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

	cin >> n >> x >> m;

	map<int, int> seen;
	
	int f = x;
	int clen, cfirst; 

	for (int i = 0; i <= m; i++) {
		if (seen.count(f)) {
			clen = i - seen[f];
			cfirst = f;
			break;
		}

		seen[f] = i;
		f = nxt(f);
	}

	long long ans = 0;

	f = x;
	for (int i = 0; n && i < seen[cfirst]; i++) {
		ans += (long long) f;
		f = nxt(f);
		n -= 1;
	}

	long long cnum = (long long) n / clen;
	long long crem = (long long) n % clen;

	long long sum = 0;

	f = cfirst;
	for (int i = 0; i < clen; i++) {
		if (i == crem) {
			ans += sum;
		}
		sum += f;
		f = nxt(f);
	}

	ans += cnum * sum;

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 5928
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")

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

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

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

    if(s.size() + 1 != t.size()){ cout << "No" << endl; return 0; }
    for(size_t i=0;i<s.size();++i){
        if(s[i] != t[i]){ cout << "No" << endl; return 0; }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3648
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;
    
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int w=a*c;
    int x=a*d;
    int y=b*c;
    int z=b*d;
    cout<<max({w,x,y,z})<<endl;
}

Measured memory_bytes: 3632
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, X = map(int, readline().split())
    if A<=X<=A+B:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


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

int main()
{

        int W, H, x, y, r;
        cin >> W >> H >> x >> y >> r;

        int max_x = x + r;
        int min_x = x - r;
        int max_y = y + r;
        int min_y = y - r;

        bool ok = true;
        if (max_x > W) {
                ok = false;
        }
        else if (min_x < 0) {
                ok = false;
        }
        else if (max_y > H) {
                ok = false;
        }
        else if (min_y < 0) {
                ok = false;
        }
        if (ok) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
}



Measured memory_bytes: 3120