akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>


using namespace std;


int main()
{
  char s[26];
  int a[200] = {0}, flag=true;

  cin >> s;
  for (int i=0; i<strlen(s); i++){
    if (a[s[i]] == 1){
      flag = false;
      break;
    }
    a[s[i]] = 1;
  }

  if (flag) cout << "yes" << endl;
  else cout << "no" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int NTYPE = 26;
int d;
array<int, NTYPE> c;
vector<array<int, NTYPE>> s;

void input(){
    cin >> d;
    REP(i, NTYPE){
        cin >> c.at(i);
    }
    s.resize(d);
    REP(i, d){
        REP(j, NTYPE){
            cin >> s.at(i).at(j);
        }
    }
}

void output(const vector<int>& sch){
    assert(sch.size() == d);
    for(auto x : sch){
        cout << x + 1 << endl;
    }
}

void solve(){
    vector<int> ans(d);
    REP(i, d){
        // int max_type = 0;
        // for(int j = 1; j < NTYPE; ++j){
        //     if(s.at(i).at(j) > s.at(i).at(max_type)){
        //         max_type = j;
        //     }
        // }
        ans.at(i) = i % NTYPE;
    }
    output(ans);
}

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


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
using namespace std;

int main(){
    int X;
    cin >> X;
    if(X == 7 || X == 5 || X == 3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

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

  int ans = N - K + 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

loop do
  n, x = readline.split(' ').map(&:to_i)
  break if n.zero? && x.zero?

  count = 0
  (1..n).each do |i|
    ((i + 1)..n).each do |j|
      k = x - (i + j)
      count += 1 if k <= n && k > j
    end
  end
  puts count
end



Measured memory_bytes: 6868
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N;
int main(){
    cin >> N;
    bool flag = false;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;    
        if(tmp % 2 == 1) flag = true;
    }
    cout << (flag ? "first" : "second") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		List<Integer> list = new ArrayList<>();
		String ans = "No";

		list.add(a);
		list.add(b);
		list.add(c);
		Collections.sort(list);

		if (list.get(0) + list.get(1) == list.get(2)) {
			ans = "Yes";
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    string str;
    int ans;
    while (cin>>str) {
        for (int i = 0; i < str.length(); ++i) {
            if ('0' <= str[i] && str[i] <= '9') {
                int tmp = 0;
                int cnt = 0;
                for (int j = i; j < str.length(); ++j) {
                    if ('0' <= str[j] && str[j] <= '9') {
                        tmp = 10 * tmp + (str[j] - '0');
                        cnt++;
                    }
                    else break;
                }
                i += cnt;
                ans += tmp;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>

int main(void){
    int n,k,h,count=0;
    scanf("%d %d",&n,&k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&h);
        if (k<=h)
        {
            count++;
        }
        
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();
void dfs(int f);

int x[2];
int y[2];

int main() {
  cin >> x[0] >> y[0] >> x[1] >> y[1];

  solve();

  return 0;
}

void solve() {
  int flag = 0;

  if(x[0]<=x[1]&&y[0]<=y[1]) {
    flag = 1;
  }else if(x[0]<=x[1]&&y[0]>y[1]) {
    flag = 2;
  }else if(x[0]>x[1]&&y[0]<=y[1]) {
    flag = 3;
  }else {
    flag = 4;
  }

  dfs(flag);
}

void dfs(int f) {

  if(f==1) {
    int vx = abs(x[1]-x[0]);
    int vy = abs(y[1]-y[0]);
    cout << x[1]-vy << " " << y[1]+vx << " ";
    cout << x[0]-vy << " " << y[0]+vx << endl;
  }else if(f==2) {
    int vx = abs(x[1]-x[0]);
    int vy = abs(y[1]-y[0]);
    cout << x[1]+vy << " " << y[1]+vx << " ";
    cout << x[0]+vy << " " << y[0]+vx << endl;
  }else if(f==3) {
    int vx = abs(x[1]-x[0]);
    int vy = abs(y[1]-y[0]);
    cout << x[1]-vy << " " << y[1]-vx << " ";
    cout << x[0]-vy << " " << y[0]-vx << endl;
  }else {
    int vx = abs(x[1]-x[0]);
    int vy = abs(y[1]-y[0]);
    cout << x[1]+vy << " " << y[1]-vx << " ";
    cout << x[0]+vy << " " << y[0]-vx << endl;
  }
}


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

using namespace std;

int main()
{
    int N,i,p[150],x;
    long long sum1,sum=10000000007;
    cin>>N;
    for(i=1; i<=N; i++)
        cin>>p[i];
    sort(p+1,p+N+1);
    for(x=p[1]; x<=p[N]; x++)
    {
        sum1=0;
        for(i=1;i<=N;i++)
            sum1+=(p[i]-x)*(p[i]-x);
        if(sum1<sum)
            sum=sum1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10**15
N, M = map(int, input().split())
G = [[]for i in range(N)]
for i in range(1, N):
    G[i].append([i-1, 0])

for i in range(M):
    L, R, C = map(int, input().split())
    G[L-1].append([R-1, C])

S = 0

def dijkstra(N, S):
    d = [INF for i in range(N)]

    que = []
    d[S] = 0
    heapq.heappush(que, [0, S])

    while not(len(que) == 0):
        q = heapq.heappop(que)
        ver = q[1] # ノード
        dis = q[0] # 過去に更新された最短距離

        # vまで2番目に短い距離（最新）　＜　過去最短距離　の時、
        # キューから取り出した過去のものを無視する
        if d[ver] < dis:
            continue

        # 隣接リストに対してループ
        for i in range(len(G[ver])):
            e = G[ver][i]
            if d[e[0]] > d[ver] + e[1]:
                d[e[0]] = d[ver] + e[1]
                heapq.heappush(que, [d[e[0]], e[0]])

    return d[N-1]

ans = dijkstra(N, S)
if ans == INF:
    print(-1)
else:
    print(dijkstra(N, S))

Measured memory_bytes: 104624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    /*int n, k;
    cin >> n >> k;
    long double rui[200100];
    rui[0] = 0;
    bool ok = true;
    ll a[200100];
    rep1(i, n) {
        cin >> a[i];
        rui[i] += rui[i-1] + a[i];
        if(i>1)if(a[i] != a[i - 1]) ok = false;
    }
    if(ok) {
        cout << (rui[1]+1)/2 * k << endl;
        return 0;
    }
    long double ma = -1;
    for(int i = k; i <= n; i++) ma = max(ma, rui[i] - rui[i - k]);
    cout << fixed << setprecision(10) << (ma + k) / 2 << endl;*/
    int n, k;
    cin >> n >> k;
    double a[200100];
    a[0] = 0;
    rep1(i, n) {
        double A;
        cin >> A;
        A = (A+1)/2;
        a[i] = A;
        a[i] += a[i-1];
    }
    double ma = -1;
    rep(i, n - k + 1) ma = max(ma, a[i + k] - a[i]);
    cout << fixed << setprecision(10) << ma << endl;
    return 0;
}

Measured memory_bytes: 5348
N, L = map(int, input().split())
S = []
master = 'abcdefghijklmnopqrstuvwxyz'

def f(s1, s2, l):
    for i in range(l):
        if master.index(s1[i]) == master.index(s2[i]):
            continue
        elif master.index(s1[i]) > master.index(s2[i]):
            return 'greater'
        elif master.index(s1[i]) < master.index(s2[i]):
            return 'less'
    return 'equal'

for _ in range(N):
    if _ == 0:
        S.append(input())
    else:
        s = input()
        max_iter = len(S)
        for i in range(max_iter):
            compared = f(s, S[i], L)
            if compared == 'greater' and i == max_iter-1:
                S.append(s)
                break
            elif compared == 'less':
                S.insert(i, s)
                break
            elif compared == 'equal':
                S.insert(i, s)
                break
            else:
                continue

print(''.join(S))

Measured memory_bytes: 3064
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
#define INF 1 << 30
typedef pair<int, int> P;

int n, d[10000];
vector<P> M[10000];

void dijkstra(void) {
    int i, u, v;
    P t;
    priority_queue<P, vector<P>, greater<P> > pq;

    pq.push(make_pair(0, 0));
    while (!pq.empty()) {
        t = pq.top(); pq.pop();
        v = t.first;
        u = t.second;

        if (d[u] != INF) continue;
        d[u] = v;

        for (i = 0; i < M[u].size(); i++) {
            t = M[u][i];
            if (d[t.second] != INF) continue;
            pq.push(make_pair(v + t.first, t.second));
        }
    }
}

int main(void) {
    int i, j, u, k, v, c;
    scanf("%d", &n);

    for (i = 0; i < n; i++) d[i] = INF;

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d %d", &v, &c);
            M[u].push_back(make_pair(c, v));
        }
    }

    dijkstra();

    for (i = 0; i < n; i++) printf("%d %d\n", i, d[i]);

    return 0;
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll b = 1, n = S.size();
    vector<ll> a(n + 1, 0), c(2019, 0);
    rep(i, n) {
        a[i + 1] = (a[i] + (S[n - 1 - i] - '0') * b) % 2019;
        b = (b * 10) % 2019;
    }
    rep(i, n + 1) {
        c[a[i]]++;
    }
    ll ans = 0;
    rep(i, 2019) {
        ans += c[i] * (c[i] - 1) / 2;
    }
    cout << ans << "\n";
}

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

using namespace std;

int n;

double ans,dp[3000];

int main(){
    cin >> n;
    dp[0] = 1;
    // dp[i] - probability that there are i heads so far
    for(int i = 1; i <= n; i++){
    	double p;
    	cin >> p;
    	for(int j = i; j >= 0; j--){
    		dp[j] = (j == 0 ? 0 : dp[j - 1] * p) + dp[j] * ((double)1 - p);	
    	}
    }
    for(int i = n / 2 + 1; i <= n; i++){
    	ans += dp[i];
    }
    cout << fixed << setprecision(9) << ans;
	return 0;
}

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


int main() {
    string s;
    cin>>s;
    
    int res=0;
    if (s[0]=='R' && s[1]=='R' && s[2]=='R') {
        res =3 ;
    }
    
    for (int i=1; i<s.size(); i++){
        if (s[i]==s[i-1] && s[i]=='R') res = max(res,2);
    }
    
    for (int i=0; i<s.size(); i++){
        if (s[i]=='R') res = max(res,1);
    }
    
    cout<<res;
    
    
    
    return 0;
}

Measured memory_bytes: 3624
a = input()
b = input()
c = input()
x = input()


counter = 0
for aa in range(0,int(a)+1):
    for bb in range(0,int(b)+1):
        for cc in range(0, int(c)+1):
            sumx = 500 * aa + 100 * bb + 50 * cc
            if int(x) == sumx and int(x) % 50 == 0 and 50 <= int(x) <= 20000:
                counter += 1
print(counter)

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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q;

ll gcd(ll i, ll j){
    if(j == 0)return i;
    return gcd(j,i%j);
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e,f;

    ll g;
    cin >> n >> k;
    ll ma = 0;
    for(ll c1 = 0; c1 < n; c1++){
        cin >> a;
        if(c1 == 0){
            g = a;
        }
        else{
            g = gcd(g,a);
        }
        ma = max(ma,a);
    }

    if(k%g == 0 && k <= ma){
        cout << "POSSIBLE\n";
    }
    else{
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int ng=0,ans=0;
    if(a[0]!=0&&n!=1) ng++;
    if(n==1&&a[0]!=0) ng++;
    rep(i,n-1){
        if(a[i]+1<a[i+1]) ng++;
    }
    if(ng>0){
        cout<<-1<<endl;
        return 0;
    }
    rep(i,n-1){
        if(a[i]<a[i+1]){
            a[i]=0;
        }
    }
    rep(i,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	int ans,n=0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		n += s[i]-48;
	}
	if (n % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
int n,m,vis[20];
int Check(int x){
	while(x){
		if(vis[x%10])return 0;
		x/=10;
	}return 1;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=m;i++)vis[read()]=1;
	for(int x=n;;x++)if(Check(x)){cout<<x;return 0;}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = false;

int N, M;
string b[500];
bool cnt[500];
int dp[2][1<<24];

int main() {
	while (cin >> N >> M, N || M) {
		REP(i, N) cin >> b[i];
		REP(i, N) REP(j, M) b[i][j] -= '0';
		if (debug) putchar('@');

		int ans = 0;
		if (M >= 25) { // レシピN <= 25, 全探索
			REP(s, 1<<N) {
				memset(cnt, 0, sizeof(cnt));
				int cur = 0;
				REP(i, N) if (s >> i & 1) {
					cur++;
					REP(j, M) cnt[j] ^= b[i][j];
				}
				bool ng = false;
				REP(i, M) ng |= cnt[i];
				if (!ng) chmax(ans, cur);
			}
		}
		else { // 材料 M <= 24, bitDP

			vector<int> recip;
			REP(i, N) {
				int s = 0;
				REP(j, M) if (b[i][j]) s |= 1<<j;
				recip.push_back(s);
			}

			fill(dp[0], dp[2], -INF);
			dp[0][0] = 0;
			REP(i, N) {
				int cur = i & 1;
				int nex = cur ^ 1;
				REP(j, 1<<M) if (dp[cur][j] != -INF) {
					chmax(dp[nex][j ^ recip[i]], dp[cur][j] + 1);
					chmax(dp[nex][j], dp[cur][j]);
				}
			}
			ans = max(dp[0][0], dp[1][0]);
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 134204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    cout<<s;
    if(s[s.size()-1]=='s') cout<<"e";
    cout<<"s"<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(j,n) for(int i=(int)(j);i<(int)(n);i++)
#define int int64_t
signed main(){
  int ans=0;
  int N,K;
  cin>>N>>K;
  int X=(K-1)*K/2;
  X%=1000000007;
  vector<int> A(N);
  rep(0,N) cin>>A[i];
  rep(0,N){int count=0,sum=0;
           for(int j=0;j<N;j++){if(A.at(j)<A.at(i)){sum++;
                                                    if(j>i)count++;}
                               }
           ans+=count*K;
           ans+=sum*X;
           if(ans>=1000000007) ans%=1000000007;
             }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
s = input()
if len(s)%2==0:
  a = len(s)//2-1
  b = len(s)//2
else:
  a=b=len(s)//2
ans = b
cs = s[b]
while (a>0):
  if s[a] == cs and s[b] == cs:
    ans += 1
    a -= 1
    b += 1
  else:
    break

L = [0]
for i in range(len(s)-1):
  if s[i] != s[i+1]:
    L.append(i + 1)
L.append(len(s))
LL = [0]
for i in range(len(L) - 1):
  LL.append(L[i+1] - L[i])
LL.append(0)
ma = 0
for i in range(len(LL) - 2):
  ma = max(ma,LL[i+1] + min(LL[i], LL[i+2]))

print(max(ma, ans))




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

int main() {
  int n;
  string s,t;
  cin>>n>>s>>t;
  string ans;
  rep(i,n){
    ans=ans+s[i]+t[i];
  }
  cout<<ans;

}


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

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

  // vector<int> h(n);
  // for (int i = 0; i < n; ++i) {
  //   cin >> h.at(i);
  //   h.at(i) = abs(t * 1000 - h.at(i) * 6 - a * 1000);
  // }

  // int minnum = h.at(0);
  // for (int i = 0; i < n; ++i) {
  //   minnum = min(minnum, h.at(i));
  // }
  // for (int i = 0; i < n; ++i) {
  //   if (minnum == h.at(i)) {
  //     cout << i + 1 << endl;
  //     break;
  //   }
  // }

  int iter = 0;
  int cc = 1 << 30;
  for (int i = 0; i < n; ++i) {
    int h;
    cin >> h;
    int c = t * 1000 - h * 6 - a * 1000;
    if (c < 0) c = -c;
    if (cc > c) cc = c, iter = i;
  }
  cout << iter + 1 << endl;
}

Measured memory_bytes: 256
program tap_dance
  implicit none
  character(100) :: s
  integer :: n, i
  read(*,*) s
  n = len_trim(s)
  do i = 1, n
    if ((mod(i,2) == 1 .and. s(i:i) == "L") .or. &
    & (mod(i,2) == 0 .and. s(i:i) == "R")) then
      write(*,'(a)') "No"
      stop
    end if
  end do
  write(*,'(a)') "Yes"
end program tap_dance

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

int main(){
  int A , B , C;
  cin >> A >> B >> C;
  bool can = true;
  if( A == 5 && B == 5 && C == 7 ||
      A == 5 && B == 7 && C == 5 ||
      A == 7 && B == 5 && C == 5 ){
    can = true;
  }else{
    can = false;
  }

  if(can) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}

           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    int c=0;
    for (int i= 1;i<=N;i*=100) {
        if (i*10<=N) c+=  i*9;
        else if(N/i>1) c+=(N/i-1)*i+(N-(N/i)*i+1);
        else c += N-(N/i)*i+1;
    }
    cout << c << "\n";
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

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

    int cnt=0;
    while(true){
        for(int i=0; i<n; i++){
            if(a[i]%2==0) a[i]/=2;
            else goto END;
        }
        cnt++;
    }
    END:;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#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() {
}

long long n, a, b;

bool read() {
  if (scanf("%lld%lld%lld", &n, &a, &b) < 3) {
    return false;
  }
  a--;
  b--;
  return true;
}

void solve() {
  if ((a & 1) == (b & 1)) {
    printf("%lld\n", abs(b - a) / 2);
    return;
  }
  long long res = infll;
  for (int it = 0; it < 2; it++) {
    long long cur = min(a, b);
    long long x = max(a, b) - cur;
    x--;
    cur++;
    cur += x / 2;
    res = min(res, cur);
    a = n - 1 - a;
    b = n - 1 - b;
  }
  printf("%lld\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: 256
x = [int(i) for i in input().split()]
ans1 = x[0]
ans2 = x[1]
if ans1 >= x[2]:
    ans1 -= x[2]
else:
    x[2] -= ans1
    ans1 = 0
    ans2 = max(0,ans2 - x[2])
print(ans1,ans2)

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

const int MAXN = 200200;

long long a[MAXN];
int n;
map<long long, int> app;
long long Lg[50];

signed main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) app[a[i]]++;
	for(int i = 1; i <= 30; i++) Lg[i] = (1 << i);
	long long ans = 0;
	for(int i = n; i; i--) {
		for(int j = 30; j; j--) {
			if(app[a[i]] == 0) break;
			if(Lg[j] == a[i] * 2) {
				if(app[a[i]] >= 2) {
					app[a[i]] -= 2;
					ans++;
					break;
				}
			}
			if(Lg[j] - a[i] > a[i] && app[Lg[j] - a[i]]) {
				app[a[i]] --, ans++, app[Lg[j] - a[i]]--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

string S;
bool f(){
	for(int i=0; i<int(S.length()); i++){
		if(i%2 && S[i]=='R') return false;
		if(!(i%2) && S[i]=='L') return false;
	}
	return true;
}

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

	cin>>S;
	cout<<(f() ? "Yes" : "No")<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> adj(n+1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	vector<bool> vis(n+1,false);
	vector<int> par(n+1,-1);
	
	queue<int> q;
	q.push(1);
 	vis[1]=true;
	par[1]=0;
	while(!q.empty())
	{
		int s=q.front();
		q.pop();
		for(int i=0;i<adj[s].size();i++)
		{
			if(vis[adj[s][i]]==false)
			{
				vis[adj[s][i]]=true;
				par[adj[s][i]]=s;
				q.push(adj[s][i]);
			}
		}
	}
	int flag=true;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==false)
		flag=false;
	}
	if(!flag)
	cout<<"No";
	else
	{
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++)
		cout<<par[i]<<endl;
	}
	
}

Measured memory_bytes: 10128
// ProblemURL : https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	if (n+1)/2 >= k {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int d,a,b,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    cout<<d<<" "<<r<<" ";
    printf("%.9lf\n",f);
    
}



Measured memory_bytes: 3236
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d;
  a--;b--;c--;d--;
  cin>>s;
  if(c<d){
    for(int i=a;i+1<=d;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
  }else{
    for(int i=a;i+1<=c;i++){
      if(s[i]=='#'&&s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b-1;i+1<=d;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	int n; get n;
	int i; get i;

	put n - i + 1;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};
struct Node T[MAX];

int n;

void preorder(int);
void inorder(int);
void postorder(int);

int main()
{
  int id, left, right;
  int i, tmp;
  
  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ) T[i].p = NIL;

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d%d", &id, &left, &right);
    T[id].l = left;
    T[id].r = right;
    if( left != NIL ) T[left].p =id;
    if( right != NIL ) T[right].p = id;
  }

  for( i = 0 ; i < n ; i++ ) if( T[i].p == NIL ) tmp = i;

  printf("Preorder\n");
  preorder(tmp);
  printf("\nInorder\n");
  inorder(tmp);
  printf("\nPostorder\n");
  postorder(tmp);
  printf("\n");
  
  return 0;
}

void preorder(int u)
{
  if( u == NIL ) return;
  printf(" %d", u);
  preorder(T[u].l);
  preorder(T[u].r);
}

void inorder(int u)
{
  if( u == NIL ) return;
  inorder(T[u].l);
  printf(" %d", u);
  inorder(T[u].r);
}

void postorder(int u)
{
  if( u == NIL ) return;
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d", u);
}

Measured memory_bytes: 620
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;

int n, x, t;

int main() {
    cin >> n >> x >> t;
    int ans = ceil((double)n/x) * t;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    if(n==3){
        cout<<2<<' '<<5<<' '<<63<<endl;
        return 0;
    }
    if(n==4){
        cout<<2<<' '<<5<<' '<<20<<' '<<63<<endl;
        return 0;
    }
    ll c2=8,c3=15,c6=12;
    cout<<2<<' '<<4<<' '<<6<<' '<<3<<' '<<9<<' ';
    n-=5;
    while(n&&c2<=30000){
        if(n>=2){
            n-=2;
            cout<<c2<<' '<<c2+2<<' ';
            c2+=6;
        }else{
            break;
        }
    }
    while(n&&c3<=30000){
        if(n>=2){
            n-=2;
            cout<<c3<<' '<<c3+6<<' ';
            c3+=12;
        }else{
            break;
        }
    }
    while(n){
        cout<<c6<<' ';
        n--;
        c6+=6;
    }
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  ll t=(n-m+19*m)*100;
  rep(i,0,m)t*=2;
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] sumA = new long[N+1];
		long[] sumB = new long[N+1];
		long countA = 0,countB = 0;
		for( int i=1; i<=N; i++ ){
			long a = sc.nextLong();
			sumA[i] = a + sumA[i-1];
			sumB[i] = a + sumB[i-1];
			if( sumA[i]<=0 && i%2!=0 ){
				countA += 1 - sumA[i];
				sumA[i] += 1 - sumA[i];
			}
			if( sumA[i]>=0 && i%2==0 ){
				countA += sumA[i] + 1;
				sumA[i] += (-1) - sumA[i];
			}
			if( sumB[i]<=0 && i%2==0 ){
				countB += 1 - sumB[i];
				sumB[i] += 1 - sumB[i];
			}
			if( sumB[i]>=0 && i%2!=0 ){
				countB += sumB[i] + 1;
				sumB[i] += (-1) - sumB[i];
			}
		}
		System.out.println(Math.min(countA,countB));
	}
}


Measured memory_bytes: 50940
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int A;
    int B;
    
    cin >> A;
    cin >> B;
    if(A>8) cout << ":(";
    else if(B>8) cout << ":(";
    else cout << "Yay!";

    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >>c;
  if (a==b && b==c){
    cout << 1 << endl;
  }
  else if (a==b || a==c || b==c){
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

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

  int A = 0;
  for (int i = 0; i < N - 1; i++) {
    A += vec.at(i);
  }

  if (vec.at(N - 1) < A) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def solve(A, B, n):
    if n == 1:
        return max(A, B)
    else:
        n -= 1
        h, l = max(A, B), min(A, B)
        return h + solve(h-1, l, n)

A, B = map(int, input().split())
print(solve(A, B, 2))

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

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		tList.ForEach(t =>
		{
			if(sList.BinarySearch(t) > -1) count++;
		});
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r=in();
    int D=in();
    int x2000=in();
    REP(i,10){
        
        x2000=r*x2000-D;
        cout<<x2000<<endl;
    }
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int H, W;
    cin >> H >> W;

    int a[H][W];
    rep(i, H) {
        rep(j, W) {
            char tmp;
            cin >> tmp;
            if (tmp == '#') a[i][j] = 1;
            else a[i][j] = 0;
        }
    }

    rep(i, H) {
        int cnt = 0;
        rep(j, W) {
            if (a[i][j] == 0 || a[i][j] == -1) {
                cnt++;
            }
        }
        if (cnt == W) {
            rep(j, W) {
                a[i][j] = -1;
            }
        }
    }

    rep(i, W) {
        int cnt = 0;
        rep(j, H) {
            if (a[j][i] == 0 || a[j][i] == -1) {
                cnt++;
            }
        }
        if (cnt == H) {
            rep(j, H) {
                a[j][i] = -1;
            }
        }
    }

    rep(i, H) {
        int cnt = 0;
        rep(j, W) {
            if (a[i][j] == -1) continue;
            else if (a[i][j] == 0) {
                cout << ".";
                cnt++;
            }
            else {
                cout << "#";
                cnt++;
            }
        }
        if (cnt != 0) cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int, input().split())
b=list(map(int, input().split()))
tmp=0
cnt=0
a_i=[]
for _ in range(n):
    a=list(map(int, input().split()))
    tmp=0
    for i in range(m):
       
        tmp+=int(a[i])*int(b[i])
    
    if tmp+c>0:
        cnt+=1
        
print(cnt)

Measured memory_bytes: 3064
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var x = Enumerable.Range(1, n).FirstOrDefault(i => (int)(1.08 * i) == n);
		Console.WriteLine(x > 0 ? $"{x}" : ":(");
	}
}


Measured memory_bytes: 13268
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    if(a+b>=a*b && a+b>=a-b){
      System.out.println(a+b);
    }else if(a-b>=a+b && a-b>=a*b){
      System.out.println(a-b);
    }else if(a*b>=a+b && a*b>=a-b){
      System.out.println(a*b);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> a(n);

    a[0] = 1;
    for (int i = 1; i < n; i++) {
        if (p[i] > p[i-1]) a[i] = a[i-1] + 1;
        else a[i] = 1;
    }

    bool flag = 0;
    if (a[k-1] == k) flag = 1;

    set<int> s;
    int ans = 1;

    rep(i, k) s.insert(p[i]);
    for (int i = k; i < n; i++) {
        s.insert(p[i]);
        if (a[i] >= k) {
            if (!flag) ans++;
            flag = 1;
        } else if (*s.begin() != p[i-k] || *s.rbegin() != p[i]) ans++;
        s.erase(p[i-k]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
using namespace std;
  
class UF {
public:
    vector<int> xs;
    vector<int> ys;
    int gid;
    UF(int n) : xs(n,0), ys(), gid(0) { ys.push_back(0); }
    int get(int p) {
        int gp = xs[p];
        while (gp != ys[gp]) gp=ys[gp];
        return xs[p]=gp;
    }
    int newid() {
        gid++; ys.push_back(gid); return gid;
    }
    int add(int a) {
        int ga = get(a);
        if (ga == 0) {
            ga=newid();
            xs[a]=ga;
        }
        return ga;
    }
    void unite(int a, int b) {
        int ga = get(a);
        int gb = get(b);
        if (ga == 0 && gb == 0) { ga=gb=newid(); }
        else if (ga==0) { ga=gb; }
        else if (gb==0) { gb=ga; }
        else if (ga<gb) { ys[gb]=ga; gb=ga; }
        else { ys[ga]=gb; ga=gb; }
        xs[a]=xs[b]=ga;
    }
};
  
int main() {
int n, q;cin>>n>>q;
UF uf(n);
while(q--) {
int c,x,y;cin>>c>>x>>y;
if(c==0){uf.unite(x,y);}
else{int ga=uf.get(x);int gb=uf.get(y);
cout <<((ga==0||gb==0||ga!=gb)?0:1)<<endl;
}
}
  
return 0;}


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

int main(){
  string s;
  cin >> s;
  int ans=1;
  ans*=(s.at(0)=='A');
  int x=0;
  int y;
  for(int i=2;i<s.size()-1;i++){
    if(s.at(i)=='C') {x++; y=i;}
  }
  ans*=(x==1);
  for(int i=1;i<s.size();i++){
    int a=s.at(i);
    if(i!=y) ans*=(a>96);
  }
  
  if(ans) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
gets
N = gets.split.map(&:to_i)
counter = 0
(1..(N.count - 2)).each do |i|
  if N[i - 1] < N[i] && N[i] < N[i + 1]
    counter += 1
  elsif N[i - 1] > N[i] && N[i] > N[i + 1]
    counter += 1
  end
end
puts counter

Measured memory_bytes: 1788
import bisect
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
 
res = 0
for i in range(n - 1 , -1, -1):
    if a[i] == int(a[i]):#判定
        b = 1
        while b <= a[i]:
            b =b*2
 
        j = bisect.bisect_left(a, b - a[i])
        if i > j:
            if b - a[i] == a[j]:
                res += 1
                a[j] = a[j] - 0.5
                a[i] = a[i] + 0.5
print(res)

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans <= (a - b)) ans = a - b;
	if (ans <= a * b) ans = a * b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
require 'prime'

n = gets.to_i

# substraction only or `n` itself
m = Prime.prime_division(n-1).inject(1) { |z,(x,y)| z * (y+1) }

a = Prime.prime_division(n)

def f(ary, z, &block)
  return yield(z) if ary.empty?
  
  ary = ary.dup
  x, y = ary.pop
  (0..y).each do |i|
    f(ary, z * x**i, &block)
  end
end

f(a, 1) do |z|
  next if z <= 1 || z * z > n
  
  s, t = n, 0
  s, t = s.divmod(z) while t == 0
  
  m += 1 if t == 1
end

p m

load __FILE__ unless $stdin.eof?


Measured memory_bytes: 2300
from sys import stdin, stdout
from time import perf_counter

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

# import sys
# sys.stdout = open("e:/cp/output.txt","w")
# sys.stdin = open("e:/cp/input.txt","r")

n,l = map(int,input().split())
a = [input() for item in range(n)]
b = sorted(a)
print(''.join(b))

Measured memory_bytes: 9128
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 1000000000
#define MOD 1000000007
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
inline ll power(ll a,ll b){ll ans=1;while(b){if(b&1){ans=ans*a%MOD;--b;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	#ifdef zincsabian
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
	int n=read(),a[100005],ans=0;a[0]=0;a[n+1]=0;
	for(int i=1;i<=n;i++){
		a[i]=read();ans+=abs(a[i]-a[i-1]);
	}ans+=abs(a[n+1]-a[n]);
	for(int i=1;i<=n;i++){
		cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1])<<"\n";
	}
//	int a=read(),b=read();
//	cout<<"100 "<<"100 \n";
	 
}


Measured memory_bytes: 1664
n = int(input())
p = [int(input()) for _ in range(n)]

d = {pi: i for i, pi in enumerate(p)}
idx = -1
count = 0
ma = 0

for i in range(1, n+1):
    if d[i] > idx:
        count += 1
        idx = d[i]
    else:
        ma = max(ma, count)
        idx = d[i]
        count = 1

ma = max(ma, count)
print(n - ma)



Measured memory_bytes: 35100
#include<iostream>
#include<fstream>
#include<vector>
#include <cmath>
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  long N;
  cin>>N;
  
  double T = sqrt(N);
  //cout<<T<<endl;
  //cout<<(int)T<<endl;

  for(int i=(int)T;i>0;i--){
    //cout<<i<<endl;
    if(N%i==0){
      cout<<i+(N/i)-2<<endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        int total = 0;
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            s[i] = num;
            total += num;
        }
        Arrays.sort(s);
        if(total % 10 != 0) {
            System.out.println(total);
            return;
        }
        for(int i = 0; i < n; i ++) {
            if(s[i] % 10 != 0) {
                System.out.println(total - s[i]);
                return;
            }
        }
        System.out.println(0);
    }
}

Measured memory_bytes: 22868