akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	string s,t;
	int flag=0;
	cin>>s>>t;
	forr(i,0,s.size())
	{
		if(s[i]!=t[i])
			flag=1;
	}
	if(abs(int(s.size())-int(t.size()))>2)
		flag=1;
	cout<<(flag?"No":"Yes");
	
	return 0;
}

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

long long N, mod, dp[3009][3009], nr[3009][3009], FinalAns;

void init() {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (i == j || i == 0) dp[i][j] = 1;
			else dp[i][j] = (dp[i - 1][j - 1] + 1LL * dp[i - 1][j] * (j + 1)) % mod;
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (i == 0 || j == 0) nr[i][j] = 1;
			else nr[i][j] = (nr[i - 1][j] + nr[i][j - 1]) % mod;
		}
	}
}

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	long long K = 31; if (b <= 2500000) K = 22;
	for (int i = 0; i < K; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long ncr(long long n, long long r) {
	return nr[n - r][r];
}

int main() {
	cin >> N >> mod;
	init();

	for (int i = 0; i <= N; i++) {
		long long A1 = modpow(2, modpow(2, i, mod - 1), mod);
		long long A2 = 0;
		for (int j = 0; j <= N - i; j++) {
			long long K1 = dp[N - i][j];
			long long K2 = modpow(2, 1LL * j * i, mod);
			A2 += K1 * K2; A2 %= mod;
		}
		long long ans = (A1 * A2 % mod) * ncr(N, i) % mod;
		if ((N - i) % 2 == 0) FinalAns += ans;
		else FinalAns -= ans;
	}
	FinalAns += 1000000000LL * mod; FinalAns %= mod;
	cout << FinalAns << endl;
	return 0;
}

Measured memory_bytes: 141568
s = str(input())
ACGT = {"A", "C", "G", "T"}

ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        t = s[i: j]
        for k in t:
            if k not in ACGT:
                break
        else:
            ans = max(ans, len(t))
print(ans)


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


int main() {
  int n, r;
  while(cin >> n >> r) {
    queue<int> deck[3];
    for(int i = 0; i < n; i++) {
      deck[2].push(i);
    }

    for(int i = 0; i < r; i++) {
      for(int i = 0; i < n/2; i++) {
	deck[1].push(deck[2].front());
	deck[2].pop();
      }
      for(int i = 0; i < n/2+n%2; i++) {
	deck[0].push(deck[2].front());
	deck[2].pop();
      }
      int c;
      cin >> c;
      for(int i = 0; !(deck[0].empty() && deck[1].empty()); i++) {
	for(int j = 0; j < c; j++) {
	  if(deck[i%2].empty()) break;
	  deck[2].push(deck[i%2].front());
	  deck[i%2].pop();
	}
      }
    }
    int ans;
    while(!deck[2].empty()) {
      ans = deck[2].front();
      deck[2].pop();
    }

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

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  string s;
  cin >> s;
  int n=s.size(),a=0,pow10=1;
  vector<int>mod2019(n+1,0);
  string ss;
  rep(i,n){
    ss=s.at(n-i-1);
    a=stoi(ss);
    mod2019[i+1]=(mod2019[i]+a*pow10)%2019;
    pow10*=10;
    pow10%=2019;
    //debug(i+1,mod2019[i+1]);
  }
  ll sum=0;
  sort(mod2019.begin(),mod2019.end());
  //rrep(i,0,n+1)debug(i,mod2019[i]);
  for(int i=0;i<=n;){
    ll j=1;
    while(mod2019[i]==mod2019[i+1]&&i<=n){i++;j++;}
    sum+=j*(j-1)/2;
    i++;
  }
  cout << sum;
}


Measured memory_bytes: 4316
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    FastIO io = new FastIO("in.txt");
    
    long N, D;

    public void main() throws Exception {
        N = io.nextLong(); D=  io.nextLong();
        long ans = 0;
        for(int i=0; i<N; i++){
            long x, y;
            x = io.nextLong(); y = io.nextLong();
            long d = x*x + y * y;
            if(d <= D*D){
                ans++;
            }
        }
        io.out(ans + "\n");
    }

    public static void main(String[] args) throws Exception {
        Main task = new Main();
        task.main();
    }

    class FastIO {
        BufferedReader br;
        StringTokenizer sk;

        public FastIO(String fname){
            try{
                File f = new File(fname);
                if(f.exists()) {
                    System.setIn(new FileInputStream(fname));
                }

            }catch (Exception e){
                throw new IllegalArgumentException(e);
            }

            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastIO(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(sk==null || !sk.hasMoreElements()){
                try {
                    sk = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new IllegalArgumentException(e);
                }
            }
            return sk.nextToken();
        }

        public int nextInt(){
            return Integer.parseInt(next());
        }

        public char nextChar(){
            return next().charAt(0);
        }

        public long nextLong(){
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }

        public String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            }catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }

        public void out(String v){
            System.out.print(v);
        }

        public void out(int v) {
            System.out.print(v);
        }

        public void out(long v){
            System.out.print(v);
        }

        public void out(double v) {
            System.out.print(v);
        }
    }
}



