akhauriyash/Code-Regression huggingface dataset:
n = int(input())

_list = []
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    _list.append([a, b, c])


for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        wait = s - time

        if wait >= 0:
            time += wait + c
            num += 1
            continue

        test = (wait * -1) // f
        s += int(f * test)

        wait = s - time

        if wait >= 0:
            time += wait + c

        else:
            time += wait + c + f

        num += 1

    print(time)


print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
#define SIZE 100

class stack{
	private:
		int top;
		int S[SIZE];
	public:
		void init(){
			top=0;
		}
	
		int pop(){
			top--;
			return S[top+1];
		}
		
		void push(int value){
			top++;
			S[top]=value;
		}
		
		void result(){
			cout<<S[top]<<endl;
		}
};

int main() {
	string word;
	stack A;
	A.init();
	while(cin>>word){
		if(word=="+"){
			int n=A.pop();
			int m=A.pop();
			A.push(n+m);
		}
		else if(word=="-"){
			int n=A.pop();
			int m=A.pop();
			A.push(m-n);
		}
		else if(word=="*"){
			int n=A.pop();
			int m=A.pop();
			A.push(n*m);
		}
		else A.push(atoi(word.c_str()));
	}
	A.result();
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
vector<int> v[N];
int n,k,result=1;
vector<int> a;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) {
    cin >> k;
    a.push_back(k);
  }
  VSORT(a);
  rep(i,n-1) {
    if(a[i] != a[i+1]) result++;
  }
  cout << result << endl;
}


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

struct card
{
  char picture;
  int value;
};

int partition (card A[], int p, int r)
{
  int x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++){
      if (A[j].value <= x){
	  i = i + 1;
	  swap(A[i],A[j]);
	  }
  }
  
  swap(A[i+1],A[r]);
  return i + 1;
}

void quicksort (card A[], int p, int r)
{
  if (p < r)
    {
      int q = partition (A, p, r);
      quicksort (A, p, q - 1);
      quicksort (A, q + 1, r);
    }
}

void merge(card n[], int left, int mid, int right)
{
	int num = right - left;
	card *tmp = new card[num];

	int iw = 0;
	int il = left;
	int ir = mid;

	while (il < mid && ir < right)
	{
		if (n[il].value <= n[ir].value)
		{
			tmp[iw++] = n[il++];
		}
		else {
			tmp[iw++] = n[ir++];
		}
	}

	while (il < mid) tmp[iw++] = n[il++];
	while (ir < right) tmp[iw++] = n[ir++];

	for (int i = 0; i<num; i++) n[left + i] = tmp[i];

	delete[] tmp;
}


void merge_sort_sub(card n[], int left, int right)
{
	if (right - left <= 1) return;

	int mid = left + (right - left) / 2;
	merge_sort_sub(n, left, mid);
	merge_sort_sub(n, mid, right);

	merge(n, left, mid, right);
}


void merge_sort(card n[], int len)
{
	merge_sort_sub(n, 0, len);
}

int main()
{
	int num = 0;
	cin >> num;
	card* cards = new card[num];
	card* cardscopy = new card[num];
	for (int i = 0; i < num; i++)
	{
		cin >> cards[i].picture >> cards[i].value;
		cardscopy[i].picture = cards[i].picture;
		cardscopy[i].value = cards[i].value;
	}

	quicksort(cards, 0, num - 1);
	merge_sort(cardscopy,num);
	bool flag = true;
	int i = 0;
	while (i < num)
	{
		if (cards[i].picture != cardscopy[i].picture) {
			flag = false;
			break;
		}
		i++;
	}

	if (flag)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	for (int i = 0; i < num; i++) {
		cout << cards[i].picture << " " << cards[i].value << endl;
	}
  return 0;
}

