akhauriyash/Code-Regression huggingface dataset:
N = int(input())
list = []
for i in range(1,N+1):
    list.append(i)
for i in range(1,(N+3)//3):
    list[3*i-1] = 0
for i in range(1,(N+5)//5):
    list[5*i-1] = 0
print(sum(list))

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

int main()
{
	int st = 1;
	string s, t, hi;
	char temp;
	cin >> s >> t;
	hi = s;
	if (s.length() == t.length())
	{
		for (int i = 0; i < s.length(); i++)
		{
			if (hi == t)
			{
				st = 0;
				break;
			}
			else
			{
				temp = hi[s.length() - 1];
				for (int y = 1; y < s.length(); y++)
				{
					hi[y] = s[y - 1];
				}
				hi[0] = temp;
				s = hi;
			}
		}
		if (st == 0)
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
	}
	else
	{
		cout << "No";
	}

	return 0;
}

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

using namespace std;

#define ll long long

int main(){
	int n, x, y, count;
	cin >> n >> x >> y;
	cout << n << endl;
	for(int k=2; k<n; k++){
		count = 0;
		for(int i=1; i<=n-k; i++){
			if(abs(x-i)<k){
				if(abs(x-i)+abs(i+k-y)+1>=k){
					count++;
				}
				if(y-(k-abs(x-i)-1)-i>k){
					count++;
				}
				if((y+(k-abs(x-i)-1)-i>k) && (k-abs(x-i)-1 != 0) && (y+(k-abs(x-i)-1)<=n)){
					count++;
				}
			}
			else{
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    int ans=0;
    int k=0;//这是布的数量
    for(int i=0;i<s.length();i++){
        if(s[i]=='g'){
            if(k>0){
                ans++;
                k--;
            }else{
                k++;
            }
        }
        else{
            if(k>0){
                k--;
            }else{
                k++;
                ans--;
            }

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


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;

    int result = 0;
    if(s == "SSS"){
        result = 0;
    }
    if(s == "SSR"){
        result = 1;
    }
    if(s == "SRS"){
        result = 1;
    }
    if(s == "SRR"){
        result = 2;
    }
    if(s == "RSS"){
        result = 1;
    }
    if(s == "RSR"){
        result = 1;
    }
    if(s == "RRS"){
        result = 2;
    }
    if(s == "RRR"){
        result = 3;
    }
    cout<<result<<endl;
    
    
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a;
    cin>>a;
    int b=0;
  int c=0;
  int d=0;
  int e=0;
    for(int i=0;i<4;i++){
        if(a.at(i)==a.at(0)){
            b =b+1;
        }
    }
        for(int i=0;i<4;i++){
        if(a.at(i)==a.at(1)){
            c =c+1;
        }
    }
        for(int i=0;i<4;i++){
        if(a.at(i)==a.at(2)){
            d =d+1;
        }
    }
        for(int i=0;i<4;i++){
        if(a.at(i)==a.at(3)){
            e =e+1;
        }
    }
    if(b==c&&c==d&&d==e&&b==2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < 50000; i++){
        int money = i * 1.08;
        if(n == money){
            cout << i << "\n";
            return 0;
        }
    }
    cout << ":(\n";
}

Measured memory_bytes: 256
// -- Nitin
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a,n) for(int i = a; i < (int)n; i++)
#define foj(a,n) for(int j = a; j < (int)n; j++)
#define foin(a,n) for(int i = n; i >= a; i--)
#define fojn(a,n) for(int j = n; j >= a; j--)
#define bug(x) cerr << #x << " is " << x << endl;
#define isp2(x) x&&(!(x&(x-1)))
#define ln '\n'
#define ee 1000000007
#define eem 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define cases int tests; cin >> tests; while(tests--)

using namespace std;

ll fast(ll n,ll k){
    ll res = 1;
    n = n;
    while(k > 0){
        if ((k&1) == 1)
            res = (res * n);
        k = k>>1;
        n = (n * n);
    }
    return res;
}
 
//~ ll strsum(string s){
    //~ ll sm = 0, r = s.size();
    //~ foi(0,r)    sm += int(s[i]-'a');
    //~ return sm;
//~ }
 
//~ set <ll, greater <ll> > ss; //Prime Factors
//~ void pF(ll n)  {    
    //~ while (n % 2 == 0)  {  
        //~ ss.insert(2);  
        //~ n = n/2;  
    //~ }  
    //~ for (int i = 3; i <= sqrt(n); i = i + 2)  {   
        //~ while (n % i == 0)  {  
            //~ ss.insert(i); 
            //~ n = n/i;  
        //~ }  
    //~ }    
    //~ if (n > 2)  ss.insert(n);  
//~ }

//~ ll pre[1001][1001];

//~ ll go(ll n, ll k){
	//~ if(n==1) return 1;
	//~ else {
		//~ pre[n][k] = (go(n - 1, k) + k - 1) % n + 1;
		//~ return pre[n][k];
	//~ }
//~ }

//~ int dp[1002][1002];
//~ bool pal(string s){
	//~ for(int i = 0, j = s.size() - 1; i < s.size(); i++, j--){
		//~ if(s[i] != s[j]) return 0;
	//~ }
	//~ return 1;
//~ }

//~ void solve(){
	//~ int n;
	//~ cin >> n;		
//~ }


void go(){
	string s, t;
	cin >> s;
	cin >> t;
	int ans = INT_MAX;
	for(int i = 0; i < s.size() - t.size() + 1; i++){
		int c = 0;
		for(int j = 0; j < t.size(); j++){
			if(t[j] != s[i+j]) c++;
		}
		ans = min(c, ans);
	}
	cout << ans;
}

int main(){
    fio;
	//~ ll q, n, x, m , y;
	//~ string t;
	//~ for(int i = 1; i <= 1000; i++){
		//~ pre[1][i]=1;
		//~ go(1000,i);
	//~ }
	ll n, m, k;
    //~ cases
    {	
		go();
		cout << "\n";
	}
}
       
        


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(RALL(v));
    int ans = 0;
    REP(i,k) ans += v[i];
    cout << ans << '\n';

    return 0;
}

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

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

  int H[N];
  for(int i=0;i<N;i++) {
    cin >> H[i];
  }

  bool flag = true;

  for(int i=N-1;i>0;i--) {
    if(H[i-1]<=H[i]) ;
    else if (H[i-1]-1==H[i]) H[i-1] -= 1;
    else {
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return (0);
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0, k; i < M; i++) {
    cin >> k;
    for (int j = 0, s; j < k && cin >> s; j++) S.at(i).push_back(--s);
  }
  vector<int> P(M);
  for (int &p : P) cin >> p;

  int ans = 0;
  for (int bit = 0; bit < 1 << N; bit++) {
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int s : S.at(i)) if (bit >> s & 1) cnt++;
      if (cnt % 2 != P.at(i)) goto NG;
    }
    ans++;
    NG:;
  }

  cout << ans << "\n";
}

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

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    cout << X*min(N, K) + max(0, (N - K)*Y) << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v;
  int Alice = 0, Bob = 0;

  for(int i = 0; i < N; i++) {
    int input;
    cin >> input;
    v.push_back(input);
  }

  sort(v.begin(), v.end(), std::greater<int>());

  for(int i = 0; i < N; i++) {
    if (i % 2 == 0)
      Alice += v[i];
    else
      Bob += v[i];
  }

  cout << Alice - Bob;
  return 0;
}


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

using namespace std;

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

int main(){
  long n;
  cin >> n;
  
  set<long> s;
  
  rep(i,n) {
    long a;
    cin >> a;
    s.insert(a);
  }
 
  
  if(s.size()%2) cout << s.size() << endl;
  else cout << s.size()-1 << endl;
}


Measured memory_bytes: 4992
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		boolean ans = true;
		int px = 0, py = 0, pt = 0;
		for(int i = 0; i < N; i++){
			int t = in.nextInt();
			int x = in.nextInt();
			int y = in.nextInt();
			int dist = Math.abs(x - px) + Math.abs(y - py);
			
			if(t - pt < dist || (t - pt - dist) % 2 != 0){
				ans = false;
				break;
			}else{
				px = x;
				py = y;
				pt = t;
			}
		}
		
		System.out.println(ans ? "Yes" : "No");
	}
}


