akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            int[] number = new int[N];
            for(int i = 0; i < N; i++)
            {
                number[i]= cin.ReadInt;
            }
            int min = number[0];
            int count = 1;
            for(int i = 1; i < N; i++)
            {
                if (number[i] < min)
                {
                    min = number[i];
                    count++;
                }
            }
            WriteLine(count);

            // 解答はココに書く

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 35452
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

n=int(input())
cnt=0
a=list(map(int, input().split()))
for i in range(0,n,2):
    if a[i]%2==1:
        cnt+=1
print(cnt)

Measured memory_bytes: 9172
#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()
{
  long long N, M;
  cin >> N >> M;
  
  long long n = N, m = M;
  long long ans = 0;
  long long fir = min(n, m / 2);
  n -= fir; m -= fir * 2; ans += fir;
  //cout << n << " " << m << endl;
  long long sec = m / 4;
  m -= sec; ans += sec;

  cout << ans << endl;
}

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

int main(){
    int n,i,j,k,m,key,l;
    int a[N];
    
    scanf("%d",&n);
    for(k=0;k<n;k++){
        scanf("%d",&a[k]);
    }
    
    for(l=0;l<n;l++){
        if(l>0){
            printf(" ");
        }
        printf("%d",a[l]);
    }
    printf("\n");
    
    for(j=1;j<=n-1;j++){
        key = a[j];
        i = j-1;
        while(i>=0 && a[i]>key){
            a[i+1]=a[i];
            i--;
        }
        a[i+1] = key;
        
        for(m=0;m<n;m++){
            if(m>0) printf(" ");
            printf("%d",a[m]);
        }
        printf("\n");
    }
    return 0;
}





Measured memory_bytes: 2072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();

            TreeSet<Integer> set = new TreeSet<>();
            for (int i = 0; i < k; i++) {
                if (a + i <= b) set.add(a + i);
                if (b - i >= a) set.add(b - i);
            }

            for (int x : set) {
                out.println(x);
            }
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 22484
A = list([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, \
    1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])
K = int(input())

ans = A[K-1]

print (ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define N 21

using namespace std;
const int MOD = (int)1e9 + 7;

int n, inv[1<<N], bt[1<<N];
int a[N+1][N+1], cnt[N+2][1<<N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int p = 1;
	for(int i=0; i<N; i++) {
		inv[p] = i;
		p <<= 1;
	}
	for(int i=0; i<1<<N; i++) {
		bt[i] = __builtin_popcount(i);
	}
	cin >> n;
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			cin >> a[i][j];
		}
	}
	for(int i=n; i>=0; i--) {
		for(int mask=0; mask < 1<<n; mask++) {
			if(mask == 0) cnt[i][mask] = (i == n);
			else if(bt[mask] < n-i) cnt[i][mask] = 0;
			else {
				int x = mask;
				while(x) {
					int y = x & (-x);
					int idx = inv[y];
					x -= y;
					if(a[i][idx] == 0) continue;
					cnt[i][mask] = (cnt[i][mask] + cnt[i+1][mask^y]) % MOD;
				}
			}
		}
	}
	cout << cnt[0][(1<<n)-1] << endl;
	return 0;
}

