akhauriyash/Code-Regression huggingface dataset:
s = input()
ans = "AC"
if s[0] != "A":
  ans = "WA"
elif s[-1].upper() == s[-1]:
  ans = "WA"
elif s[1].upper() == s[1]:
  ans = "WA"
elif s[2:-1].count("C") != 1:
  ans = "WA"
elif not s[2:].replace("C", "").islower():
  ans = "WA"
  
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

#define INF (1<<29)
 
using namespace std;
 
int main(void){
  
  int n,m,p,a,b,x,y,z,in;
  double dp[(1<<8)][31],graph[31][31];
  vector<int>t;
  
  while(cin >> n >> m >> p >> a >> b){
    if(!(n|m|p|a|b))break;
    
    t.clear();
    
    fill(graph[0],graph[31],-1);
    fill(dp[0],dp[(1<<8)],INF);

    for(int i=0;i<n;i++){
      cin >> in;
      t.push_back(in);
    }
    
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      graph[x][y]=graph[y][x]=z;
    }
    
    dp[0][a]=0;
    double res=INF;
    for(int S=0;S<(1<<n);S++){
      res=min(res,dp[S][b]);
      for(int v=1;v<=m;v++){
	for(int i=0;i<n;i++){
	  if(!(S>>i & 1)){
	    for(int u=1;u<=m;u++){
	      if(graph[v][u]<0)continue;
		dp[S|(1<<i)][u]=min(dp[S|(1<<i)][u],dp[S][v]+graph[v][u]/t[i]);
	    }
	  }
	}
      }
    }
    if(res==INF)printf("Impossible\n");
    else printf("%.3f\n",res);
  }
  
  return 0;
}

