akhauriyash/Code-Regression huggingface dataset:
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
num=int(input())
list=[int(input()) for i in range(num)]

for n in list:
  row1 = [0 if i == n else i for i in row1]
  row2 = [0 if i == n else i for i in row2]
  row3 = [0 if i == n else i for i in row3]

# 横
if row1.count(0) == 3 or row2.count(0) == 3 or row3.count(0) == 3:
  print('Yes')

# 縦
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[1]==0 and row2[1]==0 and row3[1]==0:
  print('Yes')
elif row1[2]==0 and row2[2]==0 and row3[2]==0:
  print('Yes')

# ななめ
elif row2[1] == 0:
  if row1[0] == 0 and row3[2] == 0:
    print('Yes')
  elif row1[2] == 0 and row3[0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3064
n = int(input())
# n = 703
# n = 123456789
n -= 1
char = ['a','b','c','d','e','f','g','h','i','j','k','l',
             'm','n','o','p','q','r','s','t','u','v','w','x','y','z']

s = ""
f = 0
while True:
    s = s + char[n % 26]
    n = n // 26 - 1
#     print(n)
    if n <= -1:
        break
print(s[::-1])

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>

int N;
std::string s, t;
int main() {
    std::cin >> N;
    std::cin >> s;
    std::cin >> t;
    
    int cmn = 0;
    for(int i=0; i<N; ++i) {
        bool f = true;
        for(int j=0; i+j<N; ++j) {
        	if(s[i+j] != t[j]){
	    f = false;
	    break;
        	}
        }
        if(f){
            cmn = std::max(cmn, N-i);        	
        }
    }
    std::cout << 2*N - cmn << std::endl;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k);
    }
};

int main(){
    ll n, k;
    cin >> n >> k;

    if(n < k){
        cout << 0 << endl;
        return 0;
    }

    ModComb mc(1001);
    ll ans = modpow(k, n);
    for(int i = 1; i < k; i++){
        if(i%2 == 1)    ans = (ans + mod - (mc.nCk(k, i)*modpow(k-i, n))%mod )%mod;
        else            ans = (ans + mc.nCk(k, i) * modpow(k-i, n));
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3124
#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: 3040
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    vector<int> time(5), p(5);
    for(int i=0; i<5; i++){
        cin >> time[i];
        p[i] = i;
    }

    int sum = 0;
    int ans = 10000;
    do{
        sum = 0;
        for(int i=0; i<5; i++){
            while(sum%10!=0) sum++;
            sum += time[p[i]];
        }
        ans = min(sum, ans);
    }while(next_permutation(p.begin(), p.end()));
    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<bool> b(n);
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        b[i]=false;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        int num=i+1;
        bool upper = false;
        for (int j = i+num; j < n; j+=num)
        {
            if(b[j]==true)
            {
                upper=!upper;
            }
        }
        bool isone = (a[i]==1);
        if(isone != upper)
        {
            b[i]=true;
        }
    }
    
    vector<ll> ans;
    for (int i = 0; i < n; i++)
    {
        if(b[i]==true)
        {
            ans.push_back(i+1);
        }
    }
    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        if(i!=0)cout<<" ";
        cout<<ans[i];
    }
    if(ans.size()>0) cout<<endl;

    return 0;
}

Measured memory_bytes: 3576
n,k=map(int,input().split())
mod=10**9+7 
 
def nCr(n, r, mod):#mod=10**9+7 
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
for i in range(1,k+1):
  if i==1:
    print(n-k+1)
  elif i>n-k+1:
    print(0)
  else:
    print((nCr(k-1,i-1,mod)*nCr(n-k+1,i,mod))%mod)

Measured memory_bytes: 3316
#include<stdio.h>
#define N 100

int main(){
  int n,i,j,a[N];
  int tmp,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	count++;
      }
    }
  }
  printf("%d",a[0]);
  for(i=1;i<n;i++){
    printf(" %d",a[i]);
  } 
      
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K;
  string S;
  cin >> N >> K >> S;

  S[K-1] -= 'A'-'a';
  cout << S << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

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

  ll a,b;
  std::cin>>a>>b;

  rep(i,1,100000){
    if(8*i/100==a&&i/10==b){
      std::cout<<i<<"\n";
      return 0;
    }
  }

  std::cout<<-1<<"\n";

  return 0;
}



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

using namespace std;