Measured memory_bytes: 55472
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(Math.abs(a - b) <= W){
			System.out.println("0");
		}else{
			System.out.println(Math.abs(a - b) - W);
		}
		
	}

}


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

class Combination {
private:
  const int max;
  const int mod;
  std::vector<long long> finv; // finv[k] = (k!)^-1 in Fp
public:
  Combination(int max, int mod) : max(max), mod(mod), finv(max, -1) {
    std::vector<long long> inv(max, -1); // inv[k] = k^-1 in Fp
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < max; ++i) {
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  long long operator()(int n, int k) const {
    if (n < k || n < 0 || k < 0)
      return 0;
    long long res = 1;
    for (int i = 0; i < k; ++i)
      res = res * (n - i) % mod;
    return res * finv[k] % mod;
  }
};

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  const int MAX = 1000000;
  const int MOD = 1000000007;
  Combination comb(MAX, MOD);

  long long res = modpow(2, n, MOD) - 1;
  if (res < 0)
    res += MOD;
  res -= comb(n, a);
  if (res < 0)
    res += MOD;
  res -= comb(n, b);
  if (res < 0)
    res += MOD;
  std::cout << res << std::endl;
}


Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int ap=0,bp=0;
        int n=scan.nextInt();
        for(int i=0;i<n;i++){
            String a=scan.next();
            String b=scan.next();

            if(a.compareTo(b)>0){
                ap+=3;
            }else if(a.compareTo(b)==0){
                ap++;
                bp++;
            }else{
                bp+=3;
            }
        }
        System.out.println(ap+" "+bp);
    }
}



Measured memory_bytes: 30060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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 const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,K;
cin >> N >> K;
vi L(N);
rep(i,N) cin >> L[i];

sort(all(L),greater<int>());
int sum = 0;
rep(i,K) sum+= L[i];

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, d;
ll pw[maxn], t;
std::unordered_map<ll, ll> map[100];
inline ll dfs(int high,int can,ll rem) {
	if(high <= 0) return !rem * (high == 0 ? 10 : 1);
	if(!can && map[high].count(rem)) return map[high][rem];
	ll & ans = can ? t = 0 : map[high][rem];
	for(int i = can;i < 10;++i) {
		for(int j = 0;j < 10;++j) {
			ll v = rem + (pw[high] - 1) / 9 * (j - i);
			ans += v % 10 ? 0 : dfs(high - 2, 0, v / 10);
		}
	}
	return ans;
}
int main() {
	rep(i, 1, 20) map[i].rehash(1e5 + 7);
	*pw = 1;
	for(int i = 1;i < 19;++i) pw[i] = pw[i - 1] * 10;
	cin >> d;
	if(d % 9) {
		cout << 0 << '\n';
		return 0;
	}
	ll ans = 0;
	for(n = 1;n < 19;++n) {
		ans += dfs(n, 1, -d / 9);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 17152
n = int(input())
a = list(map(int, input().split()))
ans1 = list(range(1, n+1, 2))
ans2 = list(range(2, n+1, 2))
if n % 2 == 0:
    ans2.reverse()
    ans = ans2 + ans1
else:
    ans1.reverse()
    ans = ans1 + ans2
for i in ans:
    print(a[i-1])


Measured memory_bytes: 30800
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b && b==c)
    puts("1");
  else if(a==b || b==c ||c==a)
    puts("2");
  else
    puts("3");
  return 0;
}