Measured memory_bytes: 87064
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  int answer; // stdout
  int k; // stdin
  int n;
  int *a;
  int distance;
  int max_diff;

  /* 標準出力からの読み込み */
  scan = scanf("%d", &k);
  scan = scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * (n + 1));
  for (int i = 0; i < n; i++) {
    scan = scanf("%d", &a[i]);
  }
  /* 最短移動距離の計算 */
  max_diff = 0;
  distance = a[n - 1] - a[0];
  if (distance <= (k / 2))
    answer = distance;
  else
  {
    for (int i = 0; i < (n - 1); i++) {
      if (max_diff < (a[i + 1] - a[i]))
        max_diff = a[i + 1] - a[i];
    }
    answer = k - max_diff;
    if (answer > distance)
      answer = distance;
  }

  printf("%d", answer);
  return (0);
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MAX_LEN = 30;
    int[][] as;
    int tmp;
    int n;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());
            as = new int[n][];
            for (int j = 0; j < n; j++) {
                String[] es = br.readLine().split(" ");
                as[j] = new int[MAX_LEN];
                for (int i = 0; i < MAX_LEN; i++) {
                    as[j][i] = Integer.parseInt(es[i]);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void solve() {
        for (n = 0; n < as.length; n++) {
            int ans = dfs(0);
            System.out.println(ans);
        }
    }

    private int dfs(int depth) {
        if (check())
            return depth;
        if (depth == 8)
            return Integer.MAX_VALUE;
        int min = Integer.MAX_VALUE, tmp;
        for (int i = 0; i < 4; i++) {
            operation(i);
            tmp = dfs(depth+1);
            min = Math.min(min, tmp);
            operation(i);
        }
        return min;
    }

    private void operation(int op) {
        switch (op) {
            case 0:
                for (int i = 0; i < 3; i++) {
                    swap(i, 27+i);
                }
                swap(14, 15);
                swap(18, 20);
                break;
            case 1:
                for (int i = 0; i < 3; i++) {
                    swap(6+i, 21+i);
                }
                swap(12, 17);
                swap(9, 11);
                break;
            case 2:
                for (int i = 0; i < 3; i++) {
                    swap(i*3, 23+3*i);
                }
                swap(15, 17);
                swap(9, 20);
                break;
            case 3:
                for (int i = 0; i < 3; i++) {
                    swap(2+3*i, 21+3*i);
                }
                swap(11, 18);
                swap(12, 14);
                break;
            default:
                break;
        }

    }

    private void swap(int i, int j) {
        tmp = as[n][i];
        as[n][i] = as[n][j];
        as[n][j] = tmp;
    }

    private boolean check() {
        boolean flg = true;
        for (int i = 0; i < 9; i++) {
            flg &= as[n][0] == as[n][i];
        }
        for (int i = 3; i < 6; i++) {
            for (int j = 0; j < 3; j++) {
                flg &= as[n][i*3] == as[n][i*3+j];
            }
        }
        for (int i = 23; i < MAX_LEN; i++) {
            flg &= as[n][23] == as[n][i];
        }
        return flg;
    }
}

Measured memory_bytes: 40708
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> F[i];
    
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());
    // rep(i, 0, N) cout << i << ' ' << A[i] << ' ' << F[i] << endl;
    // return 0;
    
    ll low = 0, high = 1000000000000;
    while (low < high)
    {
        // cout << low << ' ' << high << endl;
        ll mid = (low+high)/2;
        ll k = K;
        rep(i, 0, N)
        {
            ll tgt = mid/F[i];
            if (A[i] <= tgt) continue;
            else
                k -= A[i]-tgt;
        }
        // cout << k << endl;
        if (k >= 0)
            high = mid;
        else
            low = mid+1;
    }
    cout << low << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	static FastScanner sc = new FastScanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int d = (int)Math.sqrt(n);
		out.print(n+":");
		for (int i=2; i<=d; i++) {
			while (n%i==0) {
				n /= i;
				out.print(" "+i);
			}
			if (i==d && n>1) {out.print(" "+n);}
		}
		out.println();
	}
}



