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

int n,m,p;
int board[7][7][7];
int height[7][7];
int dx[]={1,0,0,1,1,1,1,0,0,1,1,1,1};
int dy[]={0,1,0,1,-1,0,0,1,1,1,1,-1,-1};
int dz[]={0,0,1,0,0,1,-1,1,-1,1,-1,1,-1};

void init(){
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      height[i][j]=0;
      for(int k=0;k<n;k++)
	board[i][j][k]=0;
    }
}

bool search(int color){
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++)
	for(int d=0;d<13;d++){
	  int cnt=0;
	  int nx=i; int ny=j; int nz=k;
	  while(nx>=0&&nx<n&&ny>=0&&ny<n&&nz>=0&&nz<n){
	    if(board[ny][nx][nz]!=color) break;
	    nx+=dx[d]; ny+=dy[d]; nz+=dz[d];
	    cnt++;
	  }
	  if(cnt>=m) return true;
	}
  return false;
}	

int main(){
  while(cin>>n>>m>>p,n){
    int cnt;
    bool found=false;
    init();
    for(int i=0;i<p;i++){
      int x,y;
      cin>>x>>y;
      if(found) continue;
      int color=(i%2==0)?1:2;
      board[y-1][x-1][height[y-1][x-1]++]=color;
      if(search(color)){
	cnt=i+1; found=true;
      }
    }
    if(found) cout<<((cnt%2==1)?"Black":"White")<<" "<<cnt<<endl;
    else cout<<"Draw"<<endl;
  }
}   


Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
	int x,y,atai,keta;//??\?????????
	while(scanf("%d %d",&x,&y)!=EOF){
		keta=0;
		atai=x+y;
		while(atai!=0){
			atai=atai/10;
			keta++;
		}
		printf("%d\n",keta);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 100001
#define max_m 50
#define max_w 1000
#define max_h 1000
#define max_k 10000
#define max_l 10000
#define INF 9999999

typedef long long lint;

int main()
{
    char a[max_n];
    cin>>a;
    int count=0;
    for(int i=0;i<strlen(a)-1;i++){
        if(a[i]!=a[i+1]){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 384
n,m,*x=map(int,open(0).read().split())
a,b=[0]*m,[0]*m
s=set()
for i in x:
  j=i%m
  if i in s:
    s-={i}
    b[j]+=1
  else:
    s|={i}
  a[j]+=1
c=a[0]//2+(m%2<1and a[m//2]//2)
for i in range(1,m//2+m%2):
  (i,_),(j,k)=sorted((a[j],b[j])for j in(i,m-i))
  c+=i+min(j-i>>1,k)
print(c)

Measured memory_bytes: 17504
#include<cstdio>
#include<cstring>
#define int long long
int tree[4001000],n,cnta,cntb,p[300100],A[300100],B[300100];
void modify(int t,int l,int r,int pos){
	if(l==r){
		tree[t]++;
		return;
	}
	int mid=(l+r)/2;
	if(pos<=mid)modify(t*2,l,mid,pos);
	else modify(t*2+1,mid+1,r,pos);
	tree[t]=tree[t*2]+tree[t*2+1];
}
int query(int t,int l,int r,int L,int R){
	if(l>R||L>r)return 0;
	if(L<=l&&r<=R)return tree[t];
	int mid=(l+r)/2;
	return query(t*2,l,mid,L,R)+query(t*2+1,mid+1,r,L,R);
}
int calc(int *a,int len){
	memset(tree,0,sizeof(tree));
	int res=0;
	for(int i=1;i<=len;i++){
		res+=query(1,1,n,a[i]+1,n);
		modify(1,1,n,a[i]);
	}
	return res;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&p[i]);
		if(i&1){
			A[++cnta]=p[i];
			if(p[i]%2==0)return puts("No"),0;
		}
		else{
			B[++cntb]=p[i];
			if(p[i]%2!=0)return puts("No"),0;
		}
	}
	int val=calc(p,n),val1=calc(A,cnta),val2=calc(B,cntb);
	if(val!=(val1+val2)*3)return puts("No"),0;
	puts("Yes");
}

Measured memory_bytes: 37600
N = input()
N = int(N)
S = input()
S = S.split()
S = list(S)

if N % 2 == 0:
  H = int(N/2)
  if S[0][:H] == S[0][H:]:
    print("Yes")
  else:
    print("No")
  
else:
  print("No")

Measured memory_bytes: 3060
k,s=map(int,input().split())
ans=0
def als(n):
  if 0<=n<=k:
    return n+1
  elif k+1<=n<=2*k:
    return 2*k+1-n
  else:
    return 0
for i in range(k+1):
  ans+=als(s-i)
print(ans)


Measured memory_bytes: 39024
from heapq import*
i=input
c=int(i())
while c:
 n=m=int(i());s,x,*y=0,[]
 while m:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[(n-k,r,l)]*(l<=r);m-=1
 for x in x,y:
  x.sort();n,*h=len(x),
  while n:
   n-=1
   while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
  for*_,r in x+h:s+=r
 print(s);c-=1

Measured memory_bytes: 44540
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int p = sc.nextInt();
			
			if(n == 0 && p == 0){
				break;
			}
			
			int[] hands = new int[n];
			
			int cur_person = 0;
			int cur_stone = p;
			
			while(true){
				if(cur_stone == 0){
					cur_stone = hands[cur_person];
					hands[cur_person] = 0;
				}else{
					cur_stone--;
					hands[cur_person]++;
					
					if(cur_stone == 0 && hands[cur_person] == p){
						System.out.println(cur_person);
						break;
					}
				}
				
				cur_person = (cur_person + 1) % n;
			}
		}
		
		sc.close();
	}

}