Measured memory_bytes: 1624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;
    map<char, int> dict;
    
    rep(i, 0, S.size()) dict[S[i]]++;
    
    for (const auto& record : dict) {
      if (record.second%2 != 0) { cout << "No" << endl; return 0; }
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
N, M, *ab = map(int, open(0).read().split())
ans = [0] * N
for a, b in zip(*[iter(ab)] * 2):
    ans[a - 1] += 1
    ans[b - 1] -= 1
print("NO") if any(a % 2 for a in ans) else print("YES")


Measured memory_bytes: 31808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.stream.DoubleStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      String[] lines;
      double[] s;
      while( !(line = br.readLine()).equals("0") ){

        int n = Integer.parseInt(line);
        lines = br.readLine().split(" ");

        s =
          Stream.of(lines)
            .mapToDouble(Double::parseDouble)
            .toArray();
        
        double dm =
          Arrays.stream(s)
            .average()
          .getAsDouble();

        double result =
        Arrays.stream(s)
          .parallel()
          .map(d -> Math.pow((d-dm),2) / n)
          .sum();

        System.out.printf("%.8f\n" , Math.sqrt(result));
      }
    }
  }
}


Measured memory_bytes: 33228
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cassert>
#include<vector>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=320;
const int mod=1e9+7;
inline void pls(int &a,int b){ a+=b;if(a>=mod)a-=mod;}
int n,m;
vector<int>to[maxn];
int l[maxn],r[maxn],x[maxn];

inline void init()
{
	n=read();m=read();
	REP(i,1,m)
	{
		l[i]=read(); r[i]=read(); x[i]=read();
		to[r[i]].push_back(i);
	}
}

int dp[maxn][maxn][maxn];

struct Node {
	int a,b,c;
	Node(int _a=0,int _b=0,int _c=0){ a=_a;b=_b;c=_c;}
};

queue<Node>q;
int ans;
int vis[maxn][maxn][maxn];

inline void doing()
{
	q.push(Node(0,0,0));
	dp[0][0][0]=1;
	while(!q.empty())
	{
		Node t=q.front();q.pop();
		int now=max(t.a,max(t.b,t.c))+1;
		int a=t.a,b=t.b,c=t.c;

		int flg=1;
		for(int v:to[now-1])if((l[v]<=a)+(l[v]<=b)+(l[v]<=c)!=x[v]){flg=0;break;}
		if(!flg)continue;
		if(now>n)pls(ans,dp[a][b][c]);
		else {		
			pls(dp[now][b][c],dp[a][b][c]);if(!vis[now][b][c])vis[now][b][c]=1,q.push(Node(now,b,c));
			pls(dp[a][now][c],dp[a][b][c]);if(!vis[a][now][c])vis[a][now][c]=1,q.push(Node(a,now,c));
			pls(dp[a][b][now],dp[a][b][c]);if(!vis[a][b][now])vis[a][b][now]=1,q.push(Node(a,b,now));
		}
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



Measured memory_bytes: 247168
N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append((a, b))

parent = [i for i in range(N)]
height = [1] * N
size = [1] * N

def find(i):
    while i != parent[i]:
        i = parent[i]
    return i

def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i]


score = N*(N-1)//2
ans = [score]
for a, b in edges[::-1]:
    a = find(a)
    b = find(b)
    if a != b:
        score -= size[a] * size[b]
        union(a, b)
    ans.append(score)

for i in ans[len(ans)-2::-1]:
    print(i)

Measured memory_bytes: 91148
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  REP(i,1,s.size()-1) {
    if(s[i-1]==s[i]&&s[i]==s[i+1]) {
      pr("Yes");
      return;
    }
  }
  pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
//static const int maxn = 2e5 + 228;;
const ld eps = 1e-7;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef DEBUG
//      freopen("haybales.in", "r", stdin);
//      freopen("haybales.out", "w", stdout);
    #endif
}

