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

using namespace std;
using ll = long long;

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

int f(int k) {
  int cnt = 0;
  while (k > 0) {
    k %= __builtin_popcount(k);
    ++cnt;
  }
  return cnt;
}

ll modpow(ll k, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % m;
    k = k * k % m;
    n /= 2;
  }
  return res;
}

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

  int pc = 0;
  rep(i, n) pc += s[i] - '0';

  int a = 0, b = 0, mula = 1, mulb = 1;
  rep(i, n) {
    a += (s[n - i - 1] - '0') * mula;
    a %= pc + 1;
    b += (s[n - i - 1] - '0') * mulb;
    if (pc - 1 != 0) b %= pc - 1;
    mula *= 2;
    mula %= pc + 1;
    mulb *= 2;
    if (pc - 1 != 0) mulb %= pc - 1;
  }

  rep(i, n) {
    int d = s[i] - '0';
    int res = 0;
    if (d) {
      if (pc - 1 == 0) {
        cout << 0 << endl;
        continue;
      }
      res = modpow(2, n - i - 1, pc - 1);
      res = (b - res + pc - 1) % (pc - 1);
    } else {
      res = modpow(2, n - i - 1, pc + 1);
      res = (a + res) % (pc + 1);
    }
    cout << f(res) + 1 << endl;
  }
  return 0;
}


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

int main(){
  int n; cin>>n;
  vector<int> l(n);
  for(int &i:l)
    cin>>i;
  int count=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(l[j]!=l[i]){
        for(int k=j+1;k<n;k++){
          if(l[i]!=l[k] && l[j]!=l[k]){
            if(l[i]>l[j] && l[i]>l[k]){
              if(l[i]<l[j]+l[k])
                count++;
            }
            else if(l[j]>l[i] && l[j]>l[k]){
              if(l[j]<l[i]+l[k])
                count++;
            }
            else if(l[k]>l[i] && l[k]>l[j]){
              if(l[k]<l[i]+l[j])
                count++;
            }            
          }
        }
      }
    }
  }
  
  cout<<count<<endl;
}

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

#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
vector<int>g[300005];
int v[300005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	while(cin >> n >> m){
		f(m){
			int add1,add2;
			cin >> add1 >> add2;
			g[add1].pb(add2+n);
			g[add1+n].pb(add2+n+n);
			g[add1+n+n].pb(add2);
		}
		int s,t;
		cin >> s >> t;
		ms(v);
		queue<int>q;
		q.push(s);
		v[s] = 1;
		while(!q.empty()){
			int now = q.front();
			q.pop();
			for(auto i:g[now]){
				if(!v[i]){
					v[i] = v[now]+1;
					q.push(i);
				}
			}
		}
		if(!v[t]){
			cout<<-1<<endl;
		}
		else{
			cout<<(v[t]-1)/3<<endl;
		}
	}
}

Measured memory_bytes: 17792
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n, m = map(int, input().split())
a = list(map(int, input().split()))


for i in range(m):
    n = n - a[i]
    if (n < 0):
        print(-1)
        exit()

print(n)


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

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<char> VC;
typedef vector<VC> VVC;

#define Y first
#define X second
#define RANGE(x, y, mX, mY) (0 <= (x) && 0 <= (y) && (x) < (mX) && (y) < (mY))
#define MP make_pair

const int INF = 0x3f3f3f3f;

int N, M;
vector<string> ss;

set<char> not_zero;

VC as;

map<char, int> ks;

// alphabet?????????
VC find_alphas() {
    set<char> as_set;
    for (auto s : ss) {
        for (auto c : s) {
            as_set.insert(c);
        }
    }

    VC res;
    for (auto c : as_set) {
        res.push_back(c);
    }

    return res;
}

void find_not_zero() {
    not_zero.clear();

    for (auto &s : ss) {
        if (s.size() == 1) continue;
        not_zero.insert(s[0]);
    }   
}

// ?????°?¨????
void calc_ks() {
    ks.clear();

    for (auto c : as) {
        ks[c] = 0;
    }

    for (int i = 0; i < N; i++) {
        int v = 1;
        string &s = ss[i];

        for (int j = (int)s.size() - 1; j >= 0; --j) {
            ks[s[j]] += v * (i == N - 1 ? -1 : 1);
            v *= 10;
        }
    }
}

