akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;
const string sp = " ";

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};

int h, w;
char a[1010][1010];
int dp[1010][1010];
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '#' || (i == 0 && j == 0)) continue;
			dp[i][j] = dp[max(i - 1, 0LL)][j] + dp[i][max(j - 1, 0LL)];
			dp[i][j] %= mod;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}

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

#define X first
#define Y second
#define MP make_pair

using namespace std;

typedef long long ll;

const int N = 1e5 + 12;
const ll mod = 1e9 + 7;

int n, a[N];

int main () {
	scanf("%d\n", &n);
	for(int i = 0;i < n;i++)
		scanf("%d", a + i);
	sort(a, a + n, [](int x, int y){return x > y;});
	int z = 0;
	while(z < n && a[z + 1] > z + 1)
		z++;
	int x = a[z] - z, y = 0;
	while(z + y < n && a[z + y] > z)
		y++;
	if(x % 2 == 1 && y % 2 == 1)
		cout << "Second";
	else
		cout << "First";
}


Measured memory_bytes: 4040
#2017 code festival a
s=input()
if len(s)>9 or ("AA" in s)or ("KIH" not in s):
    print("NO")
else:
    new_s=""
    for i in range(len(s)):
        if s[i]!="A":
            new_s+=s[i]
    if new_s=="KIHBR":
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
N, M = map(int, input().split())
nums = []
for n in range(1, int(M**0.5)+1):
  if M%n == 0:
    nums.append(n)
    nums.append(M//n)
nums.sort()
answer = 1
for num in nums:
  if M//num < N:
    break
  else:
    answer = num
print(answer)

Measured memory_bytes: 63524
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

def gcd(a,b)
	if(a>b)
		return gcd(b,a)
	end
	if(b%a == 0)
		return a
	else
		return gcd(a,b%a)
	end
end
def lcm(a,b)
	a/gcd(a,b)*b
end

MAX_INT = 9999999999999999

N,M=gets.chomp.split(' ').map{|n| n.to_i}
S=gets.chomp.split('').map{|n| n}
T=gets.chomp.split('').map{|n| n}
g = gcd(N,M)
nd = N/g
md = M/g
for i in 0..(g-1)
	if(S[i*nd] != T[i*md])
		puts -1
		exit(0)
	end
end
puts lcm(N,M)


Measured memory_bytes: 12156
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#define f cin
#define NMAX 100010
#define MOD 1000000007
using namespace std;

//ifstream f("date.in");

long long int n, m;
char a[1010][1010];
long long int dp[1010][1010];

int main() {

    f >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            f >> a[i][j];
        }
    }

    dp[0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i == 0 && j == 0) continue;
            if (a[i][j] == '#') {
                a[i][j] = 0;
            } else {
                if (i == 0) {
                    dp[i][j] = dp[i][j - 1] % MOD;
                } else if (j == 0) {
                    dp[i][j] = dp[i - 1][j] % MOD;
                } else {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                }
            }
        }
    }

    cout << dp[n - 1][m - 1];

    return 0;
}


Measured memory_bytes: 9216
#D
def main():
  N, K = map(int, input().split())
  p = list(map(int, input().split()))

  total = sum(p[:K])
  #print(0, total)

  max_total = total
  max_start_i = 0

  for i in range(1, N-K+1):
    total = total-p[i-1]+p[i-1+K]
    #print(i, total)
    if total > max_total:
      max_total = total
      max_start_i = i

  #print(max_start_i, max_total)

  print(sum([(1+p)/2. for p in p[max_start_i:max_start_i+K]]))

main()

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

dp = [10**5] *(n+1)

dp[0] = 0

