akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
const int N=80+10;
const int M=80*80;
int n,m,a[N][N],b[N][N];
bool dp[N][N][M*2+10];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&b[i][j]);
	dp[1][1][M+a[1][1]-b[1][1]]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=0;k<=2*M;k++)
				if(dp[i][j][k])
				{
					if(k+a[i+1][j]-b[i+1][j]>=0)
						dp[i+1][j][k+a[i+1][j]-b[i+1][j]]=1;
					if(k+b[i+1][j]-a[i+1][j]>=0)
						dp[i+1][j][k+b[i+1][j]-a[i+1][j]]=1;
					if(k+a[i][j+1]-b[i][j+1]>=0)
						dp[i][j+1][k+a[i][j+1]-b[i][j+1]]=1;
					if(k+b[i][j+1]-a[i][j+1]>=0)
						dp[i][j+1][k+b[i][j+1]-a[i][j+1]]=1;
				}
	for(int i=0;i<=M;i++)
		if(dp[n][m][M-i]||dp[n][m][M+i])
		{
			printf("%d",i);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 93056
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int[][][] arr = new int[4][3][10];//??????[?£?][???][??¨?±?]
//??¨?±?????????°????????????
		for(int i=0; i<4; i++){
			for(int j=0; j<3; j++){
				for(int k=0; k<10; k++){
					arr[i][j][k] = 0;
				}
			}
		}
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//??\?????????
		for(int i=0; i<n; i++){
			int b = scan.nextInt()-1;
			int f = scan.nextInt()-1;
			int r = scan.nextInt()-1;
			int v = scan.nextInt();
			arr[b][f][r] += v;
		}
		for(int i=0; i<4; i++){
			for(int j=0; j<3; j++){
				for(int k=0; k<10; k++){
					System.out.print(" " + arr[i][j][k]);
				}
				System.out.println();
			}
			if(i!=3) {
				System.out.println("####################");
				}
		}
	}
}

Measured memory_bytes: 29728
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 2000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


ll x;

int main(void){
	scanf("%lld",&x);
	ll sum=0,a=0;
	while(sum<x){
		a++;
		sum+=a;
	}
	printf("%lld\n",a);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
    int n,t;
    cin >> n >> t;
    int minCost = 10000;
    for(int i=0;i<n;i++){
        int ci,ti;
        cin >> ci;
        cin >> ti;
        if(ti<=t) minCost = min(minCost,ci);
    }
    if(minCost>1000){
        cout << "TLE" << endl;
        return 0;
    }
    cout << minCost << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc143/abc143_c
import sys
import re

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    S = i2s()
    print(len(re.sub(r'(.)(\1)*', r'\1', S)))
    return

main()


Measured memory_bytes: 14324
#!/usr/bin/env python
def main():
    A, B, K = map(int, input().split())
    cnt = 0
    for i in reversed(range(1, 101)):
        if A % i == 0 and B % i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                exit()

if __name__ == '__main__':
    main()



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

int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int>v;

    for(int i=0;i<s.size();i++)
    {
        if(i+1<s.size()&&s[i]=='A'&&s[i+1]=='C')
        {
            v.push_back(i+1);
            v.push_back(i+2);
        }
    }
    sort(v.begin(),v.end());
    //for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;

    while(k--)
    {
        int a,b;
        cin>>a>>b;
        int ans1=9999999;
        int l=0,r=v.size()-1;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(v[mid]>=a)
            {
                ans1=min(mid,ans1);
                r=mid-1;
            }
            else l=mid+1;
        }


        int ans2=0;
        l=0,r=v.size()-1;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(v[mid]<=b)
            {
                ans2=max(mid,ans1);
               l=mid+1;
            }
            else r=mid-1;
        }
       // cout<<ans1<<" "<<ans2<<endl;
        if(ans1%2==1)ans1+=1;
        if(ans2%2==0)ans2-=1;

        if(ans1<ans2&&v[ans1]>=a&&v[ans2]<=b)cout<<(ans2-ans1+1)/2<<endl;
        else cout<<0<<endl;

    }
}


Measured memory_bytes: 1528
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N;
double v[105], t[105], x[105], area;