int main()
{
    int n, x = 0, max = 0;
    string s;

    cin >> n >> s;
    int i;
    for (i = 0; i < n; i++)
    {
        if (s[i] == 'I')
            x++;
        else if (s[i] == 'D')
            x--;
        if (max < x)
            max = x;
    }
    cout << max<< endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[3005];

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    REP(i, N) {
        ans += A[i] - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = int(sys.stdin.readline())
answer = 0

for x in range(max):
    n = sys.stdin.readline()
    if isprime(int(n)):
        answer += 1

print(answer)

Measured memory_bytes: 5672
using System;

namespace abc164_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);

            while (a > 0 && c > 0)
            {
                c -= b;
                if(c <= 0)
                {
                    break;
                }
                a -= d;
            }

            if(c <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }

    }
}


Measured memory_bytes: 27524
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> b(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		cin >> b[i];
	}

	vector<int> a(n);
	for (int i = 1; i < n - 1; ++i) {
		a[i] = min(b[i - 1], b[i]);
	}

	a[0] = b[0];
	a[n - 1] = b[n - 2];
	int sum = accumulate(a.begin(), a.end(), 0);;
	
	cout << sum << "\n";

	return 0;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int N;
  cin >> N;
  vector<int> w(N);
  for (int i = 0; i < N; i++) cin >> w[i];

  int ans = 1e9;
  for (int i = 0; i < N - 1; i++) {
    int a = 0, b = 0;
    for (int j = 0; j <= i; j++) {
      a += w[j];
    }
    for (int j = i + 1; j < N; j++) {
      b += w[j];
    }
    ans = min(ans, abs(a - b));
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
	int f=1,sum=0;
	char x=getchar();
	for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
	for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
	return f*sum;
}

#define M 1000005
int n,m;
char s[M];
int e_size,head[M],vis[M];

struct node {int v,nxt;}e[M*2];

inline void e_add(int u,int v) {
	e[++e_size]=(node){v,head[u]};
	head[u]=e_size;
}

inline void dfs(int x) {
	vis[x]=1;
	for(int i=head[x];i;i=e[i].nxt) {
		int v=e[i].v;
		if(vis[v]==1) {
			puts("Yes");
			exit(0);
		}
		if(vis[v]==0) dfs(v);
 	}
 	vis[x]=-1;
}

int main () {
//	freopen("a.in","r",stdin);
	n=read(),m=read();
	scanf("%s",s+1);
	for1(1,m,i) {
		int x=read(),y=read();
		if(s[x]==s[y]) e_add(x,y+n),e_add(y,x+n);
		else e_add(x+n,y),e_add(y+n,x);
	}
	for1(1,n,i) if(!vis[i]) dfs(i);
	puts("No");
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int A[51][51];
int B[51][51];
int main(){
	int N,M;
	cin>>N>>M;
	REP(i,N){
	    string S;
	    cin>>S;
	    REP(j,N){
	        if(S[j]=='.'){
	           A[i][j]=0;
	        }else{
	           A[i][j]=1;
	        }
	    }
	}
	REP(i,M){
	    string S;
	    cin>>S;
	    REP(j,M){
                if(S[j]=='.'){
                   B[i][j]=0;
                }else{
                   B[i][j]=1;
                }
	    }
	}
	bool ans=false;
	REP(i,N-M+1){
	    REP(j,N-M+1){
	        bool check=true;
	        REP(k,M){
	            REP(l,M){
	                if(A[i+k][j+l]!=B[k][l]){
	                   check=false;
	                }
	            }
	        }
	        if(check)ans=true;
	    }
	}
	if(ans){
	   cout<<"Yes"<<endl;
	}else{
           cout<<"No"<<endl;
        }
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	ios_base::sync_with_stdio(false);
	cin.tie(0);
 	string a,b;
 	int c,d;
 	string s;
 	cin>>a>>b>>c>>d>>s;
 	if(s==a)
 	{
 		c--;
 		cout<<c<<' '<<d;
	}
	else
	{
		d--;
		cout<<c<<' '<<d;
	}
	return 0;
}


Measured memory_bytes: 256
x, y, z = gets.chomp.split(" ").map(&:to_i)
sanka = Array.new(x, y-z)

z.times do
  n = gets.to_i
  sanka[n-1] += 1 
end

sanka.each do |e|
  if e > 0
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 3196
function Main(input) {
	data = input.trim()
	if (data.length % 2 == 1) {
		console.log("No")
		return
	}
	for (var i = 0, j = data.length - 1; i < j; ++i, --j) {
		if (!((data[i] == 'b' && data[j] == 'd') ||
			(data[i] == 'd' && data[j] == 'b') ||
			(data[i] == 'p' && data[j] == 'q') ||
			(data[i] == 'q' && data[j] == 'p'))) {
				console.log("No")
				return
		}
	}
	console.log("Yes")
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int n, a[201], cnt;
  bool flag = 1;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cnt = 0;
  while(flag){
    flag = 1;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        flag = 0;
        break;
      } 
    }
    if(flag){
      cnt++;
      for(int i = 0; i < n; i++) a[i] /= 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,h[200001];
  cin >> N;
  cout << "Christmas";
  REP(i,25-N)cout << " Eve";
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int r=100000;
int n,i;

scanf("%d",&n);


for(i = 0; i<n; i++){
 r = r*1.05;


if(r%1000 > 0){
r=r/1000*1000+1000;
}
}
printf("%d\n",r);

return 0;
}


Measured memory_bytes: 1984
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    auto NAB = s_.split.map!(to!long)();
    immutable N=NAB[0], A=NAB[1], B=NAB[2];
    if(A>B || (A<B && N<2)) return 0;
    return (B-A)*(N-2)+1;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

}

