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

using namespace std;

const int mod = 1e9 + 7;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

void dfs(vector<vector<int>> &v, vector<int> &visited, int node, int &ans){
    if(visited[node]){
        return;
    }
    visited[node] = 1;
    ans++;
    for(auto i : v[node]){
        dfs(v, visited, i, ans);
    }
}

/*bool good(vector<int> &v, int d, int mid){
    vector<int> p(v.size());
    p[0] = v[0] - mid;
    for(int i = 1;i < v.size();i++){
        p[i] = p[i - 1] + (v[i] - mid);
    }
    vector<int> m(v.size());
    m[0] = p[0];
    int mi = m[0];
    for(int i = 1;i < v.size();i++){
        mi = min(mi, p[i]);
        m[i] = mi;
    }
    for(int r = 0;r < v.size();r++){
        if(r - d > 0){
            if(m[r - d - 1] <= p[r]){
                L = r - d;
                R = r;
                return true;
            }
        }
    }
    return false;
}*/

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    long long sum = 0,
        ans = 0;
    for(int i = 0;i < n;i++){
        cin >> v[i];
        ans += (v[i] * sum) % mod;
        ans %= mod;
        sum += v[i];
        sum %= mod;
    }
    ans %= mod;
    cout << ans << endl;











    /*int n, d;
    cin >> n >> d;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    int l = -1,
        r = 101;
    while(r > l + 1){
        int mid = (l + r) / 2;
        if(good(v, d, mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << L + 1 << " " << R + 1<< endl;
    cout << l << endl;*/
}
/*
5 2
-1 -2 -3 4 5
2 3
4

-3 -2 -1 4 5
2 3
5 + (-3) = 2
4 + -2 = 2
ans = 4

-3 -2 -1 4 5
3 2
5 + -3 = 2
4 + -1 = 3
ans = 5
*/


Measured memory_bytes: 4044
n = int(input())
x = list(map(int,input().split()))
sort_x = sorted(x)
m1 = n // 2 - 1
m2 = n // 2
for i in range(n):
    if x[i] <= sort_x[m1]:
        print(sort_x[m2])
    elif x[i] >= sort_x[m2]:
        print(sort_x[m1])

Measured memory_bytes: 25224
x=int(input())
y=list(map(int, input().split()))
ans=0
count=0
for i in range((x-1),0,-1):
	if y[i]<=y[i-1]:
		count=count+1
	else:
		if ans<count:
			ans=count
		count=0
if ans<count:
	ans=count
print(ans)

Measured memory_bytes: 15888
#include<bits/stdc++.h>
using namespace std;
typedef  long long                  ll;
typedef  unsigned long long        llu;
typedef  long double               ldo;
#define  mod                 1000000007
#define  pi              3.141592653589
#define  sz(c)             (ll)c.size()
#define  fr                       first 
#define  sc                      second
#define  pb                   push_back
#define  mp                   make_pair
#define  all(v)   (v).begin(),(v).end()
#define  rep(i,a,n) for(ll i=a;i<n;i++)
#define  endl                      '\n'
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef  vector <ll>               vll;
typedef  vector <string>           vss;
typedef  vector <pair <ll,ll>>    vpll; 
typedef  vector <vector <ll>>     vvll;
typedef  set <ll>                  sll;

class Solution{
  public:
 // vll v;

  //Solution():v(10, false){v[2]=6;}
  void SolutionFunc(){
    ll n;
    cin>>n;
    ll b[n+1]={};
    rep(i,0,n-1){
    	ll x;cin>>x;
    	b[x]++;
    }
    rep(i,1,n+1)cout<<b[i]<<endl;
    
    
  }
};

int main(){
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
  IOS;

  Solution obj;
  ll T=1;
  //cin>>T;
  rep(i,0,T){
    //cout<<"Case #"<<i+1<<": ";
    obj.SolutionFunc();
  }  
  return(0);
} 



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