for i in range(1,n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 6
for i in range(1,n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9
        
print(dp[n])

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  if(a >= b)cout << 10 << endl;
  else cout << 0 << endl;
}



Measured memory_bytes: 256
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC157D
int root(int *pare, int x) {
  if(pare[x-1]==x) return x;
  return root(pare, pare[x-1]);
}

void connect(int *pare, int *cou, int a, int b) {
  int tmp;
  if(pare[a-1]==a) tmp=a, a=b, b=tmp;
  int ra=root(pare, a), rb=root(pare, b);
  if(ra!=rb) cou[ra-1]+=cou[rb-1];
  pare[a-1]=ra, pare[rb-1]=ra;
}

int main(void) {
  int n, m, k, i;
  scanf("%d %d %d", &n, &m, &k);
  int a[m], b[m], c, d, pare[n], friend[n], block[n], cou[n];
  for(i=0; i<n; i++)
    pare[i]=i+1, friend[i]=0, block[i]=0, cou[i]=1;

  for(i=0; i<m; i++){
    scanf(" %d %d", &a[i], &b[i]);
    connect(pare, cou, a[i], b[i]);
    friend[a[i]-1]++, friend[b[i]-1]++;
  }
  for(i=0; i<k; i++){
    scanf(" %d %d", &c, &d);
    if(root(pare, c)==root(pare, d)) block[c-1]++, block[d-1]++;
  }

  for(i=1; i<=n; i++)
    printf("%d ", cou[root(pare, i)-1]-block[i-1]-friend[i-1]-1);
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

/*#define int ll*/
signed main(){
    
    int n;
    cin>>n;
    string ans="";
    if(n==0){
        cout<<'0'<<endl;
        return 0;
    }
    while(n!=0){
        if(n%2!=0){
            n-=1;
            ans="1"+ans;
        }else {ans="0"+ans;}
        n/=-2;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 200100, MOD = 1e9+7;

ll po(ll a, ll n) {
    if (!n)return 1;
    ll t = po(a,n/2);
    return t*t%MOD*(n%2?a:1)%MOD;
}

int h, w, n;
ll fac[MAXN+10], fnv[MAXN+10], D[3010];
pii arr[3010];
ll ans;
ll comb(ll n, ll r) {
    return (r<0||r>n)?0:fac[n]*fnv[r]%MOD*fnv[n-r]%MOD;
}

int main() {
    int i, j;

    fac[0] = 1;
    for (i=1;i<MAXN;i++) fac[i] = fac[i-1]*i%MOD;
    for (i=0;i<MAXN;i++) fnv[i] = po(fac[i],MOD-2);
    scanf("%d%d%d",&h,&w,&n);
    ans = comb(h+w-2,h-1);
    for (i=0;i<n;i++) scanf("%d%d",&arr[i].first,&arr[i].second);
    sort(arr,arr+n);
    for (i=0;i<n;i++) {
        D[i] = comb(arr[i].first+arr[i].second-2,arr[i].first-1);
        for (j=0;j<i;j++) {
            if (arr[j].first>arr[i].first||arr[j].second>arr[i].second) continue;
            D[i] -= D[j]*comb(arr[i].first+arr[i].second-arr[j].first-arr[j].second,
                              arr[i].first-arr[j].first)%MOD;
        }
        D[i]%=MOD;
        ans -= D[i]*comb(h+w-arr[i].first-arr[i].second,h-arr[i].first)%MOD;
    }
    printf("%lld\n",(ans%MOD+MOD)%MOD);

    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
#define SENTINEL 10000000000
#define MAX 5000000

int  N,c=0,L[MAX/2+2], R[MAX/2+2];
void Merge(int A[],int left,int mid,int right){
   int i,j,k,n1,n2;
   n1 = mid - left;
   n2 = right - mid;

   for(i=0;i<n1;i++)L[i] = A[left + i];
   for (i=0;i<n2;i++)R[i] = A[mid + i];

   L[n1] = SENTINEL;
   R[n2] = SENTINEL;
   i = 0;
   j = 0;
   for(k=left;k<right;k++){
     c++;
     if(L[i]<=R[j]){
       A[k]=L[i];
       i = i + 1;
     }
     else {
       A[k] = R[j];
       j = j + 1;
     }
   }
 }

void Mergesort(int A[],int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    Mergesort(A, left, mid);
  Mergesort(A, mid, right);
  Merge(A, left, mid, right);
  }
}

int main(){

  int i,A[MAX];

   scanf("%d",&N);
   for(i=0;i<N;i++){
    scanf("%d",&A[i]);

   }

   Mergesort(A,0,N);

   for(i=0;i<N;i++){
     if(i!=N-1)printf("%d ",A[i]);
     else printf("%d",A[i]);
   }
   printf("\n");
   printf("%d\n",c);
   return 0;
 }


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

int main()
{
	int a[5];
	for (int i = 1; i <= 3; ++i) cin >> a[i];
	sort(a + 1, a + 4);
	if (a[1] == a[2] && a[2] == a[3]) puts("No");
	else if (a[1] == a[2] || a[2] == a[3]) puts("Yes");
	else puts("No");
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int v = 0;
		for(int i=0;i<N;i++) v ^= A[i];
		Console.WriteLine(v == 0 ? "Yes" : "No");
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> count(n + 1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b)swap(a, b);

        if (a == 1) count[b]++;
        if (b == n)count[a]++;
    }

    bool ret = false;
    for (int i = 0; i <= n; i++) {
        if (count[i] == 2)ret = true;
    }
    cout << (ret ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  char a, b;
  cin >> a >> b;
  char ans = ' ';
  if (a < b) ans = '<';
  else if (a > b) ans = '>';
  else ans = '=';
  cout << ans << endl;

  return 0;
}



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

#define MAX_N (300000L)
#define MAX_FACT (MAX_N)
#define NUM_MOD (1000000007L)

long fs[MAX_FACT + 1], finvs[MAX_FACT + 1], invs[MAX_FACT + 1];

void combination_init() {
  fs[0] = fs[1] = 1;
  finvs[0] = finvs[1] = 1;
  invs[1] = 1;
  for (long i = 2; i <= MAX_FACT; i++) {
    fs[i] = fs[i - 1] * i % NUM_MOD;
    invs[i] = NUM_MOD - invs[NUM_MOD % i] * (NUM_MOD / i) % NUM_MOD;
    finvs[i] = finvs[i - 1] * invs[i] % NUM_MOD;
  }
}

long combination(long n, long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fs[n] * (finvs[k] * finvs[n - k] % NUM_MOD) % NUM_MOD;
}

long mod(long n, long k) { return n % k >= 0 ? n % k : n % k + k; }

long pow_mod(long x, long k, long mod) {
  long ret = 1, p = x;
  while (k > 0) {
    if (k & 1) {
      ret = (ret * p) % mod;
    }
    p = (p * p) % mod;
    k /= 2;
  }
  return ret;
}

int main(int argc, char *argv[]) {
  // read inputs
  long N, A, B, C;
  scanf("%ld %ld %ld %ld", &N, &A, &B, &C);

  // solve
  long ans = 0;
  combination_init();
  // part1
  long x1 = 0;
  for (long k = 0; k <= N - 1; k++) {
    x1 = mod(mod(mod(pow_mod(mod(A * invs[A + B], NUM_MOD), N, NUM_MOD) *
                         pow_mod(mod(B * invs[A + B], NUM_MOD), k, NUM_MOD),
                     NUM_MOD) *
                     combination(N + k, k),
                 NUM_MOD) +
                 x1,
             NUM_MOD);
  }
  x1 = mod(N * x1, NUM_MOD);
  // part2
  long x2 = 0;
  for (long k = 0; k <= N - 1; k++) {
    x2 = mod(mod(mod(pow_mod(mod(A * invs[A + B], NUM_MOD), k, NUM_MOD) *
                         pow_mod(mod(B * invs[A + B], NUM_MOD), N, NUM_MOD),
                     NUM_MOD) *
                     combination(N + k, k),
                 NUM_MOD) +
                 x2,
             NUM_MOD);
  }
  x2 = mod(N * x2, NUM_MOD);
  printf("%ld\n", mod(mod(mod(x1 + x2, NUM_MOD) * 100, NUM_MOD) * invs[A + B], NUM_MOD));

  return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m, k;
    cin >> n >> m >> k;
    int x1 = 0, y1 = 0, x2 = n, y2 = m;
    while(k--){
        int a, b, c;
        cin >> a >> b >> c;
        if(c == 1){
            x1 = max(x1, a);
        }
        else if(c == 2){
            x2 = min(x2, a);
        }
        else if(c == 3){
            y1 = max(y1, b);
        }
        else{
            y2 = min(y2, b);
        }
    }
    cout << max(0, (y2-y1))*max(0, (x2-x1));
    return 0;
}


Measured memory_bytes: 256
x ? (a,b) = if x then a else b

main = do
 [s,t] <- lines<$>getContents
 putStr $ solve [s,t]

solve [s,t]
 | null s = (length t == 1)?("Yes","No")
 | head s == head t = solve (map tail [s,t])
 | otherwise = "No"


Measured memory_bytes: 3776
n, k = map(int, input().split())
s = list(map(int, reversed(list(input()))))

p = 0
ans = []
while p < n:
    b = p
    p += k
    if p > n:
        ans.append(str(n-b))
        break
    while s[p] == 1:
        p -= 1
    if p == b:
        print(-1)
        exit()
    ans.append(str(p-b))

print(' '.join(reversed(ans)))

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

int main(void) {

	int A, B;
	cin >> A >> B;

	if (A > 12) cout << B << endl;
	else if (A > 5) cout << B / 2 << endl;
	else cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
using namespace std;

int main()
{
    ll t,i,j,n,q,x,y,k;

    string s,st;

    cin>>s>>st;
    k=0;

    for(i=0;i<s.size();i++){

        if(s[i]!=st[i])k++;
    }
    cout<<k<<endl;
}


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

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    int thresh = (sum + 4*m - 1)/(4*m);
    int ans = 0;
    rep(i, n) {
        if(a[i] >= thresh) ans++;
    }
    if(ans >= m) puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
    string S, ans = "Good";
    cin >> S;
    rep(i, 3) if(S[i] == S[i+1]) ans = "Bad";
    cout << ans << endl;
    return 0;
}

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

int main(){
    int i;
    i=0;
 while (1){
     int x;
     cin>>x;
     if (x==0){ break;
     } else {
         i++;
         cout << "Case " << i <<": "<< x << endl;
        }
    }
 return 0;
}



Measured memory_bytes: 3104
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

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

        int[] d=new int[N+10];

        int i=0;
        int j=0;
        int sum=0;

        for(i=0;i<N;i++){
            d[i]=sc.nextInt();
        }

        for(i=0;i<N-1;i++){
            for(j=1;i+j<N;j++){
                sum=sum+d[i]*d[i+j];
            }
        }

        System.out.println(sum);

        //END
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll lcm(ll i,ll j){
  if(i<j){
    swap(i, j);
  }
  ll r=i%j, a=i, b=j;
  while(r!=0){
    i=j;
    j=r;
    r=i%j;
  }
  return a/j*b;
}

int main(){
  int n;
  cin >> n;
  ll ans, t;
  cin >> t;
  ans=t;
  rep(i, n-1){
    cin >> t;
    ans=lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
ll spf[10000005];
void SPF()
{
	ll i,j;
	spf[0]=1;
	for(i=1;i<=10000004;i++)	spf[i]=i;
	for(i=2;i*i<=10000004;i++){
		if(spf[i]==i){
			for(j=i*i;j<=10000004;j+=i){
				spf[j]=min(i,spf[j]);
			}
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n;
	cin>>n;
	SPF();
	ll ans=1;
	for(ll a=2;a<=n;a++)
	{
		ll x,y,z;
		map<ll,ll> mp;
		x=0;
		z=a;
		while(z>1)
		{
			mp[spf[z]]++;
			z/=spf[z];
		}
		y=1;
		map<ll,ll>::iterator it;
		for(it=mp.begin();it!=mp.end();it++)
		{
			y=y*(it->se+1);
		}
		ans=ans+y*a;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 81780
from itertools import combinations as c
from math import gcd

n = int(input())+1

def f(n):
  res = 0
  for x, y, z in c(range(1, n), 3):
    res += gcd(x, gcd(y, z))
  res *= 6
  res += sum(range(1,n))
  for x, y in c(range(1, n), 2):
    res += 6*gcd(x, y)
  return res
print(f(n))

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

 
int main(){
  int N;
  string str;
  cin >> N;
  cin >> str;

    regex re("ABC");
    smatch m;
    int i = 0;

    while (std::regex_search(str, m, re)) {
        std::cerr << m.str() << "が見つかりました。\n";
        i++;
        str = m.suffix();
    }

    cout << i << endl;

}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut s: Vec<Vec<char>> = vec![vec![]; h];
    for i in 0..h {
        let t: String = sc.read();
        s[i] = t.chars().collect();
    }
    let dx = [0, 1, 1, 1, 0, -1, -1, -1];
    let dy = [-1, -1, 0, 1, 1, 1, 0, -1];
    let mut ans: Vec<Vec<i32>> = vec![vec![-1; w]; h];
    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '#' {
                continue;
            }
            ans[y][x] = 0;
            for i in 0..8 {
                let ny = (y as i32) + dy[i];
                let nx = (x as i32) + dx[i];
                if 0 <= ny && ny < (h as i32) && 0 <= nx && nx < (w as i32) && s[ny as usize][nx as usize] == '#' {
                    ans[y][x] += 1;
                }
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if ans[i][j] == -1 {
                print!("#");
            } else {
                print!("{}", ans[i][j]);
            }
        }
        println!("");
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	ll K=in<ll>();
	vector<ll> A(N);
	REP(i,N){
		A[i]=in<ll>();
	}
	vector<ll> FB(N,0),BB(N,0);
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A[i]>A[j]) FB[i]++;
			if(A[N-1-i]>A[N-1-j]) BB[i]++;
		}
	}
	ll num = 0;
	ll sum = K*(K+1)/2;
	ll sum2 = K*(K-1)/2;
	for(int i=0;i<N;i++){
		ll v1 = ((FB[i]%atcoder_mod)*(sum%atcoder_mod))%atcoder_mod;
		num += v1%atcoder_mod;
		num %= atcoder_mod;
		ll v2 = ((BB[i]%atcoder_mod)*(sum2%atcoder_mod))%atcoder_mod;
		num += v2%atcoder_mod;
		num %= atcoder_mod;
	}
	
	out(num);
	return 0;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    int sum = 0;
    rep(i,m) {
        int a;
        cin >>a;
        sum += a;
    }
    if( n >= sum) cout << (n - sum) << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#define LINF (1LL << 60)
using namespace std;
typedef long long Int;

string s, t;
Int n, m;
Int dp[3300][3300];

int main() {
  cin >> s >> t;
  n = s.length();
  m = t.length();

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      if (0 <= j - 1) {
        dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        if (s[i - 1] == t[j - 1]) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
      }
    }
  }

  string ans = "";
  Int cnt = dp[n][m];
  while (0 < cnt) {
    while (dp[n][m] == cnt) {
      m--;
    }
    m++;

    while (dp[n][m] == cnt) {
      n--;
    }
    n++;
    ans += s[n - 1];
    cnt--;
    n--;
    m--;
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

int main(int argc, char *argv[])
{
    int x, y, s, max, i, j, sum, tmp;
    while (cin >> x >> y >> s, x) {
        max = 0;
        for (i = 1; i < s; ++i) {
            j = (s - i * (100 + x) / 100) * 100 / (100 + x);
            tmp = i * (100 + x) / 100 + j * (100 + x) / 100;
            if (tmp != s) {
                j++;
                tmp = i * (100 + x) / 100 + j * (100 + x) / 100;
            }
            if (tmp != s || j <= 0)
                continue;
            sum = i * (100 + y) / 100 + j * (100 + y) / 100;
            max = (max < sum) ? sum : max;
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],b[100005];
int main(){
    ll n,ans=0;
    cin>>n;
    for(int i=1;i<=n+1;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        if(b[i]>=a[i]+a[i+1]){
            ans+=a[i]+a[i+1];
            a[i+1]=0;
        }
        else if(b[i]>a[i]){
            ans+=b[i];
            a[i+1]-=b[i]-a[i];
        }
        else ans+=b[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
List=[]
for i in range(m):
    road=list(map(int,input().split()))
    List.append(road)
    road=[road[1],road[0]]
    List.append(road)
ans=0
for i in range(1,n+1):
    for j in range(len(List)):
        if i==List[j][0]:
            ans+=1
    print(ans)
    ans=0


Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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 double PI=3.14159265358979323846;

int mod = 1e9+7;
int INF = 1e9+7;
// const long long INF = 1LL<<60;


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

  __int128_t ans = 1;
  bool zero = false;
  bool over = false;
  rep(i, N){
    ll A;
    cin >> A;

    if(A == 0){
      zero = true;
    }

    if(over) continue;

    ans *= (__int128_t)A;
    if(ans > (__int128_t)1e18){
      over = true;
    }
  }

  if(zero){
    cout << 0 << endl;
    return 0;
  }

  if(over){
    cout << -1 << endl;
    return 0;
  }

  cout << (ll)ans << endl;

  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int x1 = scanner.nextInt();
		int x2 = scanner.nextInt();
		int x3 = scanner.nextInt();
		int x4 = scanner.nextInt();
		int x5 = scanner.nextInt();
		int answer = 0;

		int [] array = new int[]{x1, x2, x3, x4, x5};
		for (int i =0; i < 5; i++) {
			boolean bool = array[i] == 0;
			if (bool == true) {
				if(i == 4) {
					answer = array[i - 1] + 1;
					break;
				} else {
					answer = array[i + 1] - 1;
					break;
				}
			}
		}

		System.out.println(answer);

	}

}

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


int main(){
    int A,B,T;
    cin >> A >> B >> T;
    
    int ans=0;
    while(true){
        T=T-A;
        if(T>=0){
            ans+=B;
        }else{
            break;
        }
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    char s[20];
    fgets(s, 13, stdin);

    for (int i = 0; i < 4; ++i)
        putchar(s[i]);
    printf(" ");
    for (int i = 4; i < 12; ++i)
        putchar(s[i]);
    printf("\n");

    return 0;
}


Measured memory_bytes: 760
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,l[N],r[N],ll,rr;
int main(){
	ll=1;
	cin>>n>>m;
	rr=n;
	for(int i=1;i<=m;i++)
		cin>>l[i]>>r[i],ll=max(ll,l[i]),rr=min(rr,r[i]);
	if(rr-ll+1>=0)
		cout<<rr-ll+1;
	else
		cout<<0;
	return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(I,n) for (int I = 0; I < (n); ++I)
using namespace std;
typedef long long ll;
 
int main() {
    
    int x;
    int y;
    
    cin >> x >>y;
    
    cout << x+y/2 <<endl;
    
  
  return 0;
}


Measured memory_bytes: 256
s = str(input())
k = int(input())

cnt = 0
for i in range(len(s)):
    if s[i] == '1':
        cnt += 1
    else:
        c = s[i]
        break

if cnt:
    if cnt >= k:
        print('1')
    else:
        print(c)
else:
    print(c)


Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200005
int a[maxn];
signed main()
{
    //ios_base::sync_with_stdio(false);
    int k,n;
    cin>>k>>n;
    for (int i = 1; i <=n ; ++i) {
        cin>>a[i];
    }
    int tmp=k-a[n]+a[1];
    for (int j = 2; j <=n ; ++j) {
        tmp=max(tmp,a[j]-a[j-1]);
    }
    cout<<k-tmp;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
inline int tosc(int h, int m,int s){
  return h*3600 + m * 60 + s;
}

int main(){
  int n;
  while(cin>>n,n){
    P v[10001];
    REP(i,n){
      int h,m,s;
      scanf("%d:%d:%d",&h,&m,&s);
      int m1 = tosc(h,m,s);
      scanf("%d:%d:%d",&h,&m,&s);
      int m2 = tosc(h,m,s);
      v[i] = P(m1,m2);
    }
    sort(v , v + n);
    int ans = 0;
    priority_queue<int, vector<int>, greater<int> > que;
    REP(i,n){
      if(que.empty() || que.top() > v[i].first){
        ans++;
      }else{
        que.pop();
      }
      que.push(v[i].second);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC148B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split(' ');
            var A = AB[0];
            var B = AB[1];
            var S = new List<char>();

            for (var i = 0; i < N; i++)
            {
                S.Add(A[i]);
                S.Add(B[i]);
            }

            for (var i = 0; i < 2 * N; i++)
            {
                Console.Write(S[i]);
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}


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

int main() {
    uint64_t N;
    std::cin >> N;

    uint64_t min = UINT64_MAX;
    for (uint64_t i = 1; i <= std::sqrt(N); ++i) {
        if (N % i != 0) {
            continue;
        }

        const uint64_t b = N / i; 
        const uint64_t f = std::max(std::to_string(i).size(), std::to_string(b).size());
        min = std::min(min, f);
    }

    std::cout << min << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
using namespace std;


int n;
ll A[1 << 20];


int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	scanf("%d", &n);
	loop(i, n){
		scanf("%lld", A + i);
		if(A[i] == 0){
			puts("0");
			return 0;
		}
	}
	__int128 ans = 1;
	ll mx = 1000000000000000000LL;
	loop(i, n) {
		ans *= A[i];
		if(ans > mx) {
			puts("-1");
			return 0;
		}
	}
	cout << (ll)ans << endl;
	return 0;
}


Measured memory_bytes: 4444
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll int
#define ii pair<int,int>

ll number_of_divisors(ll n)
{
    ll ans = 1;

	for (ll i=2; i*i <= n; i++){
		if (n%i != 0) continue;
		ll cnt = 0;
		while (n%i == 0){
			n /= i;
			cnt++;
		}
		ans *= (cnt+1);
	}
	if (n > 1){
		ans *= 2;
	}
	return ans;
}
ll aa[1000004]; ll bb[200004];
int main()
{
    io;
    ll a,b,c,d,m,n,i,j,k,l,t,x,y,z;
    ll ans=0;
    ll maxi=INT_MIN; ll mini=INT_MAX,sum=0,mul=1;
        sum=0,mul=1;
        scanf("%d",&n);
        x=n;
        for(i=0;i<=1000000;i++) aa[i]=0;
        while(n--)
        {
            if(aa[n]==0)
            {
            a=number_of_divisors(n);
            aa[n]=a;
            }
            sum+=aa[n];
            if(n==1) break;
        }
        cout<<sum<<endl;

    return 0;
}


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

void base_2(long n) {
  if (n) {
    if (n < 0) {
      base_2((n-1)/-2);
    }
    else {
      base_2(n/-2);
    }
    cout << abs(n)%2;
  }
}
      

int main() {
  long n;
  cin >> n;

  if (!n)
    cout << 0;
  else
    base_2(n);
  cout << endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  map<ll, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    mp[a.at(i)]++;
  }
  
  sort(a.begin(), a.end());
  
  vector<ll> x;
  for (ll i = 0; i < 40; i++) x.emplace_back(pow<ll>(2, i));
  
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (mp[a.at(i)] == 0) continue;
    ll keep = *upper_bound(x.begin(), x.end(), a.at(i)) - a.at(i);
    if (a.at(i) == keep && mp[keep] > 1) {
      ans++;
      mp[keep] -= 2;
    }
    else if (a.at(i) != keep && mp[keep] > 0) {
      ans++;
      mp[keep]--;
      mp[a.at(i)]--;
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 26880
#include<cstdio>
using namespace std;
int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=m;j++)
        {
            for(int k=0;k<=m,i+j+k<=m;k++)
            {
                if(i+j+k==m && i*1000+j*5000+k*10000==n)
                {
                    printf("%d %d %d\n",k,j,i);
                    return 0;   
                }
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int p=0,q=0,r=0;
  rep(i,0,n){
    int a;
    cin>>a;
    if(a%2!=0){
      p++;
    }
    else if(a%4==0){
      r++;
    }
    else{
      q++;
    }
  }
  if(p<=r) cout<<"Yes"<<endl;
  else if(p==r+1 && q==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N=input().split()
A=list(map(int,input().split()))

B=[]
for a in A:
  if a%2==0:
    B.append(a)
    
cnt=0
for b in B:
  if (b%3==0 or b%5==0):
    continue
  else:
    cnt=1
    
if cnt==0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
import re

def getInput():
    """

    :return: list of list of str. 1st dim: row, 2nd dim: column.
    """
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()

A, B = map(int, g[0])
S = g[1][0]
p = '[0-9]{{{0}}}-[0-9]{{{1}}}'.format(A, B)
if re.match(p, S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <iostream>
#include<queue>
#include<string.h>
using namespace std;
int main(){
    queue <int> q;
    int h,w,n,cnt;
    long ans=0;
    char map[1000][1000];
    int d[1000][1000];
    int x,fx,mx[]={0,1,0,-1};
    int y,fy,my[]={1,0,-1,0};
    cin>>h>>w>>n;
    for(int i=0;i<h;i++){
        for(int o=0;o<w;o++){
            cin>>map[i][o];
            if(map[i][o]=='S'){
                q.push(i);
                q.push(o);
                x=o;
                y=i;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cnt=1;
        memset(d,-1,sizeof(d));
        d[y][x]=0;
        while(!q.empty()){
            y=q.front();
            q.pop();
            x=q.front();
            q.pop();
            if(map[y][x]==i+48){
                ans=ans+d[y][x];
                while(!q.empty()){
                    q.pop();
                }
                q.push(y);
                q.push(x);
                break;
            }
            for(int o=0;o<4;o++){
                fy=y+my[o];
                fx=x+mx[o];
                if(fy>=0&&fy<h&&fx>=0&&fx<w&&map[fy][fx]!='X'&&d[fy][fx]==-1){
                    d[fy][fx]=d[y][x]+1;
                    q.push(fy);
                    q.push(fx);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
int ar[3];
bool cmp(int v1, int v2){
	return v1>v2;
}
int main() {
	// your code goes here
	
	scanf("%d %d %d",&ar[0],&ar[1],&ar[2]);
	sort(ar,ar+3,cmp);
	printf("%d\n", (ar[0]*10+ar[1])+ar[2]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  vec c(a);
  For(i,0,a)
    ci(c[i]);
  ll an=b;
  For(i,1,a)
    an+=min(c[i]-c[i-1],b);
  co(an);
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

void IO(){
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		scanf("%d",&x);
		b[x]++;
	}
	for(int i=n; ;i++){
		int x = i;
		bool ok=false;
		while(x){
			ok|=b[x%10];
			x/=10;
		}
		if (!ok)
			return !printf("%d\n",i);
	}
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    fast;
    long long   i,j,n,c=0,d=0,e=0,f=0,g=0,h=0,k,r;
    cin>>n>>r;
    while(n>0)
    {
        c++;
        n/=r;
    }
    cout<<c;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m,c;
    cin >> n >> m >> c;
    VI b(m);
    REP(i,0,m) cin >> b[i];
    VVI a(n, VI(m));
    REP(i,0,n) REP(j,0,m) cin >> a[i][j];
    int ans = 0;
    REP(i,0,n) {
        int sum = c;
        REP(j,0,m) sum += a[i][j] * b[j];
        if (sum > 0) ++ans;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
#増えるとしたら1,2,3..のように増加分は1ずつ
#減るとしたらnumになるとして、一つ前をnum-1にする!
if l[0]!=0:
  print(-1)
  exit()
ans=0
now=0
for i in range(1,n):
  if l[i]==1+now:
    now+=1
    ans+=1
  elif l[i]>now:
    print(-1)
    exit()
  else:
    now=l[i]
    ans+=l[i]
print(ans)

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> x(n);
    for (auto i = 0; i < n; i++)
    {
        long long xi;
        cin >> xi;
        x[i] = xi;
    }

    sort(x.begin(), x.end());

    long long ans2 = 1000000000000000;

    for (size_t i = 0; i < n; i++)
    {
        long long ans = 0;
        if(i+k-1 > n-1){
            break;
        }
        if(x[i]*x[i+k-1] < 0){
            if(abs(x[i]) > abs(x[i+k-1])){
                ans = 2 * abs(x[i + k - 1]) + abs(x[i]);
            }else{
                ans = 2 * abs(x[i]) + abs(x[i+k-1]);
            }
        }else{
            if(x[i] < 0){
                ans = abs(x[i]);
            }else{
                ans = abs(x[i + k - 1]);
            }
        }

        if(ans < ans2){
            ans2 = ans;
        }

    }
    cout << ans2 << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n_even = Integer.parseInt(sc.next()); // 偶数が書かれている
        int m_odd = Integer.parseInt(sc.next()); // 奇数が書かれている
        // 偶数同士または奇数同士の和が偶数になる
        int n_even_count = (n_even * (n_even - 1)) / 2;
        int m_odd_count = (m_odd * (m_odd - 1)) / 2;
        int answer = n_even_count + m_odd_count;
        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 35696
/*
    给n个s,m个c,两个c组成一个s,最多组成几个scc.
    先利用s组成scc,再利用剩下的c组成
    注意数据范围
*/
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
    ll n, m, ans = 0;
    scanf("%lld%lld", &n, &m);
    if(n<<1<=m){
        ans += n;
        m -= n<<1;
        ans += m >>2;
    }else{
        ans += m>>1;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 128