akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  int x; cin>>x;
  if(x) cout<<0<<endl;
  else cout<<1<<endl;
}

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  vector<int> v;
  rep(i,k){
    int x = a+i;
    if(find(v.begin(), v.end(), x) == v.end() && x<=b) v.push_back(a+i);
  }
  rep(i,k){
    int x = b-k+i+1;
    if(find(v.begin(), v.end(), x) == v.end() && x>=a) v.push_back(b-k+i+1);
  }

  for(auto it=v.begin(); it != v.end(); it++){
    cout << *it << endl;
  }
  
  return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

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

    if(a+b+c == a*2 || a+b+c == b*2 || a+b+c == c*2)flag=true;
    else flag=false;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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 gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n){
    cin >> v[i];
  }
  int ans = 0;
  rep(i,n){
    int tmp = 0;
    int temp = 0;
    REP(j,i,n-1){
      if(v[j] <= v[j+1])tmp++;
      else break;
    }
    REP(j,i,n-1){
      if(v[j] >= v[j+1])temp++;
      else break;
    }
    i += max(temp,tmp);
    ans++;
  }
  cout << ans << endl;
}


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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k; cin >> n >> k;
	int res = 0;
	for (int i = 0; i < n; ++i) {
		int h; cin >> h;
		if (h >= k) res++;
	}
	cout << res;
}


Measured memory_bytes: 256
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, int(n**0.5)+1):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
total=0
if __name__ == "__main__":
    a=int(input())
    for i in range(a):
        b=int(input())
        if isPrime(b):
            total+=1
        else:
            pass
    print(total)


