akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

int N;
double table[NUM];

void func(){

	double sum = 0;

	for(int i = 0; i < N; i++){
		scanf("%lf",&table[i]);
		sum += table[i];
	}

	int ans = 0;

	double average = sum/(double)N;

	for(int i = 0; i < N; i++){
		if(table[i] <= average){
			ans++;
		}
	}

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

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3284
#include<cstdio>

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<int> G[100100];
int N, K;
ll ans;

void dfs(int v, int par){
    int k = G[v].size();
    int t; 
    if(par != -1) t = K-2;
    else t = K-1;

    for(int i = 0; i < k; i++){
        int next = G[v][i];
        if(next == par) continue;
        ans *= t;
        //cout << t << endl;
        ans %= MOD;
        t--;
        dfs(next, v);
    }
}

int main(){
    cin >> N >> K;
    REP(i,N-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ans = 1;
    ans *= K;
    ans %= MOD;
    dfs(0, -1);

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


Measured memory_bytes: 11520
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    w,h,x,y = map(int, input().split())
    multi = 0
    if w/2 == x and h/2 == y:
        multi = 1
    print(h*w / 2, multi)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int i,j,n,d,p;
  cin>>p>>n;
  long long int a[n+1],b;
  for(i=1;i<=n;i++)
    cin>>a[i];
  b=(p-a[n])+a[1];
  d=b;
  j=1;
  for(i=2;i<=n;i++)
  {
  	if(a[i]-a[i-1]>b)
    {
    b=a[i]-a[i-1];
      j=i;
    }
  }
  for(i=1;i<n;i++)
  {
      d+=(a[i+1]-a[i]);
  }
  cout<<d-b;
return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		int cnt = 0;
		for (int a = 0; a <= 1000; a++) {
			for (int b = 0; b <= 1000; b++) {
				if (n - a - b < 0)continue;
				else if (n - a - b <= 1000)cnt += n - a - b + 1;
				else if (n - a - b <= 2000)cnt += 2000 - (n - a - b) + 1;
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int i;
    int flag=0;
    if(N>81)cout << "No" << endl;
    else{
        for(i=1;i<10;i++)if(N%i==0 && N/i<10)flag++;
        if(flag>0)cout << "Yes" << endl;
        else{cout << "No" << endl;}
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string word;
  cin >> word;
  
  //gusu
  int counter = 0;
  if(word.size() % 2 == 0){
    for (int i = 0; i < word.size()/2; i++){
      if(word[i] != word[word.size() - 1 - i]){
        counter++;
      }
    }
  } else {
    for (int i = 0; i < word.size() / 2; i++){
       if(word[i] != word[word.size() - 1 - i]){
        counter++;
       }
    }
  }
  cout << counter << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n,k;
        cin>>n>>k;
        vi a(n);
        cin>>a;
        vi dp(n);
        dp[0]=0;
        //dp[1]=abs(a[1]-a[0]);
        FF(i,1,n)
        {
            dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
            FF(j,2,k+1)
            {
                if(j<=i)
                {
                    dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
                }
            }
        }
        cout<<dp[n-1]<<"\n";
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A + B > C + D) {
        cout << "Left" << endl;
    }
    else if (A + B < C + D) {
        cout << "Right" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	ll l,r;
	cin >> l >> r;
	ll ans = INF;
	for(ll i = l; i <= r; i++){
		for(ll j = i + 1; j <= r; j++){
			if(i % 2019 == 0 || j % 2019 == 0){
				cout << 0 << endl;
				return 0;
			}
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll ch[102][5][2];
int main() {
	string s;
	cin>>s;
	ll m;
	cin>>m;
	ch[0][0][0]=1;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'0';
		for(ll j=0;j<10;j++){
			for(ll k=0;k<=3;k++){
				if(j==0){
					if(j==now){
						ch[i+1][k][0]+=ch[i][k][0];
					}
					else if(j<now){
						ch[i+1][k][1]+=ch[i][k][0];
					}
					ch[i+1][k][1]+=ch[i][k][1];
				}
				else{
					if(j==now){
						ch[i+1][k+1][0]+=ch[i][k][0];
					}
					else if(j<now){
						ch[i+1][k+1][1]+=ch[i][k][0];
					}
					ch[i+1][k+1][1]+=ch[i][k][1];					
				}
			}
		}
	}
	cout << ch[s.size()][m][0]+ch[s.size()][m][1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from bisect import *

def judge(a, b, x):
    now = a
    c = 0
    
    while x>0:
        if x&1:
            now = dp[c][now]
        
        x >>= 1
        c += 1
    
    return now>=b
    
def binary_search(a, b):
    l, r = 0, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(a, b, m):
            r = m-1
        else:
            l = m+1
    
    return l

N = int(input())
x = list(map(int, input().split()))
L = int(input())
log_size = 22
dp = [[0]*N for _ in range(log_size)]

for i in range(N):
    dp[0][i] = bisect_right(x, x[i]+L)-1
    
for i in range(1, log_size):
    for j in range(N):
        dp[i][j] = dp[i-1][dp[i-1][j]]

Q = int(input())

for _ in range(Q):
    a, b = map(int, input().split())
    a, b = min(a, b)-1, max(a, b)-1
    print(binary_search(a, b))

Measured memory_bytes: 94872
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 998244353;
 
lli solve(int b, int e, lli s, vector<lli> &a){
    if(e-b == 1){
        if(a[b] == s) return 1;
        else return 0;
    }

    lli res = 0;
    int mid = (b+e)/2;
    vector<lli> dpb(s+1, 0), dpb_sum(s+1, 0);
    dpb[0] = 1;
    for(int i=mid-1; i>=b; i--){
        for(int j=s; j>=0; j--){
            if(j+a[i] <= s){
                dpb[j+a[i]] += dpb[j];
                dpb[j+a[i]] %= mod;
            }
        }
        for(int j=0; j<=s; j++){
            dpb_sum[j] += dpb[j];
            dpb_sum[j] %= mod;
        }
    }
    for(int j=0; j<=s; j++){
        dpb_sum[j] %= mod;
    }
    vector<lli> dpe(s+1, 0);
    dpe[0] = 1;
    for(int i=mid; i<e; i++){
        for(int j=s; j>=0; j--){
            if(j+a[i] <= s){
                dpe[j+a[i]] += dpe[j];
                dpe[j+a[i]] %= mod;
            }
        }
        for(int j=0; j<=s; j++){
            dpe[j] %= mod;
        }
        for(int j=0; j<=s; j++){
            res += dpb_sum[s-j]*dpe[j] %mod;
            res %= mod;
        }
    }
    //cout << b << " " << e << " " << mid << " " << res << endl;
    res += solve(b, mid, s, a) +solve(mid, e, s, a);
    res %= mod;
    return res;
}

int main(){
    lli n,s;
    cin >> n >> s;
    vector<lli> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    cout << solve(0, n, s, a) << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <cstdio>
#include <queue>
#include <cstring> 
#include <algorithm>
#include <ctype.h>
const int bufSize = 1e6;
#define DEBUG
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
const int maxn = 2e3 + 100;
const int maxm = 2e6 + 100;
const int inf = 1061109567;
int n,m;
char s[maxm];
bool mp[maxn][maxn];
int num[maxn][maxn];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int fa[maxm],cnt;
int find(int x){return x == fa[x] ? x : fa[x] = find(fa[x]);}
inline void unite(int x,int y)
{
    x = find(x),y = find(y);
    if(x == y) return;
    fa[x] = y;
}
struct node
{
    int to,next;
}E[5*maxm];
int head[maxm];
inline void add(const int &x,const int &y)
{
    static int tot = 0;
    E[++tot].next = head[x],E[tot].to = y,head[x] = tot;
}
int dis[maxn*maxn];
int main()
{
    read(n),read(m);
    int sx,sy,tx,ty;
    read(sx),read(sy),read(tx),read(ty);
    memset(dis,0x3f,sizeof(dis));
    for (int i = 1; i <= n; ++i) 
    {
        scanf("%s", s + 1);
        for (int j = 1; j <= m; ++j) if (s[j] == '.') mp[i][j] = 1; else mp[i][j] = 0;
    }
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) num[i][j] = ++cnt, fa[cnt] = cnt;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            if (!mp[i][j]) continue;
            for (int k = 0; k < 4; ++k)
            {
                int nx = i + dx[k], ny = j + dy[k];
                if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
                if(!mp[nx][ny]) continue;
                unite(num[i][j], num[nx][ny]);
            }
        }
    }
    for(int i = 1;i<=n;++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            for (int x = std::max(i - 2, 1); x <= i + 2 && x <= n; ++x)
            {
                for (int y = std::max(j - 2, 1); y <= j + 2 && y <= m; ++y)
                {
                    if(!mp[x][y]) continue;
                    if (find(num[x][y]) == find(num[i][j])) continue;
                    add(find(num[x][y]), find(num[i][j]));
                }
            }
        }
    }
    std::queue<int> q;
    q.push(find(num[sx][sy]));
    dis[find(num[sx][sy])] = 0;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int p = head[u]; p; p = E[p].next)
        {
            int v = E[p].to;
            if(dis[v] > dis[u] + 1) dis[v] = dis[u] + 1,q.push(v);
        }
    }
    if(dis[find(num[tx][ty])] < inf) printf("%d\n",dis[find(num[tx][ty])]);
    else puts("-1");
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    if ((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
const int N=1e5+10;
char s1[N],s2[N];
map<ll,char> Map;
int main()
{
	int n,m;
	scanf("%d%d%s%s",&n,&m,s1+1,s2+1);
	ll lcm=1ll*n*m/__gcd(n,m);
	ll b1=lcm/n,b2=lcm/m,p1=0,p2=1;
	for(ll i=1;i<=lcm;i+=b1) Map[i]=s1[++p1];
	for(ll i=1;i<=lcm;i+=b2,p2++)
	{
		if(Map.find(i)==Map.end()) continue;
		if(s2[p2]!=Map[i]) return puts("-1"),0;
	}
	printf("%lld\n",lcm);return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    # groupは要素1つでエラー

    # aの逆元を求める
    def inv(a, mod=mod):
        return pow(a, mod-2, mod)

    n = int(input())
    a = list(map(int, input().split()))
    if n == 1:
        print(1)
    else:
        l = lcm_group(a)
        res = 0
        for i in a:
            res += inv(i)
        print(res*l%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 76124
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

  ll cnt[26];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  string s; cin >> s;
  rep(i,n){
      cnt[s[i]-'a']++;
  }
  ll ans = 1;
  rep(i,26){
      ans *= cnt[i]+1;
      ans %= MOD;
  }
  ans = (ans -1 + MOD) % MOD;
  cout<< ans << endl;

}

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

using namespace std;

typedef pair<int, int> II;
typedef pair<long long, int> LLI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<II> VII;

#define For(i,a,b) for(int i = a;i <= b; i++)
#define Rep(i,a,b) for(int i = a;i >= b; i--)
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, f) for(auto i : f)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define BUG(x) (cerr << #x << " = " << x << "\n")
#define ARRAY(f) {cerr << #f << " = "; FOR(i, f) cout << i << ' '; cout << "\n";}
#define sz(s) int(s.size())
#define reset(f, x) memset(f, x, sizeof(f))
#define all(x) x.begin(), x.end()
#define two(x) (1LL << x)
#define getbit(x, i) ((x >> (i)) & 1LL)
#define onbit(x, i) (x | (1LL << (i)))
#define offbit(x, i) (x & ~(1 << (i)))

int ntest;
LL a, b, c, d;

LL gcd(LL a, LL b) {
    return (!b ? a : gcd(b, a % b));
}

bool cal() {
    if (b > a) return false;
    if (b > d) return false;
    if (b <= c+1) return true;
    LL g = gcd(b, d);
    a %= b;
    if (a <= c) a += d;
    LL have = a - c - 1;
    if (b <= c + have % g + 1) return true;
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        //freopen("","w",stdout);
    #endif
    cin >> ntest;
    while (ntest--) {
        cin >> a >> b >> c >> d;
        cout << (cal() ? "Yes\n" : "No\n");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const ll MOD = 1000000007;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> p{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,91,97};
    vector<int> c(100,0);
    int s = p.size();
    for(int i=2; i<N+1; i++){
        int tmp = i;
        for(int j=0; j<s; j++){
            if(tmp%p[j] == 0){
                while(tmp%p[j]==0){
                    c[p[j]]++;
                    tmp /= p[j];
                }
            }
        }
    }
    int cnt2, cnt4, cnt14, cnt24, cnt74;
    cnt2 = 0;
    cnt4 = 0;
    cnt14 = 0;
    cnt24 = 0;
    cnt74 = 0;
    for(int i=0; i<100; i++){
        if(c[i] >= 74) cnt74++;
        if(c[i] >= 24) cnt24++;
        if(c[i] >= 14) cnt14++;
        if(c[i] >= 4)  cnt4++;
        if(c[i] >= 2)  cnt2++;
    }
    int ans = 0;
    ans += cnt74;
    ans += cnt24*(cnt2-1);
    ans += cnt14*(cnt4-1);
    ans += cnt4*(cnt4-1)*(cnt4-2)/2;
    ans += cnt4*(cnt4-1)*(cnt2-cnt4)/2;
    cout << ans;
}

Measured memory_bytes: 3620
M[100],i,j,h,s;char N[100][9],B[9];main(n,m){for(;scanf("%d%d",&n,&m)*n;printf("%d\n",s)){for(i=n;i--;)scanf("%s%d",N[i],M+i);for(s=0;m--;)for(scanf("%s",B),i=n;i--;s+=M[i]*h)for(h=1,j=8;j--;)if(N[i][j]-42&&N[i][j]-B[j])h=0;}}

Measured memory_bytes: 420
l, r = map(int, input().split())

ans = 2019
if r - l >= 2019:
    ans = 0
    pass
else:
    for i in range(l, r):
        for j in range(i+1, r+1):
            if (i*j) % 2019 < ans:
                ans = (i*j) % 2019
            
print(ans)

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	double n, m, d; cin >> n >> m >> d;


	std::cout << fixed << setprecision(10);
	if (d == 0)
	{
		std::cout << (m-1)*(1/n) << std::endl;
	}
	else
	{
		std::cout << 2*(n-d)/(n*n)*(m-1)  << std::endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
	int main(){
		int N,M;
		
		scanf("%d",&N);
		getchar();
		scanf ("%d", &M);
		getchar();
		
		if ( N <= M){
			printf ("Yes\n");
		}else {
			printf ("No\n");
		}	
		return 0;
	}


Measured memory_bytes: 1640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll mass[22][22];


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


  ll h, w;
  cin >> h >> w;
  ll x, y;
  cin >> y >> x;
  rep(i, y)rep(j, w) mass[i][j]++;
  rep(i, h)rep(j, x) mass[i][j]++;
  rep(i, h)rep(j, w) if (!mass[i][j]) ans++;
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 256
import java.math.*;

object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (N,T)=readLine()!!.split(" ").map(String::toInt)
    val time=readLine()!!.split(" ").map(String::toInt)

    assert(time.size==N&& time[0]==0)

    val ans=1.until(N).fold(BigDecimal(0)) {sum,index->
      val diff=time[index]-time[index-1]
      sum+ if(diff<T){ BigDecimal(diff)} else {BigDecimal(T)}
    }+BigDecimal(T)
    println(ans)
  }
}


Measured memory_bytes: 80964
#include<stdio.h>

int main(void)
{
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else if (a == b) {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
# E869120 は 1 円硬貨を A 枚と 500 円硬貨を無限枚持っています.
# これらの硬貨だけを使うことによって, ちょうど N 円を支払うことができるかを判定しなさい.

n = gets.to_i
a = gets.to_i

puts n % 500 <= a ? "Yes" : "No"

Measured memory_bytes: 1788
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
 
 
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
 

ans = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
while ans < 0:
    ans += mod
print(ans)


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

mon=0
amari=0
for i in range(n):
    if a[i]<=amari:
        mon=mon+a[i]
        amari=b[i]
        continue
    if a[i]>=b[i]+amari:
        mon=mon+b[i]+amari
        amari=0
    if a[i]<b[i]+amari:
        mon=mon+a[i]
        amari=b[i]+amari-a[i]

if a[n]>amari:
    mon=mon+amari
if a[n]<=amari:
    mon=mon+a[n]

print(mon)

Measured memory_bytes: 82020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

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

	sort(d.begin(), d.end(), [](int& i, int& j) {return i < j; });

	cout << d[n / 2] - d[n / 2 - 1] << endl;

}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
/*
    Prodigia comploratus,
    silens, oro:
    "Regnet exitium."
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using db = long double;
const int N = 1e5 + 5, MOD = 1e9 + 7;
/*
    for every i i need to maintain somethings
    the number of ranges such that l < i <= r
    the sum of distances between r and i
    the first one can be done easily using some kind of line sweep
*/
vector<pair<int,int>> ranges;
int n, m, a[N];
int num[N];
ll sum[N];
ll sumOut[N];
void calcNum(){
    vector<int> evs(m + 1);
    vector<vector<int>> add(m + 1), rem(m+1);
    int cur = 0;
    ll curSUM = 0;
    ll curOut = 0;
    for(auto x : ranges){
        if(x.first > x.second)
            curOut += x.first + m - x.second;
        else{
            curOut += x.second - x.first;
        }
    }
    for(auto x : ranges){
        if(x.first > x.second){
            cur++;
            curOut -= x.first + m - x.second;
            curSUM += x.second - 1;
        }
        evs[x.first]++;
        evs[x.second]--;
        add[x.first].push_back(x.second);
        rem[x.second].push_back(x.first);
    }
    for(int i = 1; i <= m; i++){
        num[i] = cur;
        sum[i] = curSUM;
        sumOut[i] = curOut;
        cur += evs[i];
        for(auto to : add[i]){
            if(to > i)curSUM += to-i, curOut -= (to - i);
            else curSUM += to + m - i, curOut -= (to + m - i);
        }
        for(auto to : rem[i]){
//            cout << i << ' ' << to << '\n';
            if(to < i)curOut += i - to;
            else curOut += i + m - to;
        }
//        cout << curOut << ' ' << rem[to] << '\n';
        curSUM -= cur;
    }
}
int main(){

    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i++){
        scanf("%d", a + i);
        if(i > 1)
            ranges.emplace_back(a[i-1], a[i]);
    }

    calcNum();
    ll out = LLONG_MAX;
    for(int i = 1; i <= m; i++){
//        cout << num[i] << ' ' << sumOut[i] << ' ' << sum[i] << '\n';
        out = min(out,  sumOut[i] + num[i] + sum[i]);
    }
    cout << out << '\n';
    return 0;
}


Measured memory_bytes: 13172
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int K, a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  std::cin >> K;

  std::cout << a[K - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input().strip())
p = list(map(int, input().split()))
ans = 0

for i in range(n - 2):
    if (p[i] < p[i + 1] < p[i + 2]) or (p[i + 2] < p[i + 1] < p[i]):
        ans += 1

print(ans)


Measured memory_bytes: 38512
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int H, int W, vector<vector<int>> a) {
  vector<int> h;
  vector<int> w;
  for (int i = 0; i < H; i++) {
    int rowsum = 0;
    for (int j = 0; j < W; j++) {
      rowsum += a[i][j];
    }
    if (rowsum != 0) {
      h.push_back(i);
    }
  }
  for (int j = 0; j < W; j++) {
    int colsum = 0;
    for (int i = 0; i < H; i++) {
      colsum += a[i][j];
    }
    if (colsum != 0) {
      w.push_back(j);
    }
  }
  for (auto i : h) {
    string row = "";
    for (auto j : w) {
      if (a[i][j] == 1) {
        row += '#';
      } else {
        row += '.';
      }
    }
    if (row != "") {
      cout << row << endl;
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H);
  for (int i = 0; i < H; i++) {
    a[i].resize(W);
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        a[i][j] = 1;
      } else {
        a[i][j] = 0;
      }
    }
  }
  solve(H, W, a);
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
#define ll long long
ll n;
map<ll,ll>q;
map<ll,ll>::iterator it;
ll mod=1e9+7;
ll  modl(ll a, ll b, ll c)
{
    ll res, t;
    res = 1 % c;
    t = a % c;
    while (b){
        if (b & 1){
            res = res * t % c;
        }
        t = t * t % c;
        b >>= 1;
    }
    return res;
}
int main()
{
    q.clear();
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        ll num;
        cin>>num;
        q[num]++;
    }
    if(q[0]>1)
    {
        cout<<"0"<<endl;
    }
    else if(q[0]==1||q[0]==0)
    {
        int num=0;
        for(it=q.begin();it!=q.end();it++)
        {
            if(it->second==2)
            {
                num++;
            }
            else if(it->second>2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        num%=mod;
        cout<<modl(2,num,mod)%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 4224
s=gets.chomp
t=gets.chomp
res=?~
i=0
while i+t.size<=s.size
    ok=true
    for j in 0...t.size
        ok=false if !s[i+j] || s[i+j]!=?? && s[i+j]!=t[j]
    end
    if ok
        w=s.dup
        for j in i...i+t.size
            w[j]=t[j-i]
        end
        w.tr!(??, ?a);
        res=w if res>w
    end
    i+=1
end

if res==?~
    puts "UNRESTORABLE"
else
    puts res
end


Measured memory_bytes: 1788
#include <cstring>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int n, m;
int field[100][100];
bool used[100];

int prim() {
	// コスト、ノード番号
	typedef pair<int, int> edge;
	int result = 0;
	fill(used, used + n, false);
	priority_queue<edge, vector<edge>, greater<edge> > que;
	que.push(make_pair(0, 0));
	while (!que.empty()) {
		edge current = que.top();
		que.pop();
		int cost = current.first;
		int pos = current.second;
		if (used[pos]) continue;
		used[pos] = true;
		result += cost;
		for (int i = 0; i < n; i++) {
			if (field[pos][i] > 0 && !used[i]) {
				que.push(make_pair(field[pos][i], i));
			}
		}
	}
	return result;
}

int main() {
	while (cin >> n >> m, n || m) {
		memset(field, 0, sizeof(field));
		for (int i = 0; i < m; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			field[a][b] = field[b][a] = c;
		}
		cout << prim() << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
string W[200];
map<string, int> m;

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> W[i];
        m[W[i]]++;
        if (i >= 1)
        {
            auto prev = W[i - 1];
            auto cur = W[i];
            if (prev[prev.size() - 1] != cur[0])
            {
                cout << "No";
                return 0;
            }
        }
    }
    for (auto e : m)
    {
        if (e.second > 1)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
    // 配列の添字は 0 から始まるので，a [0] は 0 にしている．
    int x , y ; cin >> x >> y ;
    cout << ( a[x] == a[y] ? " Yes " : " No ") << endl ;
}

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

int main(){
    int N;
    cin >> N;
    string S = to_string(N);
    for(int i=0; i<S.size(); i++){
        if(S[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string a[200000];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
    int count=1;
  for(int i=1;i<n;i++)
  {
    if(a[i]!=a[i-1])
      count++;
  }
  cout<<count<<"\n";
}


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

int main() {

	int N,T,A;
	cin >> N;
  	cin >> T >> A;
  	vector<int> H(N);
  	for(int i=0;i<N;i++)cin >> H[i];
  	
    int res;
  	double min = DBL_MAX;
  
  	for(int i=0; i<N; i++){
      double dif = abs(A-(T-H[i]*0.006));
      if(dif<min){
        min = dif;
        res = i+1;
      }
    }
  
    cout << res << endl;

}

Measured memory_bytes: 256
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
n,m=map(int,input().split())
edges=[list(map(int,input().split()))for i in range(m)]
a=0
for i in range(m):
    uf=UnionFind(n,1)
    for j in  range(m):
        if j==i:continue
        uf.unite(*edges[j])
    a+=uf.connected()
print(m-a)

Measured memory_bytes: 41068
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A[10];
    REP(i,3)cin >> A[i];
    sort(A,A+3,greater<int>());
    int ans = A[0]*10 + A[1] + A[2];
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String sysin = sc.next();
        char[] chList = sysin.toCharArray();

        char ch = chList[0];

        if (Character.isLowerCase(ch)){
            System.out.println("a");
        }else{
            System.out.println("A");
        }
    }
}


Measured memory_bytes: 35752
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const double swap_rate=0.8;
static const double change_rate=1-swap_rate;
static int ans[D+1];
static int max_score=0;
static int t=6e5;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        double p=(double)rand()/RAND_MAX;
        if(p<swap_rate) swap();
        else change();
    }
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3748
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n;
int main() {
	while (scanf("%d", &n), n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		vector<vector<int> > dp(n, vector<int>(n + 1));
		for (int i = 2; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				int r = j + i;
				for (int k = j + 1; k < r; k++) {
					dp[j][r] = max(dp[j][r], dp[j][k] + dp[k][r]);
				}
				if (abs(a[j] - a[r - 1]) <= 1 && dp[j + 1][r - 1] == i - 2) {
					dp[j][r] = max(dp[j][r], dp[j + 1][r - 1] + 2);
				}
			}
		}
		printf("%d\n", dp[0][n]);
	}
	return 0;
}

Measured memory_bytes: 3296
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool same(char c1,char c2){
	return (c1=='?'||c2=='?'||c1==c2);
}
string a,b,c;
int A,B,C;
const int M=20000;
bool ab[1000000],ac[1000000],bc[1000000];
int main(){
	fastio;
	cin>>a>>b>>c;
	A=a.length();
	B=b.length();
	C=c.length();
	rep(i,A) rep(j,B) if(!same(a[i],b[j])) ab[i-j+M]=1;
	rep(i,A) rep(j,C) if(!same(a[i],c[j])) ac[i-j+M]=1;
	rep(i,B) rep(j,C) if(!same(b[i],c[j])) bc[i-j+M]=1;
	int res=INF; 
	rb(i,-5000,5000){
		rb(j,-5000,5000){
			if(!ab[M+i]&&!ac[M+j]&&!bc[j-i+M]){
				int L = min(0, min(i, j));
 				int R = max(A, max(B + i, C + j));
 				res = min(res, R - L);
			} 
		}
		

	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

struct mint {
    static constexpr long MOD = 1000000007;
    long value;

    constexpr mint(long value = 0) noexcept : value((value % MOD + MOD) % MOD) {}
    constexpr mint operator-() const noexcept {
        return mint(-value);
    }
    constexpr mint& operator+=(const mint& rhs) noexcept {
        if ((value += rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator-=(const mint& rhs) noexcept {
        if ((value += MOD - rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator*=(const mint& rhs) noexcept {
        (value *= rhs.value) %= MOD;
        return *this;
    }
    constexpr mint operator+(const mint& rhs) const noexcept {
        mint res(*this);
        return res += rhs;
    }
    constexpr mint operator-(const mint& rhs) const noexcept {
        mint res(*this);
        return res -= rhs;
    }
    constexpr mint operator*(const mint& rhs) const noexcept {
        mint res(*this);
        return res *= rhs;
    }
    constexpr mint pow(long e) const noexcept {
        if (e == 0) return 1;
        mint a = pow(e >> 1);
        a *= a;
        if (e % 2 == 1) a *= *this;
        return a;
    }
    constexpr mint inv() const noexcept {
        return pow(MOD - 2);
    }
    constexpr mint& operator/=(const mint& rhs) noexcept {
        return *this *= rhs.inv();
    }
    constexpr mint operator/(const mint& rhs) const noexcept {
        mint res(*this);
        return res /= rhs;
    }
    friend constexpr mint pow(const mint& a, const long& b) noexcept {
        return a.pow(b);
    }
    friend ostream& operator<<(ostream& os, const mint& n) noexcept {
        os << n.value;
        return os;
    }
};


int main() {
    int n;
    cin >> n;
    vector<int> r(n, 0);
    bool correct = true;
    for (int i = 0; i < n; i++) if (i % 2 xor n % 2) r[i] = 2;
    if (r[0] == 2) r[0]--;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (!r[a]--) {
            correct = false;
            break;
        }
    }

    cout << (correct ? pow(mint(2), n / 2) : 0) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  long n, m;
  cin >> n >> m;

  long res = 1;
  vector<long> yakusu;

  for(int i = 1; i*i < m; i++) {
    if (m%i == 0) {
      yakusu.push_back(i);
      if(m/i != i) {
        yakusu.push_back(m/i);
      }
    }
  }

  for(auto y: yakusu) {
    if (y * n <= m) {
      res = max(res, y);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;

    vector<priority_queue<int>> kind(N);
    rep(i, 0, N)
    {
        int t, d;
        cin >> t >> d;
        kind[t - 1].push(d);
    }

    priority_queue<int> best, remain;

    rep(i, 0, N)
    {
        if (kind[i].empty()) continue;

        best.push(kind[i].top());
        kind[i].pop();

        while (!kind[i].empty())
        {
            remain.push(kind[i].top());
            kind[i].pop();
        }
    }

    vector<ll> bestSum = { 0 };
    while (!best.empty())
    {
        bestSum.push_back(bestSum.back() + best.top());
        best.pop();
    }

    vector<ll> remainSum = { 0 };
    while (!remain.empty())
    {
        remainSum.push_back(remainSum.back() + remain.top());
        remain.pop();
    }

    ll ans = 0;
    for (ll x = 1; x <= K; ++x)
    {
        if (x >= bestSum.size()) break;

        if (K - x >= remainSum.size()) continue;

        ans = max(ans, bestSum[x] + remainSum[K - x] + x * x);
    }

    cout << ans << endl;
}


Measured memory_bytes: 8056
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];

    SORT(d);
    int ans = 0;
    REP(i, N - 1) {
        if (d[i] < d[i + 1])
            ans++;
    }

    ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256