akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=998244353;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
bool g[51][51];
bool f[51];
int main(){
    int n;cin>>n;
    int a[51],b[51];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    fill(f,f+50,true);
    ll ans=0;
    bool s=true,z=true;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])s=false;
    }
    if(s){
        cout<<0<<endl;
        return 0;
    }
    memset(g,0,sizeof(g));
    for(int i=0;i<51;i++){
        for(int j=1;j<51;j++){
            g[i][i%j]=true;
        }
    }
    for(int l=0;l<51;l++){
        for(int i=0;i<51;i++){
            for(int j=0;j<51;j++){
                if(g[i][l]&&g[l][j])g[i][j]=true;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!g[a[i]][b[i]]){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(ll k=50;k>0;k--){
        memset(g,0,sizeof(g));
        f[k]=false;
        for(int i=0;i<51;i++){
            for(int j=1;j<51;j++){
                if(f[j]){
                    g[i][i%j]=true;
                }
            }
        }
        for(int l=0;l<51;l++){
            for(int i=0;i<51;i++){
                for(int j=0;j<51;j++){
                    if(g[i][l]&&g[l][j])g[i][j]=true;
                }
            }
        }
        bool res=false;
        for(int i=0;i<n;i++){
            if(!g[a[i]][b[i]]){
                res=true;
            }
        }
        if(res){
            ans+=(1LL<<k);
            f[k]=true;
        }
    }
    if(ans==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N;
	cin >> N;
	if (N % 1000 != 0) cout << 1000 - (N % 1000) << endl;
	else cout << 0 << endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
#define HOU 1000000007
#define INF 3e9
#define SUPpl 202
#define SUPmaxw 10002



// rsss[pi][qi][w] = [0:pi] dake tukatte, saigoni tukawanakattanoga qi-1 de, w tukuru kumiawase
int orss[SUPpl][SUPmaxw]; //orss=rsss[pi-1]
int nrss[SUPpl][SUPmaxw]; //nrss=rsss[pi]


int main(){
	int pl, maxw;
	cin>>pl>>maxw;
	int ws[pl];
	FOR(pi,0,pl){
		cin>>ws[pi];
	}
	sort(ws,ws+pl,greater<int>());
	


	FOR(qi,0,pl+1){
		FOR(w,0,maxw+1){
			nrss[qi][w]=0;
			nrss[qi][w]=0;
		}
	}
	nrss[0][0]=1;

	/*
	cout<<"pi:"<<0<<", qi:"<<0<<", w:"<<0<<", rsss[pi][qi][w]:"<<1<<endl;
	*/



	FOR(pi,1,pl+1){
		FOR(qi,0,pl+1){
			FOR(w,0,maxw+1){
				orss[qi][w]=nrss[qi][w];
				nrss[qi][w]=0;
			}
		}

		//when pi>qi: rsss[pi][qi][w] = rsss[pi-1][qi][w-ws[pi-1]]
		FOR(qi,0,pi){
			FOR(w,0,maxw+1){
				if(w-ws[pi-1]>=0){
					nrss[qi][w] = orss[qi][w-ws[pi-1]] %HOU;
				}
			}
		}

		//when pi==qi: rsss[pi][qi][w] = rsss[pi-1][0][w]+..+rsss[pi-1][qi-1][w]
		FOR(oqi,0,pi){
			FOR(w,0,maxw+1){
				nrss[pi][w] =( nrss[pi][w]+orss[oqi][w] ) %HOU;
			}
		}

		//when pi<qi: rsss[pi][qi][w]=0

		/*
		FOR(qi,0,pl+1){
			FOR(w,0,maxw+1){
				if(nrss[qi][w]!=0){
					cout<<"pi:"<<pi<<", qi:"<<qi<<", w:"<<w<<", rsss[pi][qi][w]:"<<nrss[qi][w]<<endl;
				}
			}
		}
		*/
		
	}

	int re=nrss[0][maxw];
	FOR(qi,1,pl+1){
		FOR(w,0,maxw+1){
			if(w+ws[qi-1]>maxw){
				re=( re+nrss[qi][w] )%HOU;
			}
		}
	}

	cout<<re<<endl;

}

Measured memory_bytes: 16908
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const [a, b, c]: number[] = input[0].split(' ').map((x: string): number => +x);

const A: number = a-b;
if(c-A >= 0){
    console.log(c-A);
}else{
    console.log(0);
}


Measured memory_bytes: 7500
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cassert>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define ALL(A) (A).begin(),(A).end()
#define SZ(A) int(A.size())

using namespace std;

typedef unsigned long long ull;

struct RollingHash{
  static const ull p=100000007;
  string s;
  int n;
  vector<ull> pow, phash;
  //ull *pow,*phash;
  
  RollingHash(const string &s) : s(s), n(SZ(s)),pow(n+1),phash(n+1){
    //pow=new ull[n+1];
    //phash=new ull[n+1];
    pow[0]=1,phash[0]=0;
    REP(i, n) {
      phash[i+1] = s[i] + phash[i] * p;
      pow[i+1] = pow[i] * p;
    }
  }

  //~RollingHash(){ free(pow), free(phash); }

  inline bool operator()(const int& i, const int& j) const { 
    const int k=lcp(i,j);
    return i+k >= n ? true : j+k >= n ? false : s[i+k] <= s[j+k];
  }

  /*
  static ull hash(const string &t) {
    ull h=0;
    REP(i,SZ(t))h=t[i]+h*p;
    return h;
  }  
  */

  inline ull hash(const int& b, const int& e) const {
    return phash[e]-phash[b]*pow[e-b];
  }
  /*
  inline int find(string t) {
    int w=t.size(),count=0;
    if(w > SZ(s))return 0;
    ull h=hash(t);
    REP(i,n-w+1)count+=(hash(i,i+w)==h);
    return count;
  }
  */
  
  inline int lcp(const int& i, const int& j) const {
    int l=0,r=n-max(i,j)+1;
    while(r-l>1) {
      const int m=(l+r)>>1;
      (hash(i,i+m) == hash(j,j+m) ? l : r) = m;
    }
    return l;
  }
};

int L[1000000],R[1000000];

inline void merge(int *A, const int left, const int mid, const int right, const RollingHash &rh){
  const int n1 = mid - left, n2 = right - mid;
  REP(i,n1)L[i]=A[left+i];
  REP(i,n2)R[i]=A[mid+i];
  for(int k =left,i=0,j=0;k<right;k++){
    if(n2<=j)A[k]=L[i++];
    else if(n1<=i)A[k]=R[j++];
    else A[k]=rh(L[i],R[j])?L[i++]:R[j++];
  }
}

void mergeSort(int *A,const int left,const int right, const RollingHash &rh){
  if(left+1<right){
    const int mid = (left+right)>>1;
    mergeSort(A,left,mid, rh);
    mergeSort(A,mid,right, rh);
    merge(A,left,mid,right, rh);
  }
}

//O(n (log n)^2)
vector<int> suffixArray(const RollingHash &rh){
  int n=rh.n+1,sa[n];
  REP(i,n)sa[i]=i;
  mergeSort(sa,0,n,rh);
  vector<int>res(n);
  REP(i,n)res[i]=sa[i];
  return res;
}

bool contain(const string &S, const vector<int> &sa, const string &T){
  int a=0, b=SZ(S);
  while(b-a>1){
    const int c=(a+b)/2;
    (S.compare(sa[c],T.length(),T)<0 ? a : b ) = c;
  }
  return S.compare(sa[b], T.length(), T) == 0;
}

int main(void){

  char str[1000002];
  string s,t;
  scanf("%s",str);
  s=str;
  
  RollingHash rh=RollingHash(s);
  vector<int>sa=suffixArray(rh);
  
  int n;
  cin >> n;

  while(n--){
    scanf("%s",str);
    t=str;
    printf("%d\n",contain(s,sa,t));
  }

  return 0;
}

Measured memory_bytes: 32600
#include "bits/stdc++.h"
using namespace std;
#define LL long long

void solve() {
   int n,p,q;
   cin>>n>>p>>q;
   for(int i=p;i<=q;i++){
       if(i%n==0){
           puts("OK");
           return;
       }
   }
  puts("NG");
}

int main()
{
    //int tc;
	//scanf("%d", &tc);
	//while(tc--) {
        solve();
//	}
    return 0; 
}

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

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

  bool yes = false;

  for(int i=0;i<=7;i++) {
    string begin = s.substr(0, i);
    string end = s.substr(s.size()- 7 + i, 7 - i);

    string key = "keyence";
    string keyBegin = key.substr(0, i);
    string keyEnd = key.substr(i, 7 - i);

    if(begin == keyBegin && end == keyEnd) {
      yes = true;
      break;
    }
  }

  cout << (yes ? "YES" : "NO") << endl;
}

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

using namespace std;

#define range(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) range(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define s first.first
#define l first.second 
#define p second

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

const int N = 394;

int main(){
	int n; cin >> n;
	vector< pair<pii, int> > f(n);

	rep(i, n) cin >> f[i].s >> f[i].l >> f[i].p;

	vi dp(N);
	fill(all(dp), -1);
	dp[0] = 0;

	rep(i, n)
		range(j, f[i].s, f[i].l + 1)
			rep(k, N)
				if(dp[k] != -1 && k + j < N)
					dp[k + j] = max(dp[k + j], dp[k] + f[i].p);

	int m; cin >> m;
	vi res(m);

	rep(i, m){
		int w; cin >> w;

		res[i] = dp[w];
	}

	if(find(all(res), -1) != res.end()) cout << -1 << endl;
	else rep(i, m) cout << res[i] << endl;


	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!= NIL){
      y=x;
      if(z->key < x->key){
          x=x->left;
      }else{
          x=x->right;
      }
  }
  z->parent=y;

  if(y == NIL){
      root=z;
  }else if(z->key < y->key){
      y->left = z;
  }else{
      y->right = z;
  }
}

void inorder(Node u){
    if(u == NIL) return;

    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);

}
void preorder(Node u){
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main(){
    int i,n,x;
    char com[20];

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&x);
            insert(x);
        }else{
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 25296
#include <iostream>
#include <string>
#include <sstream>

using namespace std;
int bits;
char str[1010];
char *sp;

int formula(){
	char c;
	c=*sp++;
	if('a'<=c&&c<'k') return bits>>(c-'a')&1;
	if(c=='T') return 1;
	if(c=='F') return 0;
	if(c=='-') return !formula();
	if(c=='('){
		int left, right;
		char ope;
		left = formula();
		ope = *sp++;
		if(ope=='-') sp++;
		right = formula();
		sp++;
		if(ope=='*') return  left && right;
		if(ope=='+') return  left || right;
		if(ope=='-') return !left || right;
	}
	return 0;
}

int equation(){
	int left,right;
	left=formula();
	sp++;
	right=formula();
	return left==right;
}

int main(){
	while(cin>>str, *str!='#'){
		for(bits=0;bits<2<<11;bits++){
			sp = str;
			if(!equation()) break;
		}
		cout<<(bits<2<<11?"NO":"YES")<<endl;
	}
}

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

int main() {
    int n, t;
    scanf("%d%d", &n, &t);
    vector<pair<int, int>> cts(n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &cts[i].first, &cts[i].second);
        if(cts[i].second > t){
            cts[i] = {10000, 10000};
        }
    }

    int smallest = 10000;
    for(pair<int, int> p : cts){
        smallest = min(smallest, p.first);
    }
    smallest == 10000 ? printf("TLE") : printf("%d", smallest);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    int num=0,ans=0;
    vector<int>h(n);
    rep(i,n){
        cin>>h[i];
        if(h[i]>num){
            ans+=(h[i]-num);
        }
        num=h[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    int m, p;
    vector<vector<bool> > privacy(n, vector<bool>(n + 1, false));
    for(int i = 0; i < n; i++){
      cin >> m;
      for(int j = 0; j < m; j++){
        cin >> p;
        privacy[i][p] = true;
      }
    }

    int k;
    cin >> k;
    vector<int> l(k);
    for(int i = 0; i < k; i++){
      cin >> l[i];
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
      bool flag = true;
      for(int j = 0; flag && j < k; j++)
        if(!privacy[i][l[j]])
          flag = !flag;
      if(flag){
        if(ans == 0)
          ans = i + 1;
        else
          ans = -1;
      }
    }

    if(ans == 0){ ans = -1; }
    cout << ans << endl;
  }



  return 0;
}

Measured memory_bytes: 3172
import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc =[list(map(int,input().split())) for i in range(q)]

ans = sum(a)
num = collections.Counter(a)

for i in range(q):
    before = bc[i][0]
    after = bc[i][1]
    ans += num[before]*(after-before)
    num[after] += num[before]
    num[before] = 0
    #print(a.count(before))
    #print(num(before))
    print(ans)


Measured memory_bytes: 40240
class Node:
    def __init__(self, num: str):
        self.num = num
        self.before = None
        self.next = None
    
class Linked_List:
    def __init__(self):
        self.head = None
        self.tail = None
    
    def append(self, node):
        if self.head is None:
            self.head = node
            self.tail = node
        else:
            node.before = self.tail
            self.tail.next = node
            self.tail = node

    def check(self):
        node = self.tail
        ans = 0
        while not node is self.head:
            before_node = node.before
            if node.num != before_node.num:
                ans += 2
                if before_node is self.head:
                    break
                elif node is self.tail:
                    before_node.before.next = None
                    self.tail = before_node.before
                    node = before_node.before
                else:
                    before_node.before.next = node.next
                    node.next.before = before_node.before
                    node = node.next
            else:
                node = node.before
        print(ans)

S = list(input())
cube = Linked_List()

for c in S:
    node = Node(c)
    cube.append(node)

cube.check()


Measured memory_bytes: 20392
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll cs=a[0];
    rep(i,1,n-1){
        if(cs*2>=a[i])cs+=a[i];
        else break;
        if(i==n-1){
            cout<<n<<endl;return 0;
        }
    }
    ll ok=n-1;ll ng=0;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll sum=0;
        rep(i,0,mid)sum+=a[i];
        bool f=true;
        rep(i,mid+1,n-1){
            if(sum*2>=a[i]){
                sum+=a[i];
            }else{
                f=false;
                break;
            }
        }
        if(f)ok=mid;
        else ng=mid;
    }
    cout<<n-ok<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
D dot(P a,P b) {return (conj(a)*b).X; }
D cross(P a,P b) {return(conj(a)*b).Y;}
int ccw(P a,P b,P c){
  b-=a;c-=a;
  if(cross(b,c) >EPS)return +1;
  if(cross(b,c)< -EPS)return -1;
  if(dot(b,c)< -EPS)return +2;
  if(norm(b)<norm(c))return -2;
  return 0;
}
bool isecSS(P a1, P a2, P b1, P b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}
bool isecSP(P a1,P a2,P b) {
  return abs(a1 - b) + abs(a2 - b) - abs(a2 - a1) < EPS;
}
P proj(P a1,P a2,P p){return a1+dot(a2-a1, p-a1)/norm(a2-a1)*(a2-a1);}
D distSP(P a1,P a2,P p) {
  P r=proj(a1,a2,p);
  if(isecSP(a1,a2,r))return abs(r-p);
  return min(abs(a1-p),abs(a2-p));
}
 
D distSS(P a1,P a2,P b1,P b2) {
  if (isecSS(a1,a2,b1,b2))return 0;
  return min(min(distSP(a1,a2,b1),distSP(a1,a2,b2)),min(distSP(b1,b2,a1),distSP(b1,b2,a2)));
}
int n,x,x1,y2;
double h,a[222][222];
vector<P>v[222];
main(){
  while(cin>>h>>n,h){
    r(i,222)r(j,222)a[i][j]=1e15;
    r(i,222)v[i].clear();
    v[n].push_back(P(0,0));
    v[n].push_back(P(0,1e9));
    v[n+1].push_back(P(h,0));
    v[n+1].push_back(P(h,1e9));
    r(i,n){
      cin>>x;
      while(x--){
        cin>>x1>>y2;
        v[i].push_back(P(x1,y2));
      }
    }
    r(i,n+2)r(j,n+2)r(k,v[i].size())r(l,v[j].size())
      a[i][j]=min(a[i][j],distSS(v[i][k],v[i][(k+1)%(int)v[i].size()],v[j][l],v[j][(l+1)%(int)v[j].size()]));
    r(k,n+2)r(i,n+2)r(j,n+2)a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    printf("%.9f\n",a[n][n+1]);
  }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    int a,b;

    cin >> a >> b;

    for(int i = 1;i <= 100000;i++){
        // cout << "i:" << i << endl;
        // cout << floor(i * 0.08) << endl;
        // cout << floor(i * 0.1) << endl;
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }


    cout << "-1" << endl;
    return 0;
}

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

int main() {
  int H, W, counter;
  string s0, s1, s2, s3;
  cin >> H >> W;
  s0 = "....................................................";
  for (int i = 0; i <= H; i++){
    if (i == 0){
      cin >> s3;
      s3 = "." + s3 + ".";
      s2 = s0;
    } else{
      s1 = s2;
      s2 = s3;
      if(i == H)
      s3 = s0;
      else{
        cin >> s3;
        s3 = "." + s3 + ".";
      }
      for (int j = 1; j <= W; j++){
        counter = 0;
        if (s2.at(j) == '.'){
          if (s1.at(j - 1) == '#')
          counter++;
          if (s1.at(j) == '#')
          counter++;
          if (s1.at(j + 1) == '#')
          counter++;
          if (s2.at(j - 1) == '#')
          counter++;
          if (s2.at(j + 1) == '#')
          counter++;
          if (s3.at(j - 1) == '#')
          counter++;
          if (s3.at(j) == '#')
          counter++;
          if (s3.at(j + 1) == '#')
          counter++;
          cout << counter;
        }
        else
        cout << "#";
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

template<typename IntType>
IntType all_pattern(IntType a, IntType b, IntType mod_ = 1000000007) {
  IntType res = 1;
  for (a %= mod_; b; a = a * a % mod_, b >>= 1)
    if (b & 1) res = res * a % mod_;
  return res;
}
template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    i64 n;
    cin >> n;
    mat2d_t<i64> dp(n+1, 3, 0);
    dp[0][0]=1; dp[0][1]=0;dp[0][2]=0;
    for (int i=1; i<=n; ++i) {
        dp[i][0] = (dp[i-1][0] * 8) % mod;
        dp[i][1] = (dp[i-1][1] * 9 + dp[i-1][0]) % mod;
        dp[i][2] = (dp[i-1][2] * 9 + dp[i-1][0]) % mod;
    }
    i64 ans = all_pattern<i64>(10, n);
    ans -= (dp[n][0] + dp[n][1] + dp[n][2]) %mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;

    return 0;
}

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

const int N = 500;

int sg[N][N];

int dfs(int u, int v) {
  if (sg[u][v] != -1) return sg[u][v];
  set<int> s;
  for (int i = 1; 2 * i <= u; i++) {
    s.insert(dfs(u - 2 * i, i + v));
  }
  for (int i = 1; 2 * i <= v; i++) {
    s.insert(dfs(u + i, v - 2 * i));
  }
  for (int i = 0;; i++) {
    if (s.find(i) == s.end()) {
      return sg[u][v] = i;
    }
  }
}
long long x, y;
int main() {
  memset(sg, -1, sizeof sg);
  sg[0][0] = sg[0][1] = sg[1][0] = sg[1][1] = 0;
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      dfs(i, j);
      //  printf("%d ", sg[i][j]);
    }
    // printf("\n");
  }
  cin >> x >> y;
  if (abs(x - y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
  return 0;
}



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

const int N = 2e5 + 10 ;

int main() {
    int tot , y , gap , ans = 0 ;
    scanf("%d %d %d" , &tot , &y , &gap ) ;
    for( int i = 1 ; ; i++ ) {
        if( (i+1)*gap + (i*y) > tot ) break ;
        ans = i ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
using ll = long long;
using namespace std;

const int bit_size = 60;
int msb(ll x) {
    repeat_reverse (i, bit_size) {
        ll y = 1ll << i;
        if (y & x) return i;
    }
    return -1;
}
ll solve(ll a, ll b) {
    // drop unnecessarily bits
    while (true) {
        int r = msb(b);
        if (r == -1) break;
        ll x = 1ll << r;
        if ((a & x) and (b & x)) {
            a ^= x;
            b ^= x;
        } else {
            break;
        }
    }
    // trivial case
    if (b == 0) return 1;
    assert (a < b);
    // prepare
    int r = msb(b);
    ll x = 1ll << r;
    assert (     b & x);
    assert (not (a & x));
    ll result = 0;
    // the msb is true
    if (b == x) {
        if (a == 0) {
            result += x - a;
        } else {
            result += x - a + 1;
        }
    } else {
        int k = msb(b ^ x);
        assert (k != -1);
        if (a >= (1ll << (k+1))) {
            result += 1ll << (k+1);
            result += x - a;
        } else {
            result += x;
        }
    }
    // the msb is false
    result += x - a;
    return result;
}

int main() {
    ll a, b; scanf("%lld%lld", &a, &b);
    ll result = solve(a, b);
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 55
using namespace std;
int n, m, K, flag, Ans, x[N], y[N], h[N], mx[N][N], mn[N][N];
int main(){
	scanf("%d%d%d", &n, &m, &K);
	for(int i = 1; i <= K; i++)
		scanf("%d%d%d", &x[i], &y[i], &h[i]);
	memset(mx, 0x3f, sizeof mx);
	memset(mn, -0x3f, sizeof mn);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			for(int k = 1; k <= K; k++){
				mn[i][j] = max(mn[i][j], h[k] - abs(i - x[k]) - abs(j - y[k]));
				mx[i][j] = min(mx[i][j], h[k] + abs(i - x[k]) + abs(j - y[k]));
			}
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(mn[i][j] > mx[i][j]) flag = 1;
			Ans += mn[i][j];
		}
	}
	if(flag) puts("No");
	else printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 3252
EPS = 1e-10
def cross(p, q)
  x0 = p[2] - p[0]
  y0 = p[3] - p[1]
  x1 = q[2] - q[0]
  y1 = q[3] - q[1]
  x2 = q[0] - p[0]
  y2 = q[1] - p[1]
  return if (x0 * y1 - x1 * y0).abs < EPS
  r = (y1 * x2 - x1 * y2) / (x0 * y1 - x1 * y0)
  x = p[0] + r * x0; y = p[1] + r * y0
  return unless x.abs < 100.0 && y.abs < 100.0
  [x, y]
end

while n = gets.to_i
  break if n == 0
  ls = n.times.map{ gets.split.map(&:to_f) }
  ans = 1
  (0...n).each do |i|
    (0...i).each_with_object([]) do |j, arr|
      unless (ps = cross(ls[i], ls[j])).nil?
        ans += 1 unless arr.any?{ |p, q| Math.sqrt((p - ps[0]) ** 2 + (q - ps[1]) ** 2 ) < EPS }
        arr << ps
      end
    end
    ans += 1
  end
  p ans
end

Measured memory_bytes: 8932
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18
#
A, B, C, K = map(int, input().split())

if K <= A:
    print(K)
    exit()
if A < K <= A + B:
    print(A)
    exit()
if A + B < K <= A + B + C:
    print(A - (K - A - B))

Measured memory_bytes: 65260
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

template <typename T>
inline void readArray(vector<T>& arr, int n) {
  arr.resize(n);
  for (auto& element : arr) {
    cin >> element;
  }
}

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> h;
  readArray(h, n);
  vector<int> cost(n);
  cost[n - 1] = 0;
  cost[n - 2] = abs(h[n - 1] - h[n - 2]);
  for (int i = n - 3; i >= 0; --i) {
    cost[i] = cost[i + 1] + abs(h[i + 1] - h[i]);
    for (int j = i + 1; j <= min(n - 1, i + k); ++j) {
      cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
    }
  }
  cout << cost[0] << endl;
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int dp[1001][1001];

int main(){
	int i,n,j,k,la,lb;
	char a[1001],b[1001];
	scanf("%d",&n);
	while(n--){
		scanf("%s",a);
		scanf("%s",b);
		la = strlen(a);
		lb = strlen(b);
		for( i = 0; i < la; i++ ){
            for( j = 0; j < lb; j++ ){
                if( a[i] == b[j]){
                    dp[i+1][j+1] = dp[i][j] + 1;
                } else {
                    if( dp[i+1][j] >= dp[i][j+1] ){
                        dp[i+1][j+1] = dp[i+1][j];
                    } else dp[i+1][j+1] = dp[i][j+1];
                }
            }
		}
		printf("%d\n",dp[la][lb]);
	}
}



Measured memory_bytes: 7136
fs = require('fs');
input = fs.readFileSync('/dev/stdin','utf8');
S = input.split('\n')[0];
T = input.split('\n')[1];
R = 0;
for(i = 0; i < S.length; i++) {
  if(S[i] != T[i]) R = R + 1;
}
console.log(R);


Measured memory_bytes: 33120
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


int main()
{
	int n;

	while (cin >> n,n){
		Int dp[10000];
		Int aa[10000];

		fill(aa, aa + 10000, 0);
		fill(dp, dp + 10000, 0);

		REP(i, n){
			cin >> aa[i];
		}

		Int max_i = -99999999;

		dp[0] = aa[0];

		max_i = max(max_i, dp[0]);

		for(int i = 1; i < n ; ++i){
			dp[i] = max(aa[i], dp[i - 1] + aa[i]);
			max_i = max(max_i, dp[i]);
		}

		cout << max_i << endl;
	}
	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
const lint LINF=10000000010ll;
inline lint mul(lint a,lint b,lint O){
	const static int one=(1<<20)-1;
	return (a*(b>>20)%O*(1<<20)%O+a*(b&one)%O)%O;
}
inline lint sqr(lint x,lint O){
	return mul(x,x,O);
}
inline lint gcd(lint a,lint b){
	return b?gcd(b,a%b):a;
}
inline lint fpow(lint x,lint n,lint O){
	lint ans=1;
	for(;n;n>>=1,x=sqr(x,O)){
		if(n&1){
			ans=mul(ans,x,O);
		}
	}
	return ans;
}
int mnp[N],prime[N],ps=0;
bool isp[N];
inline void gmath(int n){
	memset(isp,true,sizeof(isp));
	for(int i=2;i<=n;i++){
		if(isp[i]){
			prime[ps++]=i;
			mnp[i]=i;
		}
		for(int j=0,cur=2;j<ps&&i*cur<=n;cur=prime[++j]){
			isp[i*cur]=false;
			mnp[i*cur]=cur;
			if(i%cur==0)break;
		}
	}
}
inline bool miller_rabin(lint O){
	const static int a[]={2,3,5,7,11};
	lint t=O-1;
	int cnt2=0;
	for(;(t&1)==0;t>>=1,cnt2++);
	for(int i=0;i<5;i++){
		lint w=fpow(a[i],t,O);
		bool isp=w==1;
		for(int j=0;!isp&&j<cnt2;j++,w=sqr(w,O)){
			isp=w==O-1;
		}
		if(!isp)return false;
	}
	return true;
}
lint fact[N];
int fs;
void factorize(lint O){
	if(O<N){
		for(;O!=1;fact[fs++]=mnp[O],O/=mnp[O]);
		return;
	}
	if(miller_rabin(O)){
		fact[fs++]=O;
		return;
	}
	//pollard-rho
	lint x1=rand()%O,x2=x1,c=2;
	lint d;
	do{
		x1=(sqr((sqr(x1,O)+c)%O,O)+c)%O;
		x2=(sqr(x2,O)+c)%O;
		if(x1==x2)return factorize(O);
	}while(d=gcd((x2-x1+O)%O,O),d==1);
	assert(d<O&&O%d==0);
	factorize(d),factorize(O/d);
}
lint a[N];
map<lint,lint>m;
int main(){
	gmath(N-1);
	int n=ni;
	int ans=0;
	for(int i=1;i<=n;i++){
		fs=0,factorize(next_num<lint>());
		sort(fact,fact+fs);
		a[i]=1;
		lint b=1;
		bool flag=true;
		for(int j=0,k=0;j<fs;j=k){
			for(;k<fs&&fact[j]==fact[k];k++);
			if(fact[j]>1000000ll){
				flag=false,i--,n--,ans++;
				break;
			}
			int tmp=(k-j)%3;
			if(tmp){
				a[i]*=tmp==1?fact[j]:fact[j]*fact[j];
				b*=fact[j];
				if(b>LINF){
					flag=false,i--,n--,ans++;
					break;
				}
				if(tmp==1){
					b*=fact[j];
					if(b>LINF){
						flag=false,i--,n--,ans++;
						break;
					}
				}
			}
		}
		if(flag){
			m[a[i]]=b;
		}
	}
	sort(a+1,a+n+1);
	for(int i=1,j=1;i<=n;i=j){
		for(;j<=n&&a[i]==a[j];j++);
		lint b=m[a[i]];
		if(a[i]==b){
			ans++;
		}else{
			lint* l=lower_bound(a+1,a+n+1,b);
			lint* r=lower_bound(a+1,a+n+1,b+1);
			if(l==r){
				ans+=j-i;
			}else if(a+i<l){
				ans+=max((int)(j-i),(int)(r-l));
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6784
n = int(input())
c = input()
white = c.count("W")
red = c.count("R")
if white == 0 or red == 0:
    print(0)
    exit()

ans = 0
count = 0
if white > red:
    for x in c:
        if x == "W":
            ans += 1
            count += 1
        else:
            count += 1
        if count == red:
            print(ans)
            exit()
else:
    for x in reversed(c):
        if x == "R":
            ans += 1
            count += 1
        else:
            count += 1
        if count == white:
            print(ans)
            exit()

Measured memory_bytes: 9500
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool one(const vector<string> &v, int x, int y) {
    if(x < 0 || y < 0 || x >= v[0].size() || y >= v.size()) return false;
    return v[y][x] == '1';
}

int main() {
    vector<string> v(8);
    while(cin >> v[0]) {
        for(int i = 1; i < 8; ++i) cin >> v[i];

        char kind;
        for(int y = 0; y < 8; ++y) {
            for(int x = 0; x < 8; ++x) {
                if(one(v, x, y)) {
                    if(one(v, x+1, y) && one(v, x, y+1) && one(v, x+1, y+1)) kind = 'A';
                    else if(one(v, x, y+1) && one(v, x, y+2) && one(v, x, y+3)) kind = 'B';
                    else if(one(v, x+1, y) && one(v, x+2, y) && one(v, x+3, y)) kind = 'C';
                    else if(one(v, x, y+1) && one(v, x-1, y+1) && one(v, x-1, y+2)) kind = 'D';
                    else if(one(v, x+1, y) && one(v, x+1, y+1) && one(v, x+2, y+1)) kind = 'E';
                    else if(one(v, x, y+1) && one(v, x+1, y+1) && one(v, x+1, y+2)) kind = 'F';
                    else if(one(v, x+1, y) && one(v, x, y+1) && one(v, x-1, y+1)) kind = 'G';
                    goto end;
                }
            }
        }
end:
        cout << kind << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;

const int N = 100+10;
const int W = 1e5+10;
int n,w;
LL DP[W];

int main(){
  scanf("%d%d",&n,&w);
  int a;
  LL v;
  for(int i=1; i<=n; i++){
    scanf("%d%lld",&a,&v);
    for(int j = w; j-a>=0; j--){
      if(j-a==0 || DP[j-a]){
        DP[j] = max(DP[j], DP[j-a] + v);
      }
    }
  }
  LL res = 0;
  for(int i=1; i<=w; i++)
    res = max(res, DP[i]);

  printf("%lld\n",res);

  return 0;
}


Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, P = MAP()
	S = list(map(int, list(input())))

	if P == 2 or P == 5:
		ans = 0

		for i, s in enumerate(S):
			if int(s)%P == 0:
				ans += i+1
		print(ans)

	else:
		tmp = 0

		mod_cnt = [0]*P

		z = 1
		for i, n in enumerate(S[::-1]):
			tmp += n*z
			z = z * 10 % P
			mod_cnt[int(tmp)%P] += 1
		ans = 0
		for v in mod_cnt:
			ans += v*(v-1)//2
		print(ans+mod_cnt[0])


if __name__ == '__main__':
	main()


Measured memory_bytes: 8600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  ll cnt = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
  {
    if (a == b && b == c)
    {
      cout << -1 << endl;
      return 0;
    }
    ll ta = (b + c) / 2, tb = (a + c) / 2, tc = (a + b) / 2;
    a = ta, b = tb, c = tc;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n;
    cin >> n;
    vector<double> p(n);
    rep(i,n){
        cin >> p[i];
    }
    vector<vector<double>> dp(n+1,vector<double> (n+1,0));
    dp[0][0] = 1.0;
    rep(i,n){
        rep(j,n){
            if(i < j) dp[i+1][j+1] = 0;
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);  
        } 
    }
    int ans = (n+1)/2;
    double sum = 0;
    for(int i = ans;i < n+1;++i){
        sum += dp[n][i];
    }
    cout << fixed << setprecision(10) << sum << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		if((a<=c)&&(c<=b)) System.out.println("Yes");
		else System.out.println("No");
	}
} 

Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n;
double dp[3100][3100], ans;

int main() {
	dp[0][0] = 1;
	cin >> n;
	REP(i, n) {
		double a;
		cin >> a;
		REP(j, 3010) {
			dp[i + 1][j + 1] += dp[i][j] * a;
			dp[i + 1][j] += dp[i][j] * (1 - a);
		}
	}
	FOR(i, n / 2 + 1, n + 1) ans += dp[n][i];
	cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 73984
#include<iostream>
using namespace std;
long n,ans;
int main(){
    cin>>n;
    long a[n+1],b[n];
    for(int i=0;i<=n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        if(b[i]>=a[i]+a[i+1]){
            ans+=a[i]+a[i+1];
            a[i]=a[i+1]=0L;
        }
        else if(b[i]>=a[i]){
            ans+=b[i];
            a[i+1]-=(b[i]-a[i]);
            a[i]=0L;
        }
        else{
            ans+=b[i];
            a[i]-=b[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int k;
    cin >> k;
    rep(i, 0, k) cout << "ACL";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int pattern = 0;
  for (int i=0;i<=A;i++){
    for (int j=0;j<=B;j++){
      for (int k=0;k<=C;k++){
        if (500*i+100*j+50*k==X) ++pattern;
      }
    }
  }
  cout << pattern << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	ll result=0;

	cin>>N;
	set<string> S;
	REP(i, N) {
		string T;
		cin >>T;
		S.insert(T);
	}
	result=SIZE(S);
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 19184
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;

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

	cout << (n*(n + 1)) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int L = scanner.nextInt();

		long table[] = new long[N];
		for(int i = 0; i < N; i++){

			table[i] = scanner.nextLong();
		}

		PriorityQueue<Info> Q = new PriorityQueue<Info>();

		if(table[0] > table[1]){

			Q.add(new Info(0,L-table[0]));
		}
		for(int i = 1; i < N-1; i++){
			if(table[i] > table[i-1] && table[i] > table[i+1]){

				Q.add(new Info(i,L-table[i]));
			}
		}
		if(table[N-1] > table[N-2]){

			Q.add(new Info(N-1,L-table[N-1]));
		}

		long current = 0;

		while(!Q.isEmpty()){

			current = Q.peek().time;
			table[Q.peek().id] = 0; //折れた

			if(Q.peek().id > 0 && table[Q.peek().id-1] > 0){ //左のつららがまだ折れてない場合
				if(Q.peek().id-1 == 0 || table[Q.peek().id-1] > table[Q.peek().id-2]){

					Q.add(new Info(Q.peek().id-1,current+L-table[Q.peek().id-1]));
				}
			}
			if(Q.peek().id < N-1 && table[Q.peek().id+1] > 0){ //右のつららがまだ折れてない場合
				if(Q.peek().id+1 == N-1 || table[Q.peek().id+1] > table[Q.peek().id+2]){

					Q.add(new Info(Q.peek().id+1,current+L-table[Q.peek().id+1]));
				}
			}

			Q.poll();
		}

		System.out.println(current);
	}
}

class Info implements Comparable<Info>{
	public int id;
	public long time;

	Info(){}
	Info(int arg_id,long arg_time){

		id = arg_id;
		time = arg_time;
	}
	public int compareTo(Info another){
		if(this.time < another.time)return -1;
		if(this.time > another.time)return 1;
		return 0;
	}
}


class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


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

using namespace std;

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

	list<char> ans;

	for(int i=0;i<s.size();++i)
		ans.push_back(s[i]);

	bool rev = false;

	while(q--){
		int T;
		cin >> T;
		if(T == 1){
			rev = !rev;
		}
		if(T == 2){
			int F;
			char C;
			cin >> F >> C;
			if((F == 1 && !rev) || (F == 2 && rev)){
				ans.push_front(C);
			}
			else if((F == 2 && !rev) || (F == 1 && rev)){
				ans.push_back(C);
			}

		}
	}

	if(rev){
		while(!ans.empty()){
			cout << ans.back();
			ans.pop_back();
		}
	}
	else{
		while(!ans.empty()){
			cout << ans.front();
			ans.pop_front();
		}
	}

	cout << '\n';
}

Measured memory_bytes: 9984
function main(input) {
  var temp = parseInt(input);
  var answer = "";
  for (var i = 1; i < temp+1; i++) {

    if (i%3 == 0 || i.toString().includes("3")) {
      answer += (" "+i);
    }
  }
  console.log(answer);
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 17604
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll n,a,b; cin>>n>>a>>b;
	string s; cin>>s;
	ll j=0, f=0;
	for(auto x:s)
	{
		if(x=='c')cn;
		else if(j+f<a+b)
		{
			if(x=='a')
			{
				cy;
				j++;
			}
			else if(x=='b'&&f<b)
			{
				cy;
				f++;
			}
			else cn;
		}
		else cn;
	}
}

int main()
{
	solve();
}
/*



*/

Measured memory_bytes: 3724
n=int(input())
s=[]
M,A,R,C,H=0,0,0,0,0
for i in range(n):
    s.append(input())

for i in range(n):
    S=''
    S=s[i]
    if S[0]=='M':
        M+=1
    elif S[0]=='A':
        A+=1
    elif S[0]=='R':
        R+=1
    elif S[0]=='C':
        C+=1
    elif S[0]=='H':
        H+=1
    else:
        pass
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H)

Measured memory_bytes: 9772
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

#include<iostream>

int main(){
    int const INF = 1000000000;
    int n, c;
    cin >> n >> c;
    int d[c][c];
    int col[n][n];
    rep(i, c)rep(j, c) cin >> d[i][j];
    rep(i, n)rep(j, n) {
        cin >> col[i][j];
        col[i][j]--;
    }
    int a[3][c];
    rep(i, 3)rep(j, c) a[i][j] = 0;
    rep(i, n)rep(j, n){
        int pos = (i + 1 + j + 1) % 3;
        a[pos][col[i][j]]++;
    }
    // rep(i, 3){
    //     rep(j, c){
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int ans = INF;
    rep(i, c)rep(j, c)rep(k, c){
        if (i != j && j != k && k != i){
            int ans1 = 0;
            rep(l, c){
                ans1 += a[0][l] * d[l][i];
                ans1 += a[1][l] * d[l][j];
                ans1 += a[2][l] * d[l][k];
            }
            ans = min(ans1, ans);
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
ans=[]

while 1:
	s1=input().split('"')
	if s1[0]==".":
		break

	s2=input().split('"')
	
	if len(s1)!=len(s2):
		ans.append("DIFFERENT")
		continue
	else:
	
		cnt=0
		flag=0
		
		for i in range(len(s1)):
		
			if s1[i]!=s2[i]:
			
				if i==0:
					flag=1
					break
					
				elif i%2==0:
					flag=1
					break
				else:
					cnt+=1
			
		if flag==1 or cnt>1:
			ans.append("DIFFERENT")
		elif cnt==1:
			ans.append("CLOSE")
		else:
			ans.append("IDENTICAL")

for a in ans:
	print(a)


Measured memory_bytes: 5588