Measured memory_bytes: 370944
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int nums[] = new int [N];
        int total = 0;
        for(int i = 0;i < N;i++){
            nums[i] = sc.nextInt();
            total += nums[i];
        }
        int M = sc.nextInt();
        int Pm[] = new int [M];
        int Xm[] = new int [M];
        for(int i = 0;i < M; i++){
            Pm[i] = sc.nextInt() - 1;
            Xm[i] = sc.nextInt();
        }
        
        for(int i = 0;i < M;i++){
            System.out.println(total - (nums[Pm[i]] - Xm[i]));
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cstring>
#define MN 201000

typedef long long ll;
int fa[MN];
int c1[MN], c2[MN];
int Min[MN];
ll D; int a[MN];
int X[MN], Y[MN];
int x[MN], y[MN];
ll ans = 0;
int bl;
int n;

int Abs(int a) {return a > 0 ? a : -a;}
ll F(int i) {return i ?  i * D + a[i] : 1e18;}
ll G(int i) {return i ? -i * D + a[i] : 1e18;}
ll H(int i, int j) {if(i == 0 || j == 0) return 1e18; return Abs(i - j) * D + a[i] + a[j];}

void add(int *c, int x, int v, int type)
{
    for(int i = x; i <= n; i += i & -i)
    {
        if(!type) if(F(v) < F(c[i])) c[i] = v;
        if( type) if(G(v) < G(c[i])) c[i] = v;
    }
}

int query(int *c, int x, int type)
{
    int ans = 0;
    for(int i = x; i; i -= i & -i)
    {
        if(!type) if(F(c[i]) < F(ans)) ans = c[i];
        if( type) if(G(c[i]) < G(ans)) ans = c[i];
    }
    return ans;
}

int Find(int x) {return fa[x] == x ? x : fa[x] = Find(fa[x]);}

void solve()
{
    memset(x, 0, sizeof x);
    memset(y, 0, sizeof y); 
    memset(c1, 0, sizeof c1);
    memset(c2, 0, sizeof c2);
    memset(Min, 0, sizeof Min);
    for(int i = 1; i <= n; i++)
    {
        int u = Find(i);
        int x = query(c1, u - 1, 1);
        int y = query(c2, n - u, 1);
        if(G(x) > G(y)) x = y;
        if(H(x, i) <= H(Min[i], i)) Min[i] = x;
        add(c1, u, i, 1);
        add(c2, n - u + 1, i, 1);
    }
    memset(c1, 0, sizeof c1);
    memset(c2, 0, sizeof c2);
    for(int i = n; i >= 1; i--)
    {
        int u = Find(i);
        int x = query(c1, u - 1, 0);
        int y = query(c2, n - u, 0);
        if(F(x) > F(y)) x = y;
        if(H(x, i) <= H(Min[i], i)) Min[i] = x;
        add(c1, u, i, 0);
        add(c2, n - u + 1, i, 0);
    }
    for(int i = 1; i <= n; i++)
    {
        int u = Find(i);
        if(H(i, Min[i]) < H(x[u], y[u])) x[u] = i, y[u] = Min[i];
    }
    int tot = 0;
    for(int i = 1; i <= n; i++)
    {
        int u = Find(i);
        ++tot; X[tot] = x[u]; Y[tot] = y[u];
    }
    for(int i = 1; i <= tot; i++)
    {
        int x = Find(X[i]), y = Find(Y[i]);
        if(x == y) continue;
        ans += H(X[i], Y[i]);
        fa[x] = y;
        bl--;
    }
}

int main()
{
    scanf("%d%lld", &n, &D);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), fa[i] = i;
    bl = n;
    while(bl > 1) solve();
    printf("%lld\n", ans);
}

Measured memory_bytes: 10840
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int getdis(const pair<int, int>l, const pair<int, int>r) {

	int dy =r.second - l.second;
	int dx =r.first - l.first;
	if (l.second % 2 == r.second % 2) {
		assert(abs(dy) % 2 == 0);
		if (abs(dx) <= abs(dy) / 2)return abs(dy);
		else {
			return  abs(dy) + (abs(dx) - abs(dy) / 2);
		}
	}
	else if (l.second % 2==0 && r.second % 2 == 1) {
		{
			int amin = 1e8;
			int y = l.second > r.second ? -1 : 1;
			for (int x = -1; x <= 0; ++x) {
				amin = min(amin, 1 + getdis(make_pair(l.first + x, l.second + y), r));
			}
			
			return amin;
		}
	}
	else {
		{
			int amin = 1e8;
			int y = l.second > r.second ? -1 : 1;
			for (int x = 0; x <= 1; ++x) {
				amin = min(amin, 1 + getdis(make_pair(l.first + x, l.second + y), r));
			
			}
			return amin;
		}
	}
}