class FastScanner implements Closeable {
	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	public FastScanner(InputStream in) {this.in = in;}
	private boolean hasNextByte() {
		if (ptr < buflen) {return true;}
		else{
			ptr = 0;
			try {buflen = in.read(buffer);}
			catch (IOException e) {e.printStackTrace();}
			if (buflen <= 0) {return false;}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {throw new NumberFormatException();}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){return minus ? -n : n;}
			else{throw new NumberFormatException();}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
	public void close() {
		try {in.close();}
		catch (IOException e) {}
	}
}


Measured memory_bytes: 24456
instr = raw_input().strip()
commandnum = input()
for c in xrange(commandnum):
    command = raw_input().split()
    if command[0]=="replace":
        instr = instr[:int(command[1])]+command[3]+instr[int(command[2])+1:]
    elif command[0]=="reverse":
        instr = instr[:int(command[1])]+instr[int(command[1]):int(command[2])+1][::-1]+instr[int(command[2])+1:]
    elif command[0]=="print":
        print instr[int(command[1]):int(command[2])+1]
    else:
        print "invalid command."
        break

Measured memory_bytes: 6480
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    const as = nextIntArray()
    let m = {}
    for(let el of as){
        if(!m[el]) m[el] = 1
        else m[el]++
    }
    const Q = nextInt()
    let bs = []
    let cs = []
    while(hasNext()){
        let [b,c] = nextIntArray()
        bs.push(b)
        cs.push(c)
    }
    let sum = 0
    for(let key of Object.keys(m)){
        sum = sum + m[key]*key
    }
    for(let i = 0; i<Q; i++){
        let from = bs[i]
        let to = cs[i]
        if(m[from] && m[to]){
            sum = sum - m[from]*from + m[from]*to
            m[to] = m[to] + m[from]
            m[from] = 0
        }else if (m[from] && !m[to]){
            sum = sum - m[from]*from + m[from]*to 
            m[to] = m[from]
            m[from] = 0
        }
        console.log(sum)
    }
}
Main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

