akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		boolean ch = true;
		for(;N>0;N--) {
			int a = sc.nextInt();
			if(a%2==0) {
				if((a%3 != 0)&&(a%5 != 0)) {
					ch = false;
					break;
				}
			}
		}
		if(ch) {
			pw.print("APPROVED");
		}else {
			pw.print("DENIED");
		}
		pw.close();
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,x[N],y[N],next[N],p[N],f[N];

int travel(int x){
	int ans=0;
	for (int t=p[x];t;t=next[t])
		if (y[t]!=f[x])
		f[y[t]]=x,ans+=travel(y[t]);
	return ans^1;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n-1;i++){
		x[2*i-1]=y[2*i]=read();
		y[2*i-1]=x[2*i]=read();
		next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1;
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
	}
	printf(travel(1)?"First\n":"Second\n");
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	while(1){
		string s; cin >> s; if(s=="#") return 0;
		set<string>S; S.insert(s);
		for(int i=24;i>=0;i--){
			vector<string>vs;
			for(set<string>::iterator it = S.begin();it != S.end();++it){
				string s2 = *it;
				for(int j=0;j<s2.size();j++){
					if(s2[j] == 'a'+(i+1)) goto fail;
					if(s2[j] == 'a'+i){
						string s3 = s2;
						s3[j] = 'a'+(i+1);
						vs.pb(s3);
					}
				}vs.pb(s2); fail:;
			}
			S.clear();
			for(int j=0;j<vs.size();j++){
				if(S.find(vs[j]) == S.end()) S.insert(vs[j]);
			}
		}
		cout << S.size() << endl;
		if(S.size()<=10){
			for(set<string>::iterator it = S.begin();it != S.end();++it){
				cout << *it << endl;
			}
		}
		else{
			int c = 0;
			for(set<string>::iterator it = S.begin();;++it){
				cout << *it << endl; c++;
				if(c == 5) break;
			}c = 0;
			set<string>::iterator it = S.end(); it--;it--;it--;it--;it--;
			for(;;++it){
				cout << *it << endl; c++;
				if(c == 5) break;
			}
		}
		
	}
}

Measured memory_bytes: 5576
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;