int main() {
	while (1) {
		int W, H; cin >> W >> H;
		if (!W)break;
		vector<vector<int>>field(H, vector<int>(W, 100000));
		int S; cin >> S;
		for (int i = 0; i < S; ++i) {
			int x, y; cin >> x >> y; x--; y--;
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					field[j][k] = min(field[j][k], getdis(make_pair(x, y), make_pair(k, j)));
				}
			}
		}
		int T; cin >> T;
		int ans = 0;
		for (int i = 0; i < T; ++i) {
			int p, q; cin >> p >> q; p--; q--;
			int sum = 0;
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					if (field[j][k] > getdis(make_pair(p,q), make_pair(k, j)))sum++;

				}
			}
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int n;
set<int> st;

int main(){
	cin >> n;
	for(int i = 0 ; i < n; i++){
		int a; cin >> a;
		st.insert(a);
	}
	if(n == st.size())cout << "YES" << endl;
	else cout << "NO" <<endl; 

}

Measured memory_bytes: 9600
#include<stdio.h>
int main() {
	int a, b,c,i,cnt=0;
	scanf("%d %d %d", &a, &b,&c);
	for (i = a; i <= b; ++i) {
		if (c%i == 0) ++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2104
def gcd(a, b): #最大公約数
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
        
def main():
    n=int(input())
    a = list(map(int,input().split()))
    L=[a[0] for _ in range(n)]
    R=[a[n-1] for _ in range(n)]
    for i in range(1,n):
        L[i]=gcd(L[i-1],a[i])
    for i in range(1,n):
        R[i]=gcd(R[i-1],a[n-1-i])
    R.reverse()
    LR=[]
    for i in range(1,n-1):
        LR.append( gcd(L[i-1],R[i+1]) )
    if LR==[]:
        print(max(L[n-2],R[1] ))
    else:
        print(max(max(LR),L[n-2],R[1] ))


if __name__ == "__main__":
    main()

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  ll K;
  cin >> K;
  int N = max(2LL, min(50LL, K));
  ll a[50];
  iota(a, a+N, 0);
  for (int i = 0; i < N; i++) {
    a[i] += K / N;
  }
  for (int i = 0; i < K % N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i) a[j] += N;
      else a[j]--;
    }
  }
  cout << N << endl;
  for (int i = 0; i < N; i++) {
    cout << a[i] << " \n"[i+1 == N];
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
	double n,s[100000];
	double m,a;
	while(cin>>n){
		if(n==0)break;
		m=0;
		a=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			m+=s[i];
		}
		m=m/n;
		for(int i=0;i<n;i++){
			a+=((s[i]-m)*(s[i]-m)/n);
		}
		cout<<fixed<<setprecision(5)<<sqrt(a)<<endl;
	}
}


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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    char pre_now;
    if (s[0]=='L'){
        pre_now = 'R';
    }else{
        pre_now = 'L';
    }

    int pt = 0;
    for (int i = 0; i < n; ++i){
        if (pre_now==s[i]){
            pt += 1;
        }
        pre_now = s[i];
    }

    pt = k*2 + pt;
    if (pt>=n){
        pt = n-1;
    }
    cout << pt << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll d;cin >> d;
  vl c(26);rep(i,26)cin >> c[i];
  vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
  vector<set<ll>> ch(26);rep(i,26)ch[i].ins(-1),ch[i].ins(d);
  vl days(d);
  ll pre=0;
  vl last(26,-1);
  rep(i,d){
    ll t=0;
    ll maxi=-INF;
    rep(j,26){
        ll p=s[i][j];
        rep(k,26){
            if(k==j)continue;
            p-=c[k]*(i-last[k]);
        }
        if(chmax(maxi,p))t=j;
      }
      days[i]=t;
      last[t]=i;
  }
  rep(i,d){
    ll t=days[i];
    pre+=s[i][t];
    ch[t].ins(i);
    days[i]=t;
  }
  ll score=pre; 
  rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      score-=c[i]*mini;
  }
  //rep(i,d)cout << days[i] <<endl;

  ll q=900000;
  while(q--){
    ll x=rand()%d,y=rand()%26;
    //cout << x <<" " << y <<endl;
    ll old=days[x];
    pre-=s[x][days[x]];
    ch[days[x]].erase(x);
    days[x]=y;
    pre+=s[x][y];
    ch[y].ins(x);
    ll p=0;
    rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      p+=c[i]*mini;
    }
    //if(q>299990)cout << score <<endl;
    if(pre-p-score>-q/10){
      score=pre-p;
    }
    else{
      ch[y].erase(x);
      pre-=s[x][y];
      days[x]=old;
      ch[days[x]].ins(x);
      pre+=s[x][old];
    }
  }
  rep(i,d)cout << days[i]+1 <<endl;
}   