bool calc_siki(VI &idxes) {
    int sum = 0;

    for (int i = 0; i < M; i++) {
        char c = as[i];
        int n = idxes[i];
        sum += ks[c] * n;
    }

    return sum == 0;
}

int dfs(int used, int n, int sum) {
    if (n == M) {
        return sum == 0;
    }

    int cnt = 0;
    for (int i = 0; i < 10; i++) {
        if (1 << i & used) continue;
        if (!i && not_zero.count(as[n])) continue;

        cnt += dfs(used | 1 << i, n + 1, sum + ks[as[n]] * i);
    }

    return cnt;
}

int solve() {
    as = find_alphas();
    M = as.size();
    find_not_zero();
    calc_ks();

    return dfs(0, 0, 0);
}

int main(void) {
    cin.tie( 0 );
    ios::sync_with_stdio( false );
 
    while (cin >> N, N) {
        ss.clear();
        ss.resize(N);

        for (auto &s : ss) cin >> s;

        cout << solve() << endl;
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){

    string S;
    cin>>S;
    int N=S.size();
    int ans=S.size();
    for(int i=0;i+1<S.size();i++){
        if(S[i]==S[i+1])continue;
        int tmp=max(i+1,N-i-1);
        chmin(ans,tmp);
    }

    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    long long K;
    cin >> K;
    long long ls = 7;
    int flag = 0;
    for (int i = 1; i <= 1e6; i++)
    {
        if (ls % K == 0)
        {
            flag = 1;
            cout << i << endl;
            break;
        }
        ls = ls * 10 + 7;
        ls %= K;
    }
    if (!flag)
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
local n,m=io.read("*n","*n")
local start={}
local goal={}
for i=1,m do
    local a,b=io.read("*n","*n")
    if a==1 then
        start[i]=b
    end
    if b==n then
        goal[a]=true
    end
end

for _,i in pairs(start) do
    if goal[i] then
        print("POSSIBLE")
        return
    end
end
print("IMPOSSIBLE")

Measured memory_bytes: 11228
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
        self.X = [1]*(n+1)

    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)

    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        self.X[x] += self.X[y]


N,M = MI()
UF = UnionFind(N)
for i in range(M):
    a,b = MI()
    if not UF.same_check(a, b):
        UF.unite(a,b)

print(max(UF.X))


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

int main(){

    string S;
    cin >> S;

    int calc_length = S.size() / 2;
    int mae;
    int ushiro;

    int ans = 0;
    for(int i = 0; i < calc_length; i++){

        mae = i;
        ushiro = S.size() - 1 - i;

        if(S.at(mae) != S.at(ushiro)) {
            ans++;
        }

    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
A = list(map(int,input().split()))
a = 0
s = sum(A)
for i in range(n):
    if A[i] *4*m>= s:
        a += 1
if a >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
n>=modなら0になる
*/
const int mod=1000003;
template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<mod> mint;

ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll q,x[100010],d[100010],n[100010];
mint fact[1000010];

void init(){
	cin>>q;
	rep(i,q)cin>>x[i]>>d[i]>>n[i];
	fact[0]=1;
	reg(i,1,mod)fact[i]=fact[i-1]*i;
}

int main(void){
	init();
	rep(i,q){
		if(d[i]==0){
			cout<<modpow(x[i],n[i],mod)<<endl;
			continue;
		}
		mint y=x[i];
		y/=d[i];
		mint ans=1;
		if(n[i]>=mod || y.get()+n[i]-1>=mod){
			ans=0;
		}else{
			ans*=fact[y.get()+n[i]-1];
		}
		ans/=fact[y.get()-1];
		ans*=modpow(d[i],n[i],mod);
		cout<<ans.get()<<endl;
	}
	return 0;
}

Measured memory_bytes: 7168
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int t = sc.nextInt();

    if ((X - t) < 0) {
      System.out.println(0);
    } else {
      System.out.println(X - t);
    }

  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int ab, bc, ca; cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

status = false    # false: closed,  true: open
ids = {}          # key が id

nr = $stdin.readline.to_i
nr.times do
  id = $stdin.readline.chomp
  ids[id] = true
end

nr = $stdin.readline.to_i
nr.times do
  id = $stdin.readline.chomp

  if ids[id]

    status = !status
    if status
      puts "Opened by #{id}"
    else
      puts "Closed by #{id}"
    end

  else
    puts "Unknown #{id}"
  end

end



Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	ll n;
	cin >> n;
	ll i;
	int ans = Inf;
	for (i = 1; i * i <= n; i++) {
		if (n % i != 0) continue;
		int N = n / i;
		string S = to_string(N);
		string T = to_string(i);
		int tmp = max(S.size(), T.size());
		ans = min(ans, tmp);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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); cin.tie(NULL); cout.tie(NULL);

    int N;
    cin >> N;

    vector<int> H(N);
    rep(i,N) cin >> H[i];

    int ans = 0;
    int count = 0;
    rep(i,N-1) {
        if (H[i] >= H[i+1]) count++;
        else count = 0;
        if (ans < count) ans = count;
    }

    cout << ans << endl;

    return 0;
}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long pl,mi;

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

//        int n=sc.nextInt();
	     int a[]= {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
	     sort(a);
	     

        out.println((a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)?"YES":"NO");
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22484
using System;
using System.Linq;
using  System.Collections;
using  System.Collections.Generic;
class Program
{
static void Main(string[] args){
Console.ReadLine();
var d = (Console.ReadLine()).Split(' ').Select((n,m)=> new { h = int.Parse(n),i = m}).ToArray();
Console.WriteLine(Enumerable.Range(0, 100).ToArray().Sum(sh => {
var p = d.Where(a=>a.h>sh).Select(a=>a.i).ToArray();
int pval=-2;
return p.Sum(a=>{
if(a!=pval+1){
 pval=a;
 return 1;
}
 pval=a;
return 0;
});
}));
}
}

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

int main() {
    string s; cin>>s;
    int count=0;
    for(int i=0 ; i<s.size()/2 ; i++){
        if(s[i]!=s[s.size()-1-i]){
            count++;
        }
    }

    cout<<count;

    

    

    int l ; cin>>l;
} 

Measured memory_bytes: 256
import java.util.*;
import java.text.*;
class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        // this got WA
        // int a = sc.nextInt();
        // int b = sc.nextInt();
        // System.out.println("" + (a/b) + " " + (a%b) + " " + (a/(double)b));

        // this is OK
        int a = sc.nextInt();
        int b = sc.nextInt();
        NumberFormat format = NumberFormat.getInstance();
        format.setMaximumFractionDigits(5);
        format.setMinimumFractionDigits(5);
        format.setGroupingUsed(false);

        System.out.println("" + (a/b) + " " + (a%b) + " " + format.format(a/(double)b));

        // this is also OK
        // long a = sc.nextInt();
        // long b = sc.nextInt();
        // long a00000 = a * 100000;
        // long c = a00000 / b;
        // long d = c / 100000;
        // long f = c % 100000;
        // String sf = ""+f;
        // while(sf.length() < 5) sf = "0" + sf;
        // System.out.println("" + (a/b) + " " + (a%b) + " " + d + "." + sf);
    }
}

Measured memory_bytes: 17320
#include<stdio.h>
int main()
{
	int n,k,d[100],a[100][100],s[100]={},i,j,c=0;

	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d",&d[i]);
		for(j=0;j<d[i];j++)
			scanf("%d",&a[i][j]);
	}
	for(i=0;i<k;i++)
		for(j=0;j<d[i];j++)
			s[a[i][j]-1]=1;
	for(i=0;i<n;i++)
		if(s[i]==0)
			c++;
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 1764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n, k, j;
  cin >> n >> k;
  vector<int64_t> H(n);
  rep(i,n) cin >> H[i];
  sort(H.begin(), H.end());
  int64_t m = H[k-1]-H[0];
  for(j=1; j<=n-k; j++){
    int64_t s = H[k+j-1]-H[j];
    if(m>s) m = s;
  }
  cout << m << endl;
}