Measured memory_bytes: 1308
/*author : Yashvardhan
Saturday, January 12, 2019
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define make_pair mp
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;

	int dp[100005][3];
	int vals[n+1][3];
	for(int i = 1; i <= n ; i++){
		int a,b,c;
		cin>>a>>b>>c;
		vals[i][0] = a;
		vals[i][1] = b;
		vals[i][2] = c;
	}
	dp[1][0] = vals[1][0];
	dp[1][1] = vals[1][1];
	dp[1][2] = vals[1][2];


	for(int i = 2; i <= n ; i++){
		for(int j = 0;j<3;j++){
			if(j == 0){
				dp[i][j] = max(dp[i-1][1],dp[i-1][2]);
			}
			else if(j == 1){
				dp[i][j] = max(dp[i-1][0],dp[i-1][2]);
			}
			else{
				dp[i][j] = max(dp[i-1][0],dp[i-1][1]);
			}
			dp[i][j] += vals[i][j];
		}
	}
	int maxi = max(dp[n][0],dp[n][1]);
	maxi = max(maxi,dp[n][2]);

	cout<<maxi<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 4992
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

ll c(ll num, ll m){
    if (m == 0 || m == num)
        return (1);
    else if (m == 1)
        return (num);
    return (c(num - 1, m) + c(num - 1, m - 1));
}

int main(void){
    ll n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    map<string, ll> l;
    for(int i = 0; i < n; i++){
        l[s[i]]++;
    }

    ll ans = 0;
    for(auto i : l){
        if(i.second == 0 || i.second == 1)continue;
        ans += c(i.second, 2);
    }
    cout << ans << endl;

}

Measured memory_bytes: 18176
#include <cstdio>
#include <vector>

std::vector<int> children[100000];
int to[100000];
int N,K;

int cost=0;

int dfs(int node){
  int height=1;
  for(int child:children[node]){
    height=std::max(height,dfs(child)+1);
  }
  if(height==K&&to[node]!=0){
    cost++;
    return 0;
  }else{
    return height;
  }
}

int main(){
  scanf("%d %d",&N,&K);
  int R;
  scanf("%d",&R);
  if(R!=1){
    cost++;
  }
  for(int i=1;i<N;i++){
    int A;
    scanf("%d",&A);
    children[A-1].push_back(i);
    to[i]=A-1;
  }
  dfs(0);
  printf("%d\n",cost);
  return 0;
}


Measured memory_bytes: 10752
#include <stdio.h>

int main(){
  int i,j;
  int M, N, Q;
  int p,q;
  int **LR;
  int acc;
  scanf("%d %d %d", &N, &M, &Q);
  LR = new int*[N];
  for (i=0 ; i<N; i++){
    LR[i] = new int[N-i]();
  }
  
  for (i=0; i<M; i++){
    scanf("%d %d", &p, &q);
    LR[p-1][q-p] += 1;
  }

  for (i=N-2; 0<=i; i--){
    acc = 0;
    for (j=0; j<N-i; j++){
      acc += LR[i][j];
      LR[i][j] = acc + LR[i+1][j-1];
    }
  }
  
  for (i=0 ; i<Q; i++){
    scanf("%d %d", &p, &q);
    printf("%d\n", LR[p-1][q-p]);
  }
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var l = new long[n+1];
            l[0]= 2;
            l[1]= 1;
            for(int i = 2; i <= n; i++)
            {
                l[i] = l[i - 1] + l[i - 2];
            }
            Console.WriteLine(l[n]);

        
   

           



            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
  
  int num1=sc.nextInt();
  String op=sc.next();
  int num2=sc.nextInt();
  
  if(op.equals("+")){
    System.out.println(num1+num2);
  }else if(op.equals("-")){
    System.out.println(num1-num2);
  }
 }
}

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

typedef long long ll;
const int N = 5054, M = N * 2, mod = 1000000007;

int n, E = 0;
int to[M], first[N], next[M];
int dfact[N], size[N];
int f[N][N], t[N];

inline int & reduce(int &x) {return x += x >> 31 & mod;}
inline int & neg(int &x) {return x = (!x - 1) & (mod - x);}

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x, int px = 0) {
	int i, y, c, u, v; f[x][1] = size[x] = 1;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != px) {
			dfs(y, x);
			for (u = 1; u <= size[x]; ++u) if (f[x][u])
				for (v = 0; v <= size[y]; ++v) if (f[y][v])
					t[u + v] = (t[u + v] + (ll)f[x][u] * f[y][v]) % mod;
			size[x] += size[y], memcpy(f[x], t, (size[x] + 1) << 2), memset(t, 0, (size[x] + 1) << 2);
		}
	for (c = 2; c <= size[x]; c += 2) *f[x] = (*f[x] - (ll)f[x][c] * dfact[c]) % mod;
	reduce(*f[x]);
}

int main() {
	int i, u, v;
	scanf("%d", &n);
	for (*dfact = i = 1; i < n; i += 2) dfact[i + 1] = dfact[i] = (ll)dfact[i - 1] * i % mod;
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	dfs(1);
	printf("%d\n", neg(*f[1]));
	return 0;
}

Measured memory_bytes: 98560
import java.util.Scanner;

public class Main {

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

        while (sc.hasNext()) {
            x = sc.nextInt();
            y = sc.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            if (x < y) {
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            }
        }

        sc.close();
    }

}



Measured memory_bytes: 34632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a==b)cout << max(a,b)*2 << endl;
  else cout << max(a,b)*2-1 << endl;
  return 0;
}


Measured memory_bytes: 256
//ALLAH bachiye naw plz,amr 1400+ rating tulai daw plzz
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int a[6]={};
  for(int i=1;i<=5;i++) {
    int q;
    cin>>q;
    if(!q) { cout<<i; break; } 
  }
  return 0;
} 

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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    if (e[p].size() == 1 && par >= 0) return make_pair(0, p);
    pair<int, int> res = make_pair(0, p);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        t.first += x.cost;
        res = max(res, t);
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


Measured memory_bytes: 15924
n,k = list(map(int,input().split()))

sunuke = [i for i in range(1,n+1)]

while k > 0:
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(len(a)):
        if a[i] in sunuke:
            sunuke.remove(a[i])
    k -= 1

print(len(sunuke))


Measured memory_bytes: 9172
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

import           System.Random

helpMod::Integer->Integer->Integer->Integer
helpMod a d n= fun a d where
    fun a 1 = mod a n
    fun a 2 = mod (a^2) n
    fun a d = let
            p=fun (mod (a^2) n) (div d 2)
            q=if odd d then mod (a*p) n else p
          in mod q n

isProbable::Integer-> Bool
isProbable n |n<=1 = False
         |n==2 = True
         |even n = False
         |otherwise = rabinMiller [2,3,5,7,11,13,17,19] n s d where
             d=until (\x->mod x 2/=0) (`div` 2) (n-1) --(n-1=2^s*d)
             s=until (\x->d*2^x==pred n) (+1) 0  --counts the power


rabinMiller::[Integer]->Integer->Integer->Integer-> Bool
rabinMiller [] _ _ _ = True
rabinMiller (a:xs) n s d =  if a == n then True
                 else  case x==1 of
                    True -> rabinMiller xs n s d
                    _ -> if any ( ==pred n) $ take (fromIntegral s) $ iterate (\e->mod (e^2) n)  x then rabinMiller xs n s d
                          else  False
                   where x=helpMod a d n




fn :: Integer -> Integer -> Integer -> Integer
fn x c n = mod ( x^2 + c ) n

pollard :: Integer -> IO  Integer
pollard n
  | even n = return  2
  | otherwise =
      randomRIO ( 2 , n - 1 ) >>=
     (\x' -> randomRIO ( 2 , n - 1 ) >>=
        (\c ->  return ( until ( \( _ , _ , d ) -> d /= 1 || d == n )  ( \( x , y , d ) -> ( fn x c n , fn ( fn y c n ) c n , gcd ( fn x c n - fn ( fn y c n ) c n  ) n ) )  ( x' , x' , 1 ) ) >>=
        ( \( _ , _ , k ) -> return k  ) ) )



factor :: Integer -> IO [ Integer ]
factor 1 = return []
factor n =
   (return . isProbable $ n ) >>=
    (\x -> case x of
        True -> return [n]
        _    -> pollard n >>=
              (\d -> case d of
                   1 -> factor n
                   _ -> factor d  >>= (\l -> ( factor.div n $ d ) >>= ( \m -> return $ l ++ m ) ) ) )

main = do
        line<-getLine
        let n=read line ::Integer
        m<- factor n
        -- print m
        let prime_factors = nub m
            num = length prime_factors in
               print $ product (map (\p-> n - n `div` p) prime_factors) `div` (n ^ fromIntegral (num - 1))
        return ()



Measured memory_bytes: 4576
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  int d, n;
  cin >> d >> n;
  if(n==100){
    n++;
  }
  cout << n;
  rep(i,d){
    cout << "00";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
const int N=1e5+10;
int n,t,a[N],mn,dis,ans;
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	}
	mn=a[1];
	for(int i=2;i<=n;++i)
	{
		if(mn<a[i])dis=max(dis,a[i]-mn);
		mn=min(mn,a[i]);
	}
	mn=a[1];
	for(int i=2;i<=n;++i)
	{
		if(mn<a[i]&&a[i]-mn==dis)ans++;
		mn=min(mn,a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int convert(char a){
    return a-'0';
}
int convert_s(string a){
    int n = a.size();
    int res = 0;
    rep(i,n){
        res = res*10 + convert(a[i]);
    }
    return res;
}

int main(){
    string S; cin >> S;
    int N = S.size();
    ll ans = 0;
    rep(i, 1<<N-1){
        ll total = 0;
        vector<bool> add(N-1,false);
        rep(j, N){
            if ((i>>j) & 1 == 1){
                add[j] = true;        
            }
        }
        string tmp;
        tmp = S[0];
        for(int j=0; j < N-1; j++){
            if (add[j]){
                tmp = tmp + '+' + S[j+1];
            }
            else{
                tmp = tmp + S[j+1];
            }
        }
        ll now = 0;
        ll mid = 0;
        rep(j,tmp.size()){
            if (tmp[j] == '+'){
                now += mid;
                mid = 0;
            }
            else{
                mid = mid*10+convert(tmp[j]);
            }
        }
        now += mid; 
        ans += now;
    }
    
    cout << ans << endl;
}

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

void sortDecrease(vector<int> &array);

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

  for (int i = min(A, B); i >= 1; i--)
  {
    if (A % i == 0 && B % i == 0)
    {
      K--;
    }
    if (K == 0)
    {
      cout << i;
      return 0;
    }
  }
	

  return 0;
}

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

int main()
{
	int c[3][3];
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			cin >> c[i][j];
		}
	}
	int diff = c[0][0] - c[0][1];
	int diff2 = c[0][1] - c[0][2];
	for (int i = 1;i < 3;i++) {
		int d = c[i][0] - c[i][1];
		int d2 = c[i][1] - c[i][2];
		if (diff != d || diff2 != d2) {
			cout << "No";
			return 0;
		}
	}
	diff = c[0][0] - c[1][0];
	diff2 = c[1][0] - c[2][0];
	for (int i = 1;i < 3;i++) {
		int d = c[0][i] - c[1][i];
		int d2 = c[1][i] - c[2][i];
		if (diff != d || diff2 != d2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 1005
int n;
set<string> hi;

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

    cin >> n;
    F0R(_, n){
        string x;
        cin >> x;
        hi.insert(x);
    }
    cout << hi.size() << "\n";

    return 0;
}


Measured memory_bytes: 19188
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        a: [Chars;n],
        b: [Chars;m],
    }

    let mut ok: bool = true;
    for i in 0..n-m+1 {
        for j in 0..n-m+1 {
            for k in i..i+m {
                for l in j..j+m {
                    if a[k][l]==b[k-i][l-j] {
                        continue;
                    } else {
                        ok = false;
                        // break;
                    }
                }
            }
            if ok {
                println!("Yes");
                return;
            }
            ok = true;
        }
    }
    println!("No");
}


Measured memory_bytes: 2164
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int n,b,c,d,min;
    min = 30;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&b);
        for(int j=0;j<30;j++){
            d = pow(2,j+1);
            c = b % d;
            if(c != 0){
                c = j;
                break;
            }
        }
        if(c < min)min = c;
    }
cout << min << endl;
return 0;
    
}

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

using namespace std;

int main()
{
    long int N;
    cin >> N;

    string S[N];
    set<string> keihin;
    int i;
    for (i = 0; i < N; i++) {
        cin >> S[i];
        keihin.insert(S[i]);
    }

    cout << keihin.size();

    return 0;
}

Measured memory_bytes: 25428
x, y = gets.split.map(&:to_i)
ary1 = [1, 3, 5, 7, 8, 10, 12]
ary2 = [4, 6, 9, 11]
ary3 = [2]

tnp1 = ary1.count(x) + ary1.count(y)
tnp2 = ary2.count(x) + ary2.count(y)
tnp3 = ary3.count(x) + ary3.count(y)

if tnp1 == 2 || tnp2 == 2 || tnp3 == 2
  puts :Yes
else
  puts :No
end



Measured memory_bytes: 1788
#include <stdio.h>
 
int check(int n)
{
     if(n == 3 || n % 10 == 3){
        return 1;
    }
    else if(n == 0){
        return 0;
    }
    else {
        n /= 10;
        if(check(n) == 1){return 1;}
    }
    return 8;
}
 
int main(void)
{
    int n;
    int i;
 
    scanf("%d", &n);
 
    for(i=1;i<=n;i++){
        if(i % 3 == 0 || check(i) == 1){
            printf(" %d", i);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
import numpy as np


class FastFourierTransform:
	"""FFT
	"""

	def multiply(self, F,G):
		""" multiply by FFT
		"""
		N=1
		# 1.N > deg(g) + deg(h)となる2の冪乗を選ぶ
		while N < len(F) + len(G):
			N *= 2
		# 2. 離散フーリエ変換の計算
		nf = np.zeros(N,int)
		nf[:len(F)]=F
		ng = np.zeros(N,int)
		ng[:len(G)]=G
		nf=np.fft.fft(nf)
		ng=np.fft.fft(ng)
		# for n in range(N):
			# nf[n] *= ng[n]
		nf *= ng

		# 3. 離散フーリエ逆変換
		nf=np.fft.ifft(nf)

		ans = np.zeros(N,int)
		for n in range(N):
			# 係数を1/N倍 => np.fftの場合、すでに実行済
			#ans.append( round(nf[n].real / N) )
			ans[n] = int(nf[n].real + 0.5)

		return ans

if __name__ == "__main__":
	N=int(input())
	A=list(map(int,input().split()))

	P=200_003
	rootP=2

	# order of 1 to P-1 after fft
	order=[1]
	x=rootP
	while x!=1:
		order.append(x)
		x *= rootP
		x %= P

	ORDER_SIZE=len(order)	# 200_002

	# create order index
	where=np.zeros(P,int)
	for i in range(ORDER_SIZE):
		where[ order[i] ] = i

	# count non zero items
	prevCnt = np.zeros(P,int)
	resCnt = np.zeros(P,int)
	# prevCnt2 = [ 0 for _ in range(P)]
	# resCnt = [ 0 for _ in range(P)]
	for n in range(N):
		if A[n] != 0:
			prevCnt[ where[A[n]] ] += 1
			# prevCnt2[ where[A[n]] ] += 1
			# remove Ax * Ax pattern count
			resCnt[ (A[n] * A[n]) % P ] -= 1

	# fft to cnt (calc nC2 and all Ax * Ay)
	clsFFT = FastFourierTransform()
	fftRes = clsFFT.multiply(prevCnt,prevCnt)

	for r in range(len(fftRes)):
		if fftRes[r] != 0:
			# get result(Ax*Ay==resCnt.index) Cnt by summary fftRes
			resCnt[ order[ r % ORDER_SIZE ] ] += fftRes[r]

	ans = 0
	for p in range(P):
		if resCnt[p] != 0:
			# print(p,resCnt[p])
			# remove j <= i pattern count 
			# and
			# calc summary value((Ax * Ay cnt) * (Ax * Ay)))
			ans += (resCnt[p] // 2) * p

	print(ans)








Measured memory_bytes: 89536
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()
S1 = [S[i] for i in range(N//2)]
S2 = [S[i] for i in range(N//2,N)]

if S1 == S2:
    print('Yes')
else:
    print('No')

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  string s;
  cin >> s;
  int res = 0;
  int count = 0;
  for (int i = 0; i < int(s.size()); i++) {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      count++;
    }else{
      count = 0;
    }
    res = max(count, res);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
def factorization(n): # https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a, b = map(int,input().split())
a, b = max(a,b), min(a,b)

r = -1
while r != 0:
    r = a%b
    a, b = b, r
# a = 最大公約数

if a == 1:
    print(1)
else:
    print(len(factorization(a))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mn=100010;
typedef long long ll;
int n;
ll a[mn],m1,m2;
map<int,int> cnt;
bool cmp(ll x,ll y) {
	return x>y;
}
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		cnt[a[i]]++;
	}
	sort(a+1,a+(n+1),cmp);
	for (int i=1;i<=n;i++) {
		if (cnt[a[i]]>=2) {
			m1=a[i]; cnt[a[i]]-=2; break;
		}
	}
	for (int i=1;i<=n;i++) {
		if (cnt[a[i]]>=2) {
			m2=a[i]; cnt[a[i]]-=2; break;
		}
	}
	printf("%lld\n",m1*m2);
	return 0;
}

Measured memory_bytes: 5760
using System;
using System.Linq;

namespace abc051b
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var k = inputs[0];
            var s = inputs[1];
            var ans = 0;

            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    var z = s - (x + y);

                    if (0 <= z && z <= k)
                        ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
vector<long long>v;
long long n , k;
long long dp[100000+10];
long long INF = 1e9;
long long dfs(long long i){
    if(i >= n)return INF;
    if(i == n-1) return 0;
    if(dp[i] != -1)return dp[i];
    long long ans = INF;
    long long tk = k;
    long long ti = 1;
    while(tk--){
        if(ti == n)break;
        ans = min(ans,abs(v[i]-v[i+ti]) + dfs(i+ti));
        ti++;
    }
    dp[i] = ans;
    return ans;
}
int main(){
    cin>>n>>k;
    v.resize(n+2);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    v[n] = 0;
    v[n+1] = 0;
    memset(dp,-1,sizeof dp);
    long long c = dfs(0);
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 9600
n = int(input())
ls = [int(l) for l in input().split()]

import collections
c = collections.Counter(ls)

Ls = list(set(ls))
Ls.sort()

if len(Ls) < 3:
  print(0)
else:
  ans = 0
  LsR = sorted(Ls)
  while len(LsR) >= 3:
    L1 = LsR[0]
    Ls1 = LsR[1:]
    while len(Ls1) >= 2:
      L2 = Ls1[0]
      Ls2 = Ls1[1:]
      for L3 in Ls2:
        if L3 < L1 + L2 and L3 > abs(L1-L2):
          ans += c[L1] * c[L2] * c[L3]
      Ls1 = Ls1[1:]
    LsR = LsR[1:]
  print(ans)

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007; 
long long power(long long a, long long n){
	long long ans = 1; long long mul = a;
	while(n){
		if(n & 1){
			ans *= mul; ans %= mod;
		}
		n >>= 1;
		mul = mul * mul % mod;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, K; cin >> N >> K;
	int p = 0; int z = 0; int m = 0;  
	long long P[200010] = {}; long long M[200010] = {};
	fill(P, P+N, 1); fill(M, M+N, 1); 
	for(int i = 0; i < N; i++){
		long long a; cin >> a; 
		if(a > 0) P[p++] = a; 
		if(a == 0) z++; 
		if(a < 0) M[m++] = -a; 
	}
	sort(P, P+N, greater<long long>()); 
	sort(M, M+N, greater<long long>()); 
	if((K % 2 == 0 && p + m - m % 2 >= K) || (K % 2 == 1 && p > 0 && p + m - m % 2 >= K)){
		long long ans = 1; 
		for(int i = 0; i < K; i++){
			ans *= P[i]; ans %= mod; 
		}
		for(int i = K - 1; i >= 1; i -= 2){
			long long tmp1 = P[i] * P[i-1]; 
			long long tmp2 = M[K-1-i] * M[K-i]; 
			if(tmp1 < tmp2){
				tmp1 %= mod; tmp2 %= mod; ans *= power(tmp1, mod - 2); 
				ans %= mod; ans *= tmp2; 
				ans %= mod; 
			}else{
				break; 
			}
		}
		cout << ans << "\n"; 
	}else if(z > 0){
		cout << 0 << "\n"; 
	}else if(N == K){
		long long ans = 1; 
		for(int i = 0; i < p; i++){
			ans *= P[i]; ans %= mod; 
		}
		for(int i = 0; i < m; i++){
			ans *= M[i]; ans %= mod; 
		}
		cout << (mod - ans) % mod << "\n"; 
	}else{
		long long ans = 1; 
		for(int i = 0; i < K; i++){
			ans *= M[m-1-i]; ans %= mod; 
		}
		cout << (mod - ans) % mod << "\n"; 
	}
}

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

using namespace std;

int main() {
	
	long long a, b;
	cin >> a >> b;
	if (b != 100) {
		cout << b * pow(100, a) << endl;
	}
	else {
				cout << fixed << setprecision(0) << (b + 1) * pow(100, a) << endl;

	}
}

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

int main()
{
	string s;
	cin>>s;
	int n=s.size(),sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3672
#e digitDP    
n = int(input())
k = int(input())
s=str(n)
l=len(s)

dp = [[[0]*(3+1) for _ in range(2)] for _ in range(l) ]
#dp[i桁目][0=未満確定、1=不確定][0以外の数字の数]
x = int(s[0])
#未満確定、1以上0個 =0
dp[0][0][0] = 1
#未満確定、1以上1個 = 1 ~ x-1
dp[0][0][1] = x-1
#head、1以上0個
dp[0][1][0] = 0
#head、1以上1個 = x
dp[0][1][1] = 1


for i in range(1,l):
    x = int(s[i])
    if x>=1:
        #headじゃない、1以上０こ(0, )
        dp[i][0][0] = dp[i-1][0][0]*1 +dp[i-1][1][0]*1
        #head 1以上0個()
        dp[i][1][0] = dp[i-1][0][0]*0 +dp[i-1][1][0]*0
        for j in [1,2,3]:
            dp[i][0][j] = dp[i-1][0][j-1]*9 +dp[i-1][1][j-1]*(x-1) +dp[i-1][0][j]*1 +dp[i-1][1][j]*1
            dp[i][1][j] = dp[i-1][0][j-1]*0 +dp[i-1][1][j-1]*1     +dp[i-1][0][j]*0 +dp[i-1][1][j]*0
    else:
        #headじゃない、1以上が０こ(0, )
        dp[i][0][0] = dp[i-1][0][0]*1 +dp[i-1][1][0]*0
        #head 1以上0個
        dp[i][1][0] = dp[i-1][0][0]*0 +dp[i-1][1][0]*1
        for j in [1,2,3]:
            dp[i][0][j] = dp[i-1][0][j-1]*9 +dp[i-1][1][j-1]*0 +dp[i-1][0][j]*1 +dp[i-1][1][j]*0
            dp[i][1][j] = dp[i-1][0][j-1]*0 +dp[i-1][1][j-1]*0 +dp[i-1][0][j]*0 +dp[i-1][1][j]*1
            
print(dp[-1][0][k] + dp[-1][1][k])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int h[n + 2];
    h[0] = 0;
    h[n + 1] = 0;
    int sum = 0;
    rep(i, 1, n + 1) {
        cin >> h[i];
        sum += h[i];
    }

    int ans = 0;
    while (sum > 0) {
        int area = 0;
        for (int i = 0; i <= n; i++) {
            if (h[i] == 0) {
                if (h[i + 1] != 0) area++;
            } else {
                h[i]--;
                sum--;
            }
        }
        ans += area;
    }

    cout << ans << endl;
    return 0;


}


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

int powint(int a,int b){
	int n=1;
	for(int i=0;i<b;i++){
		n*=a;
	}
	return n;
}

int main(){
	int X,b,p,max=1;
	cin >> X;
	for(b=1;b<=X;b++){
		for(p=2;powint(b,p)<=X;p++){
			if(powint(b,p)==1){
				break;
			}
			else if(max<powint(b,p)){
				max=powint(b,p);
			}
		}
	}
	cout << max << endl;
	return 0;
}

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

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

int DP[110][10010]; //N???????????§????????????????¨?w

int main(void) {
	
	int N, W;
	cin >> N >> W;
	
	REP(i, N) {
		int v, w;
		cin >> v >> w;
		
		REP(c, W+1) {
			if ( c < w ) {
				// ????????????????????????
				DP[i+1][c] = DP[i][c];
			} else {
				DP[i+1][c] = max( { DP[i][c-w] + v, DP[i+1][c-w] + v, DP[i][c] } );
			}
		}
	}
	
	int ret = 0;
	REP(c, W+1) {
		ret = max(ret, DP[N][c]);
	}
	
	cout << ret << endl;
}

Measured memory_bytes: 6988
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,w;
    cin>>n>>w;
    pll p[n];
    for(ll i=0;i<n;i++)
    {
        cin>>p[i].ff>>p[i].ss;
    }
    ll dp[w+1];
    for(ll i=1;i<=w;i++)
    {
        dp[i]=-1;
    }
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=(w-p[i].ff);j>=0;j--)
        {
            if((dp[j]+p[i].ss)>dp[j+p[i].ff])
            {
                dp[j+p[i].ff]=(dp[j]+p[i].ss);
            }
        }
    }
    ll ans=0;
    for(ll i=1;i<=w;i++)
    {
        if(ans<dp[i])
            ans=dp[i];
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int n, i, v[6];
long long sol;
int main(){
    for(i = 1; i <= 4; i++){
        cin>> v[i];
        if(i != 1){
            v[i] = min(v[i], 2 * v[i - 1]);
        }
    }
    cin>> n;
    sol = v[3] * (n % 2) + (n / 2) * 1LL * v[4];
    cout<< sol;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

string s;

int judge(string j){
  rep(i, j.size()-1) if(j[i] != j[i+1]) return 0;
  return 1;
}

int main(){
  while(cin >> s){
    if(s[0] == '0') break;

    queue<pair<string,int> >q;
    map<string, int>m;
    q.push(MP(s, 0));
    m[s] = 1;

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

      if(judge(p.F)){
	printf("%d\n", p.S);
	goto e;
      }

      rep(i, s.size()-1){
	string n = p.F;
	if(n[i] == n[i+1]) continue;
	if(n[i] == 'r' && n[i+1] == 'g') n[i] = n[i+1] = 'b';
	else if(n[i] == 'r' && n[i+1] == 'b') n[i] = n[i+1] = 'g';
	else if(n[i] == 'g' && n[i+1] == 'r') n[i] = n[i+1] = 'b';
	else if(n[i] == 'g' && n[i+1] == 'b') n[i] = n[i+1] = 'r';
	else if(n[i] == 'b' && n[i+1] == 'g') n[i] = n[i+1] = 'r';
	else if(n[i] == 'b' && n[i+1] == 'r') n[i] = n[i+1] = 'g';

	if(m.find(n) != m.end()) continue;
	q.push(MP(n, p.S+1));
	m[n] = 1;
      }
    }
    puts("NA");
  e:;
  }
  return 0;
}

Measured memory_bytes: 2920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int a = 0;
    int count = 0;
    REP(i,1000){
        string is = to_string(i);
        if(is.size() != 3)is = "0" + is;
        if(is.size() != 3)is = "0" + is;
        REP(l,N){
            if(a == 0){
                if(S[l] == is[0])a++;
            }else if(a == 1){
                if(S[l] == is[1])a++;
            }else if(a == 2){
                if(S[l] == is[2]){
                    count++;
                    break;
                }
            }
        }
        a = 0;
    }
    cout << count << "\n";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
int arr[ 1005 ] = {};
int main( void ){
	// initialize();
	ll N, P;
	cin >> N >> P;
	const auto &vec = prime_factorize( P );
	int maximum = 0;
	ll ans = 1;
	for(auto v:vec){
		rep( i, 0, v.b / N )
			ans *= v.a;
	}
	cout << ans << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];
  int x=1;
  rep(i,n) {
    if(x==a[i]) x++;
  }
  int ans=n-x+1;
  if(ans==n) ans=-1;
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
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 all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

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

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int a, b, c;
  cin >> a >> b >> c;
  int mx = max({a,b,c});
  if((mx*3-(a+b+c))%2 != 0) mx++;
  int ans = (mx*3-(a+b+c)) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
INF = float('inf')
dp = [INF] * N
dp[0] = 0
dp2 = {}
dp2[0] = 0
bits = [1 << i for i in range(26)]
x = 0

for i in range(N):
    x = x ^ bits[ord(S[i]) - ord('a')]
    tmp = INF
    if x not in dp2:
        dp2[x] = INF
    tmp = min(tmp, dp2[x])

    for b in bits:
        k = x ^ b
        if k not in dp2:
            dp2[k] = INF
        tmp = min(tmp, dp2[k])

    dp2[x] = min(dp2[x], tmp + 1)
    dp[i] = tmp + 1

print(dp[N - 1])

Measured memory_bytes: 358396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int H, W;
	bool flag = true;

	cin >> H >> W;

	vector<vector<char>> field(H + 2, vector<char>(W + 2, '.'));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> field[i + 1][j + 1];
		}
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (field[i][j] == '.')
			{
				continue;
			}
			else
			{
				if (field[i - 1][j] == '.' &&
					field[i + 1][j] == '.' &&
					field[i][j - 1] == '.' &&
					field[i][j + 1] == '.')
				{
					flag = false;
					break;
				}
			}
		}
	}

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

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 998244353
#define INF 1000000000000000LL

using namespace std;

#define MAXNS 3001
ll dp[MAXNS][MAXNS];

int main(){
  int n,s;cin>>n>>s;
  vector<int>a(n);
  rep(i, n)cin>>a[i];

  dp[0][0]=1;
  rep(i, n)rep(j, s+1){
    ll cn = a[i];
    dp[i+1][j] += dp[i][j]*2;
    dp[i+1][j]%=MOD;
    if(j+cn<=s){
      dp[i+1][j+cn] += dp[i][j];
      dp[i+1][j+cn] %= MOD;
    }
  }

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

  return 0;

rep(i, n+1){
  rep(j, s+1)cout<<dp[i][j]<<' ';cout<<endl;
}

  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

ll h[100005];

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    rep(i, n) cin >> h[i];

    ll left = 0, right = 1e9, mid;
    while (right - left > 1)
    {
        mid = (left + right) / 2;
        ll sum = 0;
        rep(i, n)
        {
            if (h[i] - mid * b > 0)
                sum += ceil((double)(h[i] - mid * b) / (a - b));
        }

        if (sum <= mid)
            right = mid;
        else
            left = mid;
    }

    OP(right);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int V,d[200001],r[200001],z[200001];
vector<int> G[200001];
void bfs(int s){
    rep(i,V+1) d[i]=0,r[i]=0;
    queue<int> que;
    que.push(s);
    r[s]=1;
    while (!que.empty()) {
        int v=que.front();
        que.pop();
        for(int nv:G[v]) {
            if(r[nv]) continue; 
            r[nv]++;
            z[nv]=v;
            d[nv]=d[v]+1;
            que.push(nv);
        }
    }
};
int main(){
    int n,m,a,b;
    cin>>n>>m;
    rep(i,m) cin>>a>>b,G[a].push_back(b),G[b].push_back(a);
    bfs(1);
    cout<<"Yes\n";
    rep(i,n-1) cout<<z[i+2]<<"\n";
}

Measured memory_bytes: 13600
import sys
from io import StringIO
import unittest
import os
import bisect

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def cumsum(target: []):
    result = []
    for cnt, a in enumerate(target):
        result.append(a) if cnt == 0 else result.append(result[cnt - 1] + a)
    return result


# 実装を行う関数
def resolve(test_def_name=""):
    n, m, k = map(int, input().split())
    a_s = list(map(int, input().split()))
    b_s = list(map(int, input().split()))

    sum_a_s = [0] + cumsum(a_s)
    sum_b_s = [0] + cumsum(b_s)

    # k=100として AをX冊読んだ場合の残時間のリストを作る。
    # つまり・・0=100 1=80 2=40 という感じ。
    remain_time_s = []
    for sum_a in sum_a_s:
        if sum_a > k:
            break
        remain_time_s.append(k - sum_a)

    ans = 0
    b_start = 0
    sum_b_s_rev = list(reversed(list(enumerate(sum_b_s))))

    # 最適解を求める。
    for cnt_a, remain_time in enumerate(remain_time_s):
        # Bは逆から見ていく。
        for i in range(b_start, len(sum_b_s_rev)):
            if sum_b_s_rev[i][1] > remain_time:
                b_start += 1
                continue
            ans = max(ans, cnt_a + sum_b_s_rev[i][0])
            break

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 4 240
60 90 120
80 150 80 150"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3 4 730
60 90 120
80 150 80 150"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def test_origin_1(self):
        test_input = """2 3 100
90 10
10 10 10"""
        output = """3"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 163420
#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
//#define int int64_t
#define float double
#define PI acos(-1)
#define sinDegrees(x) sin((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a<b;
}
///Solution created by:Ahmadsm2005
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("rect.in","r", stdin);
iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
if(s.size()<=n)
cout<<s;
else{
for(int i=0;i<n;i++)
cout<<s[i];
cout<<"...";
}
return 0;
}


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

int main(){

  int n;
  int d[20000];

  while(cin >> n, n){
    int m = n;
    bool p = false;
    for(int i=0;i<n;i++){
      cin >> d[i];
      if(d[i] > 1) p = true;
      if(!d[i]) m--;
    }

    if(p) cout << m + 1 << endl;
    else cout << "NA" << endl;

  }
}

Measured memory_bytes: 1204
// Written by newbiechd
#include <cstdio>

inline int max(int x, int y) { return x > y ? x : y; }

int main() {
  int H, W, n;
  scanf("%d%d%d", &H, &W, &n);
  printf("%d\n", (n - 1) / max(H, W) + 1);
  return 0;
}


Measured memory_bytes: 128