int main() {
	long long n, xx = 0, yy = 0, hh = 0; cin >> n;
	long long x[105], y[105], h[105];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] >= 1) { xx = x[i], yy = y[i], hh = h[i]; }
	}

	for (int xi = 0; xi <= 100; xi++) {
		for (int yi = 0; yi <= 100; yi++) {
			bool ok = true;
			long long hi = max(abs(xx - xi) + abs(yy - yi) + hh, 0LL);
			for (int i = 0; i < n; i++) {
				if (max(hi - abs(x[i] - xi) - abs(y[i] - yi),0LL) != h[i])ok = false;
			}
			if (ok) {
				cout << xi << ' ' << yi << ' ' << hi << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3648
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    A,B,C=[],[],[]
    for _ in range(M):
        a,b=map(int, input().split())
        A.append(a)
        B.append(b-1)
        C.append(list(map(lambda x:int(x)-1, input().split())))

    #dp[i][j]=i番目の鍵まで見たとき、jの宝箱を開けられるようになった場合の費用の最小値
    dp = [[10**9] * (1<<N) for _ in range(M+1)]
    dp[0][0] = 0

    for i in range(M):
        ni = i + 1
        for j in range(1<<N):
            dp[ni][j] = min(dp[ni][j], dp[i][j])
            nj = j
            for c in C[i]: nj |= 1 << c
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + A[i])

    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < 10**9 else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 74476
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define INF 2147438647
#define nl '\n'
#define si(i) scanf("%d", &i);
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

string n;
int mi = INF;

int main(){
    cin >> n;
    int lnt = n.size();
    for( int i1 = 0 ;  i1 < lnt - 2 ; i1++ ){
            int x = (int(n[i1]) - '0') * 100 + (int(n[i1 + 1]) - '0' ) * 10 + ( int(n[i1 + 2]) - '0');
            mi = min( abs(x - 753), mi);
    }
    cout << mi << nl;
}


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

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

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

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

  sort(h.rbegin(), h.rend());

  ll ans = 0;
  if (n <= k) {
    cout << ans << endl;
  } else {
    for (int i = 0; i < k; i++) {
      h[i] = 0;
    }

    for (int i = 0; i < n; i++) {
      ans += h[i];
    }

    cout << ans << endl;
  }

  return 0;
}

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



int main(){
	string S;
	cin>>S;
	int cnt=0;
	for(int i=0;i<S.size();i++){
		if(i%2==S[i]-'0')cnt++;
	}
	cout<<min((int)S.size()-cnt,cnt)<<endl;
	
	return 0;
}


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

#define int long long 
#define MOD 1000000

vector<int> graph[1010];
vector<int> rgraph[1010];
int memo[1010][1010];

int dp1[1010];
int dp2[1010];


int mae(int i, int j){
    if(i == 0 && j == 0){
        return 1;
    }

    if(memo[i][j] != -1){
        return memo[i][j];
    }

    int ans = 0;
    if(i > 0){
        ans = (ans + mae(i-1, j)) % MOD;
    }
    if(j > 0){
        ans = (ans + mae(i, j-1)) % MOD;
    }

    return memo[i][j] = ans;
}

void dp(int i){
    int ans = 1;

    int lsize = 0;

    for(int j = 0;j < graph[i].size();j++){
        int child = graph[i][j];
        dp(child);
        ans *= dp2[child];
        ans %= MOD;
        ans *= (memo[lsize][dp1[child]+1]);
        ans %= MOD;
        lsize += dp1[child]+1;
    }

    dp1[i] = lsize; 
    dp2[i] = ans;
    return;
}

int root(int i){
    if(rgraph[i].size() == 0){
        return i;
    }else{
        return root(rgraph[i][0]);
    }
}

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

    for(int i = 0;i < n-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        rgraph[b].push_back(a);
    }

    memset(memo, -1, sizeof(memo));
    mae(n, n);

    int r = root(0);
    dp(r);

    cout << dp2[r] << endl;
}