Measured memory_bytes: 3756
#####################################################################################################
##### コイン問題
#####################################################################################################
"""

ベンチマーク
コイン問題 (※ larger = False): http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4696859#1
E - Crested Ibis vs Monster (※ larger = True): https://atcoder.jp/contests/abc153/submissions/15396586

"""


def coin(larger=False, single=False):
    """
    ナップサックに入れる重さが W 丁度になる時の価値の最小値
    :param larger: False = (重さ = W)の時の最小価値
                   True  = (重さ =< W)の時の最小価値
    :param single: False = 重複あり

    dp[weight <= W+1] = 重さを固定した時の最小価値
    dp[W+1] = 重さがWより大きい時の最小価値
    """
    W2 = W + 1              # dp[W+1] に W より大きい時の全ての場合の情報を持たせる
    dp_max = float("inf")   # 総和価値の最大値
    dp = [dp_max] * (W2 + 1)
    dp[0] = 0               # 重さ 0 の時は価値 0

    for item in range(N):
        if single:
            S = range(W2, weight_list[item] - 1, -1)
        else:
            S = range(W2)
        for weight in S:
            dp[min2(weight + weight_list[item], W2)] = min2(dp[min2(weight + weight_list[item], W2)], dp[weight] + cost_list[item])
    if larger:
        return min(dp[w] for w in range(W, W2+1))
    else:
        return dp[W]

#######################################################################################################
import sys
input = sys.stdin.readline


def max2(x, y):
    return x if x > y else y

def min2(x, y):
    return x if x < y else y

W = int(input())
cost_list = [1]
weight_list = [1]
p = 6
while p<=W:
    cost_list.append(1)
    weight_list.append(p)
    p *= 6
p = 9
while p<=W:
    cost_list.append(1)
    weight_list.append(p)
    p *= 9
N = len(weight_list)

print(coin(larger=False, single=False))


Measured memory_bytes: 74352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int cost[]=new int[n];//競技にかかる費用
		int ass[]=new int[m];//審査員の評価基準
		int cnt[]=new int[n];//票数
		int best,index=0;
		
		for(int i=0;i<n;i++){
			cost[i]=sc.nextInt();
		}
		for(int i=0;i<m;i++){
			ass[i]=sc.nextInt();
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(ass[i]>=cost[j]){
					cnt[j]++;
					break;
				}
			}
			
		}
		best=cnt[0];
		for(int i=1;i<n;i++){
			if(best<cnt[i]){
				best=cnt[i];
				index=i;
			}
		}
		
		System.out.println(index+1);
		
	}

}

Measured memory_bytes: 25068
import sys
while True:
  n,x=map(int,input().split())
  if n==0 and x==0: sys.exit()
  
  ans=0
  for i in range(n):
    i+=1
    for j in range(n-i):
      j+=i+1
      for k in range(n-j):
        k+=j+1
        if i+j+k == x: ans+=1
  print(ans)


Measured memory_bytes: 5596
n = int(raw_input())
L = []
c = 0
for i in xrange(n):
    cmd = raw_input()
    if cmd[0] == "i":
        L.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            L.pop(~L[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        L.pop()
    else:
        c += 1

print " ".join(map(str, L[c:][::-1]))

Measured memory_bytes: 61680
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		Arrays.setAll(d, i -> sc.nextInt());
		
		int sum = 0;
		for (int x = 0; x < n - 1; x++) {
			for (int y = x + 1; y < n; y++) {
				sum += d[x] * d[y];
			}
		}
		
		System.out.println(sum);
		
		sc.close();
	}
	
}