class Magatro
{
    private string S;
    private void Scan()
    {
        var sc=new Scanner();
        S=sc.Next();
    }

    public void Solve()
    {
        Scan();
        int l=0,r=S.Length-1;
        int cnt=0;
        while(l<r)
        {
            if(S[l]==S[r])
            {
                l++;
                r--;
            }
            else if(S[r]=='x')
            {
                r--;
                cnt++;
            }
            else if(S[l]=='x')
            {
                l++;
                cnt++;
            }
            else
            {
                Console.WriteLine("-1");
                return;
            }
        }
        Console.WriteLine(cnt);
    }

    static public void Main(string[]args)
    {
        new Magatro().Solve();
    }
}

Measured memory_bytes: 13664
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  string s;
  cin >> s;

  int n = s.size();

  for (int i = n - 2; i > 0; i -= 2) {
    if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
      cout << i << "\n";
      return 0;
    }
  } 
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,m,arr[100005],pen[100005];
     cin>>t>>m;
     for(int i=0;i<=t;i++)
        arr[i]=0,pen[i]=0;
     ll cnt=0,p=0;
     for(int i=0;i<m;i++)
     {
         string str;
         ll a;
         cin>>a>>str;
         if(arr[a]==2)
            continue;
         else if(arr[a]==1 && str=="WA")
         {
             pen[a]++;
         }
         else if(arr[a]==0 && str=="WA")
         {
             arr[a]++;
             pen[a]++;
         }
         else if(arr[a]==0 && str=="AC")
            arr[a]=2,cnt++;
         else if(arr[a]==1 && str=="AC")
            arr[a]=2,cnt++,p+=pen[a];

     }
     cout<<cnt<<" "<<p<<endl;
}


Measured memory_bytes: 1792
#import heapq
#import itertools
#import math
import numpy as np
#import sys

N = int(input())
A = list(map(int, input().split()))
A = np.array(A)

mod = 10 ** 9 + 7
s = 0

for i in range(60):
    #print(A)
    #print(A & 1)
    c = np.count_nonzero(A & 1) # 最下位のbitで0じゃないものの個数
    s += 2 ** i * c * (N - c) # https://qiita.com/ZhangChaoran/items/0d59eb5c95cd9414801d
    #print(c)
    A >>= 1
print(s % mod)


# N = int(input())
# #S = [input() for _ in range(H)]
# # T = [list(map(int,input().split())) for _ in range(N)]
# # sys.exit()
# #print(A)
# ans = 0
# for i in range(1,N) :
#     for j in range(i+1, N+1) :
#         #print(i,j)
#         ans += A[i - 1] ^ A[j - 1]

# # TLE orz
# print(ans % (10 ** 9 + 7))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;
int D;
ll dp[2][101][2];

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

  cin>>S>>D;
  int N=S.size();
  dp[0][0][0]=1;
  int crt=0,nxt=1;
  rep(i,N){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    rep(r,D)rep(f,2){
      rep(d,(f==0?S[i]-'0'+1:10)){
        (dp[nxt][(r+d)%D][!(f==0&&d==(S[i]-'0'))]+=dp[crt][r][f])%=mod;
      }
    }
    swap(crt,nxt);
  }
  cout<<(dp[crt][0][0]+dp[crt][0][1]+mod-1)%mod<<endl;

  return 0;
}


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