Measured memory_bytes: 5440
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int K=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		for (int i = A; i <= B; i++) {
			if (i%K==0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32556
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

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

int main() {
    n=read();
    for (re int i=1;i<=n;++i) b[i]=a[i]=read();
    sort(b+1,b+n+1); int ans=0;
    for (re int i=1;i<=n;++i) {
        int x=lower_bound(b+1,b+n+1,a[i])-b;
        ans+=(x-i)&1;
    }
    printf("%d\n",ans>>1);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define mkp make_pair
#define fi first
#define se second 
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,n_=1,m,ans,CNT,d[200004],f[200004];
vector<int>v;
pii s[200004];
struct Segment_Tree{
	int dat[530000];
	void init(int num){
		for (int i=1;i<2*n_;i++) dat[i]=num;
	}
	void upd(int id,int x){
		while (id){
			dat[id]=max(dat[id],x);
			id/=2;
		}
	}
	int qry(int l,int r,int id,int a,int b){
		if (r<a || b<l) return -1e6;
		if (a<=l && r<=b) return dat[id];
		return max(qry(l,(l+r)/2,id*2,a,b),qry((l+r+1)/2,r,id*2+1,a,b));
	}
}T1,T2; 
int main(){
	read(n);
	while (n_<n) n_<<=1;
	T1.init(0),T2.init(-1000000);
	for (int i=1;i<=n;i++){
		int x;read(x);
		d[i]=d[i-1];
		if (x==1) d[i]++,CNT++;
		else d[i]--;
	}
	read(m);
	for (int i=1;i<=m;i++) read(s[i].fi),read(s[i].se);
	sort(s+1,s+1+m);
	for (int i=1;i<=m;i++){
		int l=s[i].fi,r=s[i].se;
		if (r>l)f[i]=T2.qry(1,n_,1,l,r-1)+d[r];
		if (l>1) f[i]=max(f[i],T1.qry(1,n_,1,1,l-1)+d[r]-d[l-1]);
		else f[i]=max(f[i],d[r]);
		ans=max(ans,f[i]);
		T1.upd(r+n_-1,f[i]),T2.upd(r+n_-1,f[i]-d[r]);
	}
	write(CNT-ans);
}

Measured memory_bytes: 7552
from collections import deque
import copy

def main():
  H, W = map(int, input().split())
  maps = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if maps[i][j]])
  count = 0
  while True:
    nq = deque()
    while q:
      x, y = q.popleft()
      if x > 0 and not maps[x-1][y]:
        maps[x-1][y] = True
        nq.append((x-1,y))
      if y > 0 and not maps[x][y-1]:
        maps[x][y-1] = True
        nq.append((x,y-1))
      if x < H-1 and not maps[x+1][y]:
        maps[x+1][y] = True
        nq.append((x+1,y))
      if y < W-1 and not maps[x][y+1]:
        maps[x][y+1] = True
        nq.append((x,y+1))
    if nq:
      q = copy.copy(nq)
    else:
        break
    count += 1
  print(count)

if __name__ == "__main__":
  main()

Measured memory_bytes: 115560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputline1 = Console.ReadLine().Split(' ');
            int[] input1 = new int[4];
            input1= setData(inputline1);

            string[] inputline2 = Console.ReadLine().Split(' ');
            int[] input2 = new int[input1[0]];
            input2 = setData(inputline2);

            string[] inputline3 = Console.ReadLine().Split(' ');
            int[] input3 = new int[input1[1]];
            input3 = setData(inputline3);

            int z;

            for (z = -100; z <= 100; z++)
            {
                if (check1(z, input1[2], input1[3]) &&
                    check2(z, input2) &&
                    check3(z, input3))
                {
                    Console.WriteLine("No War");
                    return;
                }
            }



            Console.WriteLine("War");
        }

        static int[] setData(string[] s){
            List<int> i = new List<int>();

            foreach (string ss in s)
            {
                i.Add(int.Parse(ss));
            }

            return i.ToArray<int>();
        }

        static bool check1(int z, int x, int y)
        {
            return (x < z) && (z <= y);
        }

        static bool check2(int z, int[] x)
        {
            return (x.Max() < z);
        }
        
        static bool check3(int z, int[] y)
        {
            return (y.Min() >= z);
        }
    }
}


