akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn=20; // 小数第9位を復元するには2*5が高々9回あれば十分 (2数の積なので18回必要)
ll dp[maxn][maxn];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n){
    long double b; cin>>b;
    a[i]=llround(b*1000*1000*1000);
  }
  
  // rep(i,n) cout<<a[i]<<endl;
  
  ll ans=0;
  rep(i,n){
    ll tmp=a[i];
    ll a=0, b=0;
    while(tmp%2==0) tmp/=2, a++;
    while(tmp%5==0) tmp/=5, b++;
    
    chmin(a, maxn-1);
    chmin(b, maxn-1);
    
    // cout<<a<<' '<<b<<endl;
    
    rep(j,maxn) rep(k,maxn){
      if(a+j>=18 && b+k>=18) ans+=dp[j][k];
    }
    dp[a][b]++;
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4768
from collections import deque
s=input()
q=int(input())
turn=0
ans=deque(s)
for i in range(q):
    query=input().split()
    if query[0]=="1":
        turn+=1
    if query[0]=="2":
        if query[1]=="1":
            if turn%2==0:
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
        elif query[1]=="2":
            if turn%2==0:
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
ans="".join(ans)
if turn%2==1:
    ans=ans[::-1]
print(ans)

Measured memory_bytes: 8564
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

ll solve(string a,string b)
{
    ll count = 0;
    for(ll i=0;i<a.length();++i)
    {
        if(a[i] != b[i])
            count++;
    }
    
    return(count);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll D,T,S; cin>>D>>T>>S;
    if(S*T >= D)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, X;
    cin >> N >> X;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll cnt = 0;
    if(A[0] > X) {
        cnt += A[0] - X;
        A[0] = X;
    }
    REP(i,1,N) {
        if(A[i-1] + A[i] > X) {
            cnt += A[i-1] + A[i] - X;
            A[i] = X - A[i-1];
        }
    }
    PR(cnt);


    return 0;
}

/*



*/

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

int main(){
    string S;
    cin >> S;
    int res = 0;
    for(int i = 1; i < S.size(); i++){
        if(S[i] != S[i - 1]) res++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
int cake[6];
int edge[108][108];
int dist[1<<6][108];
int main() {
	int n,m,k,d;
	while(scanf("%d %d %d %d",&m,&n,&k,&d),n) {
		for(int i=0;i<m;i++) {
			scanf("%d",&cake[i]);
		}
		for(int i=0;i<=m+n+1;i++) {
			for(int j=0;j<=m+n+1;j++) edge[i][j]=1<<30;
		}
		for(int i=0;i<d;i++) {
			char s[2][10];
			int p[2],cost;
			scanf("%s %s %d",s[0],s[1],&cost);
			for(int j=0;j<2;j++) {
				if(s[j][0]=='H') {
					p[j]=0;
				}else if(s[j][0]=='D') {
					p[j]=m+n+1;
				}else if(s[j][0]=='C') {
					s[j][0]='0';
					p[j]=atoi(s[j]);
				}else {
					s[j][0]='0';
					p[j]=m+atoi(s[j]);
				}
			}
			edge[p[1]][p[0]]=edge[p[0]][p[1]]=cost*k;
		}
		for(int i=0;i<(1<<m);i++) {
			for(int j=0;j<=m+n+1;j++) dist[i][j]=1<<30;
		}
		dist[0][0]=0;
		while(true) {
			bool update=0;
			for(int i=0;i<(1<<m);i++) {
				for(int j=0;j<=m+n+1;j++) {
					for(int k=0;k<=m+n+1;k++) {
						if(edge[j][k]==(1<<30)||dist[i][j]==(1<<30)) continue;
						int ni=i,nd=dist[i][j]+edge[j][k];
						if(1<=k && k<=m) {
							if(i&(1<<(k-1))) continue;
							nd-=cake[k-1];
							ni|=(1<<(k-1));
						}
						if(nd<dist[ni][k]) {
							dist[ni][k]=nd;
							update=true;
						}
					}
				}
			}
			if(!update) break;
		}
		int ans=1<<30;
		for(int i=0;i<(1<<m);i++) {
			ans=min(ans,dist[i][m+n+1]);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1108
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))

int input() {
    char buf[6];
    int size = read(0, buf, 6);
    int n = 0;
    REP (i, 5) {
        n = n * 10 + buf[i] - '0';
    }
    return n;
}

void output(int n) {
    char buf[20];
    char *s = buf + sizeof buf;
    *(-- s) = '\n';
    if (! n) *(-- s) = '0';
    for (; n; n /= 10) {
        *(-- s) = (n % 10) + '0';
    }
    write(1, s, buf + sizeof buf - s);
}

__attribute__((constructor))
static void _main(void) {
    int a = input();
    int b = input();
    int cnt = 0;
    REP (x, 10) REP (y, 10) REP (z, 10) {
        int n = x * 10000 + y * 1000 + z * 100 + y * 10 + x;
        cnt += (a <= n && n <= b);
    }
    output(cnt);
    _exit(0);
}

int main(void) {
}


Measured memory_bytes: 128
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin >> N;
    int counter=0;
    priority_queue<long long> vec;
    for(long long i=1;i*i<=N;i++){
    if(N%i==0){
     vec.push(i);}
    }
    long long a;
    a=vec.top();
    a=N/a;
    while(a>0){
    a=a/10;
    counter++;}
    cout<<counter<<endl;}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    n, *l = map(int, read().split())
    if n < 3:
        print(0)
        sys.exit()
    com = tuple(combinations(l, 3))
    r = 0
    for c in com:
        c1 = c[0]
        c2 = c[1]
        c3 = c[2]
        if c1 == c2 or c2 == c3 or c1 == c3:
            continue
        else:
            cs = sum(c) - max(c)
            r += cs > max(c)

    print(r)
if __name__ == '__main__':
    main()

Measured memory_bytes: 20728
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	LL N,Q;
	cin >> N >> Q;
	vector<LL> qs;
	qs.push_back(N);
	for(int i=0;i<Q;i++){
		LL q;
		cin >> q;
		while(qs.size()&&qs.back()>=q){
			qs.pop_back();
		}
		qs.push_back(q);
	}
	vector<LL> vs;
	for(LL i=1;i<qs[0];i++){
		vs.push_back(i);
	}
	for(auto q:qs){
		vs.push_back(q);
	}

	vector<LL> dp;
	dp.resize(vs.size());
	dp.back()=1;
	for(int i=vs.size()-1;i>=0&&vs[i]>qs[0];i--){
		LL v=vs[i];
		int j=i-1;
		while(v>qs[0]){
			dp[j]+=(v/vs[j])*dp[i];
			v%=vs[j];
			j=upper_bound(vs.begin(),vs.end(),v)-vs.begin();
			j--;
		}
		if(v){
			dp[v-1]+=dp[i];
		}
	}
	vector<LL> sums;
	for(int i=qs[0]-2;i>=0;i--){
		dp[i]+=dp[i+1];
	}
	for(int i=0;i<N;i++){
		if(i<qs[0]){
			cout << dp[i] << endl;
		}
		else{
			cout << 0 << endl;
		}
	}

	return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vecn(n);
  //vector<int> veck(k);
  rep(i,n)cin >> vecn.at(i);
  sort(vecn.begin(),vecn.end());
  reverse(vecn.begin(),vecn.end());
  int ans = 0;
  rep(i,k)ans += vecn.at(i);
  cout << ans << endl;

	return 0;
}


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

#define PI acos(-1)
typedef long long ll;
#define INF 0x3f3f3f3f
int mod = 1000000007;
int rec[N];
int main()
{
//	freopen("in.txt", "r", stdin);
	int n, k;
	while (~scanf("%d%d", &n, &k))
	{
		map<int, int> mp;
		for (int i = 0; i < n; i++)
		{
			int x;
			scanf("%d", &x);
			if (mp.find(x) == mp.end())
			{
				mp[x] = 0;
			}
			mp[x] += 1;
		}
		if (mp.size() <= k)
			puts("0");
		else
		{
			int c = mp.size() - k;
			vector<int> v;
			for (auto x : mp)
				v.push_back(x.second);
			sort(v.begin(), v.end());
			int ans = 0;
			for (int i = 0; i < c; i++)
				ans += v[i];
			printf("%d\n", ans);
		}
	}
   	return 0;
}

Measured memory_bytes: 10748
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<climits>
using namespace std;
typedef pair<int,int> Pair;

#define N_MAX 100000
#define M_MAX 200000

int N,M,K,S;
int P,Q;
int zd[N_MAX];
bool done[N_MAX];
long long cost[N_MAX];
vector<int> load[N_MAX];

int main(){
	int i;
	int a,b;
	queue<Pair> q;

	cin>>N>>M>>K>>S;
	cin>>P>>Q;

	for(i=0;i<N;i++){
		zd[i]=-1;
		done[i]=false;
		cost[i]=LLONG_MAX;
	}
	for(i=0;i<K;i++){
		cin>>a;
		a--;
		q.push(Pair(a,-1));
	}
	for(i=0;i<M;i++){
		cin>>a>>b;
		a--;b--;
		load[a].push_back(b);
		load[b].push_back(a);
	}

	while(!q.empty()){
		int qTo=q.front().first;
		int qCost=q.front().second;
		q.pop();
		if(zd[qTo]<0){
			zd[qTo]=qCost+1;
			for(i=0;i<load[qTo].size();i++){
				q.push(Pair(load[qTo][i],zd[qTo]));
			}
		}
	}

	cost[0]=0;
	int doneTown=0;

	while(0<=doneTown){
		done[doneTown]=true;
		for(i=0;i<load[doneTown].size();i++){
			int toTown=load[doneTown][i];
			if(done[toTown] || zd[toTown]==0) continue;
			int yado=P;
			if(zd[toTown]<=S) yado=Q;
			if(toTown==N-1) yado=0;
			cost[toTown]=min(cost[toTown],cost[doneTown]+yado);
		}
		doneTown=-1;
		long long minCost=LLONG_MAX;
		for(i=0;i<N;i++){
			if(done[i]) continue;
			if(cost[i]<minCost){
				minCost=cost[i];
				doneTown=i;
			}
		}
	}

	cout<<cost[N-1]<<endl;

	return 0;
}

Measured memory_bytes: 11192
n = int(input())
a = list(map(int, input().split()))
cnt = 0
ans = []

for i in a:
    if i < 0:
        cnt += 1
    ans.append(abs(i))

if cnt%2 == 1:
    print(sum(ans)-(min(ans)*2))
else:
    print(sum(ans))

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  double n;cin>>n;
  n = ceil(n/111);
  cout<<n*111<<endl;
}


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

int main()
{
	string S, T;
	cin >> S >> T;

	int cnt = 0;
	for (int i = 0; i < S.length(); ++i)
		if (S[i] != T[i])++cnt;

	cout << cnt;
}


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

int main(){
  ll A,B,C,K;cin>>A>>B>>C>>K;
  ll ans=0;
  if(K<=A) ans = K;
  if(A<=K<=B) ans=K;
  if(K>=A+B) ans = A - (K-A-B);
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int count = 0;
    for (int i = 0; i * 500 <= x && i <= a; i++) {
        for (int j = 0; i * 500 + j * 100 <= x && j <= b; j++) {
            int rest = x - i * 500 - j * 100;
            if (rest / 50 <= c) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K; cin >> N >> K;
  ll L[K], R[K]; rep(i,K) cin >> L[i] >> R[i];
  ll dp[N] = {}; dp[0] = 1;
  ll sum[N+1] = {}; sum[1] = 1;

  repr(i,1,N) {
    rep(j,K) {
      if (L[j]<=i) {
        ll to = i-L[j]+1;
        ll from = max(0ll,i-R[j]);
        dp[i] = (dp[i]+sum[to]-sum[from]+MOD) % MOD;
      }
    }
    sum[i+1] = (sum[i]+dp[i]) % MOD;
  }
  // debug(dp,dp+N);

  ll result = dp[N-1];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6760
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		String ans = "";
		Map<Character, Integer> map = new HashMap();
		map.put('a', 1);
		map.put('b', 2);
		map.put('c', 3);
		map.put('d', 4);
		map.put('e', 5);
		map.put('f', 6);
		map.put('g', 7);
		map.put('h', 8);
		map.put('i', 9);
		map.put('j', 10);
		map.put('k', 11);
		map.put('l', 12);
		map.put('m', 13);
		map.put('n', 14);
		map.put('o', 15);
		map.put('p', 16);
		map.put('q', 17);
		map.put('r', 18);
		map.put('s', 19);
		map.put('t', 20);
		map.put('u', 21);
		map.put('v', 22);
		map.put('w', 23);
		map.put('x', 24);
		map.put('y', 25);
		map.put('z', 26);
		Map<Integer, Character> map2 = new HashMap();
		map2.put(1, 'a');
		map2.put(2, 'b');
		map2.put(3, 'c');
		map2.put(4, 'd');
		map2.put(5, 'e');
		map2.put(6, 'f');
		map2.put(7, 'g');
		map2.put(8, 'h');
		map2.put(9, 'i');
		map2.put(10, 'j');
		map2.put(11, 'k');
		map2.put(12, 'l');
		map2.put(13, 'm');
		map2.put(14, 'n');
		map2.put(15, 'o');
		map2.put(16, 'p');
		map2.put(17, 'q');
		map2.put(18, 'r');
		map2.put(19, 's');
		map2.put(20, 't');
		map2.put(21, 'u');
		map2.put(22, 'v');
		map2.put(23, 'w');
		map2.put(24, 'x');
		map2.put(25, 'y');
		map2.put(26, 'z');

		boolean use[] = new boolean[27];
		char c[] = S.toCharArray();
		if (S.equals("zyxwvutsrqponmlkjihgfedcba")) {
			ans = "-1";
		} else if (S.length() == 26) {
			int last = 0;
			String add = "";
			for (int i = 0; i < S.length() - 1; i++) {
				if (map.get(c[i]) < map.get(c[i + 1])) {
					last = i + 1;
				}
			}
			for (int i = 0; i < last; i++) {
				int tmp = map.get(c[i]);
				use[tmp] = true;
			}
			for (int i = map.get(c[last - 1]); i < 27; i++) {
				if (!use[i]) {
					add = String.valueOf(map2.get(i));
					break;
				}
			}
			ans = S.substring(0, last - 1) + add;
		} else {
			String add = "";
			for (int i = 0; i < S.length(); i++) {
				int tmp = map.get(c[i]);
				use[tmp] = true;
			}
			for (int i = 1; i < 27; i++) {
				if (!use[i]) {
					add = String.valueOf(map2.get(i));
					break;
				}
			}
			ans = S + add;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

n = int(input())
s = input()

ans = 0

for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k), b + 1)
            if c == -1:
                continue
            ans += 1
print(ans)

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

int main() {
    int n;
    cin>>n;
    string s;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    rep(i,n){
        cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3604
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($args: tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let min = parse_word::<i32>();
    let max = parse_word::<i32>();

    let count = (min..(max + 1)).filter(|x| is_palindrome(*x)).count();
    println!("{}", count);
}

fn is_palindrome(x: i32) -> bool {
    let s = x.to_string();
    let chars = s.chars().collect::<Vec<_>>();
    let chars_rev = s.chars().rev().collect::<Vec<_>>();

    chars == chars_rev
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i)
    {
        switch (s.at(i))
        {
        case '1': s[i] = '9'; break;
        case '9': s[i] = '1'; break;
        }
    }

    cout << s << endl;
}


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

int main(){
  int64_t N, S, x0, y0;
  cin >> N;
  S = (int64_t)sqrt(N);
  x0 = N;
  y0 = 1;
  for(int64_t i = 1; i <= S; i++){
    if(N % i == 0) x0 = N / i;
  }
  y0 = N / x0;
  cout << x0 + y0 -2 << endl;
}

Measured memory_bytes: 256
main(a,b,c,d,e,f){for(;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a|b|c|d|e|f;printf("%d\n",d+f+(a>e?a:e))){a+=d,b+=e,c+=f,d=(a-1)/3,a-=d*3,e=(b-1)/3,b-=e*3,d+=e,f=(c-1)/3,c-=f*3;e=(a==3)+(b==3)+(c==3);if(a>b)a=b;if(a>c)a=c;}}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  string x,y; cin >> x >> y;

  ll ans = 0;
  int last;
  if (x[0] == y[0]) { ans = 3; last = 1; }
  else { ans = 6; last = 2; }

  for (int i = last; i < n; i++) {
    if (x[i] == y[i]) {
      if (last == 1) ans *= 2;
      last = 1;
    } else {
      if (last == 1) ans *= 2;
      else ans *= 3;
      last = 2;
      i++;
    }
    ans %= MOD;
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n;
	cin >> n;
	if (n >= 2800)cout << "AGC" << endl;
	else if (n >= 1200)cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();
    ll r[n + 1][m + 1];
    For(i, 0, n + 1)
    {
        For(j, 0, m + 1)
        {
            r[i][j] = 0;
        }
    }
    For(i, 1, n + 1)
    {
        For(j, 1, m + 1)
        {
            if (s[i - 1] == t[j - 1])
            {
                r[i][j] = r[i - 1][j - 1] + 1;
            }
            else
            {
                r[i][j] = max(r[i - 1][j], r[i][j - 1]);
            }
        }
    }
    ll i = n, j = m;
    string res = "";
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            res += s[i - 1];
            i--;
            j--;
        }
        else
        {
            if (r[i - 1][j] >= r[i][j - 1])
            {
                i--;
            }
            else
                j--;
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 74024
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn is_acgt_char(c: char) -> bool {
    match c {
        'A' | 'C' | 'G' | 'T' => true,
        _ => false,
    }
}

fn is_acgt_str(s: &str) -> bool {
    s.chars().all(is_acgt_char)
}

fn main() {
    let S = rl();
    let N = S.len();

    let mut max_len = 0;

    for l in 0..N {
        for r in l + 1..N + 1 {
            if is_acgt_str(&S[l..r]) {
                max_len = max(max_len, r - l);
            }
        }
    }

    println!("{}", max_len);
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
from functools import reduce
from operator import mul
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n,k=mii()

if k%2==1:
    p=n//k
    ans=p**3
else:
    p=n//k
    q=n//k
    if n%k>=k/2:
        q+=1
    ans=p**3 + q**3
print(ans)

Measured memory_bytes: 64492
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
B = sorted(B, reverse=True)
max_a = max(A)
i = 0 
while (i < N and B[i] > max_a):
  H -= B[i]
  if H <= 0:
    print(i+1)
    exit(0)
  i += 1
print(i + (H + max_a-1)//max_a)


Measured memory_bytes: 62296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();

		int ans = 0; 
		ans = (n*(n-1))/2 + (m*(m-1))/2;
		
		System.out.println(ans);
		scan.close();
	}
}

Measured memory_bytes: 22100
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int A, B, C, D, P; cin >> A >> B >> C >> D >> P;
	int ans = A*P;
	int nans;
	if (C > P)nans = B;
	else nans = B + (P - C)*D;
	cout << min(ans, nans) << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int n=0;
    rep(i,5){
        int a;
        cin>>a;
        if(a<=40)a=40;
        n+=a;
    }
    n/=5;
    cout<<n<<endl;

    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e5 + 9;

int32_t main(){
 L_T_S_K;
 int a , b;
 cin >> a >> b;
 cout << (a * b)/__gcd(a , b);
 return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
for i in range(150):
    if p.count(x + i) == 0 and p.count(x - i) == 0:
        print(min(x + i, x - i))
        break
    elif p.count(x + i) == 0:
        print(x + i)
        break
    elif p.count(x - i) == 0:
        print(x - i)
        break
    else:
        continue

Measured memory_bytes: 61952
# coding: utf-8
import math
#a, b, c = map(int,input().split())
N = int(input())
K = int(input())
#S = input()
ans = 0
#l = list(map(int,input().split()))
A = list(map(int,input().split()))

for i in range(N):
    ans += min(A[i], abs(K-A[i])) * 2

print(ans)

Measured memory_bytes: 9168
#!perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my $N_K = <STDIN>;
my ($N, $K) = split(' ', $N_K);

my $D = <STDIN>;
my $bad = '['. join('', split(' ', $D)) .']';

while( $N =~ /$bad/ ) { $N++ };
say $N;


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<int> num_w(n + 1), num_b(n + 1);
    for (int i = 0; i < n; ++i) {
        if (s[i] == '.') ++num_w[i];
        else ++num_b[i];
    }
    for (int i = 1; i < n; ++i) {
        num_w[i] += num_w[i - 1];
        num_b[i] += num_b[i - 1];
    }

    int min_cnt = num_w[n - 1];
    for (int i = 0; i < n; ++i) {
        int num = num_b[i] + (num_w[n - 1] - num_w[i]);
        min_cnt = min(min_cnt, num);
    }

    cout << min_cnt << endl;

    return 0;
}


Measured memory_bytes: 2196
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    # mod = 1000000007
    nmax = 10 ** 6 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, M = map(int, input().split())
    ans = 1
    for i in range(N):
        ans = (ans * (M-i))%mod
    ans = (ans * ans)%mod

    mpn = fac[M] * finv[M-N]
    for k in range(1, N+1):
        tmp = ((comb(N, k) * mpn)%mod * (fac[M-k] * finv[M-N])%mod)%mod
        ans = (ans + tmp * (-1)**k) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97340
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
int ans,sum,n;
string s[300],t[300];
map<int,int>m;
signed main(){
	cin>>n;
	r(i,n)cin>>s[i];
	r(i,n){
		int j=0;
			r(k,n)t[k]=s[k];
			r(k,n){
				r(l,n){
					t[k][l]=s[(i+k)%n][(j+l)%n];
				}
			}
			int s=0;
			r(k,n){
				r(l,n){
					if(t[k][l]!=t[l][k])s++;
				}
			}
			if(!s)sum++;
	}
	cout<<sum*n<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <vector>
#include <math.h>
#include <stack>
#include <deque>

int n,u,v,sum[100005],de[100005],t;
bool state;

std::vector<int> M[100005];

void add_edge(int u, int v)
{
	M[u].push_back(v);
	M[v].push_back(u);
}

void dfs(int x,int fa)
{
	de[x] = de[fa] + 1;
	sum[x] = 1;
	std::vector<int>::iterator It = M[x].begin();
	for(; It != M[x].end(); ++It)
	{
		if(*It != fa)
		{
			dfs(*It,x);
			sum[x] += sum[*It];
		}
	}
	if(x == n)
	{
		state = true;
		t = de[x] / 2;
		t += de[x] % 2;
		t++;
	}
	if(state && de[x] == t)
	{
		state = false;
		t = x;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i = 1; i < n; ++i)
	{
		scanf("%d %d",&u,&v);
		add_edge(u,v);
	}
	state = false;
	de[0] = 0;
	dfs(1,0);
	printf(n - sum[t] > sum[t] ? "Fennec" : "Snuke");
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> sumb(n+1, 0), sumw(n+1, 0);
    rep(i, 0, n) {
        if(s[i] == '#') sumb[i+1] = sumb[i] + 1, sumw[i+1] = sumw[i];
        else sumw[i+1] = sumw[i] + 1, sumb[i+1] = sumb[i];
    }
    ll ans = INF;
    rep(i, 0, n) {
        ll tmp = sumb[i+1] + sumw[n] - sumw[i+1];
        chmin(ans, tmp);
    }
    chmin(ans, sumb[n]);
    chmin(ans, sumw[n]);

    cout << ans << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a-1;i>=b;i--)
#define CL(x) (x<<1)
#define CR(x) (x<<1)+1
#define pb push_back
#define bit1(x) __builtin_popcount(x)
#define self (*this)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,pii> plii;
#define x first
#define y second

template<typename T> inline void _read(T &x){
    char ch; x=0; bool neg=false;
    for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
        if(ch=='-') neg=true;
    for(;ch>='0'&&ch<='9';ch=getchar()) x=10*x+ch-'0';
    if(neg) x=-x;
}
#define read(a) _read(a)
#define Read(a,b) _read(a),_read(b)
#define READ(a,b,c) _read(a),_read(b),_read(c)

const int maxn=1e2+7;
const int Nblocks=400;
const int maxS=(1<<5)+7;
const ll mod=9901;
const int inf=1e9+7;
const ll linf=1e16+9;
const double pi=4*atan(1);
const ll Radix=1e9;
const int Length=9;
const int MaxDigit=2e4+1;
const int nDigits=MaxDigit/Length+1;

int n;
map<string,bool> c;

inline void Enter(){
    cin>>n;
}

inline void Prepare(){

}

inline void Solve(){
    #define Kamisama
    bool chk=true;
    char pre=0;
    up(i,1,n){
        string s;
        cin>>s;
        if(c[s]) chk=false;
        c[s]=true;
        if(i==1) pre=s[0];
        if(s[0]!=pre) chk=false;
        pre=s.back();
    }
    if(chk) cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
  #define Kamisama
    #ifndef Kamisama
    freopen("TEST.INP","r",stdin);
    freopen("TEST.OUT","w",stdout);
    #endif // Kamisama

    Enter();
    Prepare();
    Solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,i,x;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x = i;
		while(x!=0){
			if(i%3==0 || x%10==3){
				printf(" %d",i);
				break;
			}
			x=x/10;
		}
	}
	printf("\n");
	
	return 0;
}

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


int f(int n) {
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    
    return f(n-1)+f(n-2)+f(n-3);
}
int main(void){
   while(true) {
       int n;
       cin >> n;
       if(n == 0) break;
       cout << (f(n) / 3650)+1  << endl;
   }
}




Measured memory_bytes: 3096
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //codefes2017c a
    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        boolean flag = false;
        for (int i = 0; i < s.length-1; i++) {
            if(s[i]=='A'&&s[i+1]=='C') flag = true;
        }
        out.println(flag?"Yes":"No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

const int N = 1005;
const int MASK = 1 << 15;

int n, m; long long cost[N], dp[N][MASK];
vector<int> box[N];

long long fun(int pos, int mask) {
  if (mask == (1 << n) - 1) {
    return 0;
  }
  if (pos == m) {
    return mask == (1 << n) - 1 ? 0 : 1e9;
  }
  long long &tmp = dp[pos][mask];
  if (tmp != -1) {
    return tmp;
  }
  tmp = 1e9;
  int newMask = mask;
  for (auto i : box[pos]) newMask |= (1 << i);
  tmp = min(tmp, cost[pos] + fun(pos + 1, newMask));
  tmp = min(tmp, fun(pos + 1, mask));
  return tmp;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> cost[i] >> x;
    while (x--) {
      int y;
      cin >> y;
      box[i].push_back(y - 1);
    }
  }
  memset(dp, -1, sizeof dp);
  long long ans = fun(0, 0);
  if (ans == 1e9) ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 257664
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

antenas = [a, b, c, d, e]

for idx, x in enumerate(antenas):
    for y in antenas[idx:]:
        if abs(x - y) > k:
            print(':(')
            exit()

print('Yay!')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
void solve()
{
	long long n;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << n / 2<<endl;
	}
	else
	{
		cout << n / 2 + 1 << endl;
	}
}
int main()
{

		solve();
		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool PN(T x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

void solve()
{
  long long x; cin >> x;
  if(PN(x)) {
    int order = 0;
    while(x){
      x/=10;
      order++;
    }
    cout << order << endl;
    return;
  } else {
    int target = 1;
    int target_order = 0;
    for(int i = 2; i <= sqrt(x); ++i){
      if(x % i == 0) target = i;
    }
    int another = x/target;
    int another_order=0;
    while(another){
      another/=10;
      another_order++;
    }
    while(target){
      target/=10;
      target_order++;
    }
    int ans = max(target_order, another_order);
    cout << ans << endl;
  }


}

int main()
{
  solve();
  return 0;
}

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

using namespace std;

struct edge{
	int u;	//?????????
	int v;	//??°??????
	int cost;	//??????
	//???????????????????????§?????§?°???¢????????????
	bool operator<(const edge& another) const {
			return cost < another.cost;
	}
};

const int MAX_N = 100000;
const int MAX_M = 100000;

edge es[MAX_M];
int par[MAX_N];
int rank[MAX_N];

void initial(int n){		//?????????
	for(int i=0;i<n;i++){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){		//??¨??????????±???????
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x,int y){	//x???????????¨??¨y???????????¨?????????
	x = find(x);	//x???????????¨??????????????????x??¨??????
	y = find(y);	//y???????????¨??????????????????y??¨??????
	if(x == y) return;
	if(rank[x] < rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){	//x,y???????????¨???????????§?????????
	return find(x) == find(y);
}

bool comp(const edge& e1,const edge& e2){
	return e1.cost < e2.cost;
}

int kruskal(int n,int m){
	initial(n);
	int res = 0;
	for(int i=0;i<m;i++){
		edge e = es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(){
	int n,m,j,k,l;
	cin >> n;	//????????°?????\???
	cin >> m;	//?????°?????\???
	for(int i=0;i<m;i++){
		cin >> j >> k >> l;
		es[i].u = j;	es[i].v = k;	es[i].cost = l;
	}
	sort(es,es+m);
	cout << kruskal(n,m) << "\n";
}

Measured memory_bytes: 4320
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;
int main(void) {
	int N;
	cin >> N;
	vector<double> A(N);
	double den = 0.;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		den += 1./A.at(i);
	}

	cout << fixed << setprecision(10) << 1./den << endl;

	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

class MyInputStream extends InputStream {
	public BufferedInputStream bis = new BufferedInputStream(System.in);

	public int read() throws IOException {
		int i;
		while ((i = bis.read()) < 48)
			if (i == -1)
				return -1;
		int temp = 0;
		while (i > 47) {
			temp = temp * 10 + i - 48;
			i = bis.read();
		}
		return temp;
	}
}

public class Main {

	static final int N = 100005;
	static final int inf = 0x3f3f3f3f;
	static final double eps = 1e-6;
    static int a[]=new int[N];
	public static void main(String[] args) throws IOException{
	MyInputStream cin=new MyInputStream();
	int n=cin.read(),l=cin.read(),t=cin.read();
    int tmp,cnt=0,d;
    for(int i=0;i<n;i++){
        a[i]=cin.read();d=cin.read();
        if(d==1){
            tmp=a[i]+t;
            a[i]=tmp%l;
            cnt+=tmp/l;
        }else{
            tmp=a[i]-t;
            a[i]=tmp%l;
            cnt+=tmp/l;
            if(a[i]<0){
            	a[i]+=l;
            	cnt--;
            }
        }
    }
    Arrays.sort(a,0,n);
    cnt%=n;
    if(cnt<0) cnt+=n;
    cnt%=n;
    StringBuilder ans=new StringBuilder("");
    for(int i=cnt;i<cnt+n;i++){
    	int j=i%n;
    	System.out.println(a[j]);
    }
}
}

Measured memory_bytes: 46000
#include "bits/stdc++.h"
using namespace std;

const int DIV = pow(10,9)+7;

int main() {
  int N;
  cin >> N;
  long long p = 1;
  for(int i=2;i<=N;i++){
    p *= i;
    p %= DIV;
  }
  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    String a=sc.next();
    String b=sc.next();
    int x=sc.nextInt();int y=sc.nextInt();
    String c=sc.next();
    if(c.equals(a))x--;
    else y--;
    System.out.print(x+" "+y);
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

struct mypair{
    long long a;
    long long sum;
};

bool cmp(const mypair &m1, const mypair &m2){
    return m1.a < m2.a;
}

int main(){
    long long N, K;
    cin >> N >> K;
    map <long long, long long> m;
    vector <mypair> v;
    long long a, b;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        auto itr = m.find(a);
        if(itr != m.end()){
            itr->second += b;
        }else{
            m[a] = b;
        }
    }
    for(auto itr = m.begin(); itr != m.end(); itr++){
        v.push_back(mypair{itr->first, itr->second});
    }
    sort(v.begin(), v.end(), cmp);
    for(int i=0; i<N; i++){
        if(K-v[i].sum > 0){
            K -= v[i].sum;
        }else{
            cout << v[i].a;
            break;
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 5368