akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    vector<vector<char>> c(H,vector<char> (W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>c.at(i).at(j);
        }
    }
    vector<vector<char>> d(H,vector<char> (W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d.at(i).at(j)=c.at(i).at(j);
        }
    }
    int ans=0;
    for(int bit = 0;bit<(1<<H);++bit){
        for(int BIT = 0;BIT<(1<<W);++BIT){
            for(int i=0;i<H;i++){
                if(bit&(1<<i)){
                    for(int j=0;j<W;j++){
                        d.at(i).at(j)='r';
                    }
                }
            }
            for(int j=0;j<W;j++){
                if(BIT&(1<<j)){
                    for(int i=0;i<H;i++){
                        d.at(i).at(j)='r';
                    }
                }
            }
            int cnt=0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    // cout<<d.at(i).at(j)<<" ";
                    if(d.at(i).at(j)=='#'){
                        cnt++;
                    }
                    d.at(i).at(j)=c.at(i).at(j);
                }
                // cout<<endl;
            }
            // cout<<endl;
            if(cnt==K){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = 0;
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == '+'){
        ans++;
      }else{
        ans--;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

long long n, m;

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

    cin >> n >> m;

    cout << min(n, m / 2) + (m - 2 * min(n, m / 2)) / 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

#define maxn 100010
#define R register
char s[maxn];
bool ans[maxn];
int n;
inline void print_ans()
{
	for (R int i = 1; i <= n; ++i) printf("%c", ans[i] ? 'S' : 'W');
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (R int i = 0; i < 2; ++i)
	{
		ans[1] = i;
		for (R int j = 0; j < 2; ++j)
		{
			ans[n] = j; ans[2] = (s[1] == 'o') ^ ans[1] ^ ans[n];
			for (R int x = 2; x < n - 1; ++x)
				ans[x + 1] = (s[x] == 'o') ^ ans[x] ^ ans[x - 1];
			if (ans[n] == ((s[n - 1] == 'o') ^ ans[n - 1] ^ ans[n - 2])
			&& (s[n] == 'o') == (ans[n] ^ ans[n - 1] ^ ans[1]))
			{
				print_ans();
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int a[100][100], b[100], n, m,i;
	
	scanf("%d%d",&n,&m);
	
	for(i = 0; n > i; i++){
		int c;
		for(c = 0; m > c; c++){
		scanf("%d", &a[i][c]);
		}	
	}
	
	for(i = 0; m > i; i++){
		scanf("%d", &b[i]);
	}
	
	for(i = 0; n > i; i++){
		int sum = 0,c;
		for(c = 0; m > c; c++){
			sum += a[i][c] * b[c];
		}	
		printf("%d\n",sum);
	}
	return 0;
}

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

int main(){
string S;
cin >> S;
int lose = 0;
for(int i = 0; i < S.size(); i++){ 
     if(S.at(i) == 'x') lose++;
}

if(lose < 8)cout << "YES" << endl;
else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  int cnt = 0;
  REP(i,4) if(s[i]=='2') cnt++;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    S=list(map(int,input().split()))
    T=list(map(int,input().split()))
    C=[[0]*(m+1) for _ in range(n+1)] # dp の累積和を持つ
    for i in range(n): C[i][0]=1
    for j in range(m): C[0][j]=1

    for i in range(n):
        for j in range(m):
            if(S[i]==T[j]): C[i+1][j+1]+=C[i][j]
            C[i+1][j+1]+=C[i+1][j]+C[i][j+1]-C[i][j]
            C[i+1][j+1]%=MOD

    print((C[-1][-1]+2)%MOD)
resolve()

Measured memory_bytes: 72540
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	
	int n;
	cin>>n;
	
	vector< pair<int,int>>a(n);
	for(int i=0;i<n;++i)
	cin>>a[i].ff>>a[i].ss;
	
	int cnt=0;
	int mx=-1;
	 for(int i=0;i<n;++i)
	 {
	    if(a[i].ff==a[i].ss)
	    cnt++;
	    else
	    {
	    	mx=max(mx,cnt);
	    	cnt=0;
	    }
	 }
	mx=max(mx,cnt);
	 
	mx>=3?cout<<"Yes"<<endl:cout<<"No"<<endl;
	
	






}



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

	int t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}


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

int main(){
  int n;
  cin>>n;
  vector< pair< pair<string,int > , int> > vect;
  for(int i=0;i<n;i++){
    string s; int n;
    cin>>s>>n;
    vect.push_back(make_pair(make_pair(s,-n),i+1));
  }
  sort(vect.begin(),vect.end());
  for(int i=0;i<n;i++){
    cout<<vect[i].second<<"\n";
  }

  return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S

f st n = if S.member n st then S.delete n st else S.insert n st

main=do
    n <- readLn::IO Int
    res <- foldl' f S.empty <$> replicateM n B.getLine
    print $ S.size res


Measured memory_bytes: 36092
#include <stdio.h>
#include <string.h>
#define LEN 100005

/* プロセスを表す構造体 */
typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

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

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

int min(int a, int b){return a < b ? a :b;}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
 
    for(i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;


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


Measured memory_bytes: 11856
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;


int main(){
  long long s, c;
  cin >> s >> c;
  if(s*2 == c){
    cout << s << endl;
    return 0;
  }else if(s == 0 || c < 2){
    cout << 0 << endl;
    return 0;
  }
  else if(s*2 > c){
    cout << c/2 << endl;
    return 0;
  }else{
    cout << s+(c - 2*s)/4 << endl;
    return 0;
  }
  return 0;
} 


Measured memory_bytes: 256
import Foundation
//最大公約数を求める関数
func gcd(_ num1: Int, _ num2: Int) -> Int {
   let r = num1 % num2
   if r != 0 {
       return gcd(num2, r)
   } else {
       return num2
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}

//最小公倍数を求める関数
func lcm(_ num1: Int, _ num2: Int) -> Int {
    
    var gcdNum = gcd(num1, num2)
    return num1*num2/gcdNum
}

let rdInt = readLine()!.split(separator: " ").map({Int($0)!})
let a = rdInt[0]
let b = rdInt[1]
print(lcm(a, b))

Measured memory_bytes: 13600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector <int> a(n);
  vector <bool> close_list(n,false);/*既に押したボタンはtrue*/
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  int cnt=0;/*現在のボタンを押した回数*/
  int next_button=1;/*次に押すボタン*/
  for(int i=0;i<n;i++){/*ボタンの数を超える最短の経路はない（最大n回ループ*/
    close_list.at(next_button-1) = true;
    cnt++;
    
	
    
    next_button = a.at(next_button-1);
    if(close_list.at(next_button-1)==true){
      cout << -1 << endl;
      return 0;
    }
    if(next_button==2){
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

const int max_N = 1e5 + 21;

int n,m,ans,siz[max_N];

bool f[max_N][2];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		siz[i]=1,f[i][i==1]=1;
	while(m--){
		int x,y; scanf("%d%d",&x,&y);
		++siz[y];
		f[y][0]|=f[x][0],f[y][1]|=f[x][1];
		if(!--siz[x])f[x][0]=f[x][1]=0;
	}
	for(int i=1;i<=n;++i)if(f[i][1])++ans;
	printf("%d\n",ans);
	return 0;
}

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

vector<string> s;

int main(){
  int N;
  long len=1;
  int n[26]={};
  long count=0;
  string s1,temp;

  cin >> N;
  for(int i=0; i<N; i++){
    temp = "";
    for(int j=0; j<26; j++){
      n[j]=0;
    }
    cin >> s1;
    for(int j=0; j<10; j++){
      n[s1[j]-'a']++;
    }
    for(int j=0; j<26; j++){
      temp += to_string(n[j]);
    }
    s.push_back(temp);
  }
  sort(s.begin(), s.end());
  for(int i=0; i<N-1; i++){
    if(s[i]!=s[i+1]){
      count += len*(len-1)/2;
      len=1;
    }
    else len++;
  }
  count += len*(len-1)/2;
  cout << count << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<pll> A(N);

    for (ll i = 0; i < N; ++i) {
        ll num;
        cin >> num;
        A[i] = make_pair(num, i);
    }

    sort(all(A), greater<pll>());

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    for (ll i = 0; i < N; ++i) {
        for (ll j = 0; j <= i; ++j) {
            chmax(dp[i + 1][j + 1],
                  dp[i][j] + A[i].first * abs(A[i].second - j));
            chmax(dp[i + 1][j],
                  dp[i][j] + A[i].first * abs(A[i].second - (N - 1 - (i - j))));
        }
    }

    ll ans = 0;
    for (auto e : dp[N]) {
        chmax(ans, e);
    }

    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int l[N];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  sort(l, l + N, greater<int>());
  int answer = 0;
  for (int i = 0; i < K; i++) {
    answer += l[i];
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class btree
{
public:
    btree() {}
    btree(int n)
    : p(vs32(n, -1)), l(vs32(n, -1)), r(vs32(n, -1))
    {}
    ~btree() {}

    void preorder(int u)
    {
        cout << " " << u;
        int ll = l[u];
        int rr = r[u];
        if (ll >= 0) preorder(ll);
        if (rr >= 0) preorder(rr);
    }

    void inorder(int u)
    {
        int ll = l[u];
        int rr = r[u];
        if (ll >= 0) inorder(ll);
        cout << " " << u;
        if (rr >= 0) inorder(rr);
    }

    void postorder(int u)
    {
                int ll = l[u];
        int rr = r[u];
        if (ll >= 0) postorder(ll);
        if (rr >= 0) postorder(rr);
        cout << " " << u;
    }

    vs32 p;
    vs32 l;
    vs32 r;
};

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

    int n;
    cin >> n;

    btree bt(n);
    int p, l, r;
    rep (i, n)
    {
        cin >> p >> l >> r;
        bt.l[p] = l;
        bt.r[p] = r;
        if (l >= 0) bt.p[l] = p;
        if (r >= 0) bt.p[r] = p;
    }

    int root = 0;
    while (bt.p[root] >= 0) root = bt.p[root];

    cout << "Preorder\n";
    bt.preorder(root);
    cout << "\n";

    cout << "Inorder\n";
    bt.inorder(root);
    cout << "\n";

    cout << "Postorder\n";
    bt.postorder(root);
    cout << "\n";

    return 0;
}



Measured memory_bytes: 3184
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
   // freopen("file.in", "r", stdin);
    int n;
    cin>>n;
    long double ans=0;
    while(n--){
    	int x;
		cin>>x;
		ans+=1.0/x;	
    }
    cout<<setprecision(12)<<1.0/ans<<endl;
	return 0;
}


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

int main()
{
	int x[5] = { 1, 2, 3, 4, 5 };
	int in[5];
	int ans;

	for (int i = 0; i < 5; i++) {
		cin >> in[i];
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] != in[i])
			ans = i+1;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3596
import Foundation

func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func counter(_ seq: [String]) -> [String: Int] {
    var count = [String:Int]()
    for e in seq {
        if count.contains(where: {$0.key == e}) {
            count[e]! += 1
        } else {
            count[e] = 1
        }
    }
    return count
}

func main() {
    let N = Int(readLine()!)!
    let s = counter((1...N).map { _ in readLine()! })

    let M = Int(readLine()!)!
    let t = counter((1...M).map { _ in readLine()! })

    var ans = 0
    for (label, blueCount) in s {
        if let redCount = t[label] {
            if blueCount > redCount {
                ans = max(ans, blueCount - redCount)
            }
        } else {
            ans = max(ans, blueCount)
        }
    }

    print(ans)
}


main()

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

int main()
{
	int n;
	cin >> n;
	float sum = 0;
	while(n--){
		float a;
		cin >> a;
		sum += (1.0 / a);
	}
	float ans = 1.0 / sum;
	printf("%.6f",ans);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
    }else{
        ll ans =1;
        for(ll i=1;i<=n;i++){
            ans*=i;
            ans%=mod;
        }
        for(ll i=1;i<=m;i++){
            ans*=i;
            ans%=mod;
        }
        if(n==m) ans*=2;
        cout << ans%mod << endl;
    }

    return 0;
}

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


int main() {

    ll n,a,b; cin >> n >> a>> b;

    if(n == 1 && a != b) cout << 0;
    else if(a > b) cout << 0;
    else{
        cout << a+b*(n-1) - (b+a*(n-1)) + 1;
    }
    return 0;
}











Measured memory_bytes: 3592
#include<stdio.h>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
int main(){
  long long a,b,c=0,i;
  scanf("%lld %lld",&a,&b);
  a=gcd(a,b);//printf("%lld\n",a);
  for(i=2;i*i<=a;i++){
    if(a%i)continue;
    c++;
    while(a%i==0)a/=i;
  }
  if(a-1)c++;
  printf("%lld\n",c+1);
  return 0;
}


Measured memory_bytes: 128
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n,k;
  cin >> n >> k;
  string s; cin >> s;
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)) ans++;
  }
  if((n-ans-k*2)>0) ans=ans+k*2;
  else{ 
    ans=n-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a,b,c,i,j;
	j=0;
	scanf("%d %d %d",&a,&b,&c);
	i = a;
	while(i <= b)
	{
		if(c%i == 0)
		{
			j++;
		}
		i++;
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 596
(function(stdin) {
'use strict';

  var inputs = stdin.toString().trim();
  var re = /\w+\n[\w\s]*?\n/g;
  var lines = inputs.match(re).map(function(line) {
    return line.split('\n')[1]
      .split(' ')
      .slice(0, line.split('\n')[0])
      .map(Number);
  });
  var result = (function(lines) {

    return lines.map(stdev);

    function stdev(scores) {
      var dev = deviation(average(scores));
      return Math.sqrt(average(scores.map(dev)));
      // return [[scores.map(dev)].map(average)].map(Math.sqrt);
    }

    function deviation(average) {
      return function(score) {
        return Math.pow(score - average, 2);
      };
    }

    function average(scores) {
      return sum(scores) / scores.length;
    }

    function sum(scores) {
      return scores.reduce(add);
    }

    function add(a, b) {
      return a + b;
    }

  })(lines);

  console.log(result.join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
    int h,w;
    cin >> h >> w;

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

    string s[h];
    rep(i,h){
        cin >> s[i];
    }

    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                int ans(0);
                rep(k,8){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x>=0&&x<=h&&y>=0&&y<=w&&s[x][y]=='#'){
                        ans++;
                    }
                }
                s[i][j] = '0' + ans;
            }
        }
    }

    rep(i,h){
        cout << s[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long doubling(long long n, long long m){
  long long y = 1;
  long long base = n;
  while (m != 0){
    if (m % 2 == 1){
      y *= base;
      y %= mod;
    }
    base *= base;
    base %= mod;
    m /= 2;
  }
  return y;
}

int main(){
  int X, Y;
  cin >> X >> Y;
  long long cnt = 0;
  if ((2*Y-X) % 3 == 0 && (2*X-Y) % 3 == 0 && 2*Y >= X && 2*X >= Y){
    int x = (2 * Y - X) / 3, y = (2 * X - Y) / 3;
    long long fx = 1, fy = 1, fxy = 1;
    for (int i=1;i<=x+y;i++){
      if (i <= x){
        fx *= i;
        fx %= mod;
      }
      if (i <= y){
        fy *= i;
        fy %= mod;
      }
      fxy *= i;
      fxy %= mod;
    }
    cnt = fxy * doubling(fx, mod-2);
    cnt %= mod;
    cnt *= doubling(fy, mod-2);
    cnt %= mod;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	long long ans = 1, b = 1;
  	cin >> n;
	vector<long long> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if(a[0] == 0){
		ans = 0;
	}else{
		for(int i=0;i<n;i++){
			b = ans;
			ans *= a[i];
			if(b > 1000000000000000000/a[i]){
				ans = -1;
			}
			if(ans == -1) break;
		}
	}
	cout<< ans<<endl;
}

Measured memory_bytes: 4048
n = int(input())
ans = 0
for i in range(1, n + 1):
  yaku = 0
  for j in range(1, i + 1):
    if i % j == 0:
      yaku += 1
  if yaku == 8 and i % 2 == 1:
    ans += 1
print(ans)

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

int main()
{
	int N,K;
	int h[100010]={};
	int ans=1e9+10;
	
	cin >> N >> K;
	for(int i=0;i<N;i++)
	{
		cin >> h[i];
	}
	sort(h,h+N);
	for(int i=0;i<N-K+1;i++)
	{
		ans=min(ans,h[i+K-1]-h[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=10000000000;
int main() {
	int n,k;
	cin>>n>>k;
	vector<int> p(n);
	for(int i=0;i<n;i++) {
		cin>>p[i];
		p[i]--;
	}
	vector<int> c(n);
	for(int i=0;i<n;i++) cin>>c[i];
	if(k<=n) {
		ll ans=-INF;
		for(int i=0;i<n;i++) {
			ll P=i,s=0;
			for(int j=0;j<k;j++) {
				P=p[P];
				s+=c[P];
				ans=max(ans,s);
			}
		}
		cout<<ans<<endl;
	}
	else {
		vector<vector<int> > next(31,vector<int>(n) );
		for(int i=0;i<n;i++) next[0][i]=p[i];
		for(int i=1;i<31;i++) 
			for(int j=0;j<n;j++)
				next[i][j]=next[i-1][next[i-1][j]];
		vector<vector<ll> > sum(31,vector<ll>(n) );
		for(int i=0;i<n;i++) sum[0][i]=c[p[i]];
		for(int i=1;i<31;i++) 
			for(int j=0;j<n;j++) 
				sum[i][j]=sum[i-1][j]+sum[i-1][next[i-1][j]];
		ll ans=0;
		for(int i=0;i<n;i++) {
			ll P=i;
			ll s=0;
			for(int j=0;j<n;j++) {
				P=p[P];
				s+=c[P];
				ans=max(ans,s);
			}
			P=i;s=0;
			for(int j=0;j<31;j++) {
				if((k-n)>>j & 1) {
					s+=sum[j][P];
					P=next[j][P];
				}
			}
			ans=max(ans,s);
			for(int j=0;j<n;j++) {
				P=p[P];
				s+=c[P];
				ans=max(ans,s);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 5112
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ABC = il()
    if ABC[0] == ABC[1] == ABC[2]:
        print(0)
        exit()
    n = 1
    while True:
        if 3 * n >= sum(ABC) and n >= max(ABC) and (3 * n - sum(ABC)) % 2 == 0:
            print((3 * n - sum(ABC)) // 2)
            exit()
        else:
            n += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 10016
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
bool isp[N] = {};
vector<int> pri;
void build() {
    isp[0] = isp[1] = true;
    for (long long i = 2; i < N; i++)
        if (!isp[i]) {
            pri.emplace_back(i);
            for (long long j = i * i; j < N; j += i)
                isp[j] = true;
        }
}
int main() {
    build();
    long long n;
    cin >> n;
    long long ans = 0;
    for (const long long &v : pri) {
        int cnt = 0;
        while (n % v == 0) {
            cnt++;
            n /= v;
        }
        for (int i = 1; cnt; i++) {
            if (cnt >= i) {
                cnt -= i;
                ans++;
            }
            else break;
        }
    }
    if (n != 1) ans++;
    cout << ans << '\n';
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int x[m],y[m];
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  int count[n],red[n];
  count[0]=1,red[0]=1;
  for(int i=1;i<n;i++){
    count[i]=1,red[i]=0;
  }
  for(int i=0;i<m;i++){
    count[x[i]]--;
    count[y[i]]++;
    if(red[x[i]]==1){
      red[y[i]]=1;
      if(count[x[i]]==0){
        red[x[i]]=0;
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++) ans+=red[i];
  cout << ans << endl;
}

Measured memory_bytes: 1792
import collections
N=int(input())
A=list(map(int,input().split()))

c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
for i in range(len(values)):
    values[i]=(values[i]-1)%2
print(len(values)-sum(values)%2)

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

int G(int a, int b) {
  if (a<b) swap(a,b);
  if (a%b == 0) return b;
  G(b,a%b);
}

int main() {
  int N,x;
  cin >> N >> x;
  vector<int> dist(N);
  for (int i = 0; i < N; i++) {
    int e;
    cin >> e;
    dist[i] = abs(e-x);
  }
  int g = dist[0];
  for (int i = 1; i < N; i++) {
    g = G(g,dist[i]);
  }
  
  cout << g << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
    ll h, w;
    cin >> h >> w;
    ll res = h * w;

    for (ll i = 1; i < h; ++i) {
        ll areaA = i * w;

        ll n = h - i;
        ll m = w;
        if (n > 1) {
            ll x = n / 2;
            ll y = n - n / 2;
            ll areaB = x * m;
            ll areaC = y * m;
            ll mx = max({areaC, areaB, areaA});
            ll mn = min({areaC, areaB, areaA});
            res = min(res, mx - mn);
        }

        swap(n, m);
        if (n > 1) {
            ll x = n / 2;
            ll y = n - n / 2;
            ll areaB = x * m;
            ll areaC = y * m;
            ll mx = max({areaC, areaB, areaA});
            ll mn = min({areaC, areaB, areaA});
            res = min(res, mx - mn);
        }
    }
    swap(h, w);
    for (ll i = 1; i < h; ++i) {
        ll areaA = i * w;

        ll n = h - i;
        ll m = w;
        if (n > 1) {
            ll x = n / 2;
            ll y = n - n / 2;
            ll areaB = x * m;
            ll areaC = y * m;
            ll mx = max({areaC, areaB, areaA});
            ll mn = min({areaC, areaB, areaA});
            res = min(res, mx - mn);
        }

        swap(n, m);
        if (n > 1) {
            ll x = n / 2;
            ll y = n - n / 2;
            ll areaB = x * m;
            ll areaC = y * m;
            ll mx = max({areaC, areaB, areaA});
            ll mn = min({areaC, areaB, areaA});
            res = min(res, mx - mn);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())

plan = []
for i in range(N):
    plan += [[int(n) for n in input().split(' ')]]

ret = "Yes"
t0 , x0, y0 = 0, 0, 0
for t, x, y in  plan:
    dt = t-t0
    dx = abs(x-x0)
    dy = abs(y-y0)
    result = dt - (dx+dy)
    if result<0:
        ret = "No"
        break
    if result%2!=0:
        ret = "No"
        break
    t0, x0, y0 = t, x, y
print(ret)


Measured memory_bytes: 21052
#include <stdio.h>
int main(void){
	int n,i;
	long long ans=1;
	long long mod=1000000007;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		ans=ans*i%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  int a, b;
  vector<int> res(N);
  for(int i = 0; i < M; i++)
  {
    cin >> a >> b;
    res.at(a-1)++;
    res.at(b-1)++;
  }
  for(int i = 0; i < N; i++)
    cout << res.at(i) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n;
    cin >> n;
    bool k = false;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a%2 ==1) k = true;
    }
    if(k) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}

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

int main() {

    int n, count;

    cin >> n >> count;

    int i;
    bool isTrue = false;
    for(i = 0; i <= n; ++i) {

        int k = i * 4;
        int t = (n - i) * 2;

        if(k + t == count)
            isTrue = true;

        if(isTrue)
            break;

    }

    if(isTrue) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pi pair<int, int>
#define pb push_back

using namespace std;

const int maxn = 1e5 + 1;

int a[maxn], p[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m; int cs = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; cs += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] * 4 * m >= cs)
            ++cnt;
    }
    cout << (cnt >= m ? "Yes" : "No");
    return 0;
}
/*
2
aabbaabbbaaaa
aaaabbbaabbaa

2
bbaabaaaaabbbbbbbababaabaabaabbabababbbabbabbabbbabaabbbbbbaabaaaaaaaaababaaabbabbaaaaaabaababbaaabbbbbaaabababbaaabbbbaaababbbabaaabaaabbbbbbbbbbbabaaaaabaabababababbbaabaaaababaababbaaaabbababbbabba
abbabbbababbaaaabbabaababaaaabaabbbababababaabaaaaababbbbbbbbbbbaaabaaababbbabaaabbbbaaabbababaaabbbbbaaabbabaabaaaaaabbabbaaababaaaaaaaaabaabbbbbbaababbbabbabbabbbabababbaabaabaabababbbbbbbaaaaabaabb
*/


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	a := scanInts(n)
	count := make(map[int]int, n)
	for i := 0; i < n; i++ {
		count[a[i]]++
	}

	sum := make(map[int]int, n)
	sumPrev := make(map[int]int, n)
	sumAll := 0
	for i := 0; i < n; i++ {
		num := a[i]
		if _, ok := sum[num]; !ok {
			sum[num] = calculateSum(count[num])
			sumAll += sum[num]

			sumPrev[num-1] = calculateSum(count[num] - 1)
		}
	}

	for k := 0; k < n; k++ {
		sub := sum[a[k]] - sumPrev[a[k]-1]
		fmt.Println(sumAll - sub)
	}
}

func calculateSum(n int) int {
	return (n * (n - 1)) / 2
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}


Measured memory_bytes: 19840
// abc149_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int max_n = 1e5;

    int ans = 0;

    REP(i, N){
        ans += A[i]-1;
    }
    print(ans);

    return 0;
}


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

static const long MAX = 100000;
typedef pair<long, long> P;
long N, M, A[MAX], S[MAX];

P check(long X){
    long MO = 0, sum = 0;
    for(int i = N - 1; i >= 0; i--){
        long *pos = lower_bound(A, A + N, X - A[i]);
        long idx = distance(A, pos);
        if(idx >= N) break;
        MO += N - idx;
        sum += (N - idx) * A[i] + S[idx];
    }
    return P(MO, sum);
}

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);
    S[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--) S[i] = S[i + 1] + A[i];
    
    long left = 0, right = MAX * MAX;
    while(left < right){
        long mid = (left + right) / 2;
        if(check(mid).first >= M && check(mid + 1).first < M){
            cout << check(mid + 1).second + mid * (M - check(mid + 1).first) << endl;
            return 0;
        }
        if(check(mid).first < M) right = mid;
        else left = mid + 1;
    }
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  int cnt = 0, mn = 1e6;
  rep(i, n) {
    int p;
    cin >> p;
    if (p <= mn) {
      cnt++;
      mn = p;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
"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 = () => {
    let [h, w] = next().split(" ").map(el => BigInt(el))
    let first, second
    let firstRow, secondRow

    if(w == 1n || h == 1n){
        console.log(1)
        return
    }

    if (w % 2n == 0n) {
        first = w / 2n
        second = w / 2n
    } else {
        first = w / 2n + 1n
        second = w / 2n
    }
    if (h % 2n == 0n) {
        firstRow = h / 2n
        secondRow = h / 2n
    } else {
        firstRow = h / 2n + 1n
        secondRow = h / 2n
    }
    console.log((first * firstRow + second * secondRow).toString())
}
Main()


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

int main(){
  int N;
  int sum_satis = 0;
  cin >> N;
  vector<int> dinner(N);
  vector<int> satis(N);
  vector<int> add_satis(N-1);

  for(int i = 0; i < N; i++)
    cin >> dinner[i];
  for(int i = 0; i < N; i++)
    cin >> satis[i];
  for(int i = 0; i < N-1; i++)
    cin >> add_satis[i];

  int before = -1;
  for(int i = 0; i < N; i++){
    sum_satis += satis[dinner[i]-1];
    if(before == -1)
      before = dinner[i]-1;
    else if(before + 1 == dinner[i]-1)
      sum_satis += add_satis[before];
    before = dinner[i]-1;
  }

  cout << sum_satis << endl;
  return 0;

}

Measured memory_bytes: 256
/*
 * Membership Management
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1305
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string input_group(map<string, vector<string>> &group){
  string line;
  string g;
  cin >> line;
  auto it = line.begin();
  while(*it != ':') g += *it++;
  it++;
  while(it != line.end()) {
    string s;
    while(*it != ',' && *it != '.') {
      s+=*it++;
    }
    group[g].push_back(s);
    it++;
  }
  return g;
}

int main() {
  int n;
  while(cin >> n, n) {
    map<string, vector<string>> group;
    string first = input_group(group);
    REP(i, n - 1){
      input_group(group);
    }
    set<string> done;
    queue<string> que;
    que.push(first);
    int cnt = 0;
    while(!que.empty()) {
      string p = que.front(); que.pop();
      if(EXIST(done, p)) continue;
      done.insert(p);
      if(!EXIST(group, p)) {
        // cout << p << endl;
        cnt++;
      }else{
        for(string s : group[p]) {
          que.push(s);
        }
      }
    }
    cout << cnt << endl;
  }
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int INF = 1e9;
struct edge { int to, cost; };
typedef pair<int, int>P;	//最短距離,頂点

int N;
vector<edge>G[100];
int d[100];
int pre[100];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + N, INF);
	fill(pre, pre + N, -1);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
				pre[e.to] = v;
			}
		}
	}
}
vector<int>get_path(int t) {
	vector<int>path;
	for(; t != -1; t = pre[t])path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}
int main() {
	cin.sync_with_stdio(false);
	cin >> N;
	int M;
	cin >> M;
	int a, b, c;
	rep(i, M) {
		cin >> a >> b >> c;
		a--; b--;
		edge e1, e2;
		e1.to = a, e1.cost = c;
		e2.to = b, e2.cost = c;
		G[a].push_back(e2);
		G[b].push_back(e1);
	}
	int flag[100][100] = {};
	rep(i, N - 1) {
		dijkstra(i);
		reps(j, i + 1, N) {
			rep(k, get_path(j).size() - 1) {
				flag[get_path(j)[k]][get_path(j)[k + 1]] = true;
				flag[get_path(j)[k + 1]][get_path(j)[k]] = true;
			}
		}
	}
	int ans = 0;
	rep(i, N) {
		rep(j, N)if (flag[i][j])ans++;
	}
	cout << (2*M - ans)/2 << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	long long int N;
	cin >> N;
	vector<long long int>L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	int Ans = 0;
	for (long long int i = 0; i < N; i++) {
		for (long long int j = 0; j < N; j++) {
			for (long long int k = 0; k < N; k++) {
				if ((i < j) && (j < k)) {
					if (L[i] != L[j]) {
						if (L[j] != L[k]) {
							if (L[i] != L[k]) {
								//3辺の和<最大辺の2倍で比較する
								if ((L[i] + L[j] + L[k]) > max({ L[i],L[j],L[k] }) * 2) {
									Ans += 1;
								}
							}
						}
					}
				}
			}
		}
	}
	cout << Ans << endl;
}

Measured memory_bytes: 3604
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        double w=sc.nextInt();
        double h=sc.nextInt();
        double x=sc.nextInt();
        double y=sc.nextInt();
        double a=w*h/2d;
        int one=0;
        if (w==2*x && h==2*y)one=1;
        System.out.println(a+" "+one);
    }


}



Measured memory_bytes: 21716
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	ll h; cin>>h;
	ll level = log2(h); 
	ll ans = pow(2,level+1) - 1;
	cout<<ans;
	return 0;
}





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

signed main(){
  int n;
  cin>>n;
  int k=-1;
  for(int i=1;i<=n+1;i++)if(i*(i-1)/2==n)k=i;
  if(k==-1)cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    int p=2*n/k;
    vector<int> v[k];
    int c=1;
    for(int i=0;i<k;i++){
      for(int j=i+1;j<k;j++){
	v[i].push_back(c);
	v[j].push_back(c++);
      }
    }
    for(int i=0;i<k;i++){
      cout<<p;
      for(int x:v[i]){
	cout<<" "<<x;
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3200
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
        d: isize,
    }
    let v = [a * c, a * d, b * c, b * d];
    println!("{}", v.iter().max().unwrap());
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //Electric bulletin board
  int eBB = 1;
  int N, K;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    if((eBB * 2) < (eBB + K)){
      eBB *= 2;
    }else{
      eBB += K;
    }
  }
  
  cout << eBB << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a, b)
    return a // g * b

ans = 1
N = int(input())
for _ in range(N):
    t = int(input())
    ans = lcm(ans, t)
print(ans)

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

int main (){
  int A, B, X;
  cin >> A >> B >> X;
  bool jud = false;
  
  if(A+B >= X){
    if(A <= X){
      jud = true;
    }
  }
  
  if(jud){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[3010],B[3010];
int dp[3010][3010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		dp[i][i]=0;
	}
	for(int len=1;len<=N;len++){
		for(int i=0;i+len<=N;i++){
			int j=i+len;
			if((N-len)%2==0){
				dp[i][j]=max(dp[i+1][j]+A[i],dp[i][j-1]+A[j-1]);
			}
			else{
				dp[i][j]=min(dp[i+1][j]-A[i],dp[i][j-1]-A[j-1]);
			}
		}
	}
	cout<<dp[0][N]<<endl;
	return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int INF = 10000000;
int a[200005];
int n, k;
int main(void){
    cin >> n >> k;
    for (int i = 0; i <= n; i++) a[i] = 0;
    for (int i = 0; i < n; i++){
        int s;
        cin >> s;
        a[s]++;
    }
    sort(a, a + n + 1);
    int count = 0;
    for (int i = 0; i <= n; i++) if (a[i] != 0) count++;
    int ans = 0;
    int cnt = 0;
   
    for (int i = 0; i <= n; i++){
        if (cnt == max(count - k, 0)) break;
        if (a[i] == 0) continue;
        ans += a[i];
        cnt++;
    }

    cout << ans << endl;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B < C)
    {
        cout << "No" << endl;
        return 0;
    }
    if (A + B >= C)
    {
        cout << "Yes" << endl;
        return 0;
    }
}


Measured memory_bytes: 256