Measured memory_bytes: 11228
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func solve() {
	n := scanInt()
	logSum := 0.0
	prod := 1
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	for i := 0; i < n; i++ {
		num := a[i]
		logSum += math.Log10(float64(num))
		prod *= num
		if logSum > 18 || prod > 1e18 {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(prod)
	return
}

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}
func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}
func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	var i, j int
	for {
		for i = n - 2; i >= 0; i-- {
			if nums[i] < nums[i+1] {
				break
			}
		}
		if i < 0 {
			return
		}
		for j = n - 1; ; j-- {
			if nums[j] > nums[i] {
				break
			}
		}
		nums[i], nums[j] = nums[j], nums[i]
		for k, l := i+1, n-1; k < l; {
			nums[k], nums[l] = nums[l], nums[k]
			k++
			l--
		}
		*ret = append(*ret, makeCopy(nums))
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}
func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}
func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

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

    vector< long long int > v;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
    }

    long long int ans = n;
    bool f[114514] = {};

    for ( long long int i = 0; i < m; i++ ) {
        long long int a, b;
        cin >> a >> b;
        a--;
        b--;
        if ( v[a] <= v[b] ) {
            if ( f[a] == false ) {
                f[a] = true;
                ans--;
            }
        }
        if ( v[a] >= v[b] ) {
            if ( f[b] == false ) {
                f[b] = true;
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;

}


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

int main()
{
  int A,  B;
  char op;
  cin >> A >> op >> B;
  if (op=='+') {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{

    int a,b,c,m,n;

    scanf("%d %d %d",&a,&b,&c);
    m=a;
    a=b;
    b=m;
    n=a;
    a=c;
    c=n;

    printf("%d %d %d",a,b,c);

    return 0;
}


Measured memory_bytes: 128
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = 998244353;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

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

const int maxn = 3005;
int a, b, c, d;

bool read() {
  if (scanf("%d%d%d%d", &a, &b, &c, &d) < 4) {
    return false;
  }
  return true;
}

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

void solve() {
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i = 0; i <= c - a; i++) {
    for (int j = 0; j <= d - b; j++) {
      for (int take = 0; take < 2; take++) {
        auto cur = dp[i][j][take];
        if (!cur) {
          continue;
        }
        if (i < c - a) {
          auto &nxt = dp[i + 1][j][0];
          int cnt = (take ? 1 : b + j);
          add(nxt, mul(cur, cnt));
        }
        if (j < d - b) {
          auto &nxt = dp[i][j + 1][1];
          int cnt = a + i;
          add(nxt, mul(cur, cnt));
        }
      }
    }
  }
  int res = dp[c - a][d - b][0];
  add(res, dp[c - a][d - b][1]);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 74380
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<int>& A, vector<int>& B, int m) {
        vector<pair<int,int>> jobs;

        int n = A.size();
        for (int i = 0; i < n; ++i) {
            jobs.emplace_back(A[i], B[i]);
        }
        auto cmp = [&](const pair<int,int>& l, const pair<int,int>& r) {
            if (l.first == r.first) {
                return l.second > r.second;
            }
            return l.first > r.first;
        };
        sort(jobs.begin(), jobs.end(), cmp);
        
        multiset<int> que;
        int rem = m;
        long long res = 0;
        for (auto& J : jobs) {
            int t = J.first;
            int x = J.second;
            if (t <= rem) {
                res += x;
                que.insert(x);
                --rem;
            } else {
                if (!que.empty()) {
                    int y = *que.begin();
                    if (y < x) {
                        que.erase(que.begin());
                        que.insert(x);
                        res -= y;
                        res += x;
                    }
                }
            }
        }
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    vector<int> B(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i] >> B[i];
    }

    Solution sol;

    cout << sol.solve(A, B, m) << "\n";

    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

const int N_MAX = 5000;
ll Per[N_MAX] = {}; // n!
ll Per_inv[N_MAX] = {}; //(n!)^-1

ll nCr(ll n, ll r){
    if(n<r) return 0;
 
    if (n == r || r == 0)
        return 1;
    else
        return Per[n] * Per_inv[n-r] % mod * Per_inv[r] % mod;  
}
 
// a^b mod p
ll mod_pow(ll a, ll b){
    if(b==0) return 1;
 
    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

void prepare_nCr(){
    Per[0] = 1;
    Per_inv[0] = 1;

    // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }
    Per_inv[1] = 1;
    FOR(i, 2, N_MAX){
        Per_inv[i] = mod_pow(Per[i], 1000000005);
    }
}

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

    // input
    ll N, K;
    cin >> N >> K;

    prepare_nCr();
    
    ll ans = Per[N+K-1] * Per_inv[N] % mod * Per_inv[K-1] % mod;
    p(ans);
    
    return 0;
}


Measured memory_bytes: 3240
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import floor


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


n = int(readline())
prime_list = make_divisors(n)
ans = 0
prime_list.remove(1)
for i in range(len(prime_list)):
    prime_list[i] -= 1
    if floor(n / prime_list[i]) == n % prime_list[i]:
        ans += prime_list[i]
print(ans)


Measured memory_bytes: 3276
#include<cstdio>
long n,s,a[100000],b[100000],i;
main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
  for(i=n-1;i>=0;i--)s+=(b[i]-(a[i]+s)%b[i])%b[i];
  printf("%ld",s);
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<ll> L(N);
	for(int i = 0; i < N; i++) cin >> L[i];
	ll ans = 0;
	for(int i = 0; i < N - 2; i++) {
		for(int j = i + 1; j < N - 1; j++) {
			for(int k = j + 1; k < N; k++) {
				if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
					ll first = 0, second = 0, third = 0;
					if(L[i] > L[j] && L[i] > L[k]) {
						first = L[i];
						if(L[j] > L[k]) {
							second = L[j];
							third = L[k];
						}
						else {
							second = L[k];
							third = L[j];
						}
					}
					else if(L[j] > L[i] && L[j] > L[k]) {
						first = L[j];
						if(L[i] > L[k]) {
							second = L[i];
							third = L[k];
						}
						else {
							second = L[k];
							third = L[i];
						}
					}
					else if(L[k] > L[i] && L[k] > L[j]) {
						first = L[k];
						if(L[i] > L[j]) {
							second = L[i];
							third = L[j];
						}
						else {
							second = L[j];
							third = L[i];
						}
					}
					if(first < second + third) ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    H,W = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = list(tuple(input()) for i in range(H)) #改行行列

    for li in S:
        print(*li,sep="")
        print(*li,sep="")





if __name__ == "__main__":
    main()

Measured memory_bytes: 79832
#include <stdio.h>

void printFrame(int h, int w) {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
                printf("#");
            } else {
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
}

int main() {
    int h, w;

    while (1) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;

        printFrame(h, w);
    }

    return 0;
}


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

#define Rep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) Rep(i, 0, n)

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	cout << read<int>() * read<int>() << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

int main() {
   string N;
 
    cin>>N;
   for(int i=0;i<19;i++){
    if(N[i]==','){
       N[i]=' ';
    }
       cout<<N[i];
   }
    
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <unordered_map>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};


int main() {
    int n;
    cin >> n;
    unordered_map<int, int> m;
    int a = -1, b = -1;
    for (int i = 1; i <= n+1; ++i) {
        int k;
        scanf("%d", &k);
        if(m[k] != 0){
            a = m[k]-1, b = i-1;
            break;
        }else {
            m[k] = i;
        }
    }
    Factorial<int> f(n+1, MOD);
    int p = a-b+n;
    for (int i = 1; i <= n+1; ++i) {
        printf("%lld\n", (1000000007LL + f.C(n+1, i) - f.C(p, i-1)) % MOD);
    }
    return 0;
}


Measured memory_bytes: 6948
#include <bits/stdc++.h>
#define LEN 100005
using namespace std;

int head,tail,n;

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}


int main(){
    int elaps = 0, c;
    int q;
    P u;
    cin >> n >> q;

    for(int i=1; i <= n; i++){
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1; tail = n + 1;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
}


Measured memory_bytes: 13300
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  int H,W;
  cin >> H >> W;
  vector<string> field(H);
  for(int i=0; i<H; i++){
    cin >> field[i];
  }
  bool ans = true;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(field[i][j] == '#'){
        bool can = false;
        for(int k=0; k<4; k++){
          int nx = j+dx[k];
          int ny = i+dy[k];
          if(nx<0 || nx>=W || ny<0 || ny>=H) continue;
          if(field[ny][nx] == '#'){
            can =true;
          }
        }
        if(!can){
          ans = false;
        }
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n,k;
    cin>>n>>k;
    cout<<(n-2)/(k-1)+1<<endl;
}


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

typedef long long int ll;

int main()
{
	ll i,j,k,l,m,n,t;

	ll u,v;

	ll a,b,c,d;

	cin >> a >> b >> c >> d;

	ll ans = a*c;

	ans = max(ans,a*c);
	ans = max(ans,a*d);
	ans = max(ans,c*b);
	ans = max(ans,d*b);

	cout << ans << '\n';

}

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

int d, ans, m, x, q;
int c[30], s[370][30], lst[30];

int main() {
	int i, j, re, mx, mj;
	cin >> d;
	for(i=1; i<=26; i++) cin >> c[i];
	for(i=1; i<=d; i++) for(j=1; j<=26; j++) cin >> s[i][j];
	for(i=1; i<=d; i++) {
		mx = -1e9;
		for(j=1; j<=26; j++) {
			re = s[i][j] - c[j] * (i-lst[j]);
			if(re > mx) {
				mx = re;
				mj = j;
			}
		}
		lst[mj] = i;
		cout << mj << endl;
	}
	return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<string>

using namespace std;

int main(){

  string s,t,u;
  cin >> s >> t >> u;
  
  s[0] -= 32;
  t[0] -= 32;
  u[0] -= 32;
  cout << s[0] <<t[0] << u[0] << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = 444;
const int MOD = int(1e9) + 7;

int a[N], b[N];
int dp[N][N], sum[N][N], pw[N][N];

inline int get_sum(int x, int l, int r) {
    assert(l <= r);
    int res = sum[x][r] - (l > 0 ? sum[x][l - 1] : 0);
    if (res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", b + i);
    }
    for (int i = 1; i < N; ++i) {
        pw[i][0] = 1;
        for (int j = 1; j < N; ++j) {
            pw[i][j] = (1LL * pw[i][j - 1] * i) % MOD;
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            sum[i][j] = (j > 0 ? sum[i][j - 1] : 0) + pw[j][i];
            if (sum[i][j] >= MOD) {
                sum[i][j] -= MOD;
            }
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            for (int z = 0; z <= j; ++z) {
                dp[i][j] = (dp[i][j] + 1LL * get_sum(z, a[i], b[i]) * dp[i - 1][j - z]) % MOD;
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll x;
    cin >> x;
    ll ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3]==s[4]){
    cout << "Bad";
  }else{
    cout << "Good";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll a, b;
  a = A[0];
  b = A[1];
  for(int i=2;i<N;++i) {
    if(abs(a-2*b)>abs(a-2*A[i])) b = A[i];
  }
  cout<<a<<" "<<b<<endl;
}



Measured memory_bytes: 4028
N=int(input())
J=10

F=[set() for _ in range(N)]
for i in range(N):
    G=list(map(int,input().split()))
    for j in range(J):
        if G[j]:
            F[i].add(j)

P=[[] for _ in range(N)]
for i in range(N):
    P[i]=list(map(int,input().split()))

Ans=-float("inf")
for x in range(1,2**J):
    S=set()
    for t in range(J):
        if x%2:
            S.add(t)
        x>>=1

    Score=0
    for i in range(N):
        Score+=P[i][len(F[i]&S)]
    Ans=max(Ans,Score)
    assert 1

print(Ans)

Measured memory_bytes: 74228
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramD
    {
        static void Main(string[] args)
        {

            //入力
            string[] s1  = Console.ReadLine().Split(' ');
            int n = int.Parse(s1[0]);
            int q = int.Parse(s1[1]);

            string s = Console.ReadLine();
            int[] pos = new int[n + 1];
           

            for (int i = 1; i < n; i++)
            {
                if (s[i - 1] == 'A' && s[i] == 'C')
                    pos[i + 1] = pos[i]+ 1;
                else
                    pos[i + 1] = pos[i];

            }


            for (int i = 0; i < q; i++)
            {
                string[] s2 = Console.ReadLine().Split(' ');
                int f = int.Parse(s2[0]);
                int e = int.Parse(s2[1]);

                Console.WriteLine(pos[e] - pos[f]);
            }

        }

        
    }

    

}


Measured memory_bytes: 17816
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x;
    cin >> x;

    ll ans = ((x + 10) / 11) * 2;
    // std::cout << (10 + x) % 11 << '\n';
    if ((x + 10) % 11 < 6)
        ans--;

    std::cout << ans << '\n';

    return 0;
}

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

#define ll long long 
#define pll pair<ll,ll> 

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin>>s;
	ll sum=0;
	ll n=s.size();
	for(ll i=0;i<n;i++){
		sum+=s[i]-'0';
	}
	cout<<(sum%9 ? "No" : "Yes");
}




Measured memory_bytes: 3760
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nt = readln.split.to!(int[]);
    auto N = nt[0];
    auto T = nt[1];
    auto abs = new int[][](N, 2);
    foreach (i; 0..N) {
        auto ab = readln.split.to!(int[]);
        abs[i][0] = ab[0];
        abs[i][1] = ab[1];
    }
    sort!"a[0] < b[0]"(abs);
    auto DP = new int[][](N, T);
    int solve(int i, int t) {
        if (i == N || t >= T) return 0;
        if (DP[i][t] == 0) DP[i][t] = max(solve(i+1, t), solve(i+1, t+abs[i][0]) + abs[i][1]);
        return DP[i][t];
    }
    writeln(solve(0, 0));
}

Measured memory_bytes: 39164
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi a(n),b(n);
		for(int i=0;i<n;i++) cin>>a[i]>>b[i];
		vvi dp(n,vi(3,inf));
		if(b[0]<a[0]){
			cout<<"NG 1"<<endl;
			continue;
		}
		dp[0][0]=a[0];
		bool B=0;
		for(int i=1;i<n;i++){
			for(int j=0;j<3;j++) if(dp[i-1][j]<inf){
				if(j<2&&abs(a[i]-a[i-1])*(j+2)<=b[i]-b[i-1]){
					dp[i][j+1]=min(dp[i][j+1],dp[i-1][j]+abs(a[i]-a[i-1]));
				}
				if(a[i-1]*(j+2)+a[i]<=b[i]-b[i-1]){
					dp[i][0]=min(dp[i][0],dp[i-1][j]+a[i-1]+a[i]);
				}
			}
			if(dp[i][0]==inf&&dp[i][1]==inf&&dp[i][2]==inf){
				cout<<"NG "<<i+1<<endl;
				B=1;
				break;
			}
		}
		// for(int i=0;i<n;i++){
			// for(auto j:dp[i]) cout<<j<<' ';
			// cout<<endl;
		// }
		if(!B){
			cout<<"OK ";
			int res=inf;
			for(int i=0;i<3;i++) res=min(res,a[n-1]+dp[n-1][i]);
			cout<<res<<endl;
		}
	}
}


Measured memory_bytes: 3120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const x int = 1000000007
func main() {

	sc.Split(bufio.ScanWords)
	n := nextInt()
	t := make([]int, n)
	a := make([]int, n)
	var tMax, aMax int
	for i := 0; i < n; i++ {
		t[i] = nextInt()
		tMax = max(tMax, t[i])
	}
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		aMax = max(aMax, a[i])
	}
	var ans int = 1
	var wa bool
	for i := 1; i < n - 1; i++ {
		if t[i - 1] < t[i] {
			// 山の高さはt[i]
			if t[i] > a[i] {
				wa = true
			}
		}
		if a[i + 1] > a[i] {
			if a[i] > t[i] {
				wa = true
			}
		}
		if t[i - 1] == t[i] && a[i + 1] == a[i] {
			h := min(t[i], a[i])
			ans = ans * h % x
		}
	}
	if a[n-1]>t[n-1] || a[0]<t[0] || aMax!=tMax{
		wa = true
	}
	if wa {
		fmt.Println("0")
	} else {
		fmt.Println(ans)
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}


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

A = sorted(A)

ans = 0
for a in A:
  if x >= a:
    ans += 1
    x -= a

if x > 0 and ans == N:
  ans -= 1
elif x > 0 and ans < N:
  pass
print(ans)

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

bool func(int a) {
    for(int i=2;i*i<=a;i++)if(a%i == 0)return false;
    return true;
}

int main() {
    vector<int> ans(1,13);
    int i;
    for(i=0;i<333333;i++)if(func(i*30+11)&&func(i*30+13)&&func(i*30+17)&&func(i*30+19))ans.push_back(i*30+19);
    int N;
    cin >> N;
    while(N > 0) {
        int l=0,r=ans.size(),m;
        while(r-l>1) {
            m = (l+r)/2;
            if(ans[m]>N)r = m;
            else l = m;
        }
        cout << ans[l] << endl;
        cin >> N;
    }
}


Measured memory_bytes: 3168
#include<stdio.h>

int main(void)
{
	char s[100];
	int a,i,blue=0,red=0;
	scanf("%d",&a);
	scanf("%s",s);
	for(i=0;i<a;i++)
	{
		if(s[i]=='R') red++;
		else blue++;
	}
	
	if(red>blue) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string reverse(string s, int a, int b)
{
	string sub = s.substr(a, b - a + 1);
	reverse(sub.begin(), sub.end());
	s.replace(a, b - a + 1, sub);
	return s;
}

int main()
{
	string str;
	int q;
	string cmd;
	int a, b;
	string p;
	vector<string> print(101, "\0");
	cin >> str >> q;
	int count = 0;
	for (int i = 0; i < q; i++)
	{
		cin >> cmd;
		if (cmd == "print")
		{
			cin >> a >> b;
			print[count++] = str.substr(a, b - a + 1);
		}
		else if (cmd == "reverse")
		{
			cin >> a >> b;
			str = reverse(str, a, b);
		}
		else if (cmd == "replace")
		{
			cin >> a >> b >> p;
			str.replace(a, b - a + 1, p);
		}
	}
	for (int i = 0; print[i] != "\0"; i++)
	{
		cout << print[i] << endl;
	}
}


Measured memory_bytes: 3232
import fractions
import math

A, B = map(int, input().split())

gcd = fractions.gcd(A, B)


ans = 1

max_N = int(math.sqrt(gcd))

for p in range(2, max_N+1):
    if gcd % p == 0:
        ans += 1
        gcd = gcd / p
        while gcd % p == 0:
            gcd = gcd / p
    if p > gcd:
        break
if gcd != 1:
    ans += 1
print(ans)

Measured memory_bytes: 66028
s = input()
inc = 0
dec = 0
increasing = True
ans = 0
for c in s:
    if increasing:
        if c == '<':
            inc += 1
        else:
            increasing = False
            dec += 1
    else:
        if  c == '>':
            dec += 1
        else:
            if inc > dec:
                inc, dec = dec, inc
            ans += inc * (inc - 1) // 2 + dec * (dec + 1) // 2
            increasing = True
            inc = 1
            dec = 0
else:
    if increasing:
        ans += inc * (inc + 1) // 2
    else:
        if inc > dec:
            inc, dec = dec, inc
        ans += inc * (inc - 1) // 2 + dec * (dec + 1) // 2
print(ans) 


Measured memory_bytes: 4212
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define PI acos(-1)
#define eps 1e-10
#define mem(x) memset(x,0,sizeof(x))
#define _for(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define __for(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

const int INF=0x3f3f3f3f;
const int MAX=1e4+5;
const int MOD=1e9+7;

int n;
int a[MAX],b[MAX];

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    _for(i,1,n) cin>>a[i];
    _for(i,1,n) cin>>b[i];
    //sort(a+1,a+1+n);
    //sort(b+1,b+1+n);
    ll _1=0,_2=0;
    _for(i,1,n){
        b[i]-=a[i];
        if(b[i]<0){
            _1-=b[i];
        }
        else{
            _2+=b[i]/2;
        }
    }
    if(_2>=_1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}





















Measured memory_bytes: 384
import Data.Functor( (<$>))
import Data.List( sort)
import Control.Monad( forM_)

main = do
    inputs <- takeWhile ("0 0"/=) . lines <$> getContents
    let
	processPerLine line = sort $ (read::String->Int) <$> (words line)
	putStrLn4itp0103c [small,big]
	  =
	    putStrLn $ (show small)++" "++(show big)

    forM_ inputs $
	    putStrLn4itp0103c . processPerLine



Measured memory_bytes: 4576
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] hl = new int[n];
        for(int i = 0; i < n; i++){
            hl[i] = sc.nextInt();
        }
        boolean[] bools = new boolean[n];
        Arrays.fill(bools,true);
        for(int i = 0; i < m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            if(hl[a] < hl[b]){
                bools[a] = false;
            }else if(hl[a] > hl[b]){
                bools[b] = false;
            }else{
                bools[a] = false;
                bools[b] = false;
            }
        }
        int ans = 0;
        for(boolean b: bools){
            if(b) ans++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 49364
#include <stdio.h>
int main(void)
{
 	int N,a,i,t=0;
  	scanf("%d",&N);
  	for(i=1;i<=N;i++){
     scanf("%d",&a);
  	 if(i%2!=0&&a%2!=0)
       t++;
 	 }
  printf("%d",t);
  return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>

#define ll long long

using namespace std;

long long calc(long long A) {

	A++;
	ll ans = 0;
	for (int i = 0; i < 50; i++)
	{
		ll loop = (1LL << (i + 1));
		ll cnt = (A / loop) * (loop / 2);

		cnt += max(0LL,(A % loop) - (loop / 2));
		if (cnt % 2 == 1) {
			ans += 1LL << i;
		}

	}
	return ans;
}

int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = calc(B) ^ calc(A - 1);

	cout << ans << endl;
}

Measured memory_bytes: 384
N=int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

P1=[p for p in P if p <=A]
P2=[p for p in P if (p >A and p<=B)]
P3=[p for p in P if (p >B)]

print(min([len(P1),len(P2),len(P3)]))

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

int main() {
    int x, n;   cin >> x >> n;
    int *p = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    sort(p, p+n);

    int a = 9999;
    int ans;
    for (int k = -1; k <= 101; k++) {
        if (a > abs(x-k) && *(lower_bound(p, p+n, k)) != k) {
            a = abs(x-k);
            ans = k;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
using System;

public class ABC157_A {
    private static void Main(string[] args) {
        var n = Read1LineAsInt();
      
        var answer = (n / 2) + (n % 2);
        Console.WriteLine(answer);
    }

    private static int Read1LineAsInt() => int.Parse(Console.ReadLine().Trim());
}

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

int main() {
    string s;
    cin >> s;
    int start, end;
    rep(i, s.size()) {
        if(s[i] == 'A') {
            start = i;
            break;
        }
    }
    for(int i = s.size() - 1; i > -0; i--) {
        if(s[i] == 'Z') {
            end = i;
            break;
        }
    }
    cout << end - start + 1 << endl;

    return 0;
}

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

typedef long long ll;

typedef long double ld;

void ActivateFastIO()
{
	std::ios::sync_with_stdio(false);
	std::cout.tie(nullptr);
	std::cin.tie(nullptr);
}

template <typename type1, typename type2>
std::istream& operator>>(std::istream& in, std::pair<type1, type2>& p)
{
	in >> p.first >> p.second;
	return in;
}

template <typename type1, typename type2>
std::ostream& operator<<(std::ostream& o, const std::pair<type1, type2>& p)
{
	o << p.first << ' ' << p.second;
	return o;
}

template <typename type>
std::istream& operator>>(std::istream& in, std::vector<type>& v)
{
	for (int i = 0; i < v.size(); ++i)
	{
		in >> v[i];
	}
	return in;
}

template <typename type>
std::ostream& operator<<(std::ostream& o, const std::vector<type>& v)
{
	if (!v.empty())
	{
		o << v.front();
	}
	for (int i = 1; i < v.size(); ++i)
	{
		o << ' ' << v[i];
	}
	return o;
}

constexpr int MOD = 998244353;

ll power(ll b, int p)
{
	ll ans = 1;
	while (p)
	{
		if (p & 1)
		{
			ans = (ans * b) % MOD;
		}
		p /= 2;
		b = (b * b) % MOD;
	}
	return ans;
}

int GCD(int a, int b)
{
	while (b)
	{
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

template <typename type>
void Fill(void* arr, int size, type val)
{
	type* ptr = static_cast<type*>(arr);
	for (int i = 0; i < size; ++i, ++ptr)
	{
		*ptr = val;
	}
}

int main()
{
	ActivateFastIO();
	char grid[2][4];
	std::cin >> grid[0];
	std::cin >> grid[1];
	bool flag = true;
	for (int i = 0; i < 3; ++i)
	{
		if (grid[0][i] != grid[1][2 - i])
		{
			flag = false;
		}
	}
	std::cout << (flag ? "YES" : "NO") << '\n';
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  int K,N;
  cin >> K >> N;
  vector<int> data(N);
  rep(i,0,N){
      cin >> data[i];
  }
  vector<int> check(N);
  check[0]=K-data[N-1]+data[0];
  //cout << data[N-1] << endl;
  rep(i,1,N){
      check[i]=data[i]-data[i-1];
  }
  sort(check.begin(),check.end());
  cout << K-check[N-1]<<endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

int main()
{
    int a;

    cin >> a;
    if (a == 7 || a == 3 || a == 5)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256