void solve(){
	int n, m;
	cin >> n >> m;
	cout << (n==m?"Yes":"No") << endl;
	
	
}

signed main(){
        fast_io();
	srand(time(NULL));
//	cout << fixed << setprecision(12);
	int q = 1;
//	cin >> q;
	while(q--)
		solve();
     
}





Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=55,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n,m;
int d[MAXn][MAXn];
int dis[MAXn][MAXn];
queue<ii> q;
int dx[] = {1,0,0,-1};
int dy[] = {0,1,-1,0};
bool chk(int i,int j){
  return i<0 || i>=n || j<0 || j>=m;
}
int main(){
  IOS();
  cin>>n>>m;
  int cnt=0;
  REP(i,n)REP(j,m){
    char c;
    cin>>c;
    if( c=='.' ) d[i][j] = 0, cnt++;
    else d[i][j] = 1;
  }
  RST(dis,INF);
  dis[0][0] = 0;
  q.push(mkp(0,0));
  while( SZ(q) ){
    ii cur = q.front();
    q.pop();
    REP(i,4){
      int tx = cur.X+dx[i], ty = cur.Y+dy[i];
      if( chk(tx,ty) || d[tx][ty] ) continue;
      if( dis[tx][ty] > dis[cur.X][cur.Y]+1 ){
        dis[tx][ty] = dis[cur.X][cur.Y]+1;
        q.push(mkp(tx,ty));
      }
    }
  }
  if( dis[n-1][m-1]==INF ) cout<<-1<<endl;
  else cout<<cnt-dis[n-1][m-1]-1<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n), p(n);
	for(int i = 0; i < n; i++){
		scanf("%d", &p[i]);
		a[i] = 30000 * (i + 1);
		b[i] = 30000 * (n - i);
	}
	for(int i = 0; i < n; i++){
		b[p[i] - 1] += i;
	}
	for(int i = 0; i < n; i++){
		printf("%d", a[i]);
		if(i != n - 1){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	for(int i = 0; i < n; i++){
		printf("%d", b[i]);
		if(i != n - 1){
			printf(" ");
		} else{
			printf("\n");
		}
	}
	return 0;
}

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

int main(void){
  int N;
  cin>>N;
  long L[N];
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  long retval=0;
  for(int i=0;i<N;i++){
    long a=L[i];
    for(int j=i+1;j<N;j++){
      long b=L[j];
      for(int k=j+1;k<N;k++){
        long c=L[k];
        if(a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a){
          retval++;
        }
      }
    }
  }
  cout<<retval<<endl;
  return 0;
}


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

using namespace std;

int main(){
  int N, D, A;
  cin >> N >> D >> A;
  
  vector<pair<int, int>> monster(N);
  for(int i = 0; i < N; i++){
    int X, H;
    cin >> X >> H;
    monster[i] = make_pair(X, H);
  }
  sort(monster.begin(), monster.end());
  
  long long cnt = 0;
  vector<long long> damage(N + 1, 0);
  int right = 0;
  for(int i = 0; i < N; i++){
    if(i > 0) damage[i] += damage[i - 1];
    while(right < N && monster[right].first <= monster[i].first + 2 * D) right++;
    long long d = max((monster[i].second - damage[i] - 1 + A) / A, 0ll);
    cnt += d;
    damage[i] += d * A;
    damage[right] -= d * A;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

const double DTR = (2 * acos(-1)) / 360;

double myfmod(double x, double y) { return x - (int) (x / y) * y; }
 
enum ans {
        ABC, ACD, ADB, BCD,
};

int solve() {
        string xy;
        cin >> xy;
        int d, l;
        scanf("%d%d", &d, &l);
        double base = 
                xy == "BC" ? -60 :
                xy == "CD" ? 0 :
                xy == "DB" ? 60:
                0;
        double theta = (base + d) * DTR;
        double y = l * sin(theta);
        double x = l * cos(theta);
        double z60 = x + sqrt(3) / 3.0 * y;
        double z120 = -x + sqrt(3) / 3.0 * y;
        z60 = myfmod(myfmod(z60, 2.0) + 2.0, 2.0);
        z120 = myfmod(myfmod(z120, 2.0) + 2.0, 2.0);
        y = (z60 + z120) * sqrt(3) / 2.0;
        if (z60 < 1.0) {
                if (z120 < 1.0) {
                        if (y < sqrt(3) / 2.0) {
                                return ADB;
                        } else {
                                return BCD;
                        }
                } else {
                        if (y < sqrt(3)) {
                                return ABC;
                        } else {
                                return ACD;
                        }
                } 
        } else {
                if (z120 < 1.0) {
                        if (y < sqrt(3)) {
                                return ACD;
                        } else {
                                return ABC;
                        }
                } else {
                        if (y < 3.0 * sqrt(3) / 2.0) {
                                return BCD;
                        } else {
                                return ADB;
                        }
                }
        }
}

int main() {
        int a = solve(), b = solve();
        puts(a == b ? "YES" : "NO");
        return 0;
}

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

#define int long long

auto main() -> signed {
    int a, b;
    cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
string s;cin>>s;
int n=s.length();
bool b=0;
if(s[n-1]=='1'||s[0]=='0')b=true;
for(int i=0;i<n-1;i++)if(s[i]!=s[n-2-i])b=true;
if(b)cout<<-1<<endl;
else{
int l = 1, i = 2;
for(;i<=n;++i){
cout << l << " " << i <<endl;
if(s[i-2]=='1')l = i;
}
}
return 0;
}

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

using namespace std;

typedef long long ll;

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

    int N, Q;
    string S;
    char T[200000], D[200000];
    cin >> N >> Q >> S;

    for(int i = 0; i < Q; i++) cin >> T[i] >> D[i];

	int L = 0;
	int R = N;
	for(int i = Q - 1; i >= 0; i--){
		if (R > 0 && D[i] == 'R' && S[R - 1] == T[i]) R--;
		else if (R < N && D[i] == 'L' && S[R] == T[i]) R++;
		if (L > 0 && D[i] == 'R' && S[L - 1] == T[i]) L--;
		else if (L < N && D[i] == 'L' && S[L] == T[i]) L++;
	}

	cout << R - L << endl;

	return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int A , B;
    cin >> A >> B;
    if(A + B >= 10){
        cout << "error" << endl;
    }
    else{
        cout << A + B << endl;
    }
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A%2!=0 && B%2!=0) puts("Yes");
  else puts("No");
    
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int X, Y;
	cin >> X >> Y;
	bool found = false;
	for (int a = 0; a <= 100; a++) {
		for (int b = 0; b <= 100; b++) {
			if (2*a + 4*b == Y && a + b == X) {
				found = true;
			}
		}
	}
	if (found) cout << "Yes\n";
	else cout << "No\n";
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
#define input(n,v) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,ans=0;
vl v,kaijo,cost(300010,0),visited(300010,0),vv;
vp gragh[300010];
string s;
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
ll solve(){
	b=x;
	cost[b]=0;
    visited[b]=1;
    //cout<<gragh[b].size()<<endl;
    rep(i,gragh[b].size()){
            if(cost[b]+gragh[b][i].second<cost[gragh[b][i].first]){
                pq.push(make_pair(cost[b]+gragh[b][i].second,gragh[b][i].first));
            }
        }
    while(!pq.empty()){
        a=pq.top().first;
        b=pq.top().second;
        //cout<<a<<" "<<b<<endl;
        pq.pop();
        if(visited[b]==1)continue;
        visited[b]=1;
        cost[b]=a;
        rep(i,gragh[b].size()){
            if(cost[b]+gragh[b][i].second<cost[gragh[b][i].first]){
                pq.push(make_pair(cost[b]+gragh[b][i].second,gragh[b][i].first));
            }
        }
    }

    if(cost[y]!=INF)return cost[y]/3;
    return -1;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        gragh[a].emplace_back(b+n,1);
        gragh[a+n].emplace_back(b+n*2,1);
        gragh[a+n*2].emplace_back(b,1);
    }
    
    cin>>x>>y;

    rep(i,n*3){
        cost[i]=INF;
    }
    
    cout<<solve()<<endl;    
}

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

int main(){
	string S;
  	cin >> S;
  	size_t size = S.length(); //文字列の長さを把握
  	for(int i=0;i<size;i++){
    if(i % 2 == 0) {
    	if(S[i] == 'L') {
        cout << "No" << endl;
        return 0;
        }
    }else{
    	if(S[i] == 'R'){ 
          cout << "No" << endl;
          return 0;
      }
    }
  }
    cout <<"Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int i;
    int A, B, C;
    long long int K;
    scanf("%d %d %d %lld", &A, &B, &C, &K);


    int hoge, hoge1, hoge2, hoge3, hoge4;
    //hoge = (K-1) / 2;
    hoge1 = K % 2;
    //if(hoge > 30){
    //    printf("Unfair\n");
    //}else{
    //    if(hoge==0){
    //        hoge2 = 0;
    //    }else{
    //        hoge2 = 1;
    //    }
    //    for(i=1; i<hoge; i++){
    //        hoge2 = hoge2 * 4
    //    }
    //    hoge2 = hoge2 + 1;

    //    if(hoge1 == 1){
    //        hoge2 = hoge2 + hoge2 + 1;
    //    }

    //    if(hoge1){
    //        res = A * 
    //    }
    //}

    int ans;
    if(hoge1){
        ans = B - A;
    }else{
        ans = A - B;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <algorithm>
using namespace std;

class D
{
public:
	int n;
	long long c;
	vector<long long> x;
	vector<long long> v;
	vector<long long> w;

	void input ()
	{
		cin >> n >> c;
		x.resize(n+1);
		v.resize(n+1);
		w.resize(n+1);

		x[0] = 0;
		v[0] = 0;
		for (int i=1; i<=n; ++i)
		{
			cin >> x[i];
			cin >> v[i];
			v[i] += v[i-1];
		}
		x.push_back(c);
		for (int i=0; i<=n; ++i)
		{
			w[i] = v[n] - v[i];
		}
	}

	long long solve ()
	{
		for (int a = 1; a <= n; ++a)
		{
			v[a] = max(v[a-1], v[a] - x[a]);
			w[n-a] = max(w[n+1-a], w[n-a] - (c - x[n+1-a]));
		}
		long long max_value = 0;
		for (int a = 0; a <= n; ++a)
		{
			max_value = max(max_value, v[a] + w[a] - x[a]);
			max_value = max(max_value, v[a] + w[a] - (c - x[a+1]));
		}

		return max_value;
	}
};

int main ()
{
	D d;
	d.input();

	cout << d.solve() << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

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

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int i = 1; i < n - 1; i++) {
			if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n,k;
        cin >> n >> k;
        string s;
        cin >> s;
        for(int i=0; i<n; i++){
            if(i+1==k){
                s[i]=tolower(s[i]);
            }
        }
        cout << s;
        

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var q = Reads();
            var l = q[0];
            var r = q[1];
            long ans = long.MaxValue;
            if (r - l <= 2019)
            {
                for (long i = l; i <=r; i++)
                {
                    for (long j = i+1; j <=r; j++)
                    {
                        ans = Math.Min(ans, i % 2019 * (j % 2019) % 2019);
                    }
                }
                WriteLine(ans);
            }
            else WriteLine(0);
            

            Console.Out.Flush();
        }
    }
}


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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  dp[i][j]
    i文字目まででj文字青のとき
    場合の数
}*/

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

  map<pair<string, string>, int> cnt;
  rep(i, 1<<n){
    string a, b; //aka blue
    rep(j, n){
      if(i & 1<<j) a += s[j];
      else b += s[j];
    }
    
    cnt[{a, b}]++;

//    cout << a << " : " << b << endl;
  }

  int ans = 0;
  rep(i, 1<<n){
    string a, b;
    rep(j, n){
      if(i & 1<<j) a += s[n+j];
      else b += s[n+j];
    }

    reverse(all(a));
    reverse(all(b));

    ans += cnt[{b, a}];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <stdio.h>
#include <cmath>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
typedef long long ll;
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
 
int main(){
  double n,k;
  int ans;
  cin >> n >> k;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  ans = ceil(log(n)/log(k));
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int>P(N), dp(N+1, 0);
    for(int i=0;i<N;i++)cin>>P[i];

    int length = 0;
    for (int i = 0; i < N; ++i) {
        dp[P[i]]=dp[P[i]-1]+1;
        length = max(length, dp[P[i]]);
    }
    cout<<N-length<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <functional>
#include <stdio.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef pair<int, int> Point;
typedef pair<int, Point> SP;
typedef vector<vector<int> > Mat;

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int n;
Mat mat;
vector<vector<bool> > used;
vector<SP> starts(0);
 
bool dfs(int cur, int sum, int x, int y) {
//  cout << x << ", "<< y << ", " << sum << endl;
  if (starts[cur].first == sum) {
    //cout << "ok " << cur << endl;
    cur++;
    sum = 0;
    if (cur >= starts.size()) {
      return true;
    }
    x = starts[cur].second.second;
    y = starts[cur].second.first;
  }
  else if (starts[cur].first < sum) {
    return false;
  }
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];

    if (0 <= nx && nx < n && 0 <= ny && ny < n && !used[ny][nx]) {
      used[ny][nx] = true;
      if (dfs(cur, sum + mat[ny][nx], nx, ny)) return true;
      used[ny][nx] = false;
    }
  }
  return false;
  
}
void solve() {
  mat = Mat(n, vector<int>(n));
  used = vector<vector<bool> >(n, vector<bool>(n, false));
  starts.clear();
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int a;
      cin >> a;
      sum += a;
      if (a < 0) {
        a *= -1;
        used[i][j] = true;
        starts.push_back(SP(a, Point(i, j)));
      }
      mat[i][j] = a;
    }
  }
  bool ret = false;;
  if (sum != 0) {
    ret = false;
  }
  else if (starts.size() == 1) {
    ret = true;
  }
  else {
    sort(starts.begin(), starts.end(), greater<SP>());

    ret = dfs(0, 0, starts[0].second.second, starts[0].second.first);
  }
  cout << (ret ? "YES" : "NO") << endl;
  return;
}


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