bool noC(string in) {
    int count = 0, n = in.size();
    for (int i = 2; i < n - 1; ++i) {
        if (in[i] == 'C')count++;
    }
    return (count == 1);
}

bool noUp(string in) {
    int n = in.size();
    for (int i = 1; i < n; ++i) {
        if (isupper(in[i]) && in[i] != 'C') return false;
    }
    return true;
}

int main() {
    fastio;
    string in;
    cin >> in;

    if (in[0] != 'A') cout << "WA";
    else if (!noC(in)) cout << "WA";
    else if (!noUp(in)) cout << "WA";
    else cout << "AC";

    return 0;
}

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

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

    int happy = 0;
    int num_g = 0;
    for( int n=1; n<N; n++){
        if( S[n] != S[n-1] ){
            num_g++;
        }else{
            happy++;
        }
    }

    for( int k=0; k<K; k++ ){
        if( num_g >= 2 ){
            happy += 2;
            num_g -= 2;
        }else if( num_g == 1 ){
            happy += 1;
            num_g -= 1;
        }
    }
    cout << happy << endl;
} 

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  UnionFind uf(N);
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    uf.con(a, b);
  }
  ll cnt=0;
  rep(i, N){
    if(uf.p[i]==i)cnt++;
  }
  cout << cnt-1;
  return 0;
}