int main(void) {
    double A, B , H , M;
    double ans;
    cin >> A >> B >> H >> M;

    if(H==0 && M==0) {
      cout << abs(A-B) << endl;
      return 0;
    }

    double ang_A,ang_B;

    ang_A = 30.0*H + 0.5*M;
    ang_B = 6.0*M;

    double rad;
    rad = (ang_A-ang_B)*M_PI/180.0;
    ans = A*A + B*B - 2.0*A*B*cos(rad);
    printf("%.10lf\n",sqrt(ans) );

    return 0;
}


Measured memory_bytes: 4212
# AGC035A_XORCircle.py

import sys

n = int(input())
numbers = tuple(map(int, input().split()))
kinds = set(numbers)


def answer(ans):
    print(ans)
    sys.exit()


if kinds == {0}:
    answer("Yes")

elif len(kinds) == 2:
    a, b = sorted(kinds)
    if a == 0:
        if numbers.count(a) * 3 == n:
            answer("Yes")
        else:
            answer("No")
    else:
        answer("No")

elif len(kinds) == 3:
    a, b, c = tuple(kinds)
    if (numbers.count(a) == numbers.count(b)) and (numbers.count(b) == numbers.count(c)):
        if a ^ b == c:  # "ko(up)ko(down)"
            answer("Yes")
        else:
            answer("No")
    else:
        answer("No")
else:
    answer("No")


Measured memory_bytes: 14244
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main(void) {
	ll N, a = 1;
	scanf("%lld", &N);
	deque<int> ans;
	if (N == 0)printf("%d\n", 0);
	while (N) {
		if(abs(N) & abs(a))ans.push_front(1), N -= a;
		else ans.push_front(0);
		a *= -2;
	}
	for (auto v : ans)printf("%d", v);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main(){
	int N; cin>>N;
 char S[N];
 char T[N];
for(int i=0;i<N;i++){
  cin >> S >> T;
cout<<S[i]<<T[i];
}
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i = 0; i < N; i++) cin >> V[i];
  sort(V.begin(), V.end(), greater<int>());
  int a = 0;
  int b = 0;
  for(int i = 0; i < N; i++){
    if((i) % 2 == 0) a += V[i];
    else b+= V[i];
  }
  cout << a - b;
}


Measured memory_bytes: 256
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
#input = sys.stdin.readline
from heapq import*


N,M=map(int,input().split())
S=list(input())
S.reverse()
idx=0
lst=[]
while idx<N:
    for i in range(1,M+1)[::-1]:
        if i+idx<=N:
            if S[i+idx]=="0":
                idx+=i
                lst.append(i)
                break

    else:
        print(-1)
        exit()
lst.reverse()
print(" ".join([str(i) for i in lst]))