Measured memory_bytes: 5704
#include<stdio.h>
int m,n,k;
int f,g,h;
int a,b,c,d;
char map[1003][1003];
int j[1003][1003],o[1003][1003],i[1003][1003];
int main(void){
	scanf("%d %d",&m,&n);
	scanf("%d",&k);
	for(f=1;f<=m;f++){
		for(g=1;g<=n;g++){
			j[f][g]=0;
			o[f][g]=0;
			i[f][g]=0;
		}
	}
	for(f=1;f<=m;f++){
		for(g=1;g<=n;g++){
			scanf(" %c",&map[f][g]);
			if(map[f][g]=='J'){
				j[f][g]++;
			}
			else if(map[f][g]=='O'){
				o[f][g]++;
			}
			else if(map[f][g]=='I'){
				i[f][g]++;
			}
			j[f][g+1]+=j[f][g];
			o[f][g+1]+=o[f][g];
			i[f][g+1]+=i[f][g];
		}
	}
	for(g=1;g<=n;g++){
		for(f=1;f<=m;f++){
			j[f+1][g]+=j[f][g];
			o[f+1][g]+=o[f][g];
			i[f+1][g]+=i[f][g];
		}
	}
	int anj,ano,ani;
	for(f=0;f<k;f++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		anj=j[c][d]-j[c][b-1]-j[a-1][d]+j[a-1][b-1];
		ano=o[c][d]-o[c][b-1]-o[a-1][d]+o[a-1][b-1];
		ani=i[c][d]-i[c][b-1]-i[a-1][d]+i[a-1][b-1];
		printf("%d %d %d\n",anj,ano,ani);
	}
	/*for(f=1;f<=m;f++){
		for(g=1;g<=n;g++){
			printf("%d,%d=%d%d%d ",f,g,j[f][g],o[f][g],i[f][g]);
		}
		printf("\n");
	}*/
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

string S;

int main(){
	cin >> S;
	repp(i,0,S.size()-8){
		cout << S[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();

    int t = (y - 2*x)/2;
    int c = x - t;
    
    if(t < 0 || c < 0 || y%2 == 1)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,b[100];
pair<ll,ll>a[100];
double ans;
int32_t main(){
CODE_START;
cout<<fixed;
cin>>n;
for(ll i=0;i<n;i++)
cin>>a[i].f>>a[i].s;
ans=0;
for(ll i=0;i<n;i++)
b[i]=i;
do{
    for(ll i=1;i<n;i++){
    ans=ans+sqrt((a[b[i]].f-a[b[i-1]].f)*(a[b[i]].f-a[b[i-1]].f)+(a[b[i]].s-a[b[i-1]].s)*(a[b[i]].s-a[b[i-1]].s));
    }
}while (next_permutation(b,b+n));
double x=1;
for(ll i=1;i<=n;i++)
x=x*i;
cout<<setprecision(8)<<ans/x<<endl;
}


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

using namespace std;

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

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

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll neck = min(a,min(b,min(c,min(d,e))));
    ll ans= (n+neck-1)/neck + 4;
    cout<<ans<<endl;
    return  0;
}


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

int N, K, cx = 0, cnt; string S;

int main() {
	cin >> N >> K >> S;
	for (int i = 0; i < K; i++) {
		if (S[cx] == 'A') { S[cx] = 'B'; }
		else {
			cx++; if (cx == N) { cnt = i + 1; break; }
			if (cx % 2 == 1) {
				if (S[cx] == 'A') S[cx] = 'B'; else S[cx] = 'A';
			}
		}
	}
	if (cx % 2 == 1 && cx < S.size()) { if (S[cx] == 'A') S[cx] = 'B'; else S[cx] = 'A'; }
	if (cx == N) {
		if (N % 2 == 0) {
			for (int i = 0; i < N / 2; i++) cout << "BA"; cout << endl;
		}
		else {
			if ((K - cnt) % 2 == 0) { cout << "A"; for (int i = 0; i < N / 2; i++) cout << "BA"; }
			else { cout << "B"; for (int i = 0; i < N / 2; i++) cout << "BA"; }
			cout << endl;
		}
	}
	else {
		string T = "";
		for (int i = cx; i < N; i++) {
			if (cx % 2 == 0) T += S[i];
			else { if (S[i] == 'A') T += "B"; else T += "A"; }
		}
		for (int i = 0; i < cx; i++) {
			if ((cx - i) % 2 == 0) T += "B"; else T += "A";
		}
		cout << T << endl;
	}
	return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N; cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];

    ll res = 0;
    rep(i, 0, N) res += a[i]-1;

    cout << res << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    let mut map: HashMap<String, u64> = HashMap::new();
    map.insert("AC".to_string(), 0);
    map.insert("WA".to_string(), 0);
    map.insert("TLE".to_string(), 0);
    map.insert("RE".to_string(), 0);
    for _ in 0..n {
        let s: String = input();
        let n = map.entry(s).or_insert(0);
        *n += 1;
    }

    println!("AC x {}", map.get("AC").unwrap());
    println!("WA x {}", map.get("WA").unwrap());
    println!("TLE x {}", map.get("TLE").unwrap());
    println!("RE x {}", map.get("RE").unwrap());
}


Measured memory_bytes: 2192
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;

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

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll n, m, x, tmp;
  cin >> n >> m >> x;

  VI a(n + 1, 0);
  REP(i, m) {
    cin >> tmp;
    a[tmp] = 1;
  }

  cout << min(accumulate(a.begin(), a.begin() + x + 1, 0),
              accumulate(a.begin() + x, a.end(), 0))
       << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,sum;
  cin>>N;
  sum=0;
  int arr[N];
  for(int i=0;i<N;i++)
   cin>>arr[i];

  for(int i=0;i<N-1;i++)
  {
    for(int j=i+1;j<N;j++)
    {
     sum=sum+arr[i]*arr[j];
    }
  }

cout<<sum; 

return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int sum1=0,a;
	int sum2=0,b;
	int i;
	for(i=0;i<4;i++){
		cin>>a;
		sum1+=a;
	}
	for(i=0;i<4;i++){
		cin>>b;
		sum2+=b;
	}
	if(sum1>sum2){
		cout<<sum1<<endl;
	}
	else if(sum1<sum2){
		cout<<sum2<<endl;
	}
	else{
		cout<<sum1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a,d=0;
  cin>>a;
  vector<int> b(a),c(a);
  for(int i=0;i<a;i++)
    cin>>b.at(i);
  for(int i=0;i<a;i++){
    if(i==0)
      continue;
    b.at(i)+=b.at(i-1);
  }
  for(int i=0;i<a;i++)
    cin>>c.at(i);
  for(int i=a-1;i>=0;i--){
    if(i==a-1)
      continue;
    c.at(i)+=c.at(i+1);
  }
  for(int i=0;i<a;i++)
    d=max(d,b.at(i)+c.at(i));
  cout<<d<<endl;
}


Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int a, b;
    cin >> a >> b;
    if(a < b)
    swap(a,b);
    int sol = 0;
    sol += a;
    a--;
    if(a < b)
    swap(a,b);
    sol += a;
    cout << sol;
    return 0;
}

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

int main(){
	int A,B;
	cin >> A >> B;
	if (A == 1){
		if (B == 1)
		cout << "Draw";
		else{
			cout << "Alice";
		}
	}
	else if (B == 1){
		cout << "Bob";
	}
	else if (A > B){
		cout << "Alice";
	}
	else if (A == B){
		cout << "Draw";
	}
	else {
		cout << "Bob";
	}
}


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

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

  int A,B; cin >> A >> B;
  char G[50][100];

  // 上半分を黒で埋める
  rep(h, 50) {
    rep(w, 100) {
      G[h][w] = h < 25 ? '#' : '.';
    }
  }

  A--; B--;

  rep(h, 25) {
    if(A == 0) break;
    if(h % 2 != 0) continue;
    rep(w, 100) {
      if(w % 2 == 0) {
        G[h][w] = '.';
        A--;
        if(A == 0) break;
      }
    }
  }

  rep(h, 25) {
    if(B == 0) break;
    if(h % 2 != 0) continue;
    rep(w, 100) {
      if(w % 2 == 0) {
        G[h + 26][w] = '#';
        B--;
        if(B == 0) break;
      }
    }
  }

  cout << "50 100" << endl;

  rep(h, 50) {
    rep(w, 100) {
      cout << G[h][w];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int a[3]={0}, tmp=0;

  cin >> a[0] >> a[1] >> a[2];

  for(int i = 0; i<2; i++){
    for(int i = 0; i<2; i++){
      if(a[i] < a[i+1]){
        tmp = a[i];
        a[i] = a[i+1];
        a[i+1] = tmp;
      }
    }
  }

  cout << a[1] + a[2] << endl;
  return 0;
}


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

int64_t ncr2(int64_t n) {
    return (n * (n-1)) / 2;
}
int main(void) {
    int64_t N;
    string s;
    int64_t sum = 0;
    cin >> N;

    map<vector<char>,int> m;
    for(int i=0;i<N;i++) {
        cin >> s;    
        vector<char> tempm(26,0);
        for(int j=0;j<10;j++) {
            tempm[s[j]-'a']++;
        }
        m[tempm]++;
    
    }

    map<vector<char>,int>::iterator it = m.begin();
    while(it != m.end()) {
//        cout << it->second << endl;
        if(it->second >= 2) {
            sum += ncr2(it->second);
        }
        it++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    rep(i, n) {
        ll num; cin >> num;
        if (num % 2 == 0) {
            if (!(num % 3 == 0 || num % 5 == 0)) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);

#define l_ength size

ll MOD;

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int m=(1<<19);
ll p[225816],x[1<<19]={1ll},rev;
std::vector<ll> a(1<<19),b(1<<19);

ll rwpw(ll q, ll t = MOD-2){
	ll ret = 1ll;
	while(t){
		if(t%2){
			mul_mod(ret,q);
		}
		mul_mod(q,q);
		t /= 2;
	}
	return ret;
}

std::vector<ll> fft(std::vector<ll> f){
	int i,n,t;
	n = f.l_ength();
	if(n==1){
		return f;
	}
	std::vector<ll> g[2]; t = m/n;
	for(i=0; i<n; ++i){
		g[i%2].push_back(f[i]);
	}
	for(i=0; i<2; ++i){
		g[i] = fft(g[i]);
	}
	for(i=0; i<n; ++i){
		f[i] = g[1][i%(n/2)];
		mul_mod(f[i],x[i*t]);
		add_mod(f[i],g[0][i%(n/2)]);
	}
	return f;
}

int main(void){
	int n,i;
	ll c = 1ll, d = 2ll, ans = 0ll, mod = 200003ll;
	for(i=1; i<mod; ++i){
		c *= d; c %= mod;
		p[c] = i;
	}
	for(i=0; i<m; ++i){
		a[i] = 0ll; b[i] = 0ll;
	}
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> c;
		if(!c){
			continue;
		}
		ans -= c*c%mod;
		++a[p[c]]; ++b[p[c]];
	}
	MOD = 985661441ll;
	rev = rwpw(m);
	x[1] = rwpw(3ll,(MOD-1)/m);
	for(i=2; i<m; ++i){
		x[i] = x[i-1];
		mul_mod(x[i],x[1]);
	}
	a = fft(a);
	for(i=0; i<m; ++i){
		mul_mod(a[i],a[i]);
	}
	std::reverse(&x[1],&x[m]);
	a = fft(a);
	for(i=m-1; i>=0; --i){
		mul_mod(a[i],rev);
	}
	MOD = 998244353ll;
	rev = rwpw(m);
	x[1] = rwpw(3ll,(MOD-1)/m);
	for(i=2; i<m; ++i){
		x[i] = x[i-1];
		mul_mod(x[i],x[1]);
	}
	b = fft(b);
	for(i=0; i<m; ++i){
		mul_mod(b[i],b[i]);
	}
	std::reverse(&x[1],&x[m]);
	b = fft(b);
	for(i=m-1; i>=0; --i){
		mul_mod(b[i],rev);
	}
	c = 1ll;
	for(i=0; i<mod*2; ++i){
		while(b[i]%985661441ll!=a[i]){
			b[i] += 998244353ll;
		}
		ans += c*b[i];
		c *= d; c %= mod;
	}
	ans /= 2;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 33632
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    ll N, M; cin >> N >> M;
    
    ll ans = 0;
    if (N > M) {
        ll t = N;
        N = M;
        M = t;
    }

    if (N==1 && M==1) {
        ans = 1;
    } else if (N==1) { // M>1
        ans = M - 2;    
    } else { // N>1 && M>=N
        ans = (N - 2)*(M - 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  vector<int> ans(S.size() + 1);
  vector<int> kyori(S.size(), -1);
  int cnt = -1;
  REP(i, S.size()) {
    if (S[i] == 'L') {
      cnt++;
      kyori[i] = cnt;
    } else {
      cnt = -1;
    }
  }
  REP(i, S.size()) {
    int j = S.size() - 1 - i;
    if (S[j] == 'L') {
      cnt = -1;
    } else {
      cnt++;
      kyori[j] = cnt;
    }
  }
  REP(i, S.size()) {
    if (S[i] == 'L') {
      if (kyori[i] % 2 == 0) {
        ans[i - kyori[i]+1]++;
      } else {
        ans[i - kyori[i]]++;
      }

    } else {
      if (kyori[i] % 2 == 0) {
        ans[i + kyori[i]+1]++;
      } else {
        ans[i + kyori[i] + 2]++;
      }
    }
  }
  REP(i, S.size()) { cout << ans[i + 1] << " "; }
  cout << endl;
}

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

int main() {
  int N,Z=0;
  cin>>N;
  vector<vector<int>> G(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      char a;
      cin>>a;
      if(a=='1'){
        G.at(i).push_back(j);
      }
    }
  }
  vector<int> c(N,0);
  c.at(0)=1;
  for(int i=0;i<N;i++){
  queue<int> q;
  vector<int> r(N,-1);
  q.push(i);
  r.at(i)=0;
  while(!q.empty()){
    int b=q.front();
    q.pop();
    for(int x:G.at(b)){
      if(r.at(x)==-1){
        r.at(x)=r.at(b)+1;
        q.push(x);
      }
      if(i==0&&c.at(x)==0){
        c.at(x)=c.at(b)*(-1);
      }
      if(c.at(x)==c.at(b)){
        Z=-2;
        break;
      }
    }
    if(Z==-2){
      break;
    }
    else{
      Z=max(Z,r.at(b));
    }
  }
  }
    cout<<Z+1<<endl;
}




Measured memory_bytes: 512
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)


int main(){ FastIO;

int i,n,x,c=1,s=0;cin>>n>>x;
int a[n];
for(i=0;i<n;i++) cin>>a[i];
for(i=0;i<n;i++)
{
	s+=a[i];
	if(s<=x) c++;
	else {
		break;
	}
}
cout<<c;
return 0;
}


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


int main()
{
   int A,B ;
   scanf("%d",&A);
   scanf("%d",&B);

        if( (A+B)%3 == 0 || A%3==0 || B%3==0)
        {
            cout<< "Possible";
        }
        else
        {
            cout<< "Impossible";
        }
  return 0;
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int solve(int n) {
  int lunlun_count = 0;
  queue<int> que;
  for(int i = 1; i <= 9; ++i) {
    que.push(i);
  }
  int front_value;
  while(lunlun_count < n) {
    ++lunlun_count;
    front_value = que.front(); que.pop();
    int front_value_last_digit = front_value % 10;
    if(front_value_last_digit != 0) que.push(front_value*10 + front_value_last_digit-1);
    que.push(front_value*10 + front_value_last_digit);
    if(front_value_last_digit != 9) que.push(front_value*10 + front_value_last_digit+1);
  }
  return front_value;
}
/***** MAIN *****/
signed main() {
  int n = in();
  cout << solve(n) << endl;
  return 0;
}
/***** MAIN *****/


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

int main() {
  string S,T;
  cin >> S >> T;
  string H = S;
 vector<string> a;
 if(S.size() >= T.size()){
  for(int i = 0;i<S.size()-T.size()+1;i++){//Sのどの連続した|T|文字がTと一致するかを考える
   bool flag1 = false;
    string X = S.substr(i,T.size());
    for(int j = 0;j<T.size();j++){
      if(X[j] != '?' && X[j] != T[j]){
        flag1 = true;
        break;
      }
    }
    if(flag1) {
      S = H;
      continue;//X != Tの時以下の処理を飛ばす
    }
    S.replace(i,T.size(),T);
    for(int k = 0;k<S.size();k++){
      if(S[k] == '?'){
        S[k] = 'a';
      }
    }
    a.push_back(S);
    S = H;
  }
 sort(a.begin(),a.end());
  if(a.size() >=1){
  cout << a[0] << endl;
  }
  else cout << "UNRESTORABLE" << endl;
 }
  else cout << "UNRESTORABLE" << endl;
  
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans=0
for ia in range(a+1):
    for ib in range(b+1):
        if 500*ia+100*ib+50*c>=x & x>=500*ia+100*ib: ans+=1
print(ans)

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

int main() {
    lnt N;
    cin>>N;
    vector<lnt>A(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(A.rbegin(),A.rend());

    lnt ans = -A[0];
    rep(i,N/2){
        ans += 2*A[i];
    }
    if(N%2 == 0){
        cout << ans << endl;
    }
    else{
        cout << ans + A[(N-1)/2] << endl;
    }
}

Measured memory_bytes: 4756
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int ans=0;
   ans+=(n*(n-1))/2;
   ans+=(m*(m-1))/2;
   cout<<ans<<endl;

}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    double ans = v.at(0);
    for(int i = 1; i < n; i++){
        ans = (ans + v.at(i)) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>

using namespace std;

struct PAIR {
    string   first;
    int second;
};

int main(){
	int number;
	scanf("%d",&number);
	int qu;
	scanf("%d",&qu);
	queue<PAIR> Q;
	
	string name; 
	int t;
	for(int i=0;i<number;i++){
		cin >> name >> t;
		PAIR d;
		d.first=name;
		d.second=t;
		Q.push(d);
		}
	
	int time=0;
	while(!Q.empty()){
		if(Q.front().second<= qu) {
			PAIR c=Q.front();
			Q.pop();
			int elapse=c.second+time;
			cout << c.first<<" "<< elapse << endl;
			time+=c.second;
		}
		else{
			PAIR c=Q.front();
			Q.pop();
			c.second-= qu;
			Q.push(c);
			time +=  qu;
			}
		}
	return 0;
}

Measured memory_bytes: 4456
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, ans = 0 ;
  for(int i=0;i<5;i++){
    cin >> N ;
    if(N == 0){
      cout << i+1 << endl ;
      return 0 ;
    }
  }
  
  return 0 ;
}  

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int a[1005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
 
int a[1 << 17],b[1 << 17];
 
int32_t main(){_
    //freopen("input","r",stdin);
    int n;
    cin >> n;
    int x = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for(int i = 1;i <= n;i++)
    {
        cin >> b[i];
    }
    for(int i = 1;i <= n;i++)
    {
        if(a[i] < b[i]) x += (b[i] - a[i]) / 2;
        else x += b[i] - a[i];
    }
    if(x >= 0) rc("Yes");
    rc("No");
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    while (c > 0)
    {
        c--;
        ans++;
        if (b > 0)
        {
            b--;
            ans++;
            continue;
        }
        if (a > 0)
        {
            a--;
            continue;
        }
        c = 0;
    }
    if (b > 0)
        ans += b;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  long long N, K;
  cin >> N >> K;
  long long ans = 1;
  for (int i = 0; i < N;i++){
    ans = min(ans * 2, ans + K);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int w,s;
	cin >> s >> w;
	if(w >= s)cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	FE(i,1,t)
		solve();
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define Max(_A,_B) (_A>_B?_A:_B)
#define Min(_A,_B) (_A<_B?_A:_B)
#define maxn 5007
#define md 1000000007
#define V e[i].v
#define ull unsigned long long
#define R register
int n, m, k, tot;
inline int read(){
    R int s = 0, f = 1; R char c = getchar();
        while (c > '9' || c < '0') { c = getchar();}
            while (c >= '0' && c <= '9') {s = s * 10 + c - '0'; c = getchar();}
                return s * f;
                }
char s[5007];
ll f[maxn][maxn], ans;   //f[i][j]表示i次操作构成序列j的 方案数
ll ksm(ll a, int b){
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % md;
        a = a * a % md;
        b >>= 1;
    }
    return res;
}
int main() {
    f[0][0] = 1ll;
    for (int i = 0; i <= 5000; i++)
        for (int j = 0; j <= 5000; j++) {
            if (f[i][j]){
                f[i + 1][j + 1] = (f[i + 1][j + 1] + 2ll * f[i][j] % md) % md;
                f[i + 1][Max(0, j - 1)] = (f[i + 1][Max(0, j - 1)] + f[i][j] % md) % md;
            }
        }
    scanf("%d\n%s", &n, s);
        m = strlen(s);
        ans = f[n][m];
        ans = (ans * ksm(ksm(2ll, m), md - 2)) % md;
        printf ("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 194048
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
{
  string str;
  int ans = 0;

  while (cin >> str){
    int num = 0;
    for (int i = 0; i < str.size(); i++){
      if (isdigit(str[i])){
        num *= 10;
        num += str[i] - '0';
      }
      else {
        ans += num;
        num = 0;
      }
    }
    ans += num;
  }
  cout << ans << endl;

  return (0);
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
long long n,k,x,y,z;
int main()
{
    cin>>n>>k>>x>>y;
    for(int i=1;i<=n;i++)
    	if(i<=k)z+=x;
    	  else z+=y;
    cout<<z;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] list = br.readLine().split(" ");
			int W = Integer.parseInt(list[0]);
			int H = Integer.parseInt(list[1]);
			int x = Integer.parseInt(list[2]);
			int y = Integer.parseInt(list[3]);
			int r = Integer.parseInt(list[4]);


			if (x > 0 && y > 0 && W >= x + r && H >= y + r) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17092
#include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
  int N, M;
	cin >> N >> M;
	int dtc[N], ftg[M];
	for(int i=0; i<N; i++) {
		cin >> dtc[i];
	}
	for(int i=0; i<M; i++) {
		cin >> ftg[i];
	}

	int dp[N][M];
	int temp;
	for(int i=0; i<N; i++) {
		for(int j=0; j<M; j++) {
			if(i-1-j >= 0) dp[i][j] = 2000000000;
			else {
				temp = dtc[i] * ftg[j];
				if(0<i) dp[i][j] = temp + dp[i-1][j-1];
				else dp[i][j] = temp;
				if(0<j && dp[i][j] > dp[i][j-1]) dp[i][j] = dp[i][j-1];
			}
		}
	}

	cout << dp[N-1][M-1] << endl;
}

Measured memory_bytes: 4316
#include <stdio.h>
int main(){
bool a[31];
int temp;
for(int i=1;i<31;i++)a[i]=true;
for(int i=0;i<28;i++){
scanf("%d",&temp);
a[temp]=false;
}
for(int i=1;i<31;i++)if(a[i])printf("%d\n",i);
}

Measured memory_bytes: 2592
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

const int maxn = int(1e5)+5;

int p[maxn];

int main(void)
{
	int n;
	scanf("%d", &n);
	for(int i = 1;i <= n;i++) scanf("%d", &p[i]);

	int res = 0, prev = -1;
	for(int i = 1;i <= n;i++)
	{
		if(p[i] == i)
		{
			if(prev == -1) prev = i;
		}
		else
		{
			if(prev != -1)
			{
				res += ceil((i-prev)/2.0);
				prev = -1;
			}
		}
	}
	if(prev != -1) res += ceil((n+1-prev)/2.0);
	printf("%d\n", res);
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;

int main(){
  string a;
  int b;
  map<string,set<int> > kok;
  map<string,set<int> >::iterator it;
  while(cin >> a >> b){
    it = kok.find(a);
    if(it != kok.end())
      it->second.insert(b);
    else{
      set<int> p;
      p.insert(b);
      kok[a] = p;
    }
  }
  for(it=kok.begin(); it!=kok.end(); ++it){
    cout << it->first << endl;
    set<int>::iterator i;
    int u = 0;
    for(i=it->second.begin(); i!=it->second.end(); ++i){
      cout << *i;
      if(u != it->second.size()-1)
	cout << " ";
      u++;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+4;
vector <int> v;
int a[N];
int mx[N][25];
int len;
int n;
int jump(int x, int y)
{
	int ans = 0;
	for(int i=19;i>=0;i--)
	{
		if(mx[x][i] < y)
		{
			x = mx[x][i];
			ans += (1<<i);
		}
	}
 
	return ans+1;
}
 
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	cin>>len;
 
	for(int i=1;i<=n;i++)
	{
		mx[i][0] = lower_bound(a+1, a+1+n, a[i] + len + 1) - (a+1);
		// cout<<mx[i][0]<<'\n';
	}
 
 
	for(int j=1;j<=19;j++)
	{
		for(int i=1;i<=n;i++)
		{
			mx[i][j] = mx[mx[i][j-1]][j-1];
		}
	}
 
	int q;
	cin>>q;
	while(q--)
	{
		int i,j;
		scanf("%lld %lld",&i,&j);
		if(i > j)
			swap(i,j);
 
		cout<<jump(i,j)<<'\n';
	}
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	double r;
	cin >> r;
	double ans = PI * 2 * r;
	printf("%.6f\n", ans);
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

vector<int> zalgorithm(vector<int>& s) {
    int n = s.size();
    vector<int> ret(n, 0);
    ret[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i + j < n && s[j] == s[i + j])
            j++;
        ret[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (i + k < n && k + ret[k] < j)
            ret[i + k] = ret[k], k++;
        i += k;
        j -= k;
    }
    return ret;
}

int N, a[202020], b[202020];

void solve() {
    vector<itn> A(N);
    vector<int> B(N);
    FOR(N) {
        A[i] = a[i] ^ a[(i + 1) % N];
        B[i] = b[i] ^ b[(i + 1) % N];
    }
    vector<int> S;
    S.insert(S.end(), all(B));
    S.eb(INF);
    S.insert(S.end(), all(A));
    S.insert(S.end(), all(A));
    S.erase(S.end() - 1);
    //for (auto& c : S) {
    //  cout << c << endl;
    // }
    // cerr << endl;
    auto z = zalgorithm(S);

    FOR(i, 0, N) {
        if (z[N + 1 + i] == N) {
            cout << i << " " << (b[0] ^ a[i]) << endl;
        }
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(N)
    cin >> a[i];
    FOR(N)
        cin >> b[i];


    solve();
    return 0;
}


Measured memory_bytes: 19920
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int W, H, N;
    cin >> W >> H >> N;

    vector<vector<bool> > c(H, vector<bool>(W));

    for(int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        
        if(a == 1) {
            for(int j = 0; j < H; j++) {
                for(int k = 0; k < x; k++) {
                    c[j][k] = true;
                }
            }
        } else if(a == 2) {
            for(int j = 0; j < H; j++) {
                for(int k = x; k < W; k++) {
                    c[j][k] = true;
                }
            }
        } else if(a == 3) {
            for(int j = 0; j < y; j++) {
                for(int k = 0; k < W; k++) {
                    c[j][k] = true;
                }
            }
        } else {
            for(int j = y; j < H; j++) {
                for(int k = 0; k < W; k++) {
                    c[j][k] = true;
                }
            }
        }
    }

    int ans = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(c[i][j]) continue;
            ans++;
        }
    }

    cout << ans << endl;
}

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

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

  ll N; cin >> N;
  if (N % 2 == 1) {
    cout << 0 << '\n';
    return 0;
  }
  ll ans = N / 10;
  N /= 10;
  while (N > 0) {
    ans += (N / 5);
    N /= 5;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256