Measured memory_bytes: 20208
#include <vector>
#include <set>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    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;
        }
        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)];
    }
    void clear() { for (int i=0; i<data.size(); ++i) data[i] = -1; }
};


int N,M;
int h[201];
int ord[201];

int adj[201][201];

struct Comp {
    bool operator()(const int i, const int j) { return h[i] < h[j]; }
};

struct Edge {
    int src, dst, cost;
};
bool operator<(const Edge &e, const Edge &f) {
    return (e.cost != f.cost) ? e.cost < f.cost : e.src < f.src;
}

int main() {
    while(cin>>N>>M, N|M) {
        vector<int> ord(N);
        for (int i=0; i<N; ++i) {
            cin>>h[i];
            ord[i] = h[i];
        }
        sort(ord.begin(), ord.end());
        ord.erase(unique(ord.begin(), ord.end()), ord.end());

        vector<Edge> e;
        memset(adj, -1, sizeof(adj));
        for (int i=0; i<M; ++i) {
            int a,b,c;
            cin>>a>>b>>c; a--, b--;
            adj[a][b] = adj[b][a] = c;
            e.push_back((Edge){a,b,c});
        }
        sort(e.begin(), e.end());

        int cnt = 0;
        bool all_connect[201] = {};
        UnionFind con(N);
        for (int i=ord.size()-1; i>=0; --i) {
            cnt = 0;
            for (int p=0; p<N; ++p) {
                if (ord[i] <= h[p]) cnt++;
                for(int q=0; q<N; ++q)
                    if (h[p] >= ord[i] && h[q] >= ord[i] && adj[p][q] >= 0)
                        con.unionSet(p,q);
            }
            for (int p=0; p<N; ++p) {
                if (ord[i] <= h[p] && con.size(p) == cnt) {
                    all_connect[i] = true;
                    break;
                }
            }
        }
        if (!all_connect[0]) {
            cout<<0<<endl;
            continue;
        }

        con.clear();
        int last = 0, ans = 0;
        for (; last < ord.size() && all_connect[last]; ++last);
        last--;
        for (; last >= 0; --last) {
            for (int i=0; i<M; ++i) {
                int v = e[i].src, w = e[i].dst, c = e[i].cost;
                if (h[v] >= ord[last] && h[w] >= ord[last]) {
                    if (con.findSet(v, w)) continue;
                    ans += c; con.unionSet(v, w);
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1876
#include<stdio.h>

int main(void){
    int N,X,l=0;
    int i,j,k=0;
    scanf("%d %d",&N,&X);
    long long int L[N];
    for(i=0;i<N;i++) scanf("%lld",&L[i]);
    for(j=0;j<N;j++){
        if(l <= X){
            l += L[j];
            k++;
        }
    }
    if(l <= X) k++;
    printf("%d",k);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  string s = in;
  if (s[0] != 'A') {
    cout << ("WA") << endl;
    return;
  }
  int cnt = 0;
  rep(i, 1, size(s)) {
    if (2 <= i && size(s) - i >= 2 && s[i] == 'C') {
      if (cnt == 1) {
        err(1);
        cout << ("WA") << endl;
        return;
      }
      cnt++;
      continue;
    }
    if ('a' <= s[i] && s[i] <= 'z')continue;
    err(2, i, s[i], size(s) - i);
    cout << ("WA") << endl;
    return;
  }
  if (cnt == 1) {
    cout << ("AC") << endl;
  }
  else {
    cout << ("WA") << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,A,B;
    cin >> N >> A >> B;
    int c=B-A;
    if(c%2==0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;

int main(){
    long long Q,H,S,D;
    long long N;
    cin>>Q>>H>>S>>D;
    cin>>N;
    //1リットルの最小値
    long long L=min(4*Q,min(2*H,S));
    //2リットルの最小値
    long long LL=min(2*L,D);
    long long ans = (N/2)*LL + (N%2)*L;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int t = a + b + c + d;
  cout << t / 60 << endl << t % 60 << endl;
  return 0;
}


Measured memory_bytes: 3072
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static long[] dist;
	static ArrayList<TreeMap<Integer, Long>> edges;
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		dist = new long[n];
		edges = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			edges.add(new TreeMap<Integer, Long>());
		}
		for(int i= 0; i < n-1; i++) {
			int a = sc.nextInt()-1,b = sc.nextInt()-1;
			long d = sc.nextLong();
			edges.get(a).put(b, d);
			edges.get(b).put(a, d);
		}
		int q = sc.nextInt();
		dfs(-1, sc.nextInt()-1, 0);
		for(int i = 0; i < q; i++) {
			System.out.println(dist[sc.nextInt()-1]+dist[sc.nextInt()-1]);
		}
	}
	static void dfs(int from, int to, long d) {
		dist[to] = d;
		TreeMap<Integer, Long> m = edges.get(to);
		m.remove(from);
		m.forEach((k, v) -> dfs(to, k, d+v));
	}
}


Measured memory_bytes: 231872
#include <stdio.h>

int memo[50] = {0};

int fib(n){
  if (n <= 1) {
    memo[n] = 1;
    return memo[n];
  }
  if (memo[n] > 0) {
    return memo[n];
  }
  memo[n] = fib(n-1) + fib(n-2);
  return memo[n];
}

int main(void){
  int n, ans;

  scanf("%d", &n);

  ans = fib(n);

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

  return 0;
}


Measured memory_bytes: 1968
#include<iostream>
#include<vector>
using namespace std;
int main (){
  vector<vector<int>>vec(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0; j<3;j++){
      cin >> vec[i][j];
    }
  }
  int a2,b2,b3,a3;
  for(int i=-10000;i<10000;i++){
    for(int j=-10000;j<10000;j++){      
      b2=vec[0][1]-i;
      b3=vec[0][2]-i;
      a2=vec[1][0]-j;
      a3=vec[2][0]-j;
      if(i+j==vec[0][0] && a2+b2==vec[1][1] && a3+b3==vec[2][2] && a2+b3==vec[1][2] && a3+b2==vec[2][1]){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  s.pb('#');
  s.pb('#');
  if(c>d){
      ll k=0;
      for(int i=a;i<n;i++){
        if(s[i]=='#'&&s[i+1]=='#'&&i) {
          COUT("No");
          return 0;
        }
        if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'&&i>=b-2&&i<d-1){
          k=1;
        }
      }
      if(k){
        COUT("Yes");
        return 0;
      }
      else{
        COUT("No");
        return 0;
      }
  }
  else{
      for(int i=b;i<d;i++){
        if(s[i]=='#'&&s[i+1]=='#') {
          COUT("No");
          return 0;
        }
      }
      for(int i=a;i<c;i++){
        if(s[i]=='#'&&s[i+1]=='#') {
          COUT("No");
          return 0;
        }
      }
      COUT("Yes");
  }
}
        


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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n){
        cin >> p[i];
    }
    sort(all(p));
    int ans = 0;
    rep(i, k){
        ans += p[i];
    }
    cout << ans << endl;

}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int n, k;
	int *x, *x_tmp;
	int min = INT_MAX;
	int tmp;
	scanf("%d %d\n", &n, &k);
	x = (int*)malloc(sizeof(int)*n);
	x_tmp = x;
	for(int i=0; i<n; i++){
		scanf("%d", x_tmp++);
	}
	for(int i=0; i<=n-k; i++){
		tmp = abs(x[i]) + abs(x[i+k-1] - x[i]);
		if(tmp < min) min = tmp;
		tmp = abs(x[i+k-1]) + abs(x[i+k-1] - x[i]);
		if(tmp < min) min = tmp;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0 && m==0)
        break;
        cout<<min(n,m)<<" "<<max(n,m)<<endl;
    }

    return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<pair<long long, long long>, long long>> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i].first.first >> A[i].first.second;
        A[i].second = i;
    }
    vector<pair<int, string>> ans;
    vector<int> cnt(N, 1);
    sort(A.begin(), A.end());
    for (int i = 0; i < M; i++) {
        int num = A[i].second;
        int pre = A[i].first.first;
        int ran =cnt[pre-1]; cnt[pre-1]++;
        string P = "00000" + to_string(pre);
        string R = "00000" + to_string(ran);
        P = P.substr((int)P.length() - 6, 6);
        R = R.substr((int)R.length() - 6, 6);
        string S = P + R;
        ans.emplace_back(num, S);
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < M; i++) {
        cout << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 10992
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n,r;
int main(void){
	cin>>n>>r;
	if(n>=10)cout<<r;
	else cout<<r+100*(10-n);
	return 0;
} 

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    string s; cin >> s;
    if(s[1] == 'B')s[1] = 'R';
    else s[1] = 'B';
    cout << s;
    return 0;
}


Measured memory_bytes: 3608
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

struct P {
  int x,y;
  P(int x, int y):x(x),y(y){}
  bool operator<(const P&a)const {
    return x<a.x;
  }
};

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int h,w,m;
  cin>>h>>w>>m;
  vector<P>a;
  unordered_map<int,int>mpx,mpy;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    mpx[x]++;
    mpy[y]++;
    a.push_back(P(x,y));
  }
  sort(a.begin(),a.end());
  int ret=0;
  set<int>st;
  unordered_map<int,int>cc;
  for(auto pr: mpy){
    st.insert(pr.second);
    cc[pr.second]++;
  }
  for(int i=0;i<m;i++){
    int j = i - 1;
    while(j+1<m&&a[j+1].x==a[i].x) {
      j++;
      ret = max(ret, mpx[a[j].x] + mpy[a[j].y]-1);
      int tt = mpy[a[j].y];
      cc[tt]--;
      if(cc[tt]==0)st.erase(tt);
    }
    if(!st.empty()){
      int tt = *st.rbegin();
      ret = max(ret, mpx[a[i].x]+tt);
    }
    for(int k=i;k<=j;k++){
      int tt = mpy[a[k].y];
      cc[tt]++;
      if(cc[tt]==1)st.insert(tt);
    }
    i = j;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 32592
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

S=input()
N=len(S)

LOC=[1]*N
for i in range(N):
    if S[i] == "R":
        if S[i+1] ==  "L":
            continue
        else:
            LOC[i+2] += LOC[i]
            LOC[i] = 0

for i in range(N)[::-1]:
    if S[i] == "L":
        if S[i-1] ==  "R":
            continue
        else:
            LOC[i-2] += LOC[i]
            LOC[i] = 0

for i in LOC[:-1]:
    print(i, end=" ")
print(LOC[-1])


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

ll a[3005];

ll dp[3005][3005];

ll fn(ll s,ll e){
  if(s==e)
    return a[s];
  if(dp[s][e]!=-1)
    return dp[s][e];
  ll ans=max(a[s]-fn(s+1,e),a[e]-fn(s,e-1));
  dp[s][e]=ans;
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,0,n)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));
  ll ans=fn(0,n-1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 70912
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int p = scan.nextInt();
		if(a<p){
          
		System.out.println(0);
        }else{
          System.out.println(10);
        }
	}
 
}

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

