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

using namespace std;

const int Nmax = 3005;
typedef long long ll;

int n, Mod, comb[Nmax][Nmax], s[Nmax][Nmax], i, j, nr, ans, pw[Nmax*Nmax], pw_pw[Nmax];

int add(int x, int y) { x+=y; return (x<Mod ? x : x-Mod); }
void add_to(int &x, int y) { x+=y; if(x>=Mod) x -= Mod; }
int inm(int x, int y) { return (ll) x*y%Mod; }

int power(int x, int y, int Mod)
{
    int ans = 1;
    while(y)
    {
        if(y&1) ans = (ll)ans*x%Mod;
        x= (ll)x*x%Mod; y >>= 1;
    }
    return ans;
}

int ways(int k)
{
    int i, ans = 0;
    for(i=0; i<=k; ++i)
        add_to( ans, inm( s[k][i], pw[(n-k) * i] ) );

    ans = inm(ans, pw_pw[n-k]);
    return ans;
}

int main()
{
 //   freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> Mod;

    for(i=0; i<=n; ++i) pw_pw[i] = power(2, power(2, i, Mod-1), Mod);

    pw[0] = 1;
    for(i=1; i<=n*n; ++i) pw[i] = inm(2, pw[i-1]);

    comb[0][0] = 1;
    for(i=1; i<=n; ++i)
        for(j=0; j<=i; ++j)
            comb[i][j] = add(comb[i-1][j], (j ? comb[i-1][j-1] : 0));

    /// modified stirling: every number belongs to at most one subset

    for(i=0; i<=n; ++i)
    {
        s[i][0] = 1;
        for(j=1; j<=i; ++j)
            s[i][j] = add( s[i-1][j-1], inm(j+1, s[i-1][j]) );
    }

    for(i=0; i<=n; ++i) /// at most once
    {
        nr = inm(comb[n][i], ways(i));
        if(i&1) add_to(ans, Mod-nr);
            else add_to(ans, nr);
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 106112
#include <stdio.h>

int main(void) {
	int N;
	int asumi, iguti;
	if (scanf("%d", &N) != 1) return 1;
	for (asumi = 1;  asumi <= 9; asumi++) {
		for (iguti = 1; iguti <= 9; iguti++) {
			if (asumi * iguti == N) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


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

const int INF = 1e+6;

int N,A,B,C;
vector<int> l;

// x これまでに何本使ったか
int dfs(int x, int a, int b, int c ){
    if ( x == N ) {
        if ( min(a,min(b,c)) == 0 ) return INF;
        else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
    }
    int ans0 = dfs(x+1,a,b,c);
    int ans1 = dfs(x+1,a+l[x],b,c) + 10;
    int ans2 = dfs(x+1,a,b+l[x],c) + 10;
    int ans3 = dfs(x+1,a,b,c+l[x]) + 10;
    return min(min(ans0,ans1),min(ans2,ans3));
}

int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    for ( int i = 0; i < N; ++i){
        cin >> l[i];
    }
    
    cout << dfs(0,0,0,0) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
 
using namespace std;
 
int main() {
  int x, y; cin >> x >> y;
  for (int i = 0; i < 100; i++) {
  	for (int j = 0; j < 100; j++) {
      if (i + j == x && 2 * i + 4 * j == y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main() {
    int N;
    vector<int> X; 
    cin >> N;
    for(int i=0;i<N;i++) { int tmp; cin >> tmp; X.push_back(tmp); } 

    int m=0;
    for( auto x: X ) {
        m = max(x, m);
    }

    int v;
    for(int p=0;p<=m;p++) {
        int k=0;
        for( auto x: X ) {
            k += (x-p)*(x-p);
        }
        if( p== 0 ) v = k; else v = min(v, k);
    }
    cout << v;
    return 0;
}

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

int solve() {
  int N; cin >> N;
  if(N == 0) return 1;

  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());

  if(A[0] < 2) {
    cout << "NA" << endl;
    return 0;
  }
  else {
    int ans = 1;
    for(int i=0; i<N; i++) {
      if(A[i] > 0) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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



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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int cnt_g=0, cnt_p=0;
    int ans=0;
    int check=1e9;
    rep(i,n){
        if(s[i]=='g') cnt_g++;
        else cnt_p++;
        if(cnt_g-cnt_p>=n-1-i){
            check=i+1;
            break;
        }
    }

    for(int i=check;i<n;i++){
        if(s[i]=='g') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main  {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		//int n = sc.nextInt();
		//int k = sc.nextInt();
		//String[] array = new String[h+1];
		List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();

		String x="";
		String y="";
		int count1=0;
		int count2=0;

		for(int i=0;4>i;i++) {
			if(i==0) {
			x=list.get(i);
			}
			else {
				if(x.equals(list.get(i))) {
					count1++;
				}
				else if(y.equals(list.get(i))) {
					count2++;
				}
				else {
					y=list.get(i);
				}
			}
			//System.out.println(x);
			//System.out.println(y);
		}
		if(count1==1&&count2==1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

		}

}



Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 1; i <= n; i++) {
			int x1=i/10;
			int x2=i/100;
			int x3=i/1000;
			if (i % 3 == 0||i%10==3||x1%10==3||x2%10==3||x3%10==3) {
				System.out.printf(" " + i);
			}
		}
		System.out.print("\n");
		scanner.close();

	}
}


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

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }
const long long LINF = 1e18;

const int VMAX = 100100;

int main()
{
  ll N, W; cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> dp(N+1, vector<ll>(VMAX));
  for (int i = 0; i < N+1; ++i) {
    for (int j = 0; j < VMAX; ++j) {
      dp[i][j] = LINF;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < VMAX; ++j) {
      if (j - v[i] >= 0) {
        chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      }

      chmin(dp[i+1][j], dp[i][j]);
    }
  }

  ll res = 0;
  for (int i = 0; i < VMAX; ++i) {
    if (dp[N][i] <= W) {
      res = i;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 80256
from math import gcd

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')


Measured memory_bytes: 209656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println((n % 1000) == 0 ? 0 : 1000 - (n % 1000));
		sc.close();
	}

}

Measured memory_bytes: 35920
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint n, a, b;
  cin >> n >> a >> b;
  lint cnt  = n / (a + b);
  lint left = n % (a + b);
  cout << a * cnt + min(a, left) << endl;
  return 0;
}

Measured memory_bytes: 256
m,k=map(int,input().split())
if 2**m<=k or m*k==1:
    print(-1)
elif m==1 and k==0:
    print("0 0 1 1")
else:
    ans=[-1 for i in range(2**(m+1))]
    sta=2**m-1
    cnt=0
    for i in range(1,2**m):
        if cnt==k:
            cnt+=1
        ans[sta+i]=cnt
        ans[sta-i]=cnt
        cnt+=1
    ans[sta]=k
    ans[-1]=k
    
    print(" ".join([str(i) for i in ans]))
    
        

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	long long int ans = 1;
	const long long lim = 1e18;
	vector<long long> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	if (*min_element(begin(v), end(v)) == 0) {
		cout << 0 << '\n';
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		if (v[i] > lim/ans) {cout << -1 << '\n'; return 0;}
		ans *= v[i];
		if (ans == 0) break;
	}
	cout << ans;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int H, N;
    cin >> H >> N;
    vector<vector<int>>dp(N+1, vector<int>(H+1, pow(10,9)));
    vector<int>As(N);
    vector<int>Bs(N);
    
    for (int i=0; i<N; i++){
        int ai, bi;
        cin >> ai >> bi;
        As[i] = ai;
        Bs[i] = bi;
    }

    dp[0][0] = 0;

    for (int i=0; i<N; i++){
        for (int j=0; j<=H; j++){
            int ai, bi;
            ai = As[i];
            bi = Bs[i];
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+As[i], H)], dp[i+1][j] + Bs[i]);
            }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 39424
a, b, c, d = map(int, input().split())

l = [a*c, a*d, b*c, b*d]

if a <= 0 <= b:
    l.append(c*0)
    l.append(d*0)
if c <= 0 <= d:
    l.append(a*0)
    l.append(b*0)
print(max(l))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	char ch;
	for (int i = 0; i < N; i++) {
		cin >> ch;
		if (ch == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h = gi();
    int a = gi();
    printf("%d\n", (h+a-1)/a);

    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
db = [[0]*N for _ in range(20)]
db[0] =  [i+1 if S[i]=='R' else i-1 for i in range(N)]
for i in range(1,20):
  for j in range(N):
    db[i][j] = db[i-1][db[i-1][j]]
ans = [0]*N
for i in range(N):
  K = 10**5
  p = 0
  pos = i
  while K:
    if K%2:
      pos = db[p][pos]
    p += 1
    K >>= 1
  ans[pos] += 1
print(*ans)

Measured memory_bytes: 95860
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double L = sc.nextDouble();
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double C = sc.nextDouble();
		double D = sc.nextDouble();
		int finA = (int)Math.ceil(A/C);
		int finB = (int)Math.ceil(B/D);
		if(finA > finB){
			System.out.println((int)L-finA);
		}else{
			System.out.println((int)L-finB);
		}
	}
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

signed main()
{
    int W, H, N;
    cin >> W >> H >> N;
    bool TABLE[H + 1][W + 1];
    rep(i, H + 1)
    {
        rep(j, W + 1)
        {
            TABLE[i][j] = true;
        }
    }
    rep(t, N)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
        {
            for (int i = 1; i <= H; i++)
            {
                for (int j = 1; j <= x; j++)
                {
                    TABLE[i][j] = false;
                }
            }
        }
        else if (a == 2)
        {
            for (int i = 1; i <= H; i++)
            {
                for (int j = x + 1; j <= W; j++)
                {
                    TABLE[i][j] = false;
                }
            }
        }
        else if (a == 3)
        {
            for (int i = 1; i <= y; i++)
            {
                for (int j = 1; j <= W; j++)
                {
                    TABLE[i][j] = false;
                }
            }
        }
        else
        {
            for (int i = y + 1; i <= H; i++)
            {
                for (int j = 1; j <= W; j++)
                {
                    TABLE[i][j] = false;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {

            if (TABLE[i][j])
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);

    List<String> list = new ArrayList<String>();

    list.add("Sunny");
    list.add("Cloudy");
    list.add("Rainy");

    int index = list.indexOf(sc.next());
    System.out.println(list.get( index + 1 >= list.size() ? 0 : index + 1 ));
  }
}


Measured memory_bytes: 21844
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, way[N];
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> s;
	vector < int > g;
	for(int i = 0; i <= n; i++){
		if(s[i] == '0')g.push_back(i);
	}
	for(int i = 1, j = 0; i <= n; i++){
		if(s[i] == '1')continue;
		while(j < g.size() && g[j] < i - m)j++;
		if(j == g.size() || g[j] >= i){
			cout << "-1\n";
			return 0;
		}
		way[i] = g[j];
	}
	vector < int > inds;
	for(int i = n; i >= 1; i = way[i]){
		inds.push_back(i);
	}inds.push_back(0);
	reverse(inds.begin(), inds.end());
	for(int i = 1; i < inds.size(); i++){
		cout << inds[i] - inds[i - 1] << ' ';
	}
}

Measured memory_bytes: 1864
n=int(input())
l=list(map(int,input().split()))
count=0
suml=sum(l)
i=0
while count<suml/2:
    count+=l[i]
    i+=1
k=suml/2
a=l[i-1]
if count==k:
    print(0)
else:
    print(int(2*(min(count-k,a-count+k))))
    

Measured memory_bytes: 87760
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	string s;
	int num = 0;
	cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == '0')num++;
	}
	int x = s.length();
	cout << 2 * min(num, x - num) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
int niz[3005];
ll dp[3005][3005];
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;
 
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
        dp[i][i] = niz[i];
        if(n%2 == 0) dp[i][i] = -dp[i][i];
    }
    for(int len=2; len<=n; len++){
        for(int l=1; l+len-1<=n; l++){
            int r = l+len-1;
            if((n-len)%2 == 0){
                dp[l][r] = max(niz[l] + dp[l+1][r], niz[r] + dp[l][r-1]);
            }
            else{
                dp[l][r] = min(-niz[l] + dp[l+1][r], -niz[r] + dp[l][r-1]);
            }
        }
    }
    cout << dp[1][n];
    return 0;
}

Measured memory_bytes: 49808
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        x: usize,
        m: usize,
    }
    let mut map = BTreeMap::new();
    let mut vec = vec![0; m];

    let mut a = x;
    vec[0] = x;
    map.insert(a, 0);
    let mut val = None;
    for i in 1..m + 1 {
        a = a * a % m;
        if let Some(&j) = map.get(&a) {
            val = Some((j, i));
            break;
        }
        vec[i] = a;
        map.insert(a, i);
    }

    let (l, r) = val.unwrap();
    let begin = vec.iter().take(l).sum::<usize>();
    let sum = vec.iter().skip(l).take(r - l).sum::<usize>();

    if n <= l {
        println!("{}", vec.iter().take(n).sum::<usize>());
    } else {
        let rem = n - l;
        println!(
            "{}",
            begin + sum * (rem / (r - l)) + vec.iter().skip(l).take(rem % (r - l)).sum::<usize>()
        );
    }
}


Measured memory_bytes: 3828
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*200001
for i in a:
    cnt[i] += 1
ans = 0
for i in range(200001):
    if cnt[i] <= 1: continue
    else: 
        ans += cnt[i]*(cnt[i]-1)//2
for i in range(n):
    print(ans-cnt[a[i]]+1)


Measured memory_bytes: 81612
N,K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7
ans = 0
for i in range(N):
    for j in range(i,N):
        if A[i]<A[j]:
            ans = (ans + K*(K-1)//2)%MOD
        if A[i]>A[j]:
            ans = (ans + K*(K+1)//2)%MOD
print(ans)


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

int main()
{
 
	char text[4];

	scanf("%s", text);
	if (strcmp(text, "SUN") == 0) {
		printf("7");
	}
	else if (strcmp(text, "MON") == 0) {
		printf("6");
	}
	else if (strcmp(text, "TUE") == 0) {
		printf("5");
	}
	else if (strcmp(text, "WED") == 0) {
		printf("4");
	}
	else if (strcmp(text, "THU") == 0) {
		printf("3");
	}
	else if (strcmp(text, "FRI") == 0) {
		printf("2");
	}
	else if (strcmp(text, "SAT") == 0) {
		printf("1");
	}
	else {
		printf("-");
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int r=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}

int dp[201][201];
int main(){
	for(int i=0; i<201; ++i){
		for(int j=0; j<201; ++j){
			dp[i][j]=-1;
		}
	}
	int D,N;
	cin >> D >> N;
	vector<int> tmp(D+1);
	for(int i=1; i<=D; ++i){
		cin >> tmp[i];
	}
	vector<int> c1(N);
	vector<int> c2(N);
	vector<int> c3(N);
	for(int i=0; i<N; ++i){
		cin >> c1[i] >> c2[i] >> c3[i];
	}
	for(int i=0; i<N; ++i){
		for(int j=0; j<N; ++j){
			if(c1[i]<=tmp[1]&&tmp[1]<=c2[i]&&c1[j]<=tmp[2]&&tmp[2]<=c2[j]){
				dp[2][j]=max(dp[2][j],abs(c3[i]-c3[j]));
			}
		}
	}
	for(int i=3; i<=D; ++i){
		for(int j=0; j<N; ++j){
			if(c1[j]<=tmp[i]&&tmp[i]<=c2[j]){
				int tmp=0;
				for(int k=0; k<N; ++k){
					if(dp[i-1][k]!=-1){
						tmp=max(tmp,dp[i-1][k]+abs(c3[j]-c3[k]));
					}
				}
				dp[i][j]=tmp;
			}
		}
	}
	int ans=0;
	for(int i=0; i<N; ++i){
		ans=max(ans,dp[D][i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1356
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		sc.close();
		String ans = "";
		if(a.length > b.length) {
			ans = "GREATER";
		} else if(a.length < b.length) {
			ans = "LESS";
		} else {
			int d = 0;
			ans = "EQUAL";
			for (i = 0; i < a.length; i++) {
				if(a[i] > b[i]) {
					ans = "GREATER";
					break;
				} else if(a[i] < b[i]) {
					ans = "LESS";
					break;
				}
			}
		}
		out.println(ans);
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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


    int n; string s;
    cin >> n >> s;

    n %= 26;

    for (int i=0; i<s.size(); i++) {
        char c = s[i];
        for (int j=0; j<n; j++) {
            if (c == 'Z') c = 'A';
            else c++;
        }
        s[i] = c;
    }

    cout << s;

    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    const int MOD = 1e9 + 7;

    int Count(string S, int K, int R) {
        vector<int> ret(K, 0);
        int n = S.size();
        if (S[0] == '?') {
            for (int i = 0; i <= 9; i++) {
                ret[i % K]++;
            }
        }
        else {
            ret[(S[0] - '0') % K]++;
        }
        for (int i = 1; i < n; i++) {
            vector<int> newRet(K, 0);
            if (S[i] == '?') {
                for (int o = 0; o <= 9; o++) {
                    for (int j = 0; j < K; j++) {
                        newRet[(j * 10 + o) % K] += ret[j];
                        newRet[(j * 10 + o) % K] %= MOD;
                    }
                }
            }
            else {
                int offset = S[i] - '0';
                for (int j = 0; j < K; j++) {
                    newRet[(j * 10 + offset) % K] += ret[j];
                    newRet[(j * 10 + offset) % K] %= MOD;
                }
            }
            ret = newRet;
        }
        return ret[R];
    }
};


int main() {
    string S;
    cin >> S;
    Solution Sol;
    cout << Sol.Count(S, 13, 5) << endl;
}


Measured memory_bytes: 512
/*
    written by Pankaj Kumar.
    country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>mi;
typedef map<ll,ll> ml;
typedef set<string> ss;
typedef set<char>sc;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1e9+7LL
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define Endl "\n"
// loops
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
#define loop0(num) for(ll i=0;i<ll(num);i++)
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
// Some print
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define cc ll test;cin>>test;while(test--)
// sort
#define all(V) (V).begin(),(V).end()
#define srt(V) sort(all(V))
#define srtGreat(V) sort(all(V),greater<ll>())
// function

ll power(ll x,   ll y, ll p)  
{  
    ll res = 1;      
    x = x % p;             
    while (y > 0)  
    {    
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
/* ascii value 
A=65,Z=90,a=97,z=122 1=49
*/
/*  -----------------------------------------------------------------------------------*/
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);



int main()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll count=0;
    while(n>0)
    {
        if(n<=0)
            break;
        n=n-x;
        count+=t;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        Console.WriteLine(input<1200?"ABC":input<2800?"ARC":"AGC");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

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

if a > 0:
    ans = 'Positive'
elif a <= 0 <= b:
    ans = 'Zero'
else:
    neg = b - a + 1
    if neg % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
 
using namespace std;
int main()
{
  	long long h1, m1, h2, m2, k, ans;
  	cin >>  h1 >> m1 >> h2 >> m2 >> k;
    ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
N = int(input())
A = [0]*N
S = 0
for i,a in enumerate(input().split()):
  S += int(a)
  A[i] = S

answer = S

# index は最後に回収する番号で管理
B = 0
D = 2

for C in range(1,N-2):
  D = max(D,C+1)
  SB = A[B]
  SC = A[C] - A[B]
  SD = A[D] - A[C]
  SE = S - A[D]
  left_score = abs(SB - SC)
  # BCの境界の調整
  while True:
    B_ = B+1
    SB_ = A[B_]
    SC_ = A[C] - SB_
    x = abs(SB_ - SC_)
    if left_score > x:
      B,SB,SC,left_score = B_,SB_,SC_,x
      continue
    break
  right_score = abs(SD-SE)
  # DEの境界の調整
  while True:
    D_ = D+1
    SD_ = A[D_] - A[C]
    SE_ = S - A[D_]
    x = abs(SD_ - SE_)
    if right_score > x:
      D,SD,SE,right_score = D_,SD_,SE_,x
      continue
    break
  score = max(SB,SC,SD,SE) - min(SB,SC,SD,SE)
  answer = min(answer,score)
  
print(answer)
    

Measured memory_bytes: 27340
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
int n , d ; 
const double EPS = 1e-6 ; 
bool check(vector<int> &v1,vector<int> &v2 ){
	int ans = 0 ; 
	for(int i=0;i<d;i++){
		ans += (v2[i]-v1[i])*(v2[i]-v1[i]);
	}
	double c = sqrt(ans); 
	if ( c - (int) c < EPS) return true ; 
	return false ;
}

int main(){
    fastio
    cin >> n >> d ; 
    vector<vector<int> > v(n,vector<int>(d));
    for(int i=0;i<n;i++){
    	for(int j=0;j<d;j++){
    		cin >> v[i][j];
    	}
    }
    int ans = 0 ; 
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
    		if ( check(v[i],v[j]) ) ans++ ; 
    	}
    }
    cout << ans << 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)

const string YES = "Yes";
const string NO = "No";

bool check(const string& S, ll start, ll end){
    const ll n = end - start;
    for(ll i = 0; i < n; ++i){
        if(S.at(start + i) != S.at(end - 1 - i)){
            return false;
        }
    }
    return true;
}

void solve(std::string S){
    const ll n = S.size();
    if(!check(S, 0, n)){
        cout << NO << endl;
        return;
    }

    if(!check(S, 0, (n - 1) / 2)){
        cout << NO << endl;
        return;
    }

    if(!check(S, (n + 3) / 2 - 1, n)){
        cout << NO << endl;
        return;
    }

    cout << YES << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

typedef long long ll;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int a = H1 * 60 + M1, b = H2 * 60 + M2;
    cout << b - a - K << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    if(K >= A){
        cout << 0 << " " << max(0ll,B - (K - A) )<< endl;
    }else{
        cout << A - K << " " << B << endl;
    }

}


Measured memory_bytes: 256
while True:
    try:
        S = list(input())
        dic = {c:S.count(c) for c in set(S)}
        
        if len(dic.keys()) != 2:
            print("No")
        else:
            for cnt in dic.values():
                if cnt != 2:
                    print("No")
                    break
            else:
                print("Yes")
    except:
        break

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for (ll m = 0; m < N; m++) {
        if (C * (N - 1 - m) - D * m <= B - A && B - A <= -C * m + (N - 1 - m) * D) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void EducationalDP_A()
{
	int N;
	cin >> N;
	vector<int> h(N + 1);
	for (int i = 0; i < N; ++i)
	{
		cin >> h[i+1];
	}

	vector<int> dp(N + 1);
	dp[2] = abs(h[2] - h[1]);

	for (int i = 3; i <= N; ++i)
	{
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N] << endl;
}

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

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x,count=0,j;
  int stack[100];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      stack[count-2]=stack[count-2]+stack[count-1];
      count=count-2;
    } else if ( s[0] == '-' ){
      stack[count-2]=stack[count-2]-stack[count-1];
      count=count-2;
    } else if ( s[0] == '*' ){
      stack[count-2]=stack[count-2]*stack[count-1];
      count=count-2;
    } else {
      stack[count]=atoi(s);
    }
    //printf("%d",stack[count]);
    count++;  
 }
  printf("%d\n",stack[0]);
  return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s;

bool atgc(char b){
  if(b=='A'||b=='T'||b=='C'||b=='G') return true;
  return false;
}

bool atgcs(string s){
  rep(i,s.length()){
    if(!atgc(s[i])) return false;
  }
  return true;
}

int main(){
  cin >> s;
  int len=0;
  rep(i,s.length()){
    for(int j=i;j<(int)s.length();j++){
      if(atgcs(s.substr(i,j-i+1))){
        chmax(len,j-i+1);
      }
    } 
  }
  cout << len << endl;

  return 0;
}


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

int main(){
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    for(int i = 1; i <= n; i++){
        int ai;
        cin >> ai;
        a[i] = a[i-1] + ai;
    }
    for(int i = 1; i <= m; i++){
        int bi;
        cin >> bi;
        b[i] = b[i-1] + bi;
    }

    int ans = 0;
    for(int i = 0; i <= n; i++){
        if(a[i] > k) break;
        int ng = -1;
        int ok = (int)b.size();

        while(abs(ok-ng) > 1){
            int mid = (ok + ng)/2;
            if(b[mid] > k - a[i]) ok = mid;
            else ng = mid;
        }
        ans = max(ans, i + ok - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	vector<int> sum(n+1);
	rep(i,n)sum[i+1] = sum[i] + a[i];
	int ret = 0;
	int now = 0;
	for(int i = 1;i <= n;i++){
		// -+-+-+
		int tmp = sum[i] + now;
		if(i%2){
			//-1
			int sa = max(0ll,tmp+1);
			ret += sa;
			now -= sa;
		}
		else{
			//1
			int sa = max(0ll,1-tmp);
			ret += sa;
			now += sa;
		}
	}
	int ans = ret;
	now = 0;
	ret = 0;
	// trace(sum);
	for(int i = 1;i <= n;i++){
		// +-+0
		int tmp = sum[i] + now;
		if(i%2 == 0){
			//-1
			int sa = max(0ll,tmp+1);
			ret += sa;
			now -= sa;
		}
		else{
			//1
			int sa = max(0ll,1-tmp);
			ret += sa;
			now += sa;
		}
		// trace(i,now,tmp,ret);
	}
	
	cout << min(ans,ret) << endl;

	return 0;
}

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

int n,ans=1,i,k;
int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		if(k<=ans)ans+=k;
		if(ans<k)ans+=ans;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int C = sc.nextInt();
    	int[] B = new int[M];
    	for(int i = 0; i < M; i++){
    		B[i] = sc.nextInt();
    	}
    	int[][] A = new int[N][M];
    	for(int i = 0; i < N; i++){
    		for(int j = 0; j < M; j++){
    			A[i][j] = sc.nextInt();
    		}
    	}
    	sc.close();
    	int ans = 0;
    	for(int i = 0; i < N; i++){
    		int num = 0;
    		for(int j = 0; j < M; j++){
    			num += A[i][j] * B[j];
    		}
    		num += C;
    		if(num > 0) ans++;
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 22996
n = int(input())
al = list(map(int, input().split()))

if n == 1:
    print(1)
    exit()
    
if al[1] > al[0]:
    now = 'U'
elif al[1] < al[0]:
    now = 'D'
else:
    now = 'E'

cnt = 1
for i in range(2, n):
    if now == 'U':
        if al[i] > al[i-1] or al[i] == 'E':
            now = 'U'
        elif al[i] < al[i-1]:
            cnt += 1
            i += 1
            now = 'E'
    elif now == 'D':
        if al[i] < al[i-1] or al[i] == 'E':
            now = 'D'
        elif al[i] > al[i-1]:
            cnt += 1
            now = 'E'
    elif now == 'E':
        if al[i] == al[i - 1]:
            now = 'E'
        elif al[i] > al[i - 1]:
            now = 'U'
        elif al[i] < al[i - 1]:
            now = 'D'
print(cnt)


Measured memory_bytes: 14100
#include <iostream>

int main(int argc, char const *argv[]) {
    int a, b, k;
    std::cin >> a >> b >> k;
    for (int i = 1; i <= k; i++)
        if (i & 1)
            b += (a >>= 1);
        else
            a += (b >>= 1);
    std::cout << a << ' ' << b << '\n';
    return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    import heapq
    n,m = i_map()
    t = [[] for _ in range(m+1)]
    for i in range(n):
        a,b = i_map()
        if a> m:
            continue
        t[a].append(b)

    ans = 0
    h = []
    for l in t:
        for i in l:
            heapq.heappush(h, -i)
        if h:
            ans -= heapq.heappop(h)
    print(ans)






if __name__=="__main__":
    main()


Measured memory_bytes: 90256
/*
       ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄
      ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌
      ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌
      ▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌ ▄▄▄▄▄▄▄▄ ▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌▐░░░░░░░░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌ ▀▀▀▀▀▀█░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌       ▐░▌
      ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌
      ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌
       ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀  
 
 #can_change_the_world_with_the_help_of_0_1
                                    -darshan786    */
 
  
 
 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0); 
#define F first 
#define MAXN   100005
#define int long long
#define S second
#define all(v) v.begin(),v.end() 
#define PI pair<int,int>
#define PIS pair<int,string>





int values[41];
int vis[100005]={0};
void value()
{
   values[0]=1;
    for(int i=1;i<=40;i++)
    {
        values[i]=2*values[i-1];
    }
}
vector<int> adj[MAXN];
void dfs(int u)
{
    vis[u]=1;
    for(auto x:adj[u])
    {
        if(!vis[x])
        {
            dfs(x);
        }
    }
}
int32_t main() {
    boost
    

    int n,m;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if(!vis[i])
        {
            ans++;
            
            dfs(i);
        }
    }
    cout<<ans-1;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)



int main()
{
  ll x, b=100, c=0;
  cin >> x;
  while (b < x){
	c++;
	b *= 1.01;
  }
  cout << c << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string w;
    cin >> w;
    sort(ALL(w));
    char bef = w[0];
    int count = 0;
    bool beautiful = 1;
    REP(i,w.size()){
        if(bef == w[i]){
            count ^= 1;
        }else{
            bef = w[i];
            if(count)beautiful = 0;
            count = 1;
        }
    }
    if(count)beautiful = 0;
    cout << (beautiful ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#define ff first
#define ss second 
#define all(c) (c).begin(),(c).end()
const int Wmax = 1e5 +5 ;
const int Nmax = 1e2 +5 ; 
using namespace std; 

long long bagvalue[Nmax][Wmax]; // n * W 
int n,W ;
vector<pair<int,int>> items;
long long dp(int w, int cur){
	if(cur == n)
		return 0; 
	long long& ans = bagvalue[cur][w];
	if(ans) return ans;
	ans = max(ans, dp(w,cur+1));
	if((long long)items[cur].ff + w <= W) 
		ans = max(ans, dp(w + items[cur].ff, cur+1) + items[cur].ss);
	return ans ;
}

int main()
{
	cin >> n >> W; 
	items.resize(n);
	for(auto &it : items) cin >> it.ff >> it.ss ;
	sort(all(items));
	cout << dp(0,0);
}   


Measured memory_bytes: 78080
#include <iostream>

using namespace std;

void Selection_Sort() {
	int A[100], min_j, N;
	int count = 0;

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	for (int i = 0; i < N; i++) {
		min_j = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[min_j]) {
				min_j = j;
			}
		}
		if (min_j != i) {
			swap(A[i], A[min_j]);
			count++;
		}
	}

	for (int i = 0; i < N; i++) {
		if (i)
			cout << " ";
		cout << A[i];
	}

	cout << endl << count << endl;
}

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


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

int main() {
    int N;
    cin >> N;
    int rans = 1;
    rep(i,N){
        int A; cin >> A;
        if(!(A&1)) rans *=2;
    }

    cout << pow(3,N) - rans << endl;
}

Measured memory_bytes: 256