Measured memory_bytes: 4844
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Integer i = sc.nextInt();
    String s = i.toString();
    if(s.contains("9")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
double eps=1e-9,inf=1e10;
typedef pair<double,double> P;
typedef pair<P,int> PP;
vector<PP> vc;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	rep(i,n){
		double p,t,v;
		cin>>p>>t>>v;
		p/=100;
		if(p==1){
			double tt;
			if(v==0) tt=inf;
			else tt=l/v+m*t;
			vc.pb(PP(P(tt,1),i));
			//cout << "i" << i << " " << tt << " " << 1 << endl;
			continue;
		}
		if(p==0){
			double tt;
			if(v==0) tt=inf;
			else tt=l/v;
			vc.pb(PP(P(tt,1),i));
			//cout << "i" << i << " " << tt << " " << 1 << endl;
			continue;
		}
		double pro=1;
		rep(j,m) pro*=(1-p);
		rep(j,m+1){
			double tt;
			if(v==0) tt=inf;
			else tt=l/v+j*t;
			vc.pb(PP(P(tt,pro),i));
			//cout << "i" << i << " " << tt << " " << pro << endl;
			pro*=p/(1-p);
			pro*=(double)(m-j)/(j+1);
		}
	}
	sort(all(vc));
	double ans[100]={};
	rep(i,vc.size()){
		if(vc[i].fs.fs>1e9) break;
		double cnt[100]={};
		for(int j=i+1;j<vc.size();j++){
			if(vc[j].fs.fs<vc[i].fs.fs+eps) continue;
			cnt[vc[j].sc]+=vc[j].fs.sc;
		}
		double ret=1;
		rep(j,n){
			if(j==vc[i].sc) ret*=vc[i].fs.sc;
			else ret*=cnt[j];
		}
		ans[vc[i].sc]+=ret;
	}
	rep(i,n) printf("%.9f\n",ans[i]);
}

Measured memory_bytes: 1400
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(K):
    tmp = gdc(b+1, a+1)
    for c in range(K):
      total += gdc(c+1, tmp)
print(total)


Measured memory_bytes: 9120
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>
#include <cstring>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

long double dp[310][310][310];
Int N;

long double solve(Int i, Int j, Int k) {
	if (i==0&&j==0&&k==0) {//終端条件
		return dp[i][j][k] = 0.0;
	}
	if (dp[i][j][k]>=0) {//既に探索済みならreturn
		return dp[i][j][k];
	}

	long double res = 0.0;
	if (i > 0) {
		res += solve(i - 1, j, k) * i;
	}
	if (j>0) {
		res += solve(i + 1, j - 1, k) * j;
	}
	if (k>0) {
		res += solve(i, j + 1, k - 1) * k;
	}
	res += N;
	res *= 1.0 / (i + j + k);

	return 	dp[i][j][k] = res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	Int a;
	Int cnt1 = 0;
	Int cnt2 = 0;
	Int cnt3 = 0;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		if (a==1) {
			cnt1++;
		}
		else if (a==2) {
			cnt2++;
		}
		else {
			cnt3++;
		}
	}

	//for (Int i = 0; i < 310; i++) {
	//	for (Int j = 0; j < 310; j++) {
	//		for (Int k = 0; k < 310; k++) {
	//			dp[i][j][k] = -1.0;
	//		}
	//	}
	//}

	memset(dp, -1, sizeof(dp));

	long double ans = solve(cnt1, cnt2, cnt3);
	cout << fixed << setprecision(10) << ans << "\n";
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  using P = pair<int, int>;
  map<int, vector<P>> range;
  int N, Q; cin >> N >> Q;
  rep(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    range[x].emplace_back(max(s - x, 0), max(t - x, 0));
  }
  set<int> ds;
  map<int, int> ans;
  rep(i, Q) {
    int d; cin >> d;
    ds.insert(d);
    ans[d] = -1;
  }
  each(r, range) {
    int x = r.first;
    each(v, r.second) {
      auto le = ds.lower_bound(v.first);
      auto ri = ds.lower_bound(v.second);
      vector<int> er;
      for (auto it = le; it != ri; it++) {
        er.push_back(*it);
      }
      each(e, er) ans[e] = x, ds.erase(e);
    }
  }
  each(a, ans) {
    cout << a.second << '\n';
  }
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine(a[0]==a[1] ? 2*a[0] : 2*a.Max()-1);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/


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

vector<vector<long>> adj;


void bfs(long s, vector<long> &ans)
{
    vector<bool> visited(10000, false);
    visited[s] = true;
    vector<pair<long, long>> queue;
    queue.emplace_back(s, 0);
    for (long i = 0; i < queue.size(); i++)
    {
        long nextv = queue[i].first;
        long thisd = queue[i].second;

        for (long x: adj[nextv])
        {
            if (!visited[x])
            {
                queue.emplace_back(x, thisd + 1);
                visited[x] = true;
            }
        }
        ans [thisd] ++;
    }
}