int main(){
	int n; cin >> n;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n;i++){
		cin >> c[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans=0;
	for(int i=0;i<n;i++){
		ll left=-1; ll right=n;
		while(right-left>1){
			int mid=(left+right)/2;
			if(a[mid]>=b[i]){
				right=mid;
			}
			else{
				left=mid;
			}
		}
		ll left2=-1; ll right2=n;
		while(right2-left2>1){
			int mid=(left2+right2)/2;
			if(c[mid]>b[i]){
				right2=mid;
			}
			else{
				left2=mid;
			}
		}
		ans+=right*(n-right2);
	}
	cout << ans << endl;
}

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

int main() {
  ll a; cin >> a;
  set<ll> s; s.insert(a);
  ll x = a; ll res = 1;
  for (ll i = 0; i <= 1e7; i++) {
    if (x%2 == 0) {
      x /= 2; res++;
    } else {
      x = 3*x+1; res++;
    }
    if (s.count(x)!=0) {break;}
    s.insert(x);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
ans = 0
m = 0
if sum(a) < sum(b):
    print(-1)
    exit()
for i in range(n):
    if a[i] < b[i]:
        ans += 1
        m += b[i] - a[i]
    else:
        l.append(a[i] - b[i])
l = list(reversed(sorted(l)))
for i in l:
    if m > 0:
        m -= i
        ans += 1
print(ans)

Measured memory_bytes: 18492
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    int cnt = 1;
    int ans = 0;
    REP(i, 0, n) {
        int a;
        cin, a;
        if (a != cnt) {
            ans++;
        } else {
            cnt++;
        }
    }
    if (ans == n) {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define DUMP(v) REP(i,(v).size()){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<endl;}
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	if (x >= 1200)cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=233;
int n,m;
int a[N];
int sum=0;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int main()
{
//    freopen("input.in","r",stdin);
//    freopen("output.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) sum+=a[i]*a[j];
	printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)<0?-(a):(a))




int main(void){
	lli n;
	int *p;
	lli *a,*b;

	lli bigint = 800000000;

	lli i;

	scanf("%lld",&n);
	//for(i=1;i<=20000;i++){
	//	printf("%d\n", i);
	//}

	p = calloc(sizeof(int),n);
	a = calloc(sizeof(lli),n);
	b = calloc(sizeof(lli),n);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		p[i]--;
	}
	for(i=0;i<n;i++){
		a[i] = b[n-i-1] = i*50000 + 1;
	}
	for(i=0;i<n;i++){
		a[p[i]] += i+1;
	}
	for(i=0;i<n;i++){
		printf("%lld ", a[i]);
	}
	printf("\n");
	for(i=0;i<n;i++){
		printf("%lld ", b[i]);
	}
	printf("\n");
    return 0;
}


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

int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  long long int countk = 0;
  for (int i = 0; i < n; i++)
    if (a[i] % 2) countk++;

  if (countk % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}

signed main(){

  string s,t;
  cin>>s>>t;

  int n = size(s);
  int m = size(t);

  vector dp (n+1,vector(m+1,0ll));
  rep(i,n)rep(j,m){
    chmax(dp[i+1][j+1],dp[i+1][j]);
    chmax(dp[i+1][j+1],dp[i][j+1]);
    if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
  }
  //for(auto v:dp){for(auto x:v)cout<<x<<" ";cout<<endl;}

  string ans = "";
  int cur = dp[n][m];
  for(int i=n;i-->0;){
    for(int j=0;j<m;++j){
      if(dp[i+1][j+1]==cur and dp[i+1][j+1]==dp[i][j]+1 and s[i]==t[j]){
        ans += s[i];
        cur--;
      }
    }
  }
  reverse(begin(ans),end(ans));
  cout<<(ans)<<endl;

}

Measured memory_bytes: 73640
#include <bits/stdc++.h>  // ver1.9
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  Vi a(3);
  int n;
  cin >> a[0] >> a[1] >> a[2] >> n;
  int memo=0;
  int ans = 0;
  sort(ALL(a));
  
  repeq(i,0,n/a[2]){
    repeq(j,0,n/a[1]){
      memo = n - a[2]*i - a[1]*j;
      if(memo%a[0]==0 && memo>=0) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans=0
for bit in range(2**n):
  ok=True
  for j in range(m):
    c=0
    k=s[j][0]
    for l in range(1,k+1):
      if (bit &(1<<(s[j][l]-1))):c+=1
    if c%2!=p[j]:ok=False
  if ok:ans+=1
print(ans)




Measured memory_bytes: 3064
#include<iostream>

using namespace std;
#define endl "\n"
#define long long ll
const int MOD = 1e9 + 7;

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

	int m1,d1,m2,d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(m1 == 1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12  )
		{
			if(d1 == 31)
			cout << "1\n";
			else
				cout << "0\n";
		}
	else if(m1 == 2)
		{
			if(d1 == 28)
			cout << "1\n";
			else
				cout << "0\n";
		}
	else if(m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11)
		{
			if(d1 == 30)
			cout << "1\n";
			else
				cout << "0\n";
		}


	return 0;
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi S(N); REP(i, N) cin >> S[i];
    int M; cin >> M;
    vi T(M); REP(i, M) cin >> T[i];

    int ans = 0;
    REP(i, M) ans += binary_search(ALL(S), T[i]);
    cout << ans << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s[i];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < 2; j++) {
      cout << s[i] << "\n";
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int num = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == '+'){
                num++;
            }else{
                if(s.charAt(i) == '-'){
                    num--;
                }
            }
        }
        
        System.out.println(num);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
x*=y;
if(x%2==0)std::cout << "Even" << '\n';
else std::cout << "Odd" << '\n';
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.split.map(&:to_i)
q = gets.to_i
t = gets.split.map(&:to_i)

def binary_search(ary, left, right, value)
  mid = ((left+right)/2).floor

  if left > right
    return false
  end

  if ary[mid] == value
    return true
  end

  if ary[mid] > value
    binary_search(ary, left, mid-1, value)
  else
    binary_search(ary, mid+1, right, value)
  end

end

p (t.inject(0) do |cnt, u|
  cnt+=1 if binary_search(s, 0, s.length-1, u)
  cnt
end)



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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}


int main() {
   ll i,j,k;
   ll n,m,ans=0;
   cin >>n>>m; 
   
   ans=(n+m)*(n+m-1);
  //  ans-=
   cout<< n*(n-1)/2+m*(m-1)/2 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    ll n;
    read(n);
    ll count = 0;
    for(int a = 1; a < n ;  a++){
        int b = n / a;
        if ( a * b == n){
            b--;
        }
        count += b;
    }
    cout << count << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <iomanip>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
const long double PI = (acos(-1));


int main(){
  int r;

  cin >> r;

  cout << setprecision(10) << 2*PI*r << endl;

  return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans = a*x+b*y;
  for(int i=0;i<=max(x,y);i++){
    int ab=i*2;
    int abc=ab*c+a*max(0,x-i)+b*max(0,y-i);
    ans=min(ans,abc);
  }
  cout<< ans << endl;
  return 0;
}
    

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

int main() {
  int64_t H,ans=2;
  cin >> H;
  for(int i=0;i<1000000000000;i++){
    if(H==1) break;
    H/=2;
    ans*=2;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define mod 1000000007
using namespace std;

int main()
{ 
  string a,b,c;
  long long dp[51][2];
  
  while(1){
    cin>>a;
    if(a=="0")break;
    cin>>b>>c;

    memset(dp,0,sizeof(dp));
    dp[a.length()][0]=1;

    for(int l=a.length()-1;l>=0;l--){
      int A,B,C;
      for(int i=0;i<10;i++){
	for(int j=0;j<10;j++){
	  for(int k=0;k<10;k++){
	    A=i,B=j,C=k;
	    if(a[l]!='?')A=(a[l]-'0');
	    if(b[l]!='?')B=(b[l]-'0');
	    if(c[l]!='?')C=(c[l]-'0');
            if(l==0 && (A==0 || B==0 || C==0))continue;
	    if((A+B)%10==C){
	      if((A+B)/10==0)dp[l][0]+=dp[l+1][0];
	      else dp[l][1]+=dp[l+1][0];
	    }
	    if((A+B+1)%10==C){
	      if((A+B+1)/10==0)dp[l][0]+=dp[l+1][1];
	      else dp[l][1]+=dp[l+1][1];
	    }
	    dp[l][0]%=mod;
	    dp[l][1]%=mod;
	    if(c[l]!='?')break;
	  }
	  if(b[l]!='?')break;
	}
	if(a[l]!='?')break;
      }
      //cout<<dp[l][0]<<" "<<dp[l][1]<<endl;
    }
    cout<<dp[0][0]<<endl;
  }
  return 0;
}

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

namespace ABC129_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var H = HW[0];
            var W = HW[1];

            var S = new string[H];
            var tate = new int[H, W];
            var yoko = new int[H, W];
            for (int h = 0; h < H; h++)
            {
                S[h] = Console.ReadLine();
                for (int w = 0; w < W; w++)
                {
                    tate[h, w] = -1;
                    yoko[h, w] = -1;
                }
            }

            var ans = 0;
            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    if (S[h][w] == '#') continue;

                    var temp = 0;
                    //tate
                    var t = 0;
                    if (tate[h,w] == -1)
                    {
                        for (int h2 = 0; h2 < H; h2++)
                        {
                            if (h + h2 >= H || S[h+h2][w] == '#') break;
                            t++;
                        }

                        for (int h2 = 0; h2 < H; h2++)
                        {
                            if (h + h2 >= H || S[h + h2][w] == '#') break;
                            tate[h + h2, w] = t;
                        }
                    }
                    temp += tate[h, w];

                    //yoko
                    var y = 0;
                    if (yoko[h, w] == -1)
                    {
                        for (int w2 = 0; w2 < W; w2++)
                        {
                            if (w + w2 >= W || S[h][w+w2] == '#') break;
                            y++;
                        }

                        for (int w2 = 0; w2 < W; w2++)
                        {
                            if (w + w2 >= W || S[h][w + w2] == '#') break;
                            yoko[h, w+w2] = y;
                        }
                    }
                    temp += yoko[h, w] -1;

                    ans = Math.Max(temp, ans);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 59340
#include <iostream>
#define F(i,n) for(int i=0;i!=n;i++)
long long M=1e9+7,n,k,d[102][9999],s=1,L=4000;
int main(){
std::cin>>n>>k,k++;
F(i,n-1) s=s*k%M;
s=s*n*k*(k-1)/2%M;
d[n+1][0]=1;
F(i,n) F(a,k) F(h,L) if(d[h]>0)
if(a<=n-i) d[n-i][h+(h+a)/(n-i)]=(d[n-i][h+(h+a)/(n-i)]+d[n-i+1][h])%M;
else d[n-i][h]=(d[n-i][h]+d[n-i+1][h])%M;
F(i,L) s=(s-d[1][i]*i);
std::cout<<(s%M+M)%M;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  res = 1;
  for(int i = 2;i <= n;i++){
    res *= i,res %= 1000000007;
  }
  cout << res << endl;
  return 0;
}

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

int main(){
    int n, m, t;
    cin >> n >> m >> t;

    int be, af, ans;
    cin >> af;
    ans += af - m;
    for(int i=0; i<n-1; i++){
        be = af;
        cin >> af;
        if(af - be > 2*m){
            ans += af - be - 2*m;
        }
    }
    if(t - af > m){
        ans += t - af - m;
    }

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

Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    char c[3];
    scanf("%s", c);
    
    int mysum=700;
    if(c[0]=='o'){
        mysum+=100;
    }
    if (c[1] == 'o') {
        mysum += 100;
    }
    if (c[2] == 'o') {
        mysum += 100;
    }
    printf("%d",mysum);
    
    return 0;
    
    
}


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  if (x > y) {
    swap(x, y);
    swap(a, b);
  }

  long long ans = 0;

  if (a + b > 2 * c) {
    ans += 2 * c * x;
  }
  else ans += (a + b) * x;

  if (b > 2 * c)
    ans += 2 * c * (y - x);
  else ans += b * (y - x);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  return 0;
}


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

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()
        {
            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;
        }
    }

    struct S
    {
        public int X, Y;
    }

    class Program
    {
        private int N, M;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            M = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            var sum = new int[N + 1];
            for (int i = 0; i < N; i++)
            {
                sum[i + 1] = sum[i] + A[i];
                sum[i + 1] %= M;
            }

            Dictionary<int, long> cnt = new Dictionary<int, long>();
            foreach (int i in sum)
            {
                long o;
                cnt.TryGetValue(i, out o);
                cnt[i] = o + 1;
            }

            long ans = 0;
            foreach (var i in cnt.Values)
            {
                ans += i * (i - 1) / 2;
            }
            Console.WriteLine(ans);
        }

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

Measured memory_bytes: 20832
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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() {
	long long n, k;
	cin >> n >> k;
	vector<long long>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(), greater<long long>());
	long long ans = h[0]-h[n-1];
	rep(i, n-k+1) {
		long long res = h[i] - h[i + k - 1];
		if (res <= ans)ans = res;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 17328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,M;
  cin>>N>>M;
  bool love[N][M];
  rep(i,N){
    rep(j,M){
      love[i][j]=false;
    }
  }
  rep(i,N){
    ll K;
    cin>>K;
    ll a[K];
    rep(j,K){
      cin>>a[j];
      love[i][a[j]-1]=true;
    }
  }
  bool total_love[M];
  rep(i,M) total_love[i]=true;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(!love[i][j]){
        total_love[j]=false;
      }
    }
  }
  ll ans=0;
  for(int i=0;i<M;i++){
    if(total_love[i]) ans++;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3616