int main(void){
	int p,q,r;
	int ans;
	cin >> p >> q >>r;

	if(p < q){
		if(q < r){
			ans = p + q;
		} else {
			ans = p + r;
		}
	} else {
		if(p < r){
			ans = q + p;
		} else {
			ans = q + r;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<climits>
#include<algorithm>
#include<vector>
#include<valarray>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iostream>
#include<iomanip>
using namespace std;
   
   
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define DREP(i,n) for(int i=n;i>0;i--)
#define Rep(i,m,n) for(int i=m;i<n;i++)
#define ReP(i,m,n) for(int i=m;i<=n;i++)
#define scani(a) scanf("%d",&a)
#define scand(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define readi(a) int a;scanf("%d",&a)
#define printi(a) printf("%d",a)
#define prints(s) printf("%s",s)
#define even(n) (((n)+1)%2)
#define odd(n) ((n)%2)
#define sg(x) ((x)?1:0)
#define LF printf("\n")
#define SPACE printf(" ")
#define pb push_back
#define mp make_pair
#define bs binary_search
#define all(a) (a).begin(),(a).end()
#define forall(itr,a) for(auto itr=(a).begin();itr!=(a).end();++itr)
   
typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<double,double> pdd;
typedef pair<int,int> pii;

const double pi = acos(-1.0);
double rad(double t){return t*pi/180.0;}
double deg(double d){return d*180.0/pi;}
template<typename T>T GCD(T x,T y){return y?GCD(y,x%y):x;}
template<typename T>T LCM(T x,T y){return x/GCD(x,y)*y;}
template<class T>ostream& operator<<(ostream& os,const set<T>& s){os<<"{";for(auto itr=s.begin();s.end() != itr;++itr){if(itr!=s.begin())os<<',';os<<*itr;}os<<"}";return os;}
template<class S,class T>ostream& operator<<(ostream& os,const pair<S,T>& p){os<<'('<<p.first<<','<<p.second<<')';return os;}
const int MOD = (int)pow(10,9) +7;
 
 
//begin global variable
//


//
//end   global variable

int main(){
  ios::sync_with_stdio(false);
  //begin main()
  //

  string t = "CODEFESTIVAL2016";
  string s ;
  cin >> s;
  int ans = 0;
  rep(i,s.size())
    if( s[i] != t[i] ) ans ++ ;
  cout << ans << endl;
  //
  //end   main()
  return 0;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0;i < 3;i++){
		if(s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
  int R, C;
  int white = 0;
  int black = 0;
  cin >> R >> C;

  vector<vector<char>> c(R, vector<char>(C));

  rep(i,R){
    rep(j,C){
      char tmp;
      cin >> tmp;
      c.at(i).at(j) = tmp;
      if(tmp == '.') white++;
      else black++;
    }
  }
  
  int sy = 0, sx = 0;
  int gy = R-1, gx = C-1;
  queue<pair<int, int>> q;
  pair<int, int> p_start(sy, sx);
  pair<int, int> p_end(gy, gx);
  vector<vector<int>> dist(R, vector<int>(C, INF));
  vector<vector<bool>> seen(R,vector<bool>(C, false));

  vector<int> dy = {-1, 0, 1, 0};
  vector<int> dx = {0, 1, 0, -1};

  dist.at(sy).at(sx) = 0;

  q.push(p_start);
  while(!q.empty()){
    pair<int, int> p;
    p = q.front(); q.pop();

    int y = p.first;
    int x = p.second;

    rep(i,4){
      int h = y + dy.at(i);
      int w = x + dx.at(i);

      if(w < 0 || w >= C) continue;
      if(h < 0 || h >= R) continue;
      if(c.at(h).at(w) == '#') continue;
      if(dist.at(h).at(w) != INF) continue;

      pair<int, int> p(h, w);
      q.push(p);
      dist.at(h).at(w) = min(dist.at(h).at(w), dist.at(y).at(x) + 1);
    }   
  }

  if(dist.at(gy).at(gx) != INF){
  	cout << white-dist.at(gy).at(gx)-1 << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoderMake.EX_NOMURA2020
{
    class N20B
    {

        static void Main(string[] args)
        {
            var t = Console.ReadLine();
            t = t.Replace("?", "D");
            Console.WriteLine(t);
        }
    }
}


Measured memory_bytes: 28952
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int t; cin >> t;
	REP(t) {
		int64_t n, m, a, b; cin >> n >> m >> a >> b;
		cout << atcoder::floor_sum(n, m, a, b) << endl;
	}

	return 0;
}

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

int main(){
	std::string s, t;

	std::cin >> s >> t;
	//英小文字であることを確認
	for(int i=0; i<s.size(); i++){
		if(s[i] >= 'a' && s[i] <= 'z'){
			continue;
		}
		else{
			std::cout << "No" << std::endl;
			return 0;
		}
	}

	if(0 < s.size() && 11 > s.size()){
		if(s == t.substr(0, s.size())){
			if(t.size()-1 == s.size() && (t[t.size()-1] >= 'a' && t[t.size()-1] <= 'z')){
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  string ans;
  for (char it:a) {
    if (it=='?') {
      ans+='D';
    }
    else {
      ans+=it;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3904
n, m = map(int, input().split())
h = list(map(int, input().split()))
good = [1 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        good[a-1] = 0
    elif h[a-1] > h[b-1]:
        good[b-1] = 0
    elif h[a-1] == h[b-1]:
        good[a-1] = good[b-1] = 0
print(sum(good))

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

typedef long long int ll;


int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll flag=min(n,b-1);
  ll ans=((a*flag)/b)-(a*(flag/b));
  cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> a(N); rep(i,N) cin>>a[i];
  sort(a.begin(),a.end());
  ll n=a[N-1]; a.pop_back();
  
  //n/2以下で最大のやつ
  ll ok=-1,ng=N-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(a[mid]<=n/2) ok=mid;
    else ng=mid;
  }
  ll left;
  if(ok==-1) left=-INF;
  else left=a[ok];
  
  //n+1/2以上で最小のやつ
  ok=N-1,ng=-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(a[mid]>=(n+1)/2) ok=mid;
    else ng=mid;
  }
  ll right;
  if(ok==N-1) right=INF;
  else right=a[ok];
  
  ll k;
  if(n/2-left<=right-(n+1)/2) k=left;
  else k=right;
  
  cout<<n<<" "<<k<<endl;
  
  return 0;
}

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

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

long long MOD = 1000000000 + 7;

int R,S,P;
ll solve(string t){
  ll ret = 0;

  vector<ll> r(t.size(), 0);
  vector<ll> s(t.size(), 0);
  vector<ll> p(t.size(), 0);

  if(t[0] == 'r'){
    p[0] = P;
  }
  if(t[0] == 's'){
    r[0] = R;
    
  }
  if(t[0] == 'p'){
    s[0] = S;
  }
  for(int i = 1; i < t.size(); i++){
    if(t[i] == 'r'){
      r[i] = max(s[i-1], p[i-1]);
      s[i] = max(r[i-1], p[i-1]);
      p[i] = max(s[i-1], r[i-1]) + P;
    }
    if(t[i] == 's'){
      r[i] = max(s[i-1], p[i-1]) + R;
      s[i] = max(r[i-1], p[i-1]);
      p[i] = max(s[i-1], r[i-1]);
    }
    if(t[i] == 'p'){
      r[i] = max(s[i-1], p[i-1]);
      s[i] = max(r[i-1], p[i-1]) + S;
      p[i] = max(s[i-1], r[i-1]);
    }
  }
  ret = max(r[t.size()-1], s[t.size()-1]);
  ret = max(ret, p[t.size()-1]);

  return ret;
}

int main(){
  cout << setprecision(10);
  int N,K;
  cin >> N >> K;
  cin >> R >> S >> P;
  string T;
  cin >> T;

  // modK の値ごとにジャンケンを分割して、それぞれで最適にすればいい
  ll ans = 0;
  string tmp = "";
  for(int i = 0; i < K; i++){
    for(int j = i; j < N; j+=K){
      tmp += T[j];
    }
    ans += solve(tmp);
    tmp = "";
  }
  cout << ans << endl;

}


Measured memory_bytes: 2944
#include  <iostream>
#include  <new>

using namespace std;

typedef long long  ll;


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

	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= 1000000000 + 7;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000]={2,3},i,j,k,c=2,b[100002][101],q,w[700];
int main(){
  for(i=4;i<150000;i++){
    for(k=1,j=2;j*j<=i;j++){
      if(i%j==0){k=0;break;}
    }
    if(k)a[c++]=i;
  }k=0;
  for(i=0;i<=100000;i++){
    if(i>=a[k])k++;
    for(q=0,j=k;j<k+25;j++){
      for(c=j;c<j+25;c++){
        w[q++]=a[j]+a[c];
      }
    }
    sort(w,w+q-1);
    for(c=0;c<=100;c++)b[i][c]=w[c];
  }
  while(cin>>i>>j){
    if(i<0)break;
    cout<<b[i][j-1]<<endl;
  }
}

Measured memory_bytes: 42528
use itertools::Itertools;
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        p:[Usize1; n],
        q:[Usize1; n],
    }

    let mut cp = 0i32;
    let mut cq = 0i32;
    let mut cnt = 0;
    for idx in (0..n).permutations(n) {
        cnt += 1;
        // println!("{:?}", idx);
        // println!("p:{:?}", p);
        // println!("q:{:?}", q);
        let mut eqp = true;
        let mut eqq = true;
        for i in 0..n {
            eqp = eqp && idx[i] == p[i];
            eqq = eqq && idx[i] == q[i];
        }
        if eqp {
            cp = cnt;
        }
        if eqq {
            cq = cnt;
        }
    }
    println!("{}", (cq - cp).abs());
}


Measured memory_bytes: 2108
import sys
import math
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
print(2*N*math.pi)

Measured memory_bytes: 65272
import numpy as np
n = int(input())
f = []
p = []
for i in range(n):
    f.append(list(map(int, input().split())))
for i in range(n):
    p.append(list(map(int, input().split())))

pattern = []
tmp = []
for i in range(n):
    tmp.append(f[i][0])
pattern.append(tmp)

for i in range(1, 10):
    tmp = []
    tmp_loop = pattern[:]
    for j in range( n):
        tmp.append(f[j][i])
    for pat in tmp_loop:
        pattern.append(list(np.array(pat)+np.array(tmp)))
    pattern.append(tmp)

ans = -100000000000
for pat in pattern:
    a = 0
    for i in range(n):
        a += p[i][pat[i]]
    ans = max(ans, a)
print(ans)


Measured memory_bytes: 17432
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct{
  char name[11];
  int time;
}DATA;



int main(){

  DATA *queue;
  int n,q,i,sumT=0,head=0,tail=0;

  scanf("%d%d",&n,&q);

  queue=(DATA *)malloc(sizeof(DATA)*(n+1));

  for(i=0;i<n;i++)scanf("%s%d",queue[i].name,&queue[i].time);

  tail=n;

  for(head=0;head!=tail;head++){
    if(head==n+1)head=0;
    if(q>=queue[head].time){
      sumT+=queue[head].time;
      printf("%s %d\n",queue[head].name,sumT);
    }else{
      sumT+=q;
      if(tail==n+1)tail=0;
      strcpy(queue[tail].name,queue[head].name);
      queue[tail].time=queue[head].time-q;
      tail++;
    }
  }

  free(queue);

  return 0;

}

Measured memory_bytes: 1148
#include<iostream>
#include<string>
using namespace std;
#define MAX_N 1000000
#define MOD 1000000007LL
long long modpow[MAX_N], fact[MAX_N], inv[MAX_N], factinv[MAX_N], dp[MAX_N];
int n, m, p;
void init() {
	fact[0] = 1; for (long long i = 1; i < MAX_N; i++) fact[i] = 1LL * fact[i - 1] * i % MOD;
	inv[1] = 1; for (long long i = 2; i < MAX_N; i++) inv[i] = 1LL * inv[MOD % i] * (MOD - MOD / i) % MOD;
	factinv[0] = 1; for (long long i = 1; i < MAX_N; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % MOD;
}
long long modmul(long long A, long long B, long long C) { return ((A*B) % MOD *C) % MOD; }
long long ncr(long long n, long long r) { return modmul(fact[n], factinv[r], factinv[n - r]); }
int main() {
	modpow[0] = 1; for (long long i = 1; i < MAX_N; i++) { modpow[i] = modpow[i - 1] * 3; modpow[i] %= MOD; }
	cin >> n >> m >> p; init();
	long long sum = 0, V = 1;
	for (long long i = 0; i <= m + p; i++) {
		dp[m + p - i] = V; V *= 2;
		if (i >= m)V -= ncr(i, i - m);
		if (i >= p)V -= ncr(i, i - p);
		V = (V + MOD*MOD) % MOD;
	}
	for (long long i = 0; i <= m + p; i++) {
		long long NN = (n - 1) + m + p - i, RR = n - 1;
		sum += modmul(ncr(NN, RR), dp[i], modpow[i]); sum %= MOD;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

ll dp[3030][3030]; //dp[i][j] = i番目までで重さをjにするための通り数

int main() {
    int N,S;
    cin >> N >> S;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    for(int i = 0;i < 3030;i++) {
        for(int j = 0;j < 3030;j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < 3030;j++) {
            if(j < vec.at(i)) {
                dp[i + 1][j] += dp[i][j] * 2;               
            }
            else {
                dp[i + 1][j] += dp[i][j] * 2;
                dp[i + 1][j] += dp[i][j - vec.at(i)];
            }
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[N][S] << endl;
}

Measured memory_bytes: 75344
#include<iostream>
#include<cstdio>
#include<complex>
#include<vector>
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
#define rep(i,a) for(int i=0;i<a;i++)
struct L:public vector<P>{
  L(const P &a,const P &b){
    push_back(a);push_back(b);
  }
};
const double EPS=1e-8;
const double PI=acos(-1);
double cross(P a,P b){
  return imag(conj(a)*b);
}
double area(const G &g){
  double S=0;
  for(int i=0;i<g.size();i++){
    S+=(cross(g[i],g[(i+1)%g.size()]));
  }
  return abs(S/2.0);
}
P crosspointLL(const L &l,const L &m){
  double A=cross(l[1]-l[0],m[1]-m[0]);
  double B=cross(l[1]-l[0],l[1]-m[0]);
  if(abs(A)<EPS&&abs(B)<EPS)return m[0];
  return m[0]+B/A*(m[1]-m[0]);
}
P turn(P p,double t){
  return p*exp(P(.0,t*PI/180.0));
}
int main(){
  int n,k;
  cin>>n>>k;
  G g(n);
  g[0]=P(1,0);
  rep(i,n-1)g[i+1]=turn(g[i],360./n);
  double out=area(g);
  //  cout<<out<<endl;
  P p=crosspointLL(L(g[0],g[k]),L(g[1],g[(1-k+n)%n]));
  G t(3);
  t[0]=g[0];
  t[1]=g[1];
  t[2]=p;
  out-=n*area(t);
  printf("%.9f\n",out);
}

Measured memory_bytes: 16700
#include <bits/stdc++.h>
using namespace std;
int f[20001],q[151];
int main()
{
//	memset(f,-1,sizeof(f));
	int a,b,c,x,num=0;
	cin>>a>>b>>c>>x;
	/*for(int i=1;i<=a;i++)
		q[i]=500;
	for(int j=a+1;j<=a+b;j++)
		q[j]=100;
	for(int k=a+b+1;k<=a+b+c;k++)
		q[k]=50;
	for(int i=1;i<=a+b+c;i++)
	{
		for(int j=x;j>=q[i];j--)
			f[j]=max(f[j],f[j-q[i]]+1);
	}
	cout<<f[x]<<endl;*/
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
		if(i*500+j*100+k*50==x) num++;
	cout<<num<<endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  int turn = 1;
  int a = 0, b = 0, c = 0;
  while(true){
    if(turn == 1){
      if(a == A.size()){
        cout << "A" << endl;
        return 0;
      }
      if(A[a] == 'a') turn = 1;
      else if(A[a] == 'b') turn = 2;
      else turn = 3;
      a++;
    }
    if(turn == 2){
      if(b == B.size()){
        cout << "B" << endl;
        return 0;
      }
      if(B[b] == 'a') turn = 1;
      else if(B[b] == 'b') turn = 2;
      else turn = 3;
      b++;
    }

    if(turn == 3){
      if(c == C.size()){
        cout << "C" << endl;
        return 0;
      }
      if(C[c] == 'a') turn = 1;
      else if(C[c] == 'b') turn = 2;
      else turn = 3;
      c++;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i;
	char even[50], odd[50], com[100] = {};
	
	scanf("%s",&even);
	scanf("%s",&odd);
	for(i = 0;i < 50;i++){
		com[i * 2] = even[i];
		com[i * 2 + 1] = odd[i];
	}
	i = 0;
	while('a' <= com[i]&&com[i] <= 'z'){
		printf("%c",com[i]);
		i++;
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int ans = 1<<30,a,b,c,n;
vector<int> l;

int solve(vector<int> d){
  int p = 0,aa = 0,bb = 0,cc = 0;
  for(int i = 0; i < n; i++){
    if(d[i] == 0) aa += l[i];
    else if(d[i] == 1) bb += l[i];
    else if(d[i] == 2) cc += l[i];
    if(d[i] != 3) p += 10;
  }
  if(aa == 0 || bb == 0 || cc == 0){
    return 1<<30;
  }
  p += abs(a - aa);
  p += abs(b - bb);
  p += abs(c - cc);
  p -= 30;
    return p;
}

void dfs(vector<int> d){
  if(d.size() == n){
    int now = solve(d);
    ans = min(ans,now);
    return;
  }
  for(int i = 0; i < 4; i++){
    d.push_back(i);
    dfs(d);
    d.pop_back();
  }
}

int main(){
  cin >> n >> a >> b >> c;
  l.resize(n);
  rep(i,n) cin >> l[i];
  vector<int> d;
  dfs(d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	for (long long ans = 0; ans < 50000; ans++) {
		if (static_cast<long long>(N) == static_cast<long long>(ans * 1.08)) {
			cout << ans;
			break;
		}
		else if(N<ans) {
			cout << ":(";
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

struct Linear_Sieve{
int n;
vector<int> lp,primes;
//lp[i]...the least prime of i. primes...prime numbers
Linear_Sieve(int n = 1):n(n),lp(n+1){
    for(int i = 2;i < n+1;i++){
        if(lp[i] == 0) {
            primes.push_back(i);
            lp[i] = i;
        }
        for(int j = 0;j<primes.size() && primes[j] <= lp[i] && i*primes[j] < n+1; ++j) lp[i*primes[j]] = primes[j];
    }
}
bool isPrime(int x) {return lp[x] == x;}

vector<int> factorList(int x){
    //make list which contains prime factors of x. Ans it toralates multipled components.
    vector<int> res;
    while(x != 1){
        res.push_back(lp[x]);
        x /= lp[x];
    }
    return res;
}

vector<pair<int,int>> factor(int x){
        //make list of pairs which couple prime factor and multiplicity.
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return{};
    vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
    for(int p : fl){
        if(res.back().first == p){
            res.back().second++;
        }else{
            res.emplace_back(p,1);
        }
    }
    return res;
}
};

int main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    Linear_Sieve s(1000005);
    map<int,int> mp;
    rep(i,n)for(auto p:s.factor(a[i])) mp[p.first] = max(mp[p.first],p.second);
    mint k = 1;
    for(auto it=mp.begin();it!=mp.end();it++){
        P p = *it;
        k *= mint(p.first).pow(p.second);
    }
    //cout << k << endl;
    mint ans = 0;
    rep(i,n){
        ans += k*mint(a[i]).inv();
    }

    cout << ans << endl;

}

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

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

    int a[n+1] = {};
    for(int i = 1; i <= n; i++)  cin >> a[i];
    
    bool b[n+1] = {};

    int cnt = 0, blight = 1;
    bool loop = false;
    while(blight != 2 && !loop){
        cnt++;
        b[blight] = true;
        blight = a[blight];
        if(b[blight])    loop = true;
    }

    if(loop)    cout << -1 << endl;
    else        cout << cnt << endl;

    return 0;
}

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

int main(){
  int n, c = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if((i+1)%2 == 1 && a[i]%2 == 1) c++;
  }
  cout << c << endl;
}

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

int main(){
	int x1[4] = {-1,0,0,1}, y1[4] = {0,1,-1,0};
	int x2[4] = {-1,-1,1,1}, y2[4] = {-1,1,-1,1};
	int x3[4] = {-2,0,0,2}, y3[4] = {0,-2,2,0};
	int p[10][10], x, y, s, nx, ny, maxl = 0, count = 0;
	for(int i = 0;i < 10;i++)
		for(int j = 0;j < 10;j++)p[i][j] = 0;
	char c;
	while(cin >> x >> c >> y >> c >> s){
		
		//cout << x << " " << y << " " << s << endl;
		//if(s == 0)break;
		
		p[y][x]++;
		for(int i = 0;i < 4;i++){
			nx = x + x1[i];ny = y + y1[i];
			if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
		}
		if(s > 1){
			for(int i = 0;i < 4;i++){
				nx = x + x2[i];ny = y + y2[i];
				if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
			}
			if(s == 3){
				for(int i = 0;i < 4;i++){
					nx = x + x3[i];ny = y + y3[i];
					if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
				}
			}
		}
	}
	/*for(int i = 0;i < 10;i++){
		for(int j = 0;j < 10;j++)cout << p[i][j] << " ";
		cout << endl;
	}*/
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < 10;j++){
			maxl = max(maxl, p[i][j]);
			if(!p[i][j])count++;
		}
	}
	cout << count << endl << maxl << endl;
	return 0; 
}

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

int main()
{
  int n; cin >> n;
  vector<vector<int>> g(n);
  rep(i, n-1) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> d1(n, -1);
  {
    d1[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      int now = q.front(); q.pop();
      for (auto v:g[now]) {
        if (d1[v] < 0) {
          q.push(v);
          d1[v] = d1[now] + 1;
        }
      }
    }
  }

  vector<int> d2(n, -1);
  {
    d2[n-1] = 0;
    queue<int> q;
    q.push(n-1);
    while (!q.empty()) {
      int now = q.front(); q.pop();
      for (auto v:g[now]) {
        if (d2[v] < 0) {
          q.push(v);
          d2[v] = d2[now] + 1;
        }
      }
    }
  }

  int fen = 0;
  int snu = 0;
  rep(i, n) {
    if (d1[i] > d2[i]) snu++;
    else fen++;
  }

  if (fen <= snu) cout << "Snuke" << endl;
  else cout << "Fennec" << endl;

  return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
    //file();
    
    string s;
    cin>>s;
    int ans = 0;
    int n = s.size();
    string prev = "";
    int lel = 1;
    forn(i,n){
        if(lel){
            ans++;
            lel = 0;
        }
        else{
            if(s[i]==s[i-1]){
                if(i<n-1){
                    lel = 1;
                    ans++;
                    i++;
                }
                else{
                    break;
                }
            }
            else{
                ans++;
            }
        }
    }
    cout<<ans;

  return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int left = 0;
        int[] w = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
            left = Math.max(left, w[i]);
        }
        left = Math.max(left, sum / k);
        int right = sum;

        while(left < right) {
            int mid = (left + right) / 2;
            if(possible(w, n, k, mid)) {
                right = mid;
            }else {
                left = mid + 1;
            }
        }

        System.out.println(left);

        sc.close();
    }

    private static boolean possible(int[] w, int n, int k, int ans) {
        int tmp = ans;
        for(int i = 0; i < n; i++) {
            if(w[i] <= tmp) {
                tmp -= w[i];
            }else {
                if(k == 1) return false;
                k--;
                tmp = ans - w[i];
            }
        }
        return true;
    }
}


Measured memory_bytes: 70772
s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
a=0
for i in range(26):
  if m[i]==0:
    print(chr(i+97))
    a=1
    break
if a==0:
  print("None")

Measured memory_bytes: 3188
fun main() {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val sunuke = mutableSetOf<Int>()
    repeat(k) {
        readLine()!!
        sunuke.addAll(readLine()!!.split(" ").map(String::toInt))
    }

    println(n - sunuke.size)
}





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

int main()
{
	int A,B,V,W,T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;
	
	string out = "NO";
	if( V > W ) {
		if( abs(A-B) / (double)(V-W) <= T ) {
			out = "YES";
		}
	}
	cout << out;
	
	return 0;
}


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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k; cin >> k;
	string s; cin >> s;

	if(s.length() > k){
		string s2 = s.substr(0,k);
		cout << s2 << "..." << endl;
	} else {
		cout << s << endl;
	}	
	return 0;
}


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

using namespace std;
static const int MAX = 10;

int factorial(int n) {
    int f = 1;
    for (int i = 1; i <= n; ++i) f *= i;
    return f;
}

double distance(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1;
    int dy = y2 - y1;
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    int N, X[MAX], Y[MAX], R[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        cin >> Y[i];
        R[i] = i;
    }

    double sum = 0;
    do {
        for (int j = 1; j < N; ++j) {
            int from = R[j - 1];
            int to = R[j];
            sum += distance(X[from], Y[from], X[to], Y[to]);
        }
    } while (next_permutation(R, R + N));

    cout.precision(10);
    cout << sum / factorial(N) << endl;

    return 0;
}


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

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	
map<string,int>mp;

while(n--)
{
    string s;
    cin>>s;
    
    mp[s]++;
}

    if(mp.find("AC")!=mp.end())
    {cout<<"AC x "<<mp["AC"]<<endl;}
    else
    {cout<<"AC x 0"<<endl;}
    
    
     
    
     if(mp.find("WA")!=mp.end())
            {cout<<"WA x "<<mp["WA"]<<endl;}
        else
         {cout<<"WA x 0"<<endl;}
     
     if(mp.find("TLE")!=mp.end())
        {cout<<"TLE x "<<mp["TLE"]<<endl;}
        else
        {cout<<"TLE x 0"<<endl;}
     
     if(mp.find("RE")!=mp.end())
         {cout<<"RE x "<<mp["RE"]<<endl;}
     else
        {cout<<"RE x 0"<<endl;}
	
	return 0;
}


Measured memory_bytes: 3584
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string str; cin >> str;

	int ans = 0;

	int k = 0;
	while(1){
		// print(k, str);
		if(k > str.size() / 2) break;
		int rev_k = str.size() - 1 - k;
		if(str[k] != str[rev_k]){
			if(str[k] != 'x' && str[rev_k] != 'x'){
				cout << -1 << endl;
				return 0;
			}
			else if(str[k] == 'x'){
				str.insert(str.begin() + rev_k + 1, 'x');
				ans++;
			}
			else{
				str.insert(str.begin() + k, 'x');
				ans++;
			}
		}
		k++;
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
#define N 150000

typedef struct node {
  int id;
  int depth;
  struct node* parent;
  struct node* child;
  struct node* next;
} NODE;

void calcDepth(NODE*);

int main(){
  int i, j, n;
  int root;
  int id, nchild;
  int childid;
  NODE* last;
  NODE node[N];

  // input the number of nodes
  scanf("%d", &n);

  // input the information of nodes
  for(i = 0; i < n; i++) {
    scanf("%d", &id);  // input the node id
    node[id].id = id;
    scanf("%d", &nchild);  // input the number of children
    for(j = 0; j < nchild; j++) {
      scanf("%d", &childid);  // input the child id
      node[childid].id = childid;
      
      if(j == 0){
	node[id].child = &node[childid];
	last = node[id].child;
      }
      else {
	last->next = &node[childid];
	last = last->next;
      }
      last->parent = &node[id];
    }
  }

  //depth
  i = 0;
  while(1) {
    if(node[i].parent == NULL){
      root = i;
      break;
    }
    i++;
  }
  calcDepth(&node[root]);

  // output
  for(i = 0; i < n; i++) {
    // node id
    printf("node %d: ", i);
    // the parent of node
    if(node[i].parent == NULL) printf("parent = -1, ");
    else printf("parent = %d, ", node[i].parent->id);
    // node depth
    printf("depth = %d, ", node[i].depth);
    // the type of node
    if(node[i].parent == NULL) printf("root, ");
    else if(node[i].child == NULL) printf("leaf, ");
    else printf("internal node, ");
    // child
    last = node[i].child;
    printf("[");
    while(last != NULL) {
      printf("%d", last->id);
      last = last->next;
      if(last != NULL) printf(", ");
    }
    
    printf("]\n");
  }

  return 0;
}

void calcDepth(NODE* node) {
  // Preorder walk
  NODE *last;

  last = node;
  if(last == NULL) return;
  if(last->parent == NULL) last->depth = 0;
  else last->depth = last->parent->depth + 1;

  last = last->child;
  while(last != NULL) {
    calcDepth(last);
    last = last->next;
  }
}



Measured memory_bytes: 4932
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
//#define ONLINE_JUDGE
long long power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     
    x = x % p; 
    if (x == 0) return 0; 

    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
int main()
{
	/*
		Jainam Shah's Code
	*/
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ll A;
	long double B;
	cin>>A>>B;
	long long ans = A*B;
	cout<<ans<<endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
# define ll      long long 
# define in      freopen("input.txt", "r", stdin);
# define out     freopen("output.txt", "w", stdout);
# define all(vc) vc.begin(),vc.end()
# define str     string 
# define pb      push_back
# define speed   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
ll a,b,c,d,e,f,mn=1e9,mx,cnt,bnt,sum; str s,cal,kcal;
set <ll> st; map <char, int> mp; vector <ll> vc1;
void botsolve(){
	int right1=s.size()-1,left1=0;
	for (int i = 0; i <(int) s.size(); ++i){
		if(s[right1]=='Z' && sum==0){
			cnt+=(s.size()-1)-right1;
			sum++;
		}
		if(s[left1]=='A' && mx==0){
			cnt+=left1;
			mx++;
		}
		right1--;
		left1++;
	}
	cout<<s.size()-cnt;
}
int main(){
	speed;
	//in out
    cin>>s;
    botsolve();

	time;
	return 0;
}

Measured memory_bytes: 720
#include <stdio.h>

int main(void){
int a,b,c,d,e,n,min=125,Cnt =0;

scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);

	//kuriage
if(a%10 != 0){
  	min = a;
a+=(10-(a%10));}

if(b%10 != 0){
	if(b%10<min%10)
min = b;
b+=(10-(b%10));	
	}
	
	if(c%10 != 0){
if(c%10<min%10)
min = c;
c+=(10-(c%10));	}


	if(d%10 != 0){
if(d%10<min%10)
min = d;
d+=(10-(d%10));	}

	if(e%10 != 0){
if(e%10<min%10)
min = e;
e+=(10-(e%10));	}

  
Cnt+=(a+b+c+d+e);
  
  
if(min != 125){
Cnt+=min;
min+=(10-(min%10));
Cnt-=min;}


printf("%d",Cnt);

return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ab = a * b % 2;

    if(ab==0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 21844
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
    }

    let mut ans = vec![];
    for _ in 0..N {
        ans.push('A');
        ans.push('C');
        ans.push('L');
    }

    echo!(ans.joinToString(""));
}


Measured memory_bytes: 2160
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use std::*;

#[allow(dead_code)]
const MOD: i128 = 100_000_007;

#[fastout]
fn main() {
    input!{
        n : usize,
        k : usize,
    }
    let mut vec = vec![false; n];
    for _ in 0..k {
        input!{
            tmp : usize,
            lis : [usize; tmp]
        }
        for it in lis {
            vec[it - 1] = true;
        }
    }
    let mut ans = 0;
    for it in vec {
        if !it {
            ans += 1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2144