akhauriyash/Code-Regression huggingface dataset:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  k=2
  while True:
    kk=k*(k-1)
    if kk>n*2:
      print('No')
      exit()
    if kk==n*2:
      break
    k+=1

  print('Yes')
  print(k)
  ans=[[] for _ in range(k)]
  ln=2*n//k

  st=0
  for i in range(k):
    tmp=[]
    i_ln=ln-len(ans[i])
    for j in range(i_ln):
      st+=1
      tmp.append(st)
    ans[i]+=tmp
    
    for j in range(i+1,k):
      ans[j].append(tmp.pop())

  # print(ans)
  for x in ans:
    print(ln,' '.join(str(y) for y in x))

main()
# print(main())


Measured memory_bytes: 15548
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll n,m,k;
  cin>>n>>m>>k;

  vector<ll> p(n);
  vector<ll> q(m);
  rep(i,n){
    cin>>p[i];
  }
  rep(i,m){
    cin>>q[i];
  }

  repo(i,n){
    p[i]+=p[i-1];
  }

  repo(i,m){
    q[i]+=q[i-1];
  }

  ll sum;
  ll cnt;
  ll ans=0;
  rep(i,n){
    sum=p[i];
    cnt=i+1;
    if(sum>k) continue;
    cnt+=ub(q,k-sum);
    chmax(ans,cnt);
  }

  ll x=ub(q,k);
  chmax(ans,x);

  cout << ans << endl;
}

Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(void) {
	int num[5];
	while(1) {
		cin >> num[0];
		if(cin.eof())		break;
		
		for(int i = 1; i < 5; i++) {
			cin >> num[i];
		}
		sort(num, num + 5);
		for(int i = 4; i > 0; i--) {
			cout << num[i] << ' ';
		}
		cout << num[0] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int mod=1e9+7;
const int N=2010;
const int maxn=2000;
int dp[N][N],c[N][N],sc[N][N];
int ans;

/*void calc(int i,int j){
	if(!j)	return 1;
	//k=max(0,i-j)-i c[j][i-k]
	//c[j][0]-c[j][min(i,j)]
	return sc[j][min(i,j)];
}*/
			

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j;int n,m;
	rep(i,0,maxn)	for(c[i][0]=1,j=1;j<=i;j++)	c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	rep(i,0,maxn)	for(sc[i][0]=1,j=1;j<=maxn;j++)	sc[i][j]=(sc[i][j-1]+c[i][j])%mod;
	scanf("%d%d",&n,&m);
	rep(j,0,m)	dp[0][j]=1;
	rep(i,0,n)	dp[i][0]=1;
	rep(i,1,n)	rep(j,1,m){
		dp[i][j]=(dp[i-1][j]+sc[j-1][min(j-1,i)])%mod;
		//ans=(ans+1ll*dp[i][j]*c[m-1][j])%mod;
	}
	/*rep(i,0,n){
		rep(j,0,m){
			ans=(ans+1ll*dp[i][j]*c[m-1][j])%mod;*/
	ans=1;//all white 
	rep(i,1,n){
		rep(j,0,i){
			if(i-j>m-1)	continue;
			ans=(ans+1ll*dp[j][i-j]*c[m-1][m-1-(i-j)])%mod;
		}
	}
	printf("%d\n",ans);
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 47488
<?php
list($n) = ints();
$a = ints();
$c = 0;
for ($i = 0; $i < $n; ++$i) $c += $a[$i] % 2;
echo $c % 2 ? 'NO' : 'YES';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
    int n;
    cin >> n;
    int l[2 * n], result = 0;
    for (int i = 0; i < 2 * n; i++) {
        cin >> l[i];
    }
    sort(l, l + 2 * n);
    for (int i = 0; i < 2 * n; i += 2) {
        result += l[i];
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
int main()
{
    char ar[5][5];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf(" %c",&ar[i][j]);
        }
    }
    printf("%c%c%c\n",ar[0][0],ar[1][1],ar[2][2]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[200000], b[200000];
ll sumA[200010]= {0},sumB[200010]= {0};

ll mx(ll x, ll y)
{
    if(x>y)
        return x;
    else
        return y;
}
int main()
{
    int  n,m;
    ll k,ans;
    cin >> n >> m >> k;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        sumA[i+1] = sumA[i]+(ll)a[i];
    }
    for(int i=0; i<m; ++i)
    {
        cin >> b[i];
        sumB[i+1] = sumB[i]+(ll)b[i];
    }
    ans=0;
    int j=m;
    for(int i=0; i<=n; ++i)
    {
        if(sumA[i]>k)
            break;
        while(sumA[i]+sumB[j]>k)
            --j;
        ans=mx(i+j, ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9876
#include<stdio.h>

int main (void) {
  int A[100010];
  int N;
  int i,j;
  int x;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&x);
    A[i] = x;
  }

  int pos = 0;
  int sum = 0;
  int num[100010] = {0};
  int flag = 0;
  for(i=1;i<=N;i++){

    pos++;
    if(flag){
      num[pos] = num[pos-1];
      flag = 0;
    } else {
      num[pos] = num[pos-1] + 1;
    }

    sum ++;
    if(A[i]-sum<sum-1){
      flag = 1;
      sum--;
    } 
    
  }
      
  long long int ans = 1;
  for(i=1;i<=N;i++){
    ans *= num[i];
    ans %= 1000000007;
  }

  printf("%lld\n",ans);
  
  return 0;
}

Measured memory_bytes: 896
from collections import deque
s = deque(input())
q = int(input())

cnt = 0
for _ in range(q):
    i = input().split()
    t = int(i[0])

    if t == 1:
        cnt += 1
    else:
        f = int(i[1])
        c = i[2]
        if (cnt % 2 == 0 and f == 1) or (cnt % 2 == 1 and f == 2):
            s.appendleft(i[2])
        else:
            s.append(i[2])

if cnt % 2 == 1:
    s.reverse()
print(''.join(s))

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

using namespace std;

static const int MAX = 1000;
int N;
int A[MAX];  //素数表を作るための配列
vector<int> v;  //素数表
int B[MAX];  //各素因数の数を数えるための配列
static const int mod = 1000000007;

int main(){
	cin >> N;

	for(int i = 0; i < MAX; i++){
		A[i] = 0;
		B[i] = 0;
	}

	for(int i = 2; i * i <= MAX; i++){
		for(int j = 2; i * j <= MAX; j++){
			A[i * j - 1]++;
		}
	}
	
	for(int i = 1; i < MAX; i++){
		if(A[i] == 0){
			v.push_back(i + 1);
		}
	}

	for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
		for(int i = 2; i <= N; i++){
			int a = i;
			while(a % *it == 0){
				B[*it]++;
				a /= *it;
			}
		}
	}

	long ans = 1;
	for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
		ans = (ans * (B[*it] + 1)) % mod;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,m;
int n;
int a[10050];
int mp[150][150];
int main() {
	scanf("%d%d",&h,&m);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	int now=1,tmp=a[1];
	for(int i=1;i<=h;i++) {
		if(i&1) {
			for(int j=1;j<=m;j++) {
				mp[i][j]=now;
				tmp--;
				if(tmp==0) {
					now++;
					tmp=a[now];
				}
			}
		}
		else {
			for(int j=m;j>=1;j--) {
				mp[i][j]=now;
				tmp--;
				if(tmp==0) {
					now++;
					tmp=a[now];
				}
			}
		}
	}
	for(int i=1;i<=h;i++) {
		for (int j=1;j<=m;j++) {
			printf("%d ",mp[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return

def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


Measured memory_bytes: 83548
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = vv(201, 0, 0, ll);
bool flag = true;
std::vector<int> d(201, -1);
void bfs(int now){
  deque<pair<int, int>> q;
  q.push_back(make_pair(now, 1));
  d[now] = 1;
  while(!q.empty()){
    int n = q.front().first, dim =q.front().second;
    q.pop_front();
    for(int i=0;i<G[n].size();i++){
      if(d[G[n][i]]!=-1&&d[G[n][i]]!=dim+1&&d[G[n][i]]!=dim-1){
        flag = false;
        return;
      }
    }
    for(int i=0;i<G[n].size();i++){
      if(d[G[n][i]]==-1) {
        d[G[n][i]] = dim+1;
        q.push_back(make_pair(G[n][i], dim+1));
      }
    }
  }
}
int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  string S;
  for(int i=1;i<=N;i++){
    std::cin >> S;
    for(int j=1;j<=N;j++) if(S[j-1]=='1') G[i].push_back(j);
  }
  int ans = -1;
  for(int i=1;i<=N;i++){
    flag = true;
    for(int j=1;j<=N;j++) d[j] = -1;
    d[i] = 1;
    bfs(i);
    if(flag) for(int j=1;j<=N;j++) ans = max(ans, d[j]);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cassert>
#include <cstdio>
#include <cctype>

namespace {

bool can_assign_zero(const std::string& str)
{
  return (str.size() <= 1) || (str[0] != 'X');
}

int assign_digit(const std::string& str, int x)
{
  int value = 0;

  for (size_t i = 0; i < str.size(); ++i) {
    if (str[i] == 'X')
      value = (value * 10) + x;
    else 
      value = (value * 10) + (str[i] - '0');
  }

  return value;
}

} // unnamed namespace

int main()
{
  std::string str;
  while (std::cin >> str) {
    const size_t add_pos = str.find('+');
    const size_t eq_pos = str.find('=');

    assert(add_pos != std::string::npos);
    assert(eq_pos != std::string::npos);

    const std::string v1 = str.substr(0, add_pos);
    const std::string v2 = str.substr(add_pos + 1, eq_pos - add_pos - 1);
    const std::string sum = str.substr(eq_pos + 1, str.size() - eq_pos);
    
    const int init_number =
      (can_assign_zero(v1) && can_assign_zero(v2) && can_assign_zero(sum)) ? 0 : 1;

    int n;
    for (n = init_number; n < 10; ++n) {
      if (assign_digit(v1, n) + assign_digit(v2, n) == assign_digit(sum, n)) {
        std::cout << n << std::endl;
        break;
      }
    }

    if (n == 10) {
      std::cout << "NA" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a_(n);
    rep(i, n) {
        int a;
        cin >> a;
        a_[a-1] = i;
    }
    set<int> se;
    se.insert(-1);
    se.insert(n);

    ll ans = 0;
    rep(i, n) {
        auto itr = se.lower_bound(a_[i]);
        int l = *prev(itr);
        int r = *itr;
        ans += ll(r-a_[i])*(a_[i]-l)*(i+1);
        se.insert(a_[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 13504
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fscanf(szpFpI, "%d", &si1Array[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 合計値・最小値・負の数・０の数 - 取得
	long long llSum = 0;
	int liMin = INT_MAX;
	int liMCnt = 0;
	int liZCnt = 0;
	for (i = 0; i < siACnt; i++) {
		int liVal = abs(si1Array[i]);
		llSum += liVal;
		if (liMin > liVal) {
			liMin = liVal;
		}
		if (si1Array[i] < 0) {
			liMCnt++;
		}
		else if (si1Array[i] == 0) {
			liZCnt++;
		}
	}

	// 合計値 - 補正
	if (liMCnt % 2 == 1) {
		if (liZCnt == 0) {
			llSum -= liMin * 2;
		}
	}

	return llSum;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Array, 0, sizeof(si1Array));						// 配列

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0
for i in range(len(A)):
    point += B[A[i] - 1]
    if not i == 0 and A[i] == A[i - 1] + 1:
        point += C[A[i - 1] - 1]
print(point)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll K,N;
int main(){
    cin>>K;
    cout<<50<<endl;
    if(K<50){
        for(ll i=0;i<K;i++){
            cout<<50<<" ";
        }
        for(ll i=K;i<50;i++){
            cout<<0<<" ";
        }cout<<endl;
    }else{
        K-=50;
        ll nolm=K/50+50;
        K%=50;
        for(ll i=0;i<K;i++){
            cout<< nolm+(50-(K-1)) <<" ";
        }
        for(ll i=K;i<50;i++){
            cout<< nolm-K <<" ";
        }cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char s[100],t[100];
	scanf("%s %s",s,t);
	int i,j,cnt=0;
	for(i=0;i<strlen(s);i++){
		char c=s[0];
		for(j=0;j<strlen(s)-1;j++){s[j]=s[j+1];}
		s[j]=c;
		if(strcmp(s,t)==0){cnt=1;}
	}
	printf(cnt?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int a,b; cin >> a >> b;
  if(a*b == 15)
    cout << "*" << endl;
  else if(a+b == 15)
    cout << "+" << endl;
  else
    cout << "x" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using ll = long long;

auto R(int s, int n) {
    return boost::irange(s, n);
}
auto R(int n) {
    return boost::irange(0, n);
}
void show(const auto& v){
    for(auto i:v) cout << i << " ";
    cout << endl;
}

int main() {
    int n;
    string s1, s2;
    cin>>n;
    cin>>s1;
    cin>>s2;
    vector<int> v{};
    for(int i=0;i<n;){
        if(s1.at(i)==s2.at(i)){
            v.push_back(1);
            i+=1;
        }else{
            v.push_back(0);
            i+=2;
        }
    }
    ll ans;
    if(v.at(0)==0){
        ans=6;
    }else{
        ans=3;
    }
    ll mod=1000000007;
    for(int i:R(0,v.size()-1)){
        if(v.at(i)==0&&v.at(i+1)==1){
            ;
        }else if(v.at(i)==0&&v.at(i+1)==0){
            ans=(ans*3)%mod;
        }else{
            ans=(ans*2)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  string s;cin>>s;
  int len=s.size();
  int mn=753;
  REP(i,len-2){
    string sub=s.substr(i,3);
    int val=stol(sub);
    int diff=(val>753?val-753:753-val);
    mn=min(mn,diff);
  }
  cout << mn << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
b = len(c.keys())

def check():
    if 0 in c.keys():
        if b==1 or (b==2 and c[0]==N//3):
            return True
    elif b==3:
        s, t, u = c.keys()
        if c[s]//3==c[t]//3==c[u]//3 and s^t^u==0:
            return True
    return False

print("Yes" if check() else "No")

Measured memory_bytes: 14468
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c = MAP()
k = INT()
flag = False
while a >= b and k > 0:
    b *= 2
    k -= 1
# print(a, b, k)
while b >= c and k > 0:
    c *= 2
    k -= 1
# print(a, b, c)
if a < b < c:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 10616
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for i in range(m)]

import collections

s_count_dict = collections.Counter(s_list)
t_count_dict = collections.Counter(t_list)

max_count = 0
for s_word, s_count in s_count_dict.items():
    # 要素として存在しない値を指定すると0を返す。（エラーにはならない）
    diff_count = s_count - t_count_dict[s_word] 
    if diff_count > max_count:
        max_count = diff_count

print(max_count)

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    var (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }
    val ran = b - a + 1
    if (c == 1L || d == 1L) {
        println(0)
        return
    }
    val cc = b / c - (a - 1) / c
    val dd = b / d - (a - 1) / d
    val cd = c * d / gcd(c, d)
    val ccdd = b / cd - (a - 1) / cd
    println(ran - cc - dd + ccdd)
}

fun gcd(x: Long, y: Long): Long {
    if (x < y) return gcd(y, x)
    if (y == 0L) return x
    return gcd(y, x % y)
}

Measured memory_bytes: 37964
#include <bits/stdc++.h>
#define inf 100000
using namespace std;

typedef pair<int, int> P;
int h, w, n, sgy[10], sgx[10], dy[4]={0,1,0,-1}, dx[4]={1,0,-1,0}, d[1000][1000];
char s[1000][1000];

void bfs(void)
{
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		queue<P> que;
		for (int j = 0; j < h; ++j) for (int k = 0; k < w; ++k) d[j][k] = inf;
		que.push(P(sgy[i],sgx[i]));
		d[sgy[i]][sgx[i]]=0;
		while(que.size())
		{
			P p=que.front();
			if(p.first==sgy[i+1]&&p.second==sgx[i+1]) break;
			que.pop();
			for (int j = 0; j < 4; ++j)
			{
				int ny = p.first+dy[j], nx = p.second+dx[j];
				if(ny>=0&&ny<h&&nx>=0&&nx<w&&s[ny][nx]!='X'&&d[ny][nx]==inf)
				{
					que.push(P(ny, nx));
					d[ny][nx]=d[p.first][p.second]+1;
				}
			}
		}
		ans += d[sgy[i+1]][sgx[i+1]];
	}
	cout << ans << endl;
}

int main(int argc, char const *argv[])
{
	cin >> h >> w >> n;
	for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j){
		cin >> s[i][j];
		if(s[i][j]=='S') sgy[0]=i, sgx[0]=j;
		for (int k = 0; k < n; ++k)
		{
			if(s[i][j]=='1'+k) sgy[k+1]=i, sgx[k+1]=j;
		}
	}
	bfs();
	return 0;
}


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

#define    ll     long long int

map<int, int> mp;
string str = "MARCH";

int main( )
{
    int i, j, k, n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        mp[s[0] - 'A']++;
    }
    ll s = 0;
    for (i = 0; i < 5; i++) {
        for (j = i + 1; j < 5; j++) {
            for (k = j + 1; k < 5; k++) {
                int x, y, z;
                x = str[i] - 'A';
                y = str[j] - 'A';
                z = str[k] - 'A';
                s += ( (ll) mp[x] * mp[y] * mp[z]);
            }
        }
    }
    cout << s << '\n';
    return 0;
}


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

public class Main {

    public static void main (String args[]) {
        
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = "";
			
			while ((line = br.readLine()) != null) {
				int conv = Integer.parseInt(line);
				String type1 = "";
				String type2 = "";
				StringBuffer after = new StringBuffer(100);
				
				if (conv > 0) {
					for (int i = 0; i < conv; i++) {
						line = br.readLine();
						String[] str = line.split(" ");
						
						type1 += str[0];
						type2 += str[1];
					}
					
					line = br.readLine();
					conv = Integer.parseInt(line);

					for (int i = 0; i < conv; i++) {
						String target = br.readLine();
						int index = type1.indexOf(target);
						if (index != -1) {
							after.append(type2.substring(index, index + 1));
						}else {
							after.append(target);
						}						
					}
					
					System.out.println(after);
					
				}else if(conv == 0){
					System.exit(0);
				}
			}
		}catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
		finally {
			System.exit(0);
		}
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

string s;

signed main() {
  cin >> s;
  int n = s.size();

  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      string t = "";
      for (int k = 0; k < n; k++) {
        if (i <= k && k < j) {

        } else {
          t += s[k];
        }
      }
      if (t == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    string S;
    cin >> S;
    ll a,b,c,d;
    a=S[0]-'0';
    b=S[1]-'0';
    c=S[2]-'0';
    d=S[3]-'0';
    ll A,B;
    A=10*a+b;
    B=10*c+d;
    bool AM,BM;
    if(A>=1&&A<=12){AM=1;}
    else AM=0;
    if(B>=1&&B<=12){BM=1;}
    else BM=0;
    if(AM&&BM){cout<<"AMBIGUOUS"<<endl;}
    else if(!AM&&BM){cout<<"YYMM"<<endl;}
    else if(AM&&!BM){cout<<"MMYY"<<endl;}
    else cout<<"NA"<<endl;

    return 0;
}


Measured memory_bytes: 256
//AtCoder ABC098 C - Attention
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    string S;
    cin>>N>>S;
    vector<ll> etbl(N+1,0);
    vector<ll> wtbl(N+1,0);
    ll e=0;
    ll w=0;
    for(ll i=1;i<=N;++i){
        if(S[i-1]=='E') ++e;
        else ++w;
        etbl[i]=e;
        wtbl[i]=w;
    }
    ll ans=INT64_MAX;
    for(ll i=1;i<=N;++i){
        ll num=wtbl[i-1]+etbl[N]-etbl[i];
        ans=min(num,ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

using vec=vector<long>;
using mat=vector<vec>;

const int mod=1e9+7;

mat mul(mat &a, mat& b)
{
    mat c(a.size(), vec(b[0].size()));
    for(int i=0; i<a.size(); ++i)
        for(int k=0; k<b.size(); ++k)
            for(int j=0; j<b[i].size(); ++j)
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod;
    return c;
}

mat pow(mat a, long n)
{
    mat res(a.size(), vec(a.size()));
    for(int i=0; i<res.size(); ++i) res[i][i]=1;
    while (n>0) {
        if (n%2) res=mul(res, a);
        a=mul(a, a);
        n>>=1;
    }
    return res;
}

int main()
{
    long n, k; cin>>n>>k;
    mat a(n, vec(n));
    for(auto& v: a) for(auto& e: v) cin>>e;
    long res=0;
    for(auto&& v: pow(a, k)) for(auto& e: v) res=(res+e)%mod;
    cout<<res<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int N, a, b, c, y, z;
    scanf("%d", &N);

    a=N%10;
    y=N/10;
    b=y%10;
    z=y/10;
    c=z%10;
    if(a==7){
        printf("Yes\n");
    }

    else if(b==7){
        printf("Yes\n");
    }

    else if(c==7){
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  double D = 0.0;
  for (int i = 0; i < N; i++) {
    int O;
    cin >> O;
    D += 1.0 / O;
  }
  cout << 1.0 / D << endl;
}

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

void solve(int N, vector<int> A)
{
    sort(A.rbegin(), A.rend());

    int64_t res = 0;
    queue<int> q;
    q.push(A.at(0));
    for (int i = 1; i < N; i++)
    {
        res += q.front();
        q.pop();
        q.push(A.at(i));
        q.push(A.at(i));
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 4828
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void) {
    int R[MAX], n;
    
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3896
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<u32> = scan.next_vec(n);

    let mut b: u32 = 0;
    for x in &a {
        b ^= x;
    }
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", b ^ a[i]);
    }
    println!("");
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 5612
program ABC097A
	integer(8)::a,b,c,d
	read(5,*)a,b,c,d
	
	if(abs(a-c)<=d .or. (abs(a-b)<=d .and. abs(b-c)<=d))then
		print'(A)',"Yes"
	else
		print'(A)',"No"
	end if
end program ABC097A


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int e = scanner.nextInt();
		
		int k = scanner.nextInt();
		
		if(e - a > k) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
		
		scanner.close();

	}

}

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

using namespace std;

int main()
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(m<4||(m==4&&d<=30))
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    n, k = map(int, input().split())
    p = np.array(read().split(), np.int32)
    p += 1
    pcum = np.zeros(n + 1, np.int32)
    pcum[1:] = p.cumsum()
    sum_k = pcum[k:] - pcum[:-k]
    print(sum_k.max()/2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n,k;
	bool no[10];
	cin >> n >> k;
	for(int i = 0;i < 10;i++) no[i] = false;
	for(int i = 0;i < k;i++) {
		int a;
		cin >> a;
		no[a] = true;
	}
	while(1){
		int nn = n;
		bool flag = false;
		for(;nn != 0;){
			if(no[nn % 10]){
				flag = true;
				break;
			}
			nn /= 10;
		}
		if(!flag){
			cout << n << endl;
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();

      System.out.println((A - 1) * (B - 1));
    }
  }
}

Measured memory_bytes: 21844
import java.util.PriorityQueue;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author rn-sshawish
 */
public class Main{
    public static void main(String[] args) {
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        Scanner input = new Scanner(System.in);
        queue.add(input.nextInt());
        queue.add(input.nextInt());
        queue.add(input.nextInt());
        int count = 0;
        while (true) {
            int a = queue.remove();
            int b = queue.remove();
            int c = queue.remove();
            if (a == b && b == c) {
                break;
            }
            if (a + 1 <= c && b + 1 <= c) {
                count++;
                a++;
                b++;
            }else {
                a+= 2;
                count++;
            }
            queue.add(a);
            queue.add(b);
            queue.add(c);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
fun main(args: Array<String>){
	Swapping_Two_Numbers()
}

fun Swapping_Two_Numbers(){
	var i=0
	while(i<3000){
		val a = readLine()!!.split(" ").map(String::toInt)
		if(a[0]==0 && a[1]==0)break
		when{
			a[0]<a[1] ->{
				println("${a[0]} ${a[1]}")
			}
			else ->{
				println("${a[1]} ${a[0]}")
			}
		}

		i++
	}

}


Measured memory_bytes: 33564
// solution by Vitaliy Eroshin | 2020
 
#include <iostream>
#define endl "\n"
#define int long long
using namespace std;
const long long INF = 1e18;

void solve() {
    int n;
    long double d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans;
}

signed main() {
    #ifdef _DEBUG
        freopen(".debug_input.txt", "r", stdin);
        freopen(".debug_output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;

    while (t--) solve();
    
}


Measured memory_bytes: 3184
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

for i, j in enumerate(permutations(range(1, n + 1))):
    if list(j) == p:
        p_index = i
    if list(j) == q:
        q_index = i

print(abs(p_index - q_index))

Measured memory_bytes: 73896
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    dishes = list()
    ans = 0

    # See:
    # https://poporix.hatenablog.com/entry/2019/01/28/222905
    # https://misteer.hatenablog.com/entry/NIKKEI2019qual?_ga=2.121425408.962332021.1548821392-1201012407.1527836447
    for i in range(n):
        ai, bi = map(int, input().split())
        dishes.append((ai, bi))

    for index, dish in enumerate(sorted(dishes, key=lambda x: x[0] + x[1], reverse=True)):
        if index % 2 == 0:
            ans += dish[0]
        else:
            ans -= dish[1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22128
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	long long cnt_x = 0, cnt_y = 0, x[N], y[M];
	for(int i=0; i<N; i++){
		scanf("%lld", x+i);
		if(i > 0){
			int a = ((long long)i * (N-i)) % mod;
			cnt_x = (cnt_x + a * (x[i] - x[i-1])) % mod;
		}
	}
	for(int i=0; i<M; i++){
		scanf("%lld", y+i);
		if(i > 0){
			int a = ((long long)i * (M-i)) % mod;
			cnt_y = (cnt_y + a * (y[i] - y[i-1])) % mod;
		}
	}
	int ans = (cnt_x * cnt_y) % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
import sys


N = int(input())

for i in range(N, 1000):
    c1 = i // 100
    c2 = (i-c1*100) // 10
    c3 = (i-c1*100-c2*10)
    if c1 == c2 == c3:
        print(i)
        sys.exit()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vector<vector<P>> city(n);
    rep(i,m) {
        int p,y;
        cin >> p >> y;
        p--;
        city[p].emplace_back(y,i);
    }
    rep(i,n) sort(all(city[i]));
    vector<string> ans(m);
    auto format = [](int n) {
        string s = to_string(n);
        while(s.size() < 6) {
            s = '0'+s;
        }
        return s;
    };
    rep(i,n) {
        rep(j,city[i].size()) {
            ans[city[i][j].second] = format(i+1)+format(j+1);
        }
    }
    rep(i,m) cout << ans[i] << endl;
}


Measured memory_bytes: 12416
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
const int mod = 1e9 + 7;

void add_self(int &a, int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

void sub_self(int &a, int b){
    a -= b;
    if(a < 0){
        a += mod;
    }
}


int32_t main()
{
    fastio;
    
    int n, k; cin >> n >> k;
    vector<int> a(n); for(auto &x: a) cin >> x;

    vector<int> dp(k+1);
    dp[0] = 1; 
    for(int i=0; i<n; i++){
        vector<int> fake(k+1);
        for(int j=k; j>=0; j--){
            int L = j+1;
            int R = j+min(a[i], k-j);
            if(L <= R){
                add_self(fake[L], dp[j]);
                if(R+1 < k+1){
                    sub_self(fake[R+1], dp[j]);
                }
            }
        }

        int prefix = 0;
        for(int j=0; j<k+1; j++){
            add_self(prefix, fake[j]);
            add_self(dp[j], prefix);
        }
    }
    cout << dp[k] << endl;
    return 0;   
}
    


Measured memory_bytes: 1792
import bisect, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def resolve():
    X = I()

    primes = sieve(X * 2)
    idx = bisect.bisect_left(primes, X)
    print(primes[idx])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11544
import Data.Array
import Data.Array.ST

counter::String -> Array Char Int
counter str = runSTArray $ do
  ar<-newArray ('a','z') 0
  mapM_ (count ar) str
  return ar
    where count ar c = do
                    v<-readArray ar c
                    writeArray ar c (v+1)

min_ar::[Array Char Int]->Array Char Int
min_ar ars = array ('a','z') (zip ['a'..'z'] [ minimum [ (ar!c) | ar <-ars ] |  c<-['a'..'z'] ])

create_str::Array Char Int -> String
create_str ar = concat [ take (ar!c) (repeat c)  | c<-['a'..'z'] ]

n_getter::Int->IO [String]
n_getter 0 = return []
n_getter n = do
  str<-getLine
  rest<-n_getter (n-1)
  return (str:rest)

main::IO()
main=do
  nc<-getLine
  dats<-n_getter (read nc)
  putStr (((create_str.min_ar.(map counter)) dats)++"\n")

Measured memory_bytes: 1020
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

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

        int n = sc.nextInt();

        char[][] c = new char[n][n];

        for (int i=0; i<n; i++){
            c[i] = sc.next().toCharArray();
        }


        int ans = 1;
        for (int i=0; i<n; i++){
            int[] dep = new int[n];
            Arrays.fill(dep, -1);
            Queue<Integer> q = new ArrayDeque<>();
            q.add(i);
            dep[i] = 1;
            while (!q.isEmpty()){
                int cur = q.poll();
                for (int j=0; j<n; j++){
                    if (c[cur][j]=='1'){
                        if (dep[j]==-1){
                            dep[j] = dep[cur]+1;
                            ans = Math.max(ans, dep[j]);
                            q.add(j);
                        }
                        if (dep[j]!=dep[cur]+1 && dep[j]!=dep[cur]-1){
                            System.out.println(-1);
                            return;
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27340
N = int(input())
S = input()

def cal(data, r, c):
    for i in range(1,N):
        if data[i-1] == "W" and data[i] == "W":
            c += 1
        elif data[i-1] == "E" and data[i] == "E":
            c -= 1
            if r > c:
                r = c
    return r

if S[0] == "E":
    count = S.count("E") -1
    result = count
    result = cal(S, result, count)
else:
    count = S.count("E")
    result = count
    result =  cal(S, result, count)


print(result)

Measured memory_bytes: 3784
#include<cstdio>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int jishu=0,oushu=0,four=0;
	for(int i=1;i<=n;i++)
	{
		int cache;
		scanf("%d",&cache);
		if(cache%2) jishu++;
		else if(cache%4) oushu++;
		else four++; 
	}
	if(oushu%2==0&&jishu-1<=four)
	{
		printf("Yes");
		goto mark;
	}
	if(oushu%2!=0&&jishu==four)
	{
		printf("Yes");
		goto mark;
	}
	if(jishu==0&&oushu==0)
	{
		printf("Yes");
		goto mark;
	}
	if(oushu%2==0&&jishu==0&&four==0)
	{
		printf("Yes");
		goto mark;
	}
	printf("No");
	mark:return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    float[] A;
    A = new float[N+1];
    float tmp=0;
    for (int i= 1; i <= N; i++){
      A[i] = scan.nextFloat();
      tmp= tmp + 1/A[i];
    }
      System.out.println(1/tmp);
  
  }
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 //初期化
 int i = 0;
 string text;
 bool flag = false;
 
 cin >> i;
 
 //入力検索
 while(i>0){
  cin >> text;
  if(text=="Y")flag = true;
  i--;
 }
  
 //出力
 if(flag) cout << "Four";
 else cout << "Three";
}

Measured memory_bytes: 3520
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
D = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        D += ((d[i][0] - d[j][0])**2 + (d[i][1] - d[j][1])**2)**(1 / 2)
print(D * (n - 1) / (n * ~-n / 2))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int
main()
{
        int n, i, j, total, max;

        cin >> n;
        int up[n], down[n];
        max = 0;
        for (i = 0; i < n; i++) {
                cin >> up[i];
        }
        for (i = 0; i < n; i++) {
                cin >> down[i];
        }

        for (i = 0; i < n; i++) {
                total = 0;
                for (int ii = 0; ii <= i; ii++) {
                        total += up[ii];
                }
                for (int jj = i; jj < n; jj++) {
                        total += down[jj];
                }
                if (total > max) {
                        max = total;
                }
        }

        cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string S,T;
    cin>>S>>T;
    int N=S.size();
    int ans=0;
    rep(i,N){
        if(S.at(i)!=T.at(i)){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3916