int main(){
  FAST_IO

  cin >> N;

  area = 0;

  for(int rep = 0; rep < N; ++rep) cin >> t[rep];
  for(int rep = 0; rep < N; ++rep) cin >> v[rep];

  for(int rep = 1; rep < N; ++rep){
    x[rep] = min(v[rep - 1], v[rep]);
  }

  for(int rep = 1; rep < N; ++rep){
    min_self(x[rep], x[rep - 1] + t[rep - 1]);
  }

  for(int rep = N - 1; rep >= 1; --rep){
    min_self(x[rep], x[rep + 1] + t[rep]);
  }

  for(int i = 0; i < N; ++i){
    double d = t[i] - (v[i] - x[i]) - (v[i] - x[i + 1]);
    double b = max(x[i], x[i + 1]);
    double f = min(x[i], x[i + 1]);

    if(d >= 0){
      area += t[i] * v[i];
      area -= (v[i] - b) * (v[i] - b) / 2.0;
      area -= (v[i] - f) * (v[i] - f) / 2.0;
    }else{
      area += t[i] * f;
      area += t[i] * t[i] / 2.0;
      area -= (f + t[i] - b) * (f + t[i] - b) / 4.0;
    }
  }
      
  PRECISION(3);
  cout << area << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    char a[n][n], b[m][m], ab[m][m];
    bool isGood = true;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i <= n - m; i++)
    {
        for (int j = 0; j <= n - m; j++)
        {
            for (int x = 0; x < m; x++)
            {
                for (int y = 0; y < m; y++)
                {
                    ab[x][y] = a[i + x][j + y];
                }
            }
            isGood = true;
            for (int x = 0; x < m; x++)
            {
                for (int y = 0; y < m; y++)
                {
                    if (ab[x][y] != b[x][y])
                    {
                        isGood = false;
                    }
                }
            }
            if (isGood == true)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double d, t, s;
    cin >> d >> t >> s;
    double act = d / s;
    cout << (act <= t ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3728
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
B = [K-Q]*N

for i in range(Q):
    B[A[i]-1] += 1
    
for i in range(N):
#if A.count(i+1) > S :
#      B[i] += S + A.count(i+1)

    if B[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10452
n, w = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
ws = [x[0] for x in s]
v = [x[1] for x in s]

dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for sum_w in range(w+1):
        if sum_w + ws[i] <= w:
            dp[i+1][sum_w + ws[i]] = max(dp[i+1][sum_w + ws[i]],
                                         dp[i][sum_w]+v[i])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[-1][-1])


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

int main(){
    int K;
    cin >> K;
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<int> sa(0);
    rep(i,N - 1){
        sa.push_back(vec[i + 1] - vec[i]);
    }
    sa.push_back(vec[0] + K - vec[N - 1]);
    sort(all(sa));
    cout << K - sa[N - 1] << endl;
}



Measured memory_bytes: 5080
#include <bits/stdc++.h>
int N;

int fib() {
    int arr[N+1];
    arr[0] = 0; arr[1] = 1;

    for (int i = 2; i <= N+1; i++) {
        arr[i] = arr[i-1] + arr[i-2];
    }
    return arr[N+1];
}


int main() {

    std::scanf("%d", &N);
    std::printf("%d\n", fib());

}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
map<int,bool> m;
signed main(){
	int a;
	cin>>a;
	for(int i=0;;i++){
		if(m[a]){
			cout<<i+1<<endl;
			return 0;
		}
		m[a]=true;
		if(a%2) a=a*3+1;
		else a/=2;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
	int N = sc.nextInt();
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	int[] Di = new int[N];
	
	for(int i=0;i < N;i++){
		Di[i] = sc.nextInt();
	}
	
	Arrays.sort(Di);
	int pc = C;
	int pp = A;
	
	for(int i=N-1;i > -1; i--){
		if(pc / pp <= (pc + Di[i]) / (pp + B)){
			pc = pc + Di[i];
			pp = pp + B;
		}
	}
	System.out.println(pc/pp);
}
}

Measured memory_bytes: 18144
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back

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

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int N; cin >> N, N != 0; ) {
    vi x(N), y(N);
    REP(i, 1, N) {
      int n, d; cin >> n >> d;

      static array<int, 4> dx = {-1, 0, 1, 0};
      static array<int, 4> dy = {0, 1, 0, -1};

      x[i] = x[n] + dx[d];
      y[i] = y[n] + dy[d];
    }

    int w = *max_element(all(x)) - *min_element(all(x)) + 1;
    int h = *max_element(all(y)) - *min_element(all(y)) + 1;
    cout << w << ' ' << h << endl;

  }
  
  
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,ans,now,cnt,b[N],vi[N];
map<__int128,__int128>ma,pos;
__int128 a[N<<1];
int main(){
	scanf("%d",&n);
	for(int i=2;i<N;i++){
		if(!vi[i])	b[++now]=i;
		for(int j=1;j<=now&&b[j]*i<N;j++){
			vi[i*b[j]]=1;
			if(i%b[j]==0)	break;
		}
	}
	for(int i=1;i<=n;i++){
		__int128 x,val=1,res=1;
		long long h;
 
		scanf("%lld",&h),x=h;
		int k=pow(x+0.5,1.0/3);
		for(int i=1;i<=now;i++)
			if(b[i]>k)	break;
			else{
				int d=0;
				while(x%b[i]==0)
					x/=b[i],++d;
				d%=3;
				if(!d)	continue;
				if(d==1)	val*=b[i],res*=b[i]*b[i];
				else	val*=b[i]*b[i],res*=b[i];
			}
		k=sqrt(x),val*=x;
		if(1LL*k*k==x)	res*=k;
		else	res*=x*x;
		pos[val]=res,pos[res]=val,++ma[val],a[++cnt]=res,a[++cnt]=val;
	}
	sort(a+1,a+cnt+1);
	n=unique(a+1,a+cnt+1)-a-1;
	for(int i=1;i<=n;i++){
		if(pos[a[i]]>a[i])	ans+=max(ma[a[i]],ma[pos[a[i]]]);
		else	if(pos[a[i]]==a[i])	++ans;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int c = 100 * r + 10 * g + b;
  if (c % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
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();
		int k = sc.nextInt();

		int ans = 0;

		for(int i = 0; i < k; i++) {
			if(a >= 1) {
				a--;
				ans++;
			} else if(b >= 1) {
				b--;
			} else {
				c--;
				ans--;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 35628
S = input()
mod = 10**9+7
dp  = [[0] * (13) for i in range(100005)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
    
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki*10+j)%13] += dp[i][ki]

    for j in range(13):
        dp[i+1][j] %= mod
    
print(dp[len(S)][5])

Measured memory_bytes: 63888
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
A.sort()
a, b = [0] * N, [0] * N
c, d = A[:(N + 1) // 2], A[(N + 1) // 2:]
a[0] = c[len(c) - 1]
c.pop()
if N % 2:
	if len(c):
		a[len(a) - 1] = c[len(c) - 1]
		c.pop()
else:
	a[len(a) - 1] = d[0]
	d.pop(0)
e, f = A[:N // 2], A[N // 2:]
b[0] = f[0]
f.pop(0)
if N % 2:
	if len(f):
		b[len(b) - 1] = f[0]
		f.pop(0)
else:
	b[len(b) - 1] = e[len(e) - 1]
	e.pop()
i = 1
while i < N - 1:
	if i % 2:
		a[i] = d[len(d) - 1]
		b[i] = e[len(e) - 1]
		d.pop()
		e.pop()
	else:
		a[i] = c[len(c) - 1]
		b[i] = f[len(f) - 1]
		c.pop()
		f.pop()
	i += 1
g = [0, 0]
i = 1
while i < N:
	g[0] += abs(a[i - 1] - a[i])
	g[1] += abs(b[i - 1] - b[i])
	i += 1
print(max(g[0], g[1]))

Measured memory_bytes: 54668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

void partition (int r, int a[]) {
    int x = a[r - 1];
    int num = -1;
    rep (j, 0, r - 1) {
        if (a[j] <= x) {
            num++;
            swap (a[num], a[j]);
        }
    }
    swap (a[++num], a[r - 1]);
    rep (i, 0, r) {
        if (i == num + 1) cout << "]";
        if (i) cout << " ";
        if (i == num) cout << "[";
        cout << a[i];
    }
    cout << "\n";
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    partition (n, a);
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
int main(){
  long x;
  cin>>x;
  int a=0;
  while(a==0){
    long z=0;
    long y=0;
    for(int i=2;i<x/2;i++){
      if(x%i==0){
        y++;
        break;
      }
    }
    if(y==0){
      a++;
      break;
    }
    x++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{	
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	int x = 1;
	int cnt = 0;
	bool ok = 0;
	while(n--){
		x = a[x];
		++cnt;
		if(x == 2) {
			ok = 1;
			break;
		}	
	}
	cout << (ok ? cnt : -1);
}


 
 
int main()
{
 //	freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	   Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

const int N = 1e5 + 5, bSize = 505;

ll arr[N];
map<ll, ll> cnt;

ll ans = 0;

int main()
{
    ll n, m;
    scanf("%lld%lld", &n, &m);
    cnt[0] = 1;
    for(int i = 0 ; i < n ; i++)
    {
        scanf("%lld", arr + i);
        if(i) arr[i] += arr[i - 1];
    }
    for(int i = 0 ; i < n ; i++)
    {
        ans += cnt[arr[i] % m];
        cnt[arr[i] % m]++;
    }
    printf("%lld\n", ans);
}


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

int main(void){
    string s, find_str, ring_str = "";
    cin >> s;
    cin >> find_str;
    
    for(int i=0; i<2; i++) ring_str += s;
    
    if(ring_str.find(find_str) != string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;        
    }
    
    return 0;
}



Measured memory_bytes: 3232
import java.util.Scanner;;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a = String.valueOf(N).length();
		int sum = 0;
		
		for(int i=1;i<a;i+=2) {
			sum += 9*Math.pow(10, (double)i-1);
		}
		if(a%2 == 1){
			sum += N - Math.pow(10, (double)a-1) + 1;
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<ll>A(N);
  int maxid;
  ll maxabs=0;
  ll m=0;
  for(int i=0; i < N; i++){
    cin >> A[i];
    if(abs(A[i]) >= maxabs){
      maxid = i;
      maxabs = abs(A[i]);
      m = A[i];
    }
  }
  vector<vector<int> >B(2*N, vector<int>(2));
  int c = 0;
  if(m > 0){
    for(int i=0; i < N; i++){
      B[c][0] = maxid;
      B[c][1] = i;
      c++;
    }
    for(int i=0; i < N-1; i++){
      B[c][0] = i;
      B[c][1] = i+1;
      c++;
    }
  }else{
    for(int i=0; i < N; i++){
      B[c][0] = maxid;
      B[c][1] = i;
      c++;
    }
    for(int i=N-1; i > 0; i--){
      B[c][0] = i;
      B[c][1] = i-1;
      c++;
    }
  }

  cout << c << endl;
  for(int i=0; i < c; i++){
    cout << B[i][0]+1 << ' ' << B[i][1]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;
int a[maxn];
bool done[maxn];
bool solve(){
   int n;cin>>n;
   int pre = 0;
   int t = 0;
   for(int i= 1;i <= n;++i){
   	cin>>a[i];
   	if(t-a[i] > 1)
   		return false;
   	t = max(t,a[i]);
   }
  
   return true;
}
int main(void)
{
	if(solve())
   		cout<<"Yes"<<endl;
   	else
   		cout<<"No"<<endl;  	
   return 0;
}


Measured memory_bytes: 640
#鬼<逃の時
#鬼はA+V*T、逃B+W*Tまで移動出来る
#A+V*T＞=B+W*Tなら鬼の勝ち
#逃>鬼の時
#鬼はA-V*T,逃はB-W*Tまで移動出来る
#A-V*T＜=B-W*Tなら鬼の勝ち
a,v=list(map(int, input().split())) 
b,w=list(map(int, input().split())) 
t=int(input())
def hantei():
    if(a+v*t>=b+w*t):
        print("YES")
    else:
        print("NO")
def hantei2():
    if(a-v*t<=b-w*t):
        print("YES")
    else:
        print("NO")
if(a<b):
    hantei()
else:
    hantei2()

Measured memory_bytes: 61808
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B;
    cin >> A >> B;
    
    if(A == B)
        cout << "Draw" << endl;
    else if(A == 1)
        cout << "Alice" << endl;
    else if(B == 1)
        cout << "Bob" << endl;
    else if(A > B)
        cout << "Alice" << endl;
    else
        cout << "Bob" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){//累積和
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vector<ll> a(N, 0);
  REP(i,N) cin >> a[i];
  sort(ALL(a));
  vector<ll> rui(N+1,0);
  REP(i,N) rui[i+1] = rui[i]+a[i]; 
  
  auto calc = [&](int x) { //参照渡し[&] のラムダ式 
    //幸福度増加がx以上となるペアの総数numとその増加数の総和tot
    ll tot = 0, num = 0;
    REP(i,N) {
      int j = lower_bound(a.begin(), a.end(), x-a[i]) - a.begin();
      num += N-j;
      tot += rui[N] - rui[j];
      tot += a[i] * ll(N-j);
    }
    return make_pair(tot,num);
  };
  ll l = 0, r = 200005;
  while (l+1<r) {
    ll c = (l+r)>>1;
    if (calc(c).second >= M) l = c; else r = c;
  }
  auto p = calc(l);
  ll ans = p.first;
  ans -= (p.second-M)*l;
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int INF = TEN(9) + 10;

const int maxn = 200010;
V<int> g[maxn];
int a[maxn];
int ans[maxn];
int dp[maxn];

void dfs(int v, int p) {
    int idx = lower_bound(dp, dp + maxn, a[v]) - dp;
    int pre = dp[idx];
    dp[idx] = a[v];
    ans[v] = lower_bound(dp, dp + maxn, INF) - dp;

    for (int to : g[v]) {
        if (to != p) {
            dfs(to, v);
        }
    }
    dp[idx] = pre;
}

int main() {
    int N;
    cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].pb(v);
        g[v].pb(u);
    }
    fill(dp, dp + maxn, INF);
    dfs(0, -1);
    rep(i, N) { cout << ans[i] << '\n'; }

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> v.at(i);
  }

  map<int, int> even, odd; //mapで各数列の要素の出現数を記録する

  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0)
      odd[v[i]]++; // キーvi(first)のときの値(second)をインクリメント
    else
      even[v[i]]++; // キーviのときの値をインクリメント
  }

  int even_1 = 0, even_2 = 0, odd_1 = 0, odd_2 = 0;
  int e1 = 0, e2 = 0, o1 = 0, o2 = 0;
  int cnt = 0;
  for (auto itr = even.begin(); itr != even.end(); ++itr)
  {
    if (itr->second > cnt)
    {
      cnt = itr->second;
      even_1 = itr->first;
    }
  }
  e1 = cnt;
  cnt = 0;
  for (auto itr = even.begin(); itr != even.end(); ++itr)
  {
    if (itr->second > cnt && itr->first != even_1) // 最も出現回数が大きいeven_1を除いた要素の中で最も出現回数が大きいものを求めている．
    {
      cnt = itr->second;
      even_2 = itr->first;
    }
  }
  e2 = cnt;

  cnt = 0;
  for (auto itr = odd.begin(); itr != odd.end(); ++itr)
  {
    if (itr->second > cnt)
    {
      cnt = itr->second;
      odd_1 = itr->first;
    }
  }
  o1 = cnt;
  cnt = 0;
  for (auto itr = odd.begin(); itr != odd.end(); ++itr)
  {
    if (itr->second > cnt && itr->first != odd_1)
    {
      cnt = itr->second;
      odd_2 = itr->first;
    }
  }
  o2 = cnt;

  if (even_1 == odd_1)
  {
    cout << min(n - e1 - o2, n - e2 - o1) << endl;
  }
  else
  {
    cout << n - e1 - o1 << endl;
  }

  return 0;
}


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

int main(){
    string N;
    cin >> N;
    unsigned long long sum = 0LL;
    int len = N.length();
    for(int i = 0; i < len; i++) {
      sum += (int)N[i] - 48;
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

const ll mod=1000000007;
// int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head


int main(){

	int n, tmp;  	
  	scanf("%d",&n);
  	set<int> arr;

  	for(int i=0; i<n; i++) {
  		scanf("%d",&tmp);
  		if(arr.find(tmp) != arr.end()) {
  			printf("NO\n");
  			return 0;
  		}
  		arr.insert(tmp);
  	}

  	printf("YES\n");
}

Measured memory_bytes: 9600
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC")
			++ac;
		if (s == "WA")
			++wa;
		if (s == "TLE")
			++tle;
		if (s == "RE")
			++re;
	}
	cout << "AC x " << ac << nl;
	cout << "WA x " << wa << nl;
	cout << "TLE x " << tle << nl;
	cout << "RE x " << re << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}

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

int main(){
  int pr[N]={};
  pr[1]=1;
  for(int i=2;i*i<=N;i++)
    if(pr[i]==0)for(int j=2;j<=N/i;j++)pr[i*j]=1;
  while(1){
    int m,a,b,ansp=0,ansq=0,max=0;
    cin>>m>>a>>b;
    if(m+a+b==0) break;
    for(int p=2;p<=m;p++)
      for(int q=p;q<=m/p;q++)
	if(!pr[p] && !pr[q] && p*q<=m && p*q>=max && (double)p/q>=(double)a/b && (double)p/q<=1)ansp=p,ansq=q,max=p*q;
    cout<<ansp<<" "<<ansq<<endl;
  }
  return 0;
}

Measured memory_bytes: 1556
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

int ball[16];

bool dfs(int i, int prevB, int prevC)
{
	if(i == 10)
	{
		return true;
	}
	if(ball[i] > prevB)
	{
		return dfs(i+1, ball[i], prevC);
	}
	if(ball[i] > prevC)
	{
		return dfs(i+1, prevB, ball[i]);
	}
	return false;
	
}

int main()
{
	int n;

	cin >> n;

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

		if(dfs(0, 0, 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

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

const int N = 3e5 + 10;

int n , q , op , type , tow , h = N , t = N - 1;
char s[N] , Q[N << 1] , c;

int main(){
	scanf("%s" , s + 1) , n = strlen(s + 1);
	for(int i = 1; i <= n; i++) Q[++t] = s[i];
	scanf("%d" , &q); while(q--){
		scanf("%d" , &op);
		if(op == 1) tow ^= 1;
		else{
			scanf("%d %c" , &type , &c);
			if(tow == 0 && type == 2 || tow == 1 && type == 1)
				Q[++t] = c;
			else Q[--h] = c;
		}
	}
	if(tow == 0) for(int i = h; i <= t; i++) putchar(Q[i]);
	else for(int i = t; i >= h; i--) putchar(Q[i]);
	return 0;
}

Measured memory_bytes: 896
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 998244353;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
int main() {
    COMinit();
    ll n,m,k;
    std::cin >> n>>m>>k;
    // std::cout << modpow(99,98)%MOD*100%MOD << std::endl;
    ll ans = 0;
    for (int i = 0; i <= k; i++) {
        ans += COM(n-1,i)*modpow(m-1,(n-1-i))%MOD*m%MOD;
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}


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

int main(){
	string a;
	cin>>a;
	int ans = 1;
	for(int i=0;i<a.size()-1;i++){
		if(a[i]=='R' &&a[i]==a[i+1]){
			ans ++;
		}
	}
	if(a[0]==a[1] && a[1]==a[2] && a[0]=='S') cout<<0<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N 100000 + 5

int n, m, A[N], B[N], Ord[N];
LL ans;

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%d%d", A + i, B + i);
		Ord[i] = i;
	}
	sort(Ord + 1, Ord + n + 1, [](int u, int v) {
		return A[u] < A[v];
	});
	for (int i = 1; m && i <= n; i ++)
	{
		int j = Ord[i];
		int t = min(m, B[j]);
		ans += 1LL * t * A[j];
		m -= t, B[j] -= t;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
n = int(input())

judge = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(n):
	s = input()
	judge[s] += 1

print("AC x", judge["AC"])
print("WA x", judge["WA"])
print("TLE x", judge["TLE"])
print("RE x", judge["RE"])


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

int main()
{
    double x1,x2,y1,y2,s;
    cin >> x1 >> y1 >> x2 >> y2;
    s = sqrt( pow(x1 - x2, 2) + pow(y1 - y2, 2));
    printf("%9.7f",s);
}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
ll dp[2003][2003];
ll dpp[2003][2003];

int main()
{
    int n, m;
    cin >> n >> m;
    int s[2003], t[2003];
    for(int i = 1; i <= n; i++){
        cin >> s[i];
    }
    for(int i = 1; i <= m; i++){
        cin >> t[i];
    }
    s[0] = 10000000;
    t[0] = 10000002;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(s[j] == t[i]) dpp[i][j] = (dp[i - 1][j] + 1) % MOD;
            else dpp[i][j] = dpp[i - 1][j];
            dp[i][j] = (dp[i][j - 1] + dpp[i][j]) % MOD;
        }
    }
    cout << (dp[m][n] + 1) % MOD << endl;
}

Measured memory_bytes: 62848
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const a = lines[0].indexOf("A");
    const b = lines[0].lastIndexOf("Z");
    console.log(b-a+1);
});


Measured memory_bytes: 30156
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]



def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n,n-k+1,mod)
    B = mfac(k,1,mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

INF = float('inf')

def solve():
    n, a, b = MI()
    mod = 1000000007

    ans = pow(2, n, mod) - 1 - mcomb(n, a, mod) - mcomb(n, b, mod)
    print(ans % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    int n;
    cin >> n;
    cin >> s;
    int cnt = 0;
    int max_val = 0;
    for (char c: s) {
        if (c == 'I') cnt++;
        else cnt--;
        if (max_val < cnt) max_val = cnt;
    }
    cout << max_val << '\n';
    return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);



    int n;

    cin >> n;

    while(n--)
    {
        cout << "ACL";
    }




}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define len(a) (int)a.size()
typedef pair<int,int> pii;
// #define debug(...) /*printf(args)*/
#define debug(args...) printf(args)
#define endl "\n"


int main(){
    faster;
    //freopen("tc.txt", "r", stdin);
    int h1, m1, h2, m2,  k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if (h2 < h1){

        h2 = h2 + 24;
    }

    cout << max((h2*60 + m2) - (h1*60 + m1) - k, 0) << endl;
    return 0;
}


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

int main(){
    int n,m,cnt=0;
    cin>>n>>m;
    int a[m];

    for(int i=0; i<m; i++){
        cin>>a[i];
        cnt+=a[i];
    }
    if(n<cnt){
        cout<<"-1"<<endl;
    }else{
        cout<<n-cnt<<endl;
    }
}


Measured memory_bytes: 3616
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            Set<Character> startSet = new HashSet<>(i);
            for (int j = 0; j < i; j++) {
                startSet.add(s[j]);
            }

            Set<Character> endSet = new HashSet<>(n - i);
            for (int j = i; j < n; j++) {
                endSet.add(s[j]);
            }

            startSet.retainAll(endSet);
            ans = Math.max(ans, startSet.size());
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
q = sum(B)
for i in range(N-1):
    if A[i+1]-A[i]==1:
        q+=C[A[i]-1]
    else:
        pass
print(q)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

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

	int C = 1;
	rep(i, 0, N) {
		C = (2 * C > C + K) ? C + K : 2 * C;
	}
	cout << C << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  long long S = 1000;
  for (int i=0; i<N-1; i++){
    if (A.at(i+1)>A.at(i)){
      S = (S/A.at(i))*A.at(i+1) + S%A.at(i);
    }
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int check[3][3];

int main(){
    int A[3][3];
    for (int i=0;i<3;i++) cin >> A[i][0] >> A[i][1] >> A[i][2];
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int B;
        cin >> B;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if (A[i][j] == B) check[i][j] = 1;
            }
        }
    }

    bool flag = false;
    for(int i=0;i<3;i++){
        if((check[i][0] && check[i][1] && check[i][2]) || (check[0][i] && check[1][i] && check[2][i])) flag = true;
    }
    if ((check[0][0] && check[1][1] && check[2][2]) || (check[0][2] && check[1][1] && check[2][0])) flag = true;
    
    cout << (flag ? "Yes" : "No") << endl;
}

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

int main() {
  const long inf = 1l << 60;
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> to(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    to.at(a).emplace_back(b, -c);
  }
  vector<long> cost(n, inf);
  cost.at(0) = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      for (auto x : to.at(j)) {
        cost.at(x.first) = min(cost.at(x.first), cost.at(j) + x.second);
      }
    }
  }
  long ans = cost.at(n - 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (auto x : to.at(j)) {
        cost.at(x.first) = min(cost.at(x.first), cost.at(j) + x.second);
      }
    }
  }
  if (cost.at(n - 1) != ans) {
    cout << "inf" << endl;
  } else {
    cout << -ans << endl;
  }
}


Measured memory_bytes: 256
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;
 
 
 
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	booster;
	ll n,j;
	cin>>n;
	ll a[n];
	ll res=0;
	rep(i,0,n) cin>>a[i];
	rep(i,0,n)
	{
		rep(j,i+1,n)
		{
			res+=(a[i]*a[j]);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    ll H;
    cin >> H;
    ll ans = 0;
    ll M = 1;
    while(H!=1)
    {
        ans += M;
        H/=2;
        M *= 2;
    }
    ans += M;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
int main()
{
    int n;
    cin >> n;
    vector <int> v;
    v.resize(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    vector <int> dp;
    dp.resize(n);
    dp[n-1] = 0;
    for(int i = n-2; i >= 0; i--){
        dp[i] = abs(v[i] - v[i+1]) + dp[i+1];
        if(i+2 < n)
            dp[i] = min(dp[i], abs(v[i] - v[i+2]) + dp[i+2]);
    }
    cout << dp[0] << "\n";
}

Measured memory_bytes: 1024
#include<stdio.h>
#define DIM 8

int main(void)
{
  int h,w,i,j,s_count=0;
   char s[DIM];

  scanf("%d %d",&h,&w);

for(i=0;i<h;i++)
{
  scanf("%s",s);
for(j=0;j<w;j++)
  {
  if(s[j]=='#')
    {
      s_count++;
    }
  }
}

if(s_count==h+w-1)
{
  printf("Possible\n");
}
else
{
  printf("Impossible\n");
}
  return 0;
}


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

namespace ABC97_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool talkab = Math.Abs(input[0] - input[1]) <= input[3];
            bool talkbc = Math.Abs(input[1] - input[2]) <= input[3];
            bool talkac = Math.Abs(input[0] - input[2]) <= input[3];

            Console.WriteLine(talkac || (talkab && talkbc)? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  Int x,y;
  cin>>x>>y;
  Int n=s.size();
  vector<vector<Int> > v(2);
  Int z=0;
  if(s[0]=='T') v[0].emplace_back(0);
  for(Int i=0;i<n;i++){
    if(s[i]=='T'){
      
      z=!z;
      continue;
    }
    Int k=0;
    while(i<n&&s[i]=='F') i++,k++;
    v[z].emplace_back(k);
    i--;
  }
  if(v[0].empty()){
    if(x!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }else{
    x-=v[0][0];
    v[0].erase(v[0].begin());
  }
  //for(Int i:v[0]) cout<<"0000:"<<i<<endl;
  //for(Int i:v[1]) cout<<"1111:"<<i<<endl;
  auto calc=[](vector<Int> v,Int beet){
    
    Int s=accumulate(v.begin(),v.end(),Int(0));
    if((s+beet)&1) return false;
    if(s<beet) return false;
    
    const Int LIM=400;
    vector<Int> cnt(LIM,0);
    for(Int i:v) if(i<LIM) cnt[i]++;

    vector<Int> dp(s+1,-1);
    dp[0]=0;
    for(Int i=1;i<LIM;i++){
      for(Int j=0;j<=s;j++){
	if(dp[j]>=0){
	  dp[j]=cnt[i];
	}else if(j<i||dp[j-i]<=0){
	  dp[j]=-1;
	}else{
	  dp[j]=dp[j-i]-1;
	}
      }
    }
    for(Int i=0;i<=s;i++){
      if(dp[i]>=0) dp[i]=1;
      else dp[i]=0;
    }
    for(Int i:v){
      if(i<LIM) continue;
      for(Int j=s;j>=0;j--){
	if(j+i<=s) dp[j+i]|=dp[j];
      }
    }

    return dp[(s+beet)/2]==1;
  };
  cout<<(calc(v[0],abs(x))&&calc(v[1],abs(y))?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 384
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(int, input().split())) for _ in range(M)]
    AB.sort(key=lambda x:x[1])
    ans=0
    pre=-1
    for a,b in AB:
        if pre<=a:
            ans+=1
            pre=b
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56924
import math
import fractions
A, B, C, D = map(int, input().split())

ans = 0


c_n = (B // C) - ((A - 1) // C)
d_n = (B // D) - ((A - 1) // D)
cd = C * D // fractions.gcd(C,D)
cd_n = (B // cd) - ((A - 1) // cd)

ans = (B - A + 1) - (c_n + d_n - cd_n)
print(ans)


Measured memory_bytes: 5092