Measured memory_bytes: 32264
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = INT64_MAX;
		for (int j = max(0ll, i - k); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << "\n";
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    string S,T;
    cin>> S >> T;
    int ans=0;
    
    for(int i=0; i < S.size(); i++){
        if(S[i] != T[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int d = 0;
    int t = n;
    while(t){
        d++;
        t /= 10;
    }
    int m = d/2;
    int ans = 0;
    for(int i=0; i<m; i++){
        ans += 9*pow(10,2*i);
    }
    if(d%2){
        ans += n - pow(10,d-1) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
	int h, n;
	cin >> h >> n;
	long long total = 0;
	for (int i = 0; i < n; i++) {
		long long k;
		cin >> k;
		total += k;
	}
	if (total >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
Ls = list(map(int, input().split()))

Ls.sort(reverse=True)

diff = []
i = 0
while i + 1 <= len(Ls) :
    diff.append( min(Ls[i], Ls[i+1]) )
    i += 2

diff.sort(reverse=True)
ans = 0
for i in range(n):
    ans += diff[i]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  vector<vector<long long>>a;
  a.push_back({0,0});
  long long sum=0;long long ans=0;
  for(int i=1;i<=n;i++){
  long long x,y;
  cin>>x>>y;sum+=y;
    a.push_back({y,x});
  }long long dp[n+1][sum+1];sort(a.begin(),a.end());
    for(int i=0;i<n+1;i++){
  for(int j=0;j<sum+1;j++)dp[i][j]=1e18;}
   for(int i=1;i<=n;i++){
   for(long long j=0;j<=sum;j++){
             if(a[i][0]>=j)dp[i][j]=min(dp[i-1][j],a[i][1]);
             else dp[i][j]=min(dp[i-1][j],a[i][1]+dp[i-1][j-a[i][0]]);
     if(dp[i][j]<=w)ans=max(j,ans);
    // cout<<dp[i][j]<<" ";
   }//cout<<endl;
   }cout<<ans;
	
}

Measured memory_bytes: 79104
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
 
public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
 
    ArrayList<Integer> list = new ArrayList<Integer>();
    
    if(B-A+1 > K && ((B-A+1) > (K+K))){
      for(int i = A ; i < A+K ; i++){
         list.add(i);
      }
      
      for(int i = B ; i > B-K ; i--){
          list.add(i);
      }
      
      Collections.sort(list);

       for(int i = 0 ; i < list.size() ; i++){     
         System.out.println(list.get(i));      
       }
      
    }else{
      for(int i = A ; i <= B ; i++){
         System.out.println(i);
      }
    }
    
  }
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 2000 + 5;

int dp[N];

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

    int s;
    cin >> s;

    dp[1] = dp[2] = 0;
    dp[0] = dp[3] = 1;

    for (int i = 4; i <= s; i++) {
        for (int j = 3; j <= i; j++) {
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }
    }
    cout << dp[s] << '\n';
    return 0;
}

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

int dfs(int num) {
  if (num < 2) return 0;
  if (num % 2 == 1) return 0;

  return 1 + dfs(num / 2);
}

int main() {
  int n;
  cin >> n;
  int mx  = 0;
  int res = 0;
  for (int i = n; i >= 1; i--) {
    int tmp = dfs(i);
    if (mx < tmp) {
      res = i;
      mx  = tmp;
    }
  }
  if (n == 1) res = 1;
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC154C - Distinct or Not

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        String ans = "YES";
        for (int i = 0; i < n - 1; i++) {
            if (a[i] == a[i + 1]) {
                ans = "NO";
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 88496
#include<stdio.h>

int main(void){
    char S[3],T[3];
    
    scanf("%s",S);
    scanf("%s",T);

    int i;
    int j=0;

    for(i=0;i<3;i++){
        if(S[i]==T[i])
           j++;
    }

    printf("%d",j);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m,c,b[20],i,j,ans=0,s,t;
	cin>>n>>m>>c;
	for (i=0;i<m;i++){
		cin>>b[i];
	}
	for (i=0;i<n;i++){
		s=c;
		for (j=0;j<m;j++){
			cin>>t;
			s+=b[j]*t;
		}
		if (s>0){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import fractions
"""最小公倍数"""
def lcm(a,b):
    f = fractions.gcd(a,b)
    return a*b//f

n,m = map(int,input().split())
A = list(map(int,input().split()))
l = A[0]
for a in A[1:]:
    l = lcm(l, a)

if n==1:
    if l%2!=0:
        print(0)
    else:
        if l/2>m:
            print(0)
        else:
            print(1 + int((m-l//2)/l))

else:
    flg = True
    for a in A:
        if (l//a)%2==0:
            flg = False
    if not flg:
        print(0)
    else:
        minx = l//2
        if minx>m:
            print(0)
        else:
            print(1 + int((m-minx)//l))

Measured memory_bytes: 16320
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	x = 10^18*ones(Int,26)
	for i in 1:n
		s = readline() |> chomp
		b = zeros(Int,26)
		for j in 1:length(s)
			b[Int(s[j])-96]+=1
		end
		for j in 1:26
			x[j]=min(x[j],b[j])
		end
	end
	for i in 1:26
		for j in 1:x[i]
			print(Char(96+i))
		end
	end
	println("")
end

main()

Measured memory_bytes: 111884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string op;
  int A, B, answer;
  cin >> A >> op >> B;
  if('+' == op.at(0))
  {
    answer = A + B;
  }
  else
  {
    answer = A - B;
  }
  cout << answer << endl;

}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val t = Array(n) {-1}
    repeat(m) {
        val s = sc.nextInt() - 1
        val c = sc.nextInt()
        if (t[s] == -1) {
            t[s] = c
        } else if (t[s] != c) {
            println(-1)
            return
        }
    }
    for (i in 0..999) {
        val str = i.toString()
        if (str.length != n) {
            continue
        }
        var flg = true
        for (j in 0 until n) {
            if (t[j] == -1 || t[j] == str[j] - '0') {

            } else {
                flg = false
                break
            }
        }
        if (flg) {
            println(i)
            return
        }
    }
    println(-1)
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

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

signed main() {
  ll N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  string T;
  cin >> T;

  ll LCM = lcm(N, M);
  ll n = LCM / N;
  ll m = LCM / M;

  map<ll, char> mp;
  rep(i, len(S)) {
    mp[n * i] = S[i];
  }

  rep(j, len(T)) {
    if (mp.find(m * j) == mp.end())
      continue;
    if (mp[m * j] != T[j]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << LCM << endl;
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] arA = new int [n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				arA[i][j] = scan.nextInt();
			}
		}
		int[] vecb = new int[m];
		for (int i = 0; i < m; i++) {
			vecb[i] = scan.nextInt();
		}
		int[] vecc = new int[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				vecc[i] += arA[i][j] * vecb[j];
			}
		}
		for (int i: vecc) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 40624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;c=getchar();
	}
	while(c>='0'&&c<='9'){
		s=(s<<1)+(s<<3)+(c^48);c=getchar();
	}
	return f*s;
}
int main(){
	int a=read(),b=read(),c=read(),d=read();
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			break;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int N;
int R[114514], C[114514];

int buffer[114514];
int gyakuhiki[114514];

int solve(const int idx[], const int data[]) {
	int i;
	int mareitaso = 0;
	for (i = 1; i <= N; i++) buffer[i] = gyakuhiki[i] = 0;
	for (i = 0; i < N; i++) {
		if (buffer[idx[i]] != 0 || gyakuhiki[data[i]] != 0) return -1;
		buffer[idx[i]] = data[i];
		gyakuhiki[data[i]] = idx[i];
	}
	for (i = 1; i <= N; i++) {
		if (buffer[i] != i) {
			int sumipe = gyakuhiki[i];
			int temp;
			temp = buffer[i];
			buffer[i] = buffer[sumipe];
			buffer[sumipe] = temp;
			gyakuhiki[i] = i;
			gyakuhiki[buffer[sumipe]] = sumipe;
			mareitaso++;
		}
	}
	return mareitaso;
}

int main(void) {
	int i;
	int asumi, iguti;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &R[i], &C[i]) != 2) return 1;
	}
	asumi = solve(R, C);
	iguti = solve(C, R);
	if (asumi < 0 && iguti < 0) puts("-1");
	else if (asumi < 0) printf("%d\n", iguti);
	else if (iguti < 0) printf("%d\n", asumi);
	else printf("%d\n", asumi <= iguti ? asumi : iguti);
	return 0;
}



Measured memory_bytes: 3372
import math
x=int(input())

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    if is_prime(x):
        print(x)
        break
    x+=1

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <cmath>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

vector <ll> divisor(ll x){
    vector<ll> ret;

    for(ll i = 1; i * i <= x; i++){
        if(x % i == 0){
            ret.push_back(i);
            if(i != x / i) ret.push_back(x / i);
        }
    }
    sort(all(ret));

    return ret;
}


int main(){

    ll N, M;
    cin >> N >> M;

    auto div = divisor(M);
    for(int i = 0; i < div.size() - 1; i++){
        if( M / div[i] >= N  && M / div[i+1] < N){
            cout << div[i] << endl;
            return 0;
        }
    }
    cout << div.back() << endl;
    

}

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


void solve(long long A, long long B){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    if(16-max(A, B)>=8){
        printf("Yay!");
        printf("\n");
    }else{
        printf(":(");
        printf("\n");
    }
    return 0;
}


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  int ans = S == "SUN" ? 7 :
    S == "MON" ? 6 :
    S == "TUE" ? 5 :
    S == "WED" ? 4 :
    S == "THU" ? 3 :
    S == "FRI" ? 2 :
    S == "SAT" ? 1 : 0;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var a int
    fmt.Scan(&a)
    fmt.Printf("ABC%d",a)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DDiceInLine solver = new DDiceInLine();
    solver.solve(1, in, out);
    out.close();
  }

  static class DDiceInLine {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      // 1~pの目が出るさいころの期待値は(p+1)/2
      // 隣接k個の目の和が最大ならOK
      int n = in.nextInt();
      int k = in.nextInt();
      int[] a = new int[n];
      int sumMax = 0;
      int sumTmp = 0;
      for (int i = 0; i < n; i++) {
        a[i] = in.nextInt();
      }
      for (int i = 0; i < k; i++) {
        sumMax += a[i];
        sumTmp += a[i];
      }
      for (int i = k; i < n; i++) {
        sumTmp = sumTmp + a[i] - a[i - k];
        if (sumTmp > sumMax) {
          sumMax = sumTmp;
        }
      }

      out.println(((double) sumMax + k) / 2);

    }

  }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
#define endl '\n'
#define max3(a,b,c) max(a,max(b,c))

const int q = 1e9+9;




int main()
{
    int n;
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i+=2){
        int a=0;
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                if(i/j != j) a+=2;
                else {a++;}
            }
        }
        if(a==8) ans++;
    }
    cout<<ans<<endl;


    return 0;
}
    // gotcha;


Measured memory_bytes: 256
s = input()

count_1 = 0
count_2 = 0

flag = True
n = 0
for i in range(len(s)):

    if s[i-1] == s[i]:
        if flag:
            count_1 += n
            flag = False
        else:
            count_2 += n
            flag = True
        n = 0
    n += 1

if flag:
    count_1 += n
    flag = False
else:
    count_2 += n
    flag = True

print(min(count_1, count_2))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 21
ll n, k;

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

    cin >> n >> k;
    n %= k;
    cout << min(n, k-n) << "\n";

    return 0;
}


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

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var points = new int[n];
        for(int i = 0; i < n;i++)
        {
            points[i] = int.Parse(Console.ReadLine());
        }

        var sum = points.Sum();

        if(sum % 10 == 0)
        {
            var non10 = points.Where(p => (p % 10) != 0);
            if(non10.Count() > 0)
            {
                sum -= non10.Min();
            }
            else
            {
                sum = 0;
            }
        }


        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main(void){
  string str;
  cin >> str;
  int num = 0;
  for(int i=0;i<str.size();i++){
    num += str[i] -'0';
    num = num%9;
  }
  if(num == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
   }
  
  return 0;
}

Measured memory_bytes: 3728
package main
import . "fmt"
import . "os"
func main() {
  var s string
  var n int
  Scan(&s)
  n = len(s)/2-1
  for i:=n;i>=0;i-- {
    if s[0:i] == s[i:i+i] {
      Println(i+i)
      Exit(0)
    }
  }
}

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

int a[20];
int x[20][20];
int y[20][20];
int conter(int x)
{
    if (x == 0)
        return 0;
    return conter(x >> 1) + (x & 1);
}
int main()
{
    int n;
    cin >> n;
    rep(i, 1, n + 1)
    {
        cin >> a[i];
        rep(j, 1, a[i] + 1)
        {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    // cout << (1 << n) << endl;
    for (int bits = 1; bits < (1 << n); bits++)
    {
        bool ok = true;
        for (int i = 1; i <= n; i++)
        {
            if (!(bits & (1 << (i - 1))))
                continue;
            for (int j = 1; j <= a[i]; j++)
            {
                //　x[i][j]が正直者であるか
                //　与えられた条件と一致するか
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
                    ok = false;
            }
        }
        if (ok)
            ans = max(ans, conter(bits));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;
	int cntR = 0 ;
	rep(i,N){
		if(S[i] == 'R')cntR++;
	}
	int ans = 0;
	rep(i,cntR){
		if(S[i] == 'W') ++ans;
	}
	cout << ans << endl;
}

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

int main()
{
    int n,l,r,ans=0;
    scanf("%d%d%d",&n,&l,&r);
    for(int i=1;i<=n;i++)
    {
        int now;
        scanf("%d",&now);
        if(now<l||now>=r) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())

max_val = 10**5+1
# dictの初期化
ac_L = []
wa_L = []
for val in range(1,max_val):
    wa_L.append(0)
    ac_L.append(0)

ac_ans,wa_ans = 0,0


for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    # acの処理
    if ac_L[p] ==0 and s == "AC":
        ac_L[p] = 1
        wa_ans += wa_L[p]
    # waの処理
    wa_L[p] += 1


#print(ac_dic,wa_dic)
print(sum(ac_L),wa_ans)

Measured memory_bytes: 52708
def main():
    n,k=map(int,input().split())
    h=sorted(list(map(int,input().split())))
    if k>=n:
        print(0)
    else:
        for i in range(k):
            _=h.pop(-1)
        print(sum(h))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 88908
k, n = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(1,len(a)):
    l.append(a[i]-a[i-1])
if a[0] == 0:
    l.append(k-a[len(a)-1])
else:
    l.append(k-a[len(a)-1]+a[0])
print(k-max(l))

Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(n+1);
  rep1(i,n) cin >> p[i];
  
  UnionFind tree(n+1);
  
  rep(i,m){
    int x,y;
    cin >> x >> y;
    tree.unite(p[x],p[y]);
  }
  
  int ans = 0;
  rep1(i,n) if(tree.same(i,p[i])) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
num = []
for i in range(n):
    x = list(map(int,input().split()))
    num.append(x[1:])
ans = [0 for i in range(m)]
for i in num:
    for j in i:
        ans[j-1]+=1
print(ans.count(n))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#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; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    int wa, tle, ac, re;
    wa = tle = ac = re = 0;

    for (int i=0; i<N; i++){
        string s;
        cin >> s;
        if (s == "WA")wa++;
        if (s == "AC")ac++;
        if (s=="RE")re++;
        if (s == "TLE")tle++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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

int main() {
    int n,i = 1,num = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    while(!(num > n)){
        i = a.at(i-1);
        num++;
        if(i == 2)break;
    }
    if(num > n)num = -1;
    cout << num << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	ll a[n]; zep(i, 0, n)cin >> a[i];
	sort(a, a + n);
	
	set<int> s;
	ll ans = 0;
	zep(i, 0, n){
		if((i > 0 && a[i - 1] == a[i]) || (i < n - 1 && a[i] == a[i + 1])){
			s.insert(a[i]);
			continue;
		}
		
		bool flag = true;
		for(ll j = 1; j * j <= a[i]; j++){
			if(a[i] % j == 0){
				if(s.find(j) != s.end())flag = false;
				if(s.find(a[i] / j) != s.end())flag = false;
			}
		}
		
		if(flag)ans++;
		s.insert(a[i]);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 14448