Measured memory_bytes: 13268
n, m = map(int, input().split())
A = []
B = []
for i in range(m):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
for i in range(1, n+1):
  cnt = 0
  for j, k in zip(A,B):
    if i == j or i == k:
      cnt += 1
  print(cnt)

Measured memory_bytes: 3060
//
//  main.cpp
//  190127
//

//

#include <iostream>
#include<algorithm>

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    std::string str[3];
    std::cin>>N>>str[0]>>str[1]>>str[2];

    int sum=0;
    for(int i=0;i<N;i++){
        bool tf[3];
        tf[0]=(str[0][i]==str[1][i]);
        tf[1]=(str[0][i]==str[2][i]);
        tf[2]=(str[1][i]==str[2][i]);
        if(tf[0]&&tf[1]&&tf[2]){
            continue;
        }else if(tf[0]||tf[1]||tf[2]){
            sum+=1;
        }else{
            sum+=2;
        }
    }
    std::cout<<sum<<std::endl;
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];

        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        bool[] loop = new bool[n];

        
        long toLoopStart = 0;
        long pos = 1;

        // １でなくてものループあるので、ループを見つける
        for (int i = 0; i <= n; i++)
        {
            loop[pos - 1] = true;
            pos = a[pos - 1];
            toLoopStart++;
            if (loop[pos - 1] == true)
            {
                break;
            }
        }

        long loopStart = pos;


        // loopStart以下なら先に排除
        if (toLoopStart >= k)
        {
            pos = 1;
            for (int i = 0; i < k; i++)
            {
                pos = a[pos - 1];
            }
            Console.WriteLine(pos);
            return;
        }

        pos = loopStart;
        long count = 0;

        // posからループあるので、ループを見つける
        for (int i = 0; i <= n; i++)
        {
            pos = a[pos - 1];
            count++;
            if (pos == loopStart) break;
        }

        var ugoku = (k - toLoopStart) % count;
        pos = loopStart;

        // あとは移動するだけ
        for (int i = 0; i < ugoku; i++)
        {
            pos = a[pos - 1];
        }

        Console.WriteLine(pos);
    }
}