int main()
{
    long n, x, y;
    cin >> n >> x >> y;
    vector<long> ans(10000, 0);
    adj = vector<vector<long>> (n+1);
    for (int i = 1; i <= n; i++)
    {
        if (i != n)
            adj[i].push_back(i+1);
        if (i != 1)
            adj[i].push_back(i-1);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    for (int i = 1; i <= n; i++)
    {
        bfs(i, ans);
    }
    for (int i = 1; i <= n-1; i++)
        cout << ans[i]/2 << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  ll ans=(N-1)*N/2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define MOD1 1000000007

inline void inp( long long int  &n ){n=0;int ch=getchar();int sign=1;while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}while( ch >= '0' && ch <= '9' )n = (n<<3)+(n<<1) + ch-'0', ch=getchar();n=n*sign;}
#define pi acos(-1)
#define pii pair<int,int>
#define vii vector<pii>
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define ll  long long int
#define LL long long int
#define loop2(i,n) for(ll i=1;i<=n;i++)
#define MIN(a,b) (a) < (b) ? (a) : (b)
#define MAX(a,b) (a) > (b) ? (a) : (b)
#define ABS(a) (a) > 0 ? (a) : -(a)
#define rep1(i,a,n) for(i=a;i<(n);i++)
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
#define EPS 1e-9
#define ld long double
using namespace std;
//JAI SHREE KRISHNA
// Find the holy grail in an  adventure frought with danger
// The bigger the occasion, the better the response.
// Never giving in, fighting to the end
// Look at  the limits
// Check if it is binary search
// Code till the end of contest
#define Long                    long long
#define Ulong                   unsigned long long
#define forn(i,n)               for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define pb(a)                   push_back((a))
#define all(x)                  (x).begin(),(x).end()
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define xx                      first
#define yy                      second
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define Di(x)                   int x;scanf("%d",&x)
#define min(a,b)                ((a)>(b) ? (b) : (a) )
#define max(a,b)                ((a)>(b) ? (a):(b))
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))




int main(){
    ios::sync_with_stdio(false);
    
    cin.tie(0);
    ll n;
    cin>>n;
    cout<<(n*(n+1))/2;
    
    

   
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m,n;
while(cin>>m>>n){
    int x[m];
    for(i=0;i<m;i++)cin>>x[i];
    sort(x,x+m); k=x[m-1]-x[0];
    for(i=0;i<=m-n;i++){
        l=x[i+n-1]-x[i];
       if(k>l)k=l;
    }
    cout<<k<<endl;
} return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<pair<int, int>> R(n), B(n);
  rep(i, n) cin >> R[i].first >> R[i].second;
  rep(i, n) cin >> B[i].first >> B[i].second;
  vector<set<int>> G(2*n+2);
  rep(i, n) G[2*n].insert(i); // 始点
  rep(j, n) G[j+n].insert(2*n+1); // 終点
  rep(i, n) rep(j, n) {
    if(R[i].first < B[j].first && R[i].second < B[j].second) {
      G[i].insert(j+n);
    }
  }
  vector<int> path;
  bool flag = false;
  vector<bool> vis;
  auto dfs = [&](auto dfs, int cur, int par) {
    if(flag) return;
    if(vis[cur]) return;
    if(cur == 2*n+1) {
      path.push_back(2*n+1);
      int s = path.size();
      rep(i, s) if(i) {
        G[path[i-1]].erase(path[i]);
        G[path[i]].insert(path[i-1]);
      }
      flag = true;
      return;
    }
    vis[cur] = true;
    path.push_back(cur);
    for(int ne: G[cur]) {
      if(ne != par) {
        dfs(dfs, ne, cur);
        if(flag) return;
      }
    }
    path.pop_back();
  };
  while(1) {
    path.clear();
    flag = false;
    vis = vector<bool>(2*n+2);
    dfs(dfs, 2*n, -1);
    if(!flag) break;
  }
  cout << G[2*n+1].size() << "\n";
  return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
        ll n,m,c;
        ll b[30],a,sum=0,cnt=0;
        cin >> n >> m >> c;
        for(int i=0;i<m;i++)   cin >> b[i];
        for(int j=0;j<n;j++){
                for(int i=0;i<m;i++){
                        cin >> a;
                        sum+=a*b[i];
                }
                sum+=c;
                if(sum>0)       cnt++;
                sum=0;
        }
        cout << cnt;
        return 0;
}


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