Measured memory_bytes: 51724
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii; 
typedef vector<string> vs;
typedef vector<vi> vvi;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout); 
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<4;i++){
		if(s[i]=='2')ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(((c+b-1)/b>(a+d-1)/d)?"No":"Yes")<<endl;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;

//Princess in Danger
public class Main{

	int[][] dist, wf;
	int INF = 1<<29, P = 107;
	int N, M, L, K, A, H;
	
	class E{
		int t, d;
		public E(int t, int d) {
			this.t = t;
			this.d = d;
		}
	}
	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner();
		for(;;){
			N = sc.nextInt(); M = sc.nextInt(); L = sc.nextInt(); K = sc.nextInt(); A = sc.nextInt(); H = sc.nextInt();
			if((N|M|L|K|A|H)==0)break;
			boolean[] ice = new boolean[N];
			ice[A] = ice[H] = true;
			while(L--!=0)ice[sc.nextInt()] = true;
			List<E>[] es = new ArrayList[N];
			for(int i=0;i<N;i++)es[i]=new ArrayList<E>();
			wf = new int[N][N];
			for(int[]a:wf)Arrays.fill(a, INF);
			while(K--!=0){
				int s = sc.nextInt(), t = sc.nextInt(), d = sc.nextInt();
				wf[s][t] = wf[t][s] = d;
				es[s].add(new E(t, d)); es[t].add(new E(s, d));
			}
			for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)wf[i][j]=Math.min(wf[i][j], wf[i][k]+wf[k][j]);
			dist = new int[N][M+1];
			for(int[]a:dist)Arrays.fill(a, INF);
			for(int i=0;i<=M;i++)dist[A][i] = 0;
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(N, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					int a = o1/P, b = o1%P, c = o2/P, d = o2%P;
					return (dist[a][b]+wf[a][H])-(dist[c][d]+wf[c][H]);
				}
			});
			q.add(A*P+M);
			int res = INF;
			while(!q.isEmpty()){
				int v = q.poll();
				int pos = v/P, m = v%P;
				if(pos==H){
					res = dist[pos][m]; break;
				}
				for(E e:es[pos]){
					for(int t=0;t+m<=M;t++){
						if(t>0&&!ice[pos])break;
						int nm = t+m-e.d;
						if(nm<0)continue;
						int w = dist[pos][m]+t+e.d;
						if(w<dist[e.t][nm]){
							q.remove(e.t*P+nm); dist[e.t][nm] = w;
							int r = nm-1;
							while(r>=0&&w<=dist[e.t][r]){
								q.remove(e.t*P+r); dist[e.t][r] = w; r--;
							}
							q.add(e.t*P+nm);
						}
					}
				}
				
			}
			System.out.println(res==INF?"Help!":res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
using namespace std;
int main(){
	int N,n,a,b; cin>>N;
	while(N--){
		cin>>n>>b;
		int up=0,dn=0;
		for(int i=0;i<n-1;i++){
			a=b;cin>>b;
			if(b-a>0&&up<b-a)up=b-a;
			if(b-a<0&&dn<a-b)dn=a-b;
		}
		cout<<up<<" "<<dn<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    d = [[] for i in range(n)]

    for _ in range(m):
        a, b = ns()
        a -= 1
        b -= 1
        d[a].append(b)
        d[b].append(a)

    start = set(d[0])
    term = set(d[n-1])

    for si in start:
        if si in term:
            print("POSSIBLE")
            exit(0)

    print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 50636
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = double(a) / double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
}



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

int main() {
  string s; cin >> s;
  int cnt = 0;
  for (int i = 1; i < s.size(); i ++) {
    if (s[i] == s[i-1]) continue;
    cnt ++;
  }

  cout << cnt << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  cout << (1000-(n%1000))%1000 << endl;
  return 0;
}


Measured memory_bytes: 3624
TEST = true
def pt(obj)
  p obj if TEST
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

def culc(a, n)
  r = a.map{|e, i| (e-n).abs}
  # puts r.join(',')
  r.inject(&:+)
end

a.map!.with_index{|e, i| e - i - 1}
a.sort!

puts [culc(a,a[n/2-1]), culc(a, a[n/2])].min



Measured memory_bytes: 21104
#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 IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
const ll N = 100005;
ll a[N][3],dp[N][3];

int32_t main(){
    IOS;
    ll i,j,k,n,m;
    cin >> n;
    fori2(n) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    
    ll ans = 0;    
    fori(3) {
        dp[1][i] = a[1][i];
        if(n==1){
            ans = max(ans,dp[1][i]);
        }
    }
    for(i = 2 ; i <= n ; i++){
        for(j = 0 ; j < 3 ; j++){
            ll &t = dp[i][j];
            for(k = 0 ; k <  3 ; k++){
                if(j==k) continue;
                t = max(t,dp[i-1][k] + a[i][j]);
            }
            if(i==n) {
                ans = max(ans,t);
            }
        }
    }
    cout << ans <<"\n";
} 

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

int main(){
int n,y;
cin >> n>>y;
int man,gosen,sen;

int ansman=-1,ansgosen=-1,anssen=-1;
rep(i,n+1)
{ 
  rep(j,n+1)
  {
    sen=n-i-j;//単位(枚)
   // cout<<i<<" "<<j<<" "<<sen<<endl;

    if(sen+i+j==n&& sen>=0)
    {
      if(i*10000+j*5000+sen*1000==y)
      {
        ansman=i;ansgosen=j;anssen=sen;
        
      }
    }


  }
}
cout <<ansman<<" "<<ansgosen<<" "<<anssen <<endl;
return 0;

}

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



int main() {
  string S;
  cin >> S;
  if (S == "hi" ||
      S == "hihi" ||
      S == "hihihi" ||
      S == "hihihihi" ||
      S == "hihihihihi")
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    int x[n];
    rep(i, n) { cin >> x[i]; }

    ll sum = 0;
    rep(i, n) { sum += min(x[i], k - x[i]); }
    cout << sum * 2 << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define INF (ll) 1e18
# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


int main(){
    IOS;
    make(ll,n);
    vector <vector <ll> >vec(n);
    fr(i,n){
        makevec(ll,vecc,3);
        vec[i]=vecc;
    }
    vector <vector <ll> > dp(n,vector <ll>(3));
    fr(i,3) dp[0][i]=vec[0][i];
    for(ll i=1;i<n;i++){
        fr(j,3){
            fr(k,2){
                dp[i][j]=max(dp[i][j],dp[i-1][(j+k+1)%3] + vec[i][j]);
            }
        }
    }
    cout<<*max_element(dp[n-1].begin(),dp[n-1].end())<<endl;


    return 0;
}


Measured memory_bytes: 11264
fun main(args: Array<String>) {
    val (N, M, K) = readLine()!!.split(" ").map { it.toInt() }

    (0..N).forEach {
        val a = -2 * it + N
        val b = K - it * M
        if (a != 0 && b % a == 0 && b / a in 0..M) {
            println("Yes")
            return
        }
    }
    println("No")
}


Measured memory_bytes: 37944
#include <iostream>

using namespace std;

int main(){
    int n;
    long long int ans = 0;
    cin >> n;

    for(int i = 1;i <= n;i++){
        if(i % 3 == 0 || i % 5 == 0)continue;
        ans += i;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
n,m=map(int,input().split())
acset=set()
finacset=set()
penalty=0
pslist=[]

for i in range(m):
	p,s=input().split()
	p=int(p)
	pslist.append([p,s])
	
	if s == "AC":
		finacset.add(p)

for ps in pslist:
	p=ps[0]
	s=ps[1]
	
	if s == "AC":
		acset.add(p)
	else:
		if p in finacset and not p in acset:
			penalty += 1

output=[str(len(acset))," ",str(penalty)]
print("".join(output))



Measured memory_bytes: 32920
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000
#define MAX 1299709

// sieve of Eratosthenes (prime num)
bool p[MAX+1]; //prime number=true
void prime(int n){
  rep(i,n+1) p[i]=true;
  p[0]=p[1]=false;
  for(int i=2;i<=n;i++){
    if(p[i]){
      for(int j=i*2; j<=n; j+=i){
	p[j]=false;
      }
    }
  }
}

int solve(int k){
  if(p[k]) return 0;
  int s=k, l=k; //small, large
  while(!p[s]) s--;
  while(!p[l]) l++;
  return l-s;
}

int main(){
  prime(MAX);
  int k;
  while(scanf("%d", &k), k){
    cout << solve(k) << endl;
  }
  return 0;
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll A,B;
    cin>>A>>B;
    ll C=__gcd(A,B);
    map<ll,ll> m;
    m=prime_factor(C);
    cout<<m.size()+1<<endl;
}


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

class median_tree{
public:
    priority_queue<int>lower_than_med,higher_than_med;
    int count=0;
    long long low=0;
    long long high=0;
    long long median=0;
    long long y;
    long long push(int x){
        count=1-count;
        if (count){
            higher_than_med.push(-x);
            y=higher_than_med.top();
            higher_than_med.pop();
            lower_than_med.push(-y);
            low+=y;
            high+=x+y;
        }
        else{
            lower_than_med.push(x);
            y=lower_than_med.top();
            lower_than_med.pop();
            higher_than_med.push(-y);
            low-=x-y;
            high+=y;
        }
        median=lower_than_med.top();
        return 0;
    }
};

int main(void){
    long long n;
    long long tmp,a,b,B=0;
    median_tree m;
    cin>>n;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        if (tmp==1){
            cin>>a>>b;
            m.push(a);
            B+=b;
        }
        else{
            cout<<m.median<<" "<<m.median*m.count+B+m.low+m.high<<endl;
        }
    }
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)-v.begin()
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n,m,k;
	cin>>n>>m>>k;
	vector<l> a,b,c,d;
	l sum=0;
	for(l i=0;i<n;i++)
	{
		l x;
		cin>>x;
		sum+=x;
		a.pb(x);
		c.pb(sum);
	}
	sum=0;
	for(l i=0;i<m;i++)
	{
		l x;
		cin>>x;
		sum+=x;
		b.pb(x);
		d.pb(sum);
	}
	vector<l> v;
	l temp=k;
	l maxx=0;
	for(l i=0;i<n;i++)
	{
		temp=k;
		if(k>=c[i])
		{
			temp-=c[i];
			l in=ub(d,temp);
			in--;
			maxx=max(maxx,i+1+in+1);
		}
		else
			break;
	}
	for(l i=0;i<m;i++)
	{
		temp=k;
		if(k>=d[i])
		{
			temp-=d[i];
			l in=ub(c,temp);
			in--;
			maxx=max(maxx,i+1+in+1);
		}
		else
			break;
	}
	cout<<maxx<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}


Measured memory_bytes: 11404