Measured memory_bytes: 1024
n=int(input())
w=[input() for i in range(n)]
if len(w)!=len(set(w)):
    print("No")
else:
    for i in range(n-1):
        if w[i][len(w[i])-1]!=w[i+1][0]:
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 9152
#include"bits/stdc++.h"
using namespace std;
using ll = long long;
long long MOD = 1e9 + 7;
constexpr long long INF = numeric_limits<ll>::max();
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<ll, ll> pp;
#define rep(i,n) for(ll i=0;i<n;i++)
inline void YN(bool f) {cout<<(f?"YES":"NO")<<endl;}
inline void yn(bool f) {cout<<(f?"Yes":"No")<<endl;}
//int d[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
// 여기까지 template
ll m,d,ans;
void solve(){
	cin>>m>>d;
	for(int i=1;i<=m;++i){
		for(int j=1;j<=d;++j){
			if(j%10<2||j/10<2)continue;
			if((j%10)*(j/10)==i){++ans;
			//cout<<j<<" "<<i<<endl;
			}
		}
	}
	cout<<ans<<endl;
}
int main(){
	solve();
}

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

typedef long long ll;
ll inf = 10000000000;
int main() {
  ll N,K;
  cin >> N >> K;
  vector<ll> cost(N);
  for(int i=0;i<N;i++){
    cin >> cost.at(i);
  }
  
  vector<ll> dp(N,inf);
  dp.at(0) = 0;
  dp.at(1) = abs(cost.at(1)-cost.at(0));
  for(ll i=2;i<N;i++){
    for(ll j=1;j<=min(i,K);j++){
      dp.at(i) = min(dp.at(i),dp.at(i-j)+abs(cost.at(i)-cost.at(i-j)));
    }
  }
  
  cout << dp.at(N-1) << endl;
  
  return(0);
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
    char num[1000];
    int sum, i;
    
    while(1){
        scanf("%s", &num);
        if(num[0] == '0'){
            break;
        }
        sum = 0;
        for(i=0;num[i] != '\0';i++){
            sum += num[i] - '0';
        }
        printf("%d\n", sum);
    }
    return 0;
}

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