using namespace std;

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	for (auto& x : A) {
		cin >> x;
		--x;
	}
	vector<int> ans(N, K - Q);
	for (auto x : A) {
		++ans[x];
	}
	for (auto x : ans) {
		if (x > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<double> V;
    rep (i, 0, N) {
        double v; cin >> v;
        V.push_back(v);
    }

    sort(V.begin(), V.end());
    double ans = (V[0] + V[1]) / 2.0;
    rep (i, 2, N) {
        ans = (ans + V[i]) / 2.0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(accumulate(a))
    for i in range(n):
        b[i] %= m
    b = [0] + b
    c = Counter(b)
    res = 0
    for k, v in c.items():
            res += v*(v-1)//2
    print(res)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 17660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

Measured memory_bytes: 256
lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=lines[1].select { |n| n % 2 == 0 }
b=1
for i in 0..a.length-1
  if a[i]%3!=0 && a[i]%5!=0 then
    b=0
    break
  end
end
if b==1 then
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    double x[10][10];
    int n,d;
    cin>>n>>d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin>>x[i][j];
        }
    }
    double s = 0,ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            s = 0;
            for(int k = 0; k < d; k++){
                s += pow(x[i][k]-x[j][k],2);
            }
            int sr = static_cast<int>(pow(s,0.5));
            if(sr * sr == s) ans++;
        }
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n; cin >> n;
	long long a[n];
	rep(i,0,n,1) cin >> a[i];
	map<long long, long long> mm;
	rep(i,0,n,1) mm[a[i]]++;
	long long q; cin >> q;
	long long ans = accumulate(a, a+n, 0ll);
	while(q--){
		long long b, c; cin >> b >> c;
		ans -= (mm[b]*b);
		ans += (mm[b]*c);
		mm[c] += mm[b];
		mm[b] = 0;
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
long long n,b;
  b=1;
  cin>>n;
  vector<string> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=1;i<n;i++){
    if(vec.at(i)!=vec.at(i-1)){
b++;
}
  }
   cout<<b<<endl;
}


Measured memory_bytes: 9516
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, m, i, j, b, x, ma;
	cin >> num >> m;
	vector<int> a(m), k(m);
	ma = 1 << num;
	vector<vector<int>> dp(m + 1, vector<int>(ma, INF));
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b;
		for (j = 0; j < b; j++) {
			cin >> x;
			k[i] += 1 << (x - 1);
		}
	}
	dp[0][0] = 0;
	for (i = 0; i < m; i++) {
		for (j = 0; j < ma; j++) {
			if (dp[i][j] != INF) {
				dp[i + 1][j | k[i]] = min(dp[i + 1][j | k[i]], dp[i][j] + a[i]);
			}
		}
		for (j = 0; j < ma; j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	if (dp[m][ma - 1] == INF)
		printf("-1\n");
	else
		cout << dp[m][ma - 1] << "\n";
	return 0;
}

Measured memory_bytes: 16384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
string s;
/**********************************/

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

    if(s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
	ll n;
	cin>>n;
	string s;
	map <string, ll> m;
	rep(i,0,n){
		cin>>s;
		if (m.find(s)==m.end()){
			m[s]=1;
		}
		else m[s]++;
	}
	ll maxi=0;
	for (auto i: m){
		if (i.S>maxi)maxi=i.S;
	}
	for (auto i:m){
		if (i.S==maxi)cout<<i.F<<endl;
	}
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 23808
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1])or(p[i+1]<p[i] and p[i]<p[i-1]):
        cnt += 1
print(cnt)


Measured memory_bytes: 9160