Measured memory_bytes: 43988
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n;
    ios::sync_with_stdio(false);
    cin >> n;
    int k = 0;
    while(k * (k + 1) / 2 < n) {
        k++;
    }
    if(k * (k + 1) / 2 != n) {
        cout << "No";
        return 0;
    }
    k++;
    vector < vector <int> > sol;
    sol.resize(k + 1);
    cout << "Yes" << "\n" << k << "\n";
    int cur = 0;
    for(i = 1; i < k; i++) {
        for(j = i + 1; j <= k; j++) {
            sol[i].push_back(++cur);
            sol[j].push_back(cur);
        }
    }
    for(i = 1; i <= k; i++) {
        cout << sol[i].size() << " ";
        for(auto it : sol[i]) {
            cout << it << " ";
        }
        cout << "\n";
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 2304
n=int(input())
s=tuple(input())

m=[[] for i in range(10)]
for i in range(n):
    m[int(s[i])].append(i)

yn=""
icnt=0
for i in range(0,1000):
    yn=""
    stri=format(i,"03d")
    stri=list(map(int,stri))
    if len(m[stri[0]])>0:
        m01=m[stri[0]][0]
    else:
        continue

    if len(m[stri[1]])>0:
        for ii in m[stri[1]]:
            if m01<ii:
                m02=ii
                yn="yes2"
                break
    if yn!="yes2":
        continue

    if len(m[stri[2]])>0:
        for ii in m[stri[2]]:
            if m02<ii:
                yn="yes3"
                break
    if yn!="yes3":
        continue
    else:
        icnt+=1

print(icnt)       
    

Measured memory_bytes: 4584
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int max_i = max(max(A, B), C);
    if((3 * max_i - A - B - C) % 2 == 0){
        cout << (3 * max_i - (A + B + C))/ 2 << endl;
    }else{
        max_i++;
        cout <<(3 * max_i - (A + B + C)) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long LL;

int main(){
    int a,b,q;
    LL A[100000],B[100000],x,ans,*alb,*blb,apos[2],bpos[2];
    cin>>a>>b>>q;
    for(int i=0;i<a;i++){
        cin>>A[i];
    }
    for(int i=0;i<b;i++){
        cin>>B[i];
    }
    for(int i=0;i<q;i++){
        cin>>x;
        alb=lower_bound(A,A+a,x);
        blb=lower_bound(B,B+b,x);
        if(A+a==alb){
            alb--;
        }
        if(A==alb){
            apos[0]=A[0]-x;
        }else{
            apos[0]=A[alb-1-A]-x;
        }
        apos[1]=A[alb-A]-x;
        if(B+b==blb){
            blb--;
        }
        if(B==blb){
            bpos[0]=B[0]-x;
        }else{
            bpos[0]=B[blb-1-B]-x;
        }
        bpos[1]=B[blb-B]-x;
        ans=100000000000;
        for(int i=0;i<2;i++){
            for(int j=0;j<2;j++){
                ans=min(ans,abs(apos[i]-bpos[j])+min(abs(apos[i]),abs(bpos[j])));
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> solve(ll n,ll a,ll b){
    if(n==1)return {a,b};
    ll bit = 1 << (n-1);
    if( (a&bit) != (b&bit) ){
        auto v1 = solve(n-1,a,a^1);
        auto v2 = solve(n-1,(a^1)^bit,b);
        v1.insert(v1.end(),v2.begin(),v2.end());
        return v1;
    }
    else{
        auto v1 = solve(n-1,a,b);
        auto v2 = solve(n-1,a^bit,v1[1]^bit);
        v1.insert(v1.begin()+1,v2.begin(),v2.end());
        return v1;
    }
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,a,b;cin>>n>>a>>b;
    if(__builtin_parity(a)==__builtin_parity(b))return cout<<"NO" , 0;
    cout<<"YES\n";
    auto ans = solve(n,a,b);
    for(auto &ele:ans)cout<<ele<<" ";
}




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

int m,d,cnt=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>m>>d;
	for(int i=1;i<=m;i++){
		for(int j=20;j<=d;j++){
			int t = j / 10;
			if(t * (j % 10) == i && t > 1 && (j % 10) > 1)
				cnt++;
			
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
#define rrep(i,a,b)	for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e6+5,inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,x,y,z;
	x=y=z=-1;
	cin>>n>>m;
	rep(i,0,n)
	{
		rep(j,0,n-i)
		{
			int k=n-i-j;
			if(k>=0&&i*10000+j*5000+k*1000==m)
			{
				x=i,y=j,z=k;
				break;
			}
		}
	}
	cout<<x<<' '<<y<<' '<<z<<endl;
	return 0;
}

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

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	stringstream ss;
	for(int i = 1; i <= n; i++){
		int a;
		cin >> a;
		for(int j = 0; j < a; j++) ss << i << ' ';
	}
	int board[h][w];
	for(int i = 0; i < h; i++){
		if(i & 1){
			//左から右に
			for(int j = w - 1; 0 <= j; j--){
				int x;
				ss >> x;
				board[i][j] = x;
			}
		}else{
			//右から左に
			for(int j = 0; j < w; j++){
				int x;
				ss >> x;
				board[i][j] = x;
			}
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++) cout << board[i][j] << ' ';
		cout << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n,h;
int ct=0,c,e;
cin>>n>>h;
vector <int> b;
int max=0;
for(int i=0;i<n;i++){
  cin>>c>>e;
  b.push_back(e);
  if(c>max)max=c;
}
sort(b.begin(),b.end(),greater<int>());
int i=0;
while(b[i]>max){
  h-=b[i];
  ct++;
  if(h<=0)break;
  i++;
}
if(h>0){
  ct+=h/max;
  if(h%max!=0)ct++;
}
cout<<ct<<endl;
  return 0;
}


Measured memory_bytes: 892
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans = 0;
    int n;
    cin>>n;
    map<int,int>m1,m2;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        m1[a[i]-i]++;
        m2[a[i]+i]++;
    }
    for(auto x : m2){
        ans += (m1[-x.first] * x.second);
    }
    cout<<ans;
}


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

// #define DEBUG

using namespace std;

const int N = 1e2+7;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

int k;
string s;

inline int C(const int &p, const int &q)
{
    if (q > p || !q) return 0;
    int res = 1;
    for (int i = p; i > p-q; --i) res *= i;
    for (int i = 2; i <= q; ++i) res /= i;
    return res;
}

inline int pow9(const int &p)
{
    int res = 1;
    for (int i = 1; i <= p; ++i) res *= 9;
    return res;
}

inline int f(int i, const int &kk)
{
    while (i < (int)s.size() && s[i] == '0') ++i;
    if (i >= (int)s.size()) return 0;
    int res = pow9(kk)*C(s.size()-i-1, kk)+
        (s[i]-'1')*pow9(kk-1)*C(s.size()-i-1, kk-1);
    #ifdef DEBUG
    cout << s[i]-'1' << " " << pow9(kk-1) << " " << C(s.size()-i, kk-1) << endl;
    cout << res << endl;
    #endif
    return res+(kk == 1 ? s[i]-'0' : f(i+1, kk-1));
}

inline void solve()
{
    cin >> s >> k;
    cout << f(0, k) << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int h(int key,int i){ return (h1(key)+i*h2(key))%M;}

int find(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0){
            return 1;
        }else if(strlen(H[j])==0){
            return 0;
        }
        i++;
    }
}

int insert(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0)
            return 1;
        else if(strlen(H[j])==0){
            strcpy(H[j],str);
            return 0;
        }
        i++;
    }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
typedef std::pair<int, int> pii;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	map<int, int> v_odd = {};
	map<int, int> v_even = {};

	/* init */
	v_odd[0] = 0;
	v_even[0] = 0;

	rep (i, 1, n + 1) {
		int tmp;
		cin >> tmp;
		if (i % 2)
			v_odd[tmp]++;
		else
			v_even[tmp]++;
	}

	pii odd_max = make_pair(0, 0);
	pii odd_sub_max = make_pair(0, 0);
	pii even_max = make_pair(0, 0);
	pii even_sub_max = make_pair(0, 0);
	for (auto it = v_odd.begin(); it != v_odd.end(); it++) {
		if (odd_max.second <= it->second) {
			odd_sub_max = odd_max;
			odd_max = make_pair(it->first, it->second);
		} else if (odd_sub_max.second <= it->second) {
			odd_sub_max = make_pair(it->first, it->second);
		}

	}

	for (auto it = v_even.begin(); it != v_even.end(); it++) {
		if (even_max.second <= it->second) {
			even_sub_max = even_max;
			even_max = make_pair(it->first, it->second);
		} else if (even_sub_max.second <= it->second) {
			even_sub_max = make_pair(it->first, it->second);
		}
	}

	int res = 0;
	if (odd_max.first == even_max.first) {
		res = min(n / 2 - odd_sub_max.second + n / 2 - even_max.second,
							n / 2 - odd_max.second + n / 2 - even_sub_max.second);
	} else {
		res = n / 2  - odd_max.second + n / 2 - even_max.second;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int t = sc.nextInt();

    int bCount = 0;

    for (int curentTime = a; curentTime <= t; curentTime += a ) {
      bCount += b;
    }
    System.out.println(bCount);
  }
}

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

int N, M, L;

int main(){
  cin >> N >> M >> L;
  int ans;
  if(N>M){
    if(L>N) L *= 10;
    else N *= 10;
  }else if(L>M) L *= 10;
  else M *= 10;
  
  cout << N + M + L << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  if(a[2]==(a[1]+a[0]) )cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int a = 0, b = 0, c = 0;

int main(void) {
	Rapid;//固定高速

	int n, m;
	cin >> n >> m;
	int big = nine, small = 0;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		big = min(r, big);
		small = max(l, small);
	}
	if (big - small + 1 < 0)cout << 0 << rt;
	else cout << big - small + 1 << rt;

	please AC;
}

Measured memory_bytes: 256
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll x,y;cin>>x>>y;
	if(y%2==0)
	{
		ll b = y/2-x;
		ll a = x-b;
		if(a>=0 && b>=0 && a+b==x && 2*a+4*b==y) cout<<"Yes";
		else cout<<"No";
	}
	else cout<<"No";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll g = min(min(min(a, b), c), min(d, e));
    cout << 4 + (n + g - 1) / g << endl;
  return 0;
}


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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  vi P(N);
  for (auto& p : P) {
    cin >> p;
  }

  vector<double> E(N);
  REP(i, N) {
    E[i] = (1.0+double(P[i]))/2.0;
  }

  vector<double> sums(N);
  sums[0] = E[0];
  REP(i, 1, N) {
    sums[i] = sums[i-1] + E[i];
  }

  double ret = 0;
  REP(i, K-1, N) {
    double tmp = sums[i] - (i-K<0 ? 0 : sums[i-K]);
    chmax(ret, tmp);
  }

  cout << ret << endl;
  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 4224
N = int(input())

def dfs(s):
    if len(s) > 0:
        if int(s) > N:
            return 0

    count = 0

    if "3" in s and "5" in s and "7" in s:
        count += 1
    
    for next_n in ["3", "5", "7"]:
        count += dfs(s + next_n)

    return count

print(dfs(""))

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
char s[5];
int n,m,st[MAXN],res[MAXN],top;

bool ask(int a,int b)
{
    printf("? %d %d\n",a,b);
    fflush(stdout);scanf("%s",s);
    return s[0]=='Y';
}

int main()
{
    scanf("%d%d",&n,&m);
    if(n<=m) return printf("Impossible"),0;
    st[++top]=0;
    for(int i=1;i<n+m;i++)
        if(!top||ask(st[top],i)) st[++top]=i;
        else top--;
    for(int i=0;i<n+m;i++)
        res[i]=ask(st[top],i);
    printf("! ");
    for(int i=0;i<n+m;i++)
        printf("%d",res[i]);
    return 0;
}

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

int main(){
    unsigned long long int n;
    cin>>n;
    unsigned long long int a[n];
    unsigned long long int mod=pow(10, 9)+7;
    rep(i, n) {
        cin>>a[i];
        if(a[i]>=mod){
            a[i]%=mod;
        }
    }
    // rep(i,n){
    //     cout<<a[i]<<endl;
    // }
    unsigned long long int ans=0;
    unsigned long long int sum = 0;
    
    for(unsigned long long int i=0;i<n-1;i++){
        sum+=a[i];
        sum %= mod;
        ans += sum*a[i+1];
        ans %= mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5200
n, m = map(int,input().split())

lefts = [0] * m
rights = [0] * m

for i in range(m):
	l, r = map(int,input().split())
	lefts[i] = l
	rights[i] = r

lefts_max = max(lefts)
rights_min = min(rights)

result = rights_min - lefts_max + 1

print(max(result,0))

Measured memory_bytes: 10996
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String s = sc.next();
                int yono = 0;
                int[] a = new int[s.length()];
                for(int i = 1 ; i <= s.length() ; i++){
                        if(s.charAt(i - 1) == 'A'|| s.charAt(i - 1) == 'C' || s.charAt(i - 1) == 'G' || s.charAt(i - 1) == 'T'){
                                a[i - 1] = 1;
                        }else{
                                a[i - 1] = 0;
                        }
                }
                int pct = 0;
                for(int i = 0 ; i < s.length() ; i++){
                        if(a[i] == 1){
                                pct++;
                        }else{
                                pct = 0;
                        }
                        yono = Math.max(pct , yono);
                }
                System.out.println(yono);
        }
}
//無駄な配列の宣言をしてしまいました

Measured memory_bytes: 35692
#include<bits/stdc++.h>
using namespace std;
int a[2000005],b[2000005];
int mx = 1000005,cc=0;
bool vis[2000005];
bool sieve()
{

    int  cnt=0;
    for(int i=2;i<=mx;i+=2)
    {
        if(b[i]!=0)
            cnt+=b[i];
        vis[i] =true;
    }
    if(cnt>1)
        return false;
    for(int i=3;i*i<=mx;i++)
    {
        if(vis[i]==false)
        {
            for(int j=i*i;j<=mx;j+=i)
            {
                vis[j]= true;
            }

        }
    }
    a[0] = 2;
    cc++;
    for(int i=3;i<=mx;i+=2)
    {
        if(vis[i]==false)
            a[cc++] = i;
    }
    //cout << cc << endl;
    for(int i=0;i<cc;i++)
    {
        cnt=0;
        for(int j=a[i];j<=mx;j+=a[i])
        {
            if(b[j]!=0)
                cnt+=b[j];
        }
        if(cnt>1)
            return false;
    }
    return true;
}
int main()
{
    int n;
    cin >> n;
    int gcd=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >>  x;
        b[x]++;
        gcd = __gcd(x,gcd);
    }
    bool ans=sieve();
    if(ans==true)
        cout << "pairwise coprime\n";
    else if(ans==false &&gcd==1)
        cout << "setwise coprime\n";
    else
        cout << "not coprime\n";
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
//#define ALL(x) (x).begin(),(x).end()
//#define SZ(x) ((int)(x).size())
//#define F first
//#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;

//#define int long long

signed main()
{
    string S;
    cin >> S;
    int cnt = 0;
    if (S[0] == '1') ++cnt;
    if (S[1] == '1') ++cnt;
    if (S[2] == '1') ++cnt;
    cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	string s;//1111111
	getline(cin,s);
	for(int i=0;i<s.size();i++) {
		if(s[i]=='A' && s[i+1]=='C') {
			cout<<"Yes";
			return 0;//1111111
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

__int128 modularInverse(__int128 a, __int128 m){
	__int128 r0 = a, r1 = m, ri, s0 = 1, s1 = 0, si;
	while(r1){
		si = s0 - s1 * (r0 / r1), s0 = s1, s1 = si;
		ri = r0 % r1, r0 = r1, r1 = ri;
	}
	if(r0 < 0) s0 *= -1;
	if(s0 < 0) s0 += m;
	return s0;
}

ll n, res;

ll f (__int128 a, __int128 b) {
	if (b == 1) return n;

	__int128 inv = modularInverse(a % b, b);

	__int128 res = -a * inv;
	res %= n;
	if (res <= 0) res += n;

	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	n *= 2;

	res = n;

	for (ll i = 1; i * i <= n; i++)
		if (n % i == 0) {
			ll j = n / i;
			if (__gcd(i, j) == 1) {
				res = min(res, f(i, j));
				res = min(res, f(j, i));
			}
		}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>

int main()
{
	std::vector<int> brick;
	int a;
	std::cin >> a;
	for (int i = 0; i < a; ++i)
	{
		int temp;
		std::cin >> temp;
		brick.push_back(temp);
	}
	int count = 1;
	bool isable = false;
	for (auto itr = brick.begin(); itr != brick.end(); ++itr)
	{
		//std::cout << *itr << std::endl;
		if (count == *itr)
		{
			isable = true;
			++count;
		}
		
	}
	if (isable)
		std::cout << a - count+1 ;
	else
		std::cout << -1;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n,a=0,t=0,w=0,r=0;
     cin>>n;
     while(n--){
          string s;
          cin>>s;
          if(s[0]=='A')
          a++;
          else if(s[0]=='T')
          t++;
          else if(s[0]=='W')
          w++;
          else if(s[0]=='R')
          r++;
     }
     cout<<"AC x "<<a<<endl;
     cout<<"WA x "<<w<<endl;
     cout<<"TLE x "<<t<<endl;
     cout<<"RE x "<<r<<endl;
     return 0;
}


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

int L, now, res, lg2[1000010];
int n, cnt, from[110], to[110], val[110];

int main()
{
	lg2[1] = 0;
	for(int i = 2; i < 1000010; ++i) lg2[i] = lg2[i >> 1] + 1;
	scanf("%d", &L); --L; n = lg2[L] + 1;
	now = lg2[L], res = (1 << now) - 1;
	for(int i = 1; i <= now; ++i)
	{
		from[++cnt] = i, to[cnt] = i + 1, val[cnt] = 1 << (i - 1);
		from[++cnt] = i, to[cnt] = i + 1, val[cnt] = 0;
	}
	if(L == (1 << (now + 1)) - 1)
	{
		from[++cnt] = n, to[cnt] = n + 1, val[cnt] = 1 << (n - 1);
		from[++cnt] = n, to[cnt] = n + 1, val[cnt] = 0; ++n;
	}
	else
	{
		now = lg2[L - res];
		while(res < L)
		{
			from[++cnt] = now + 1, to[cnt] = n, val[cnt] = res + 1;
			res = res + (1 << now), now = lg2[L - res];
		}
	}
	printf("%d %d\n", n, cnt);
	for(int i = 1; i <= cnt; ++i)
		printf("%d %d %d\n", from[i], to[i], val[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 1, sizeof(mat))
const int N=10;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k,d[N],a;
	CLR(d);
	cin >> n >> k;
	FOR(i,0,k){
		cin >> a;
		d[a]=0;
	}

	for(int i=n;i<=10*n;i++){
		int j=i;
		while(j){
			a=j%10;
			j=j/10;
			if(d[a]==0){
				break;
			}
		}
		if(d[a]==0)continue;
		cout << i << endl;
		return 0;
	}
	return 0;
}


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

using namespace std;

#define pb push_back
#define UN unsigned
#define ll long long

int main(void) {
	ios::sync_with_stdio(0);

	int n, d;
	cin >> n >> d;

	int a[10][10];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++)
			cin >> a[i][j];
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			for (int k = 0; k < d; k++) {
				sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			if (sqrt(sum) == int(sqrt(sum)))
				ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define It it=se.begin();it!=se.end();it++
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define unmap unordered_map
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define sh short int
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
ll n,k;
ll a[200009];
bool done[200009];
ll out(ll ID){
    ll id = ID,q = 0;
    while(k > 0){
        id = a[id],q++,k--;
        if(id == ID) break;
    }
    if(q) k %= q;
    while(k > 0){
        id = a[id],k--;
    }
    return id;
}
int main(){
    fast,cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll id = 1;
    while(k--){
        done[id] = 1;
        id = a[id];
        if(done[id]){
            id = out(id);
        }
    }
    cout<<id<<endl;
}


Measured memory_bytes: 5388
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int X;
    cin >> X;
    ll sum = 0;
    int cnt = 0;
    while(sum < X){
        ++cnt;
        sum += cnt;
    }

    cout << cnt << endl;
    return 0;
}


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

signed main(){
  string s;
  cin >> s;
  string t="";
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      t+='A';
    }
    else{
      if(s[i]=='B'){
        if(i<n-1&&s[i+1]=='C'){
          t+='S';
        }
        else{
          t+='X';
        }
      }
      if(s[i]=='C'){
        if(i==0||s[i-1]!='B'){
          t+='X';
        }
      }
    }
  }
  int m=t.size();
  int ans=0;
  int count=0;
  for(int i=m-1;i>=0;i--){
    if(t[i]=='A'){
      ans+=count;
    }
    else if(t[i]=='S'){
      count++;
    }
    else{
      count=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 776
s = input()
li = range(1,8)
if(s == 'SUN'):
    print(li[6])
elif(s == 'MON'):
    print(li[5])
elif(s == 'TUE'):
    print(li[4])
elif(s == 'WED'):
    print(li[3])
elif(s == 'THU'):
    print(li[2])
elif(s == 'FRI'):
    print(li[1])
elif(s == 'SAT'):
    print(li[0])


Measured memory_bytes: 3060