const long long INF = LLONG_MAX;

int main()
{
	int n, k = 2;
	cin >> n;
	
	vector < long long > h(n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	
	vector < long long > dp(n);
	
	dp[0] = 0;
	
	for(int i = 1; i < n; i++)
	{
		dp[i] = INF;
	}
	
	for(int i = 0; i < n - 1; i++)
	{
		for(int j = 1; j <= min(n - i, k); j++)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	
	cout << dp[n - 1];
	
	return 0;
}

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

int main() {
    int ans = 0;
    string S, T;
    cin >> S >> T;
    rep(i, S.size()) {
        if(S[i] != T[i])
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3916
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    long double A[N];
    rep(i, 0, N) { cin >> A[i]; }
    long double AA = 0;
    rep(i, 0, N) { AA += 1.0 / A[i]; }
    cout << setprecision(16) << 1.0 / AA << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&j : b) scanf("%d", &j);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if(a[i] > b[i]) ans += a[i]-b[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(void)
{
	int x,y;
	while(~scanf("%d%d",&x,&y))
	{
		int fg=0;
		for(int i=0;i<=x;++i)
		{
			if(i*2+(x-i)*4==y)
			{
			fg=1;break;
			}
		}
		if(fg)
		puts("Yes");
		else
		puts("No");
	}
	return 0;
}

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

using namespace std;


void solve(){
   long long a, b, c, k;
   cin >> a >> b >> c >> k;
   long sum = 0;
   if(k >= a){
        sum += a;
        k-=a;
   }
   else{
    sum += k;
    k = 0;
   }
   if(k == 0){
    cout << sum << endl;
    return;
   }
   if(k >= b){
        sum += 0;
        k-=b;
   }
   else{
    sum += 0;
    k = 0;
   }
   if(k == 0){
    cout << sum << endl;
    return;
   }
    if(k >= c){
        sum -= c;
        k-=c;
   }
   else{
    sum += (-1 *k);
    k = 0;
   }
   cout << sum << endl;


}

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


Measured memory_bytes: 3536
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;

    int a,b;
    cin>>a>>b;

    if(b*2>=a){
        ans=0;
    }
    else{
        ans=a-b*2;
    }
  
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<std::string> s(n);
	int ans = 0, X = 0, Y = 0, Z = 0;
	std::vector<bool> A(n, false), B(n, false);
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		
		for(int j = 0; j < s[i].size() - 1; j++) {
			if(s[i].substr(j, 2) != "AB") continue;
			ans++;
		}
		A[i] = (s[i].back() == 'A');
		B[i] = (s[i].front() == 'B');
		if(A[i] and B[i]) Z++;
		else if(A[i]) X++;
		else if(B[i]) Y++;
	}
	
	if(X == 0 or Y == 0) {
		if(Z > 0) ans +=  !!X + !!Y + (Z - 1);
	} else if(Z == 0) {
		ans += std::min(X, Y);
	} else {
		int tmp = std::min(X, Y) - 1;
		Z += tmp;
		ans += Z + 1;
	}
	
	printf("%d\n", ans);
	return 0;
}


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

int n; string s;
int O[1000000], I[1000000], a, b;
bool ok(int t) {
	if (a < t || b < t)return false;
	int p = n - 1;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (s[p] == 'O' || (s[p] == 'I'&&p >= I[t - 1])))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I[a++] = i;
		if (s[i] == 'O'&&b < a)O[b++] = i;
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
/* -------------------------------------------------------------------------- */

int main(int argc, char *argv[])
{
    int K, A, B;
    cin >> K >> A >> B;
    bool is_ok = false;

    reb(i, A, B+1) {
        if (i%K == 0) {
            is_ok = true;
        }
    }
    if (is_ok) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


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

int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R)
    cout << "Left" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100000
#define INF 1000000000
using namespace std;

typedef long long ll;

int main()
{
    int n, m;
    int x[N] ={};
    cin >> n >> m;
    if(m==1)
    {
        cout << "0\n";
        return 0;
    }
    
    FOR(i,0,m)
        cin >> x[i];
    sort(x,x+m);
    int dist[N] = {};

    FOR(i,0,m-1)
        dist[i] = x[i+1] -x[i];

    sort(dist,dist+(m-1));

    int r = x[m-1]-x[0];
    FOR(i,0,n-1)
        r -= dist[m-2-i];
    cout << r << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    int s, w;
    cin >> s >> w;

    if (w >= s) {
        Cout("unsafe");
    }
    else {
        Cout("safe");
    }

    return 0;
}

Measured memory_bytes: 3624
# GaussJordan
module GaussJordan
  def self.calc(a)
    a.length.times do |k|
      pivot = a[k][k]
      i = k

      i.upto(a[k].length - 1) do |j|
        a[k][j] /= pivot
      end

      a.length.times do |j|
        if (j != k)
          d = a[j][k]
          l = k
          l.upto(a[k].length - 1) do |m|
            a[j][m] -= d * a[k][m]
          end
        end
      end
    end

    a
  end
end

while line = gets
  a, b, c, d, e, f = line.chomp.split.map(&:to_f)
  g = [[a, b, c], [d, e, f]]
  answer = GaussJordan.calc(g)
  puts sprintf('%.3f %.3f', answer[0][2] + 0.0, answer[1][2] + 0.0)
end

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int a[2*N-1]; rep(i,2*N-1) cin >> a[i];
  int l = 1, r = 2*N-1;
  while(l!=r) {
    int mid = (l+r+1)/2;
    bool lt[2*N-1] = {};
    rep(i,2*N-1) if (a[i]>=mid) lt[i] = true;
    bool ok = lt[0];
    // cout << l << "-" << mid << "-" << r << endl;
    // rep(i,2*N-1) cout << lt[i] << " "; cout << endl;
    rep(i,N-1) {
      // cout << lt[N-2-i] << "==" << lt[N-1-i] << " " << lt[N-1+i] << "==" << lt[N+i] << endl;
      if (lt[N-1+i]==lt[N+i]) { ok = lt[N-1+i]; break; }
      else if (lt[N-1-i]==lt[N-2-i]) { ok = lt[N-1-i]; break; }
    }
    if (ok) l = mid;
    else r = mid-1;
  }
  int result = l;
  cout << result << endl;
  return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a += b;
  c += d;
  if(a > c){
    cout << "Left" << endl;
  }else if(a < c){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
count=0
res=""
str=input()
list=[]
for i in range(len(str)):
  list.append(str[i])
for i in range(len(str)):
  if str[i]=="?":
    if i==0:
      if list[1]=="D":
        list[0]="P"
      else:
        list[0]="D"
    elif i+1==len(str):
      list[i]="D"
    else:
      if list[i-1]=="P":
        list[i]="D"
      else:
        if list[i+1]=="D" or list[i+1]=="?":
          list[i]="P"
        else:
          list[i]="D"
for i in range(len(str)):
  res+=list[i]
print(res)


Measured memory_bytes: 11084
import java.io.*;
import java.util.Scanner;


public class Main{
    public static void main(String[] args) throws IOException
    {
        Scanner scanner = new Scanner(System.in);
        String word = scanner.nextLine();
        int i = 0;

        do{
            String line = scanner.next();
            if(line.equalsIgnoreCase(word)){
                i++;
            }

            if(line.equals("END_OF_TEXT")){
                System.out.println(i);
                break;
            }
        }while(true);
            
    }
}




Measured memory_bytes: 26236
S = input()
X = int(S[0:2])
Y = int(S[2:4])

if X > 12 and Y > 12:
    print("NA")
elif X == 0 or Y == 0:
    if X == 0:
        if Y > 12 or Y == 0:
            print("NA")
        else:
            print("YYMM")
    else:
        if X > 12:
            print("NA")
        else:
            print("MMYY")
elif X < 13 and Y < 13:
    print("AMBIGUOUS")
elif X > Y:
    print("YYMM")
else:
    print("MMYY")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e2+10;
int a[maxn],b[maxn];
int n,k,ans=1;
void update(int x){
    int sum=0;
    for(int i=1;i<=n;i++){
        b[i]=a[i]%x;
        sum+=b[i];
    }
    sort(b+1,b+n+1,greater<int>());
    int sum1=sum;
    for(int i=1;i<=sum1/x;i++){
        sum-=b[i];
    }
    if(sum<=k)
        ans=max(ans,x);
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    ll sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    for(int i=2;i*i<=sum;i++){
        if(sum%i==0){
            update(i);
            update(sum/i);
        }
    }
    update(sum);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  string s;
  cin>>s;
  
  int i=0;
  while(s[i]=='h' && s[i+1]=='i')
    {
    i=i+2;
    }
  if(i==s.length())
    cout<<"Yes";
  
  else
    cout<<"No";
  return 0;
  }

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

#define LL long long
#define println(msg) cout << msg << endl

int f(LL a, LL b) {
  int ac = 0;
  while (a > 0) {
    a /= 10;
    ac ++;
  }
  int bc = 0;
  while (b > 0) {
    b /= 10;
    bc ++;
  }
  return max(ac, bc);
}

int main() {
  // 入力
  LL N;
  cin >> N;

  // 計算
  LL minNum = N + 1;
  for (LL a = 1; a <= (LL)sqrt(N); a++) {
    if ((N % a) == 0) {
      LL b = N / a;
      minNum = min((LL)f(a, b), minNum);
    }
  }
  
  // 出力
  println(minNum);
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    lint ret = 0;
    int V = 0, p10 = 1;
    VEC(int) Inv(P);
    FOR(i, 1, P)
        FOR(j, 1, P)
            if (i * j % P == 1) {
                Inv[i] = j;
            }

    map<int, int> rmap;
    rmap[0] = 1;
    FOR(i, 0, N) {
        int d = S[i] - '0';
        V = (10 * V + d) % P;
        p10 = p10 * 10 % P;
        if (P == 2 || P == 5) {
            if (V == 0) {
                ret += i + 1;
            }
            continue;
        }

        ret += rmap[V * Inv[p10] % P];
        rmap[V * Inv[p10] % P]++;
    }

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

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
int rge[100005];
int main () {
	int n, m;
	scanf("%d %d", &n, &m);
	FOR(i, 1, n, 1) rge[i] = inf;
	FOR(i, 1, m, 1) {
		int l, r;
		scanf("%d %d", &l, &r); l++;
		rge[l] = min(rge[l], r);
	}
	int cnt = 1, l = inf;
	FORD(i, n, 1, 1) {
		if (rge[i] == inf) continue;
		if (l == inf) {
			l = i;
		} else {
			if (rge[i] < l) l = i, cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

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

  vector<int> H(N);
  rep(i, N)
    cin >> H[i];
  
  long long ret=0;
  sort(H.begin(), H.end());
  rep(i, N-K) {
    ret+=H[i];
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1024
program main
    implicit none
    integer(4):: n,i
    integer(8),allocatable:: a(:)
    read*, n
    allocate(a(n))
    read*, a(:)

    call merge_sort(a(:),1,n)

    do i=1,n-1
        if (a(i) == a(i+1)) then
            print*, 'NO'
            stop
        end if
    end do
    print*, 'YES'
    
    
    
    

    contains
    recursive subroutine merge_sort(ar,fst,lst)
        integer(8):: ar(:)
        integer(4)::fst,lst
        integer(4):: tmp, mdl
        if(lst-fst < 2) then
            if (ar(fst) < ar(lst)) then
                tmp = ar(fst)
                ar(fst) = ar(lst)
                ar(lst) = tmp
            end if
            return
        end if
    
        mdl = (fst+lst)/2
        call merge_sort(ar(:), fst, mdl)
        call merge_sort(ar(:), mdl+1, lst)
        call merge(ar(:), fst, mdl, lst)
    
    end subroutine
    
    subroutine merge(ar,fst,mdl,lst)
        integer(8):: ar(:)
        integer(4)::fst,mdl,lst
        integer(4):: l,r,t
        integer(8),pointer:: tmp(:)
    
        allocate(tmp(lst-fst+1))
        l=fst
        r=mdl+1
        t=1
        do while(l <= mdl .and. r <= lst)
            if (ar(l) > ar(r)) then
                tmp(t) = ar(l)
                l=l+1
            else
                tmp(t) = ar(r)
                r=r+1
            end if
            t=t+1
        end do
        
        if (r > lst) then
            tmp(t:) = ar(l:mdl)
        else
            tmp(t:) = ar(r:lst)
        end if
    
        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine
end program main

Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
map<string ,int>aho;
string s[5000],d[5000];
int a,b,c,e,an;
char now;

int main(){
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>s[i];
        if(aho[s[i]]==1)an=1;
        aho[s[i]]=1;
    }
    for(int i=0;i<a-1;i++){
        if(s[i+1][0]!=s[i][s[i].length()-1])an++;

    }

    if(an!=0)cout<<"No"<<endl;
    if(an==0)cout<<"Yes"<<endl;


}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  char n;
    int count=0,maxnum=0;
  while(cin >> n){
    if(n=='A' || n=='G' || n=='C' || n== 'T'){
      count++;
      if(maxnum<count)maxnum=count;
    }else count=0;
  }
  cout << maxnum << endl;
}


Measured memory_bytes: 3604
n = list(map(int, input().split())) # 整数
if(n[0] == n[1]):
    print("Draw")
elif(n[0] == 1):
    print("Alice")
elif(n[1] == 1):
    print("Bob")
elif(n[0] > n[1]):
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray(int n)
        {
            var array = Array();
            var result = new int[n];
            for (int i = 0; i < n; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }


        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private string S, T;
        private void Scan()
        {
            var sc = new Scanner();
            S = sc.Next();
            T = sc.Next();
        }
        public void Solve()
        {
            Scan();
            for (int i = 0; i < S.Length; i++)
            {
                bool flag = true;
                for (int j = 0; j < S.Length; j++)
                {
                    if (S[j] != T[(j + i) % S.Length])
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }

        static void Main() => new Program().Solve();
    }
}

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

vector<pair<long long, long long>> prime(long long N) {

	vector<pair<long long, long long>> res;

	for (long long a = 2; a * a <= N; a++) {
		if (N%a != 0) continue;
		int ex = 0;
		while (N % a == 0) {
			ex++;
			N /= a;
		}
		res.push_back({ a,ex });
	}
	if (N != 1) res.push_back({ N,1 });
	return res;
}

int main(void) {
	
	long long N;

	cin >> N;
	vector<long long> e(N+1,0);
	
	for(long long i=1;i<=N;i++){
		const auto& res = prime(i);
		for (auto p : res)
			e[p.first] += p.second;
	}

	long long c = 1;

	for (long long i = 0; i < N + 1; i++) {
		c *= e[i] + 1;
		c %= 1000000007;
	}
		
	cout << c;

}

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

int main() {
  
  int n, k;
  cin >> n >> k;
  
  vector<int> vec(n);
  
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    vec.at(i) = x;
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 0;
  
  for (int i = 0; i < k; i++){
    ans = ans + vec.at(i);
  }
  
  cout << ans << endl;
  
  
}

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

vector<int> st;
const int DBG = 0;

int main(void){
  string s;
  char state;
  int n, k;
  cin >> n >> k >> s;
  st.resize(n, 0);

  if(s[0] == '0')st[0] = 1;
  state = s[0];
  for(int i = 1; i < s.size(); ++i){
    if(s[i] == '0' && state  == '1') st[i] = st[i-1] + 1;
    else st[i] = st[i-1];
     state = s[i];
  }

  int ans = 0;
  int d = -1;
  rep(i, s.size()){
    if(s[i] == '1'){
      ans = max(ans, ++d);
     }else{
      d = -1;
    }
  }

  rep(i, s.size()){
    auto it = upper_bound(st.begin(), st.end(), st[i] + k + (s[i]=='1'?0:-1));
    int x = it - st.begin();
    if(it == st.end()){
      ans = max(ans, x-i);
    }else{
      ans = max(ans, x-i);
    }
    if(DBG)cout << "i " << i << "  ans " << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int a;
	cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}


Measured memory_bytes: 256