Measured memory_bytes: 916
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

int main()
{
	long long h,w,K;
	cin >> h >> w >> K;
	vector<string> s(h);
	for(long long i=0;i<h;i++)
		cin >> s[i];

	long long mn=INF;

	for(long long i=0;i<(1<<(h-1));i++)
	{
		long long tmp=0;
		for(long long j=0;j<h;j++)
			if(i&(1<<j))tmp++;
		vector<long long> cnt(tmp+1,0);
		vector<long long> cntb(tmp+1,0);
		long long area=tmp+1;
		bool befflg=true;
		bool can=true;
		for(long long j=0;j<w;j++)
		{
			long long now=0;
			bool flg=false;
			for(long long k=0;k<area;k++)
				cntb[k]=0;
			for(long long k=0;k<h;k++)
			{
				if(s[k][j]=='1')
				{
					cnt[now]++;
					cntb[now]++;
					//cout << k << " " << j << " " << cnt[now] << " " << cntb[now] << endl;
				}
				if(cnt[now]>K)flg=true;

				if((1<<k)&i)now++;
			}
			
			if(flg)
			{
				if(befflg)
				{
				}
				befflg=true;
				tmp++;
				for(long long k=0;k<area;k++)
				{
					cnt[k]=cntb[k];
					if(cnt[k]>K)
						can=false;
				}
				
			}
			else
				befflg=false;

		}
		//cout << (can ? tmp:(-1)) << endl;
		if(can)if(tmp<mn)mn=tmp;
	}
	cout << mn << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  int orgn = n;
  vector<int> div;
  for(int i=2;i*i<=n;i++) {
    if(n % i == 0) {
      div.push_back(i);
      while(n % i == 0) n /= i;
    }
  }
  if(n != 1) div.push_back(n);
  int m = div.size();
  int ans = 0;
  for(int i = 1;i < 1<<m; ++i) {
    int mul = 1;
    for(int j=0;j<m;++j) {
      if((i >> j) & 1) mul *= div[j];
    }
    if(__builtin_popcount(i) % 2 == 1) ans += orgn / mul;
    else ans -= orgn / mul;
  }
  ans = orgn - ans;
  cout << ans << endl;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>

using namespace std;

int n, S, r[20000], p, ans;

main(){
  while(cin >> n >> S && (n|S)){
    for(int i=0;i<n;i++) cin >> r[i];
    sort(r, r+n);
    ans = 0;
    for(int i=0;i<n;i++){
      p = upper_bound(r, r+n, S - r[i]) - r;
      if(p > i) ans += n - p;
      else ans += max(n - p - 1, 0);
    }
    cout << ans / 2 << endl;
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
typedef long long ll;
ll read() {ll x = 0;char f = 1, ch = getchar();while(ch < '0' || ch > '9') {if(ch == '-')f = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * f;}
void write(ll x) {if(x < 0) x = -x, putchar('-');if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 444444;
using namespace std;
int n, s;
ll ans, a[N], b[N][4], c[5];
bool cmp(int x, int y) {
	return a[x] > a[y];
}
int main() {
	n = read();
	s = 1 << n;
	for(int i = 0; i < s; ++i)
		a[i] = read();
	a[s] = -1e11;
	b[0][0] = 0, b[0][1] = s;
	for(int i = 1; i < s; ++i) {
		b[i][0] = i, b[i][1] = s;
		for(int j = 0; j < n; ++j)
			if(i & 1 << j) {
				int k =i ^ (1 << j);
				c[0] = b[i][0], c[1] = b[i][1], c[2] = b[k][0], c[3] = b[k][1];
				sort(c, c + 4, cmp);
				b[i][0] = c[0];
				b[i][1] = c[0] == c[1] ? c[2] : c[1];
			}
	}
	for(int i = 1; i < s; ++i) {
		ans = max(ans, a[b[i][0]] +  a[b[i][1]]);
		writeln(ans);
	}
	return 0;
}

Measured memory_bytes: 17408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ALucky7 {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        rep(i,3){
            if(s[i]=='7'){
                out << "Yes" << endl;
                return ;
            }
        }
        out << "No" << endl;
	}
};


int main() {
	ALucky7 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3632
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce


# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

# import random
# import time


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

m=sum(a)
if m>=h:
    print("Yes")
else:
    print("No")


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

struct UnionFind {
    vector<int> data;
    int gnum;
    UnionFind(int size) : data(size, -1), gnum(size) {}
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
            gnum--;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
    int getGroupNum() {
        return gnum;
    }
    vector<vector<int>> getGroups() {
        int now = 0;
        map<int, vector<int>> G;
        for (int i = 0; i < data.size(); i++) {
            G[root(i)].push_back(i);
        }
        vector<vector<int>> ret;
        for(auto g : G) {
            ret.push_back(g.second);
        }
        return ret;
    }
};

void solve() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    for (int i = 0; i < Q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            uf.unionSet(x, y);
        } else {
            if (uf.findSet(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans++;
      } 
    } 
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256