akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
  val (N, i) = readInts()
  println(N - i + 1)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 37948
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 


int main()
{
 //freopen("input.txt","r",stdin);
 //  ios::sync_with_stdio(0);
// cin.tie(0);
int h,w;
cin>>h>>w;
vector<string> v(h);
for(int i=0;i<h;++i)
cin>>v[i];
vector<vector<int>>dp(h+1,vector<int>(w+1));
dp[0][1]=1;

for(int i=1;i<=h;++i){
    for(int j=1;j<=w;++j){
        if(v[i-1][j-1]=='#'){
            dp[i][j]=0;
            continue;
        }
        dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
    }
}
cout<<dp[h][w];
    return 0;
}

Measured memory_bytes: 9424
N, M, P = map(int, input().split())

abc = []
for i in range(M):
  a, b, c = map(int, input().split())
  abc.append([a-1, b-1, c-P])


dist = [-float('inf')]*N
dist[0] = 0
for i in range(N):
  for a, b, c in abc:
    dist[b] = max(dist[b], dist[a] + c)


for a, b, c in abc:
  d = dist[a] + c
  if dist[b] < d:
    dist[b] = float('inf')

for i in range(N-1):
  for a, b, c in abc:
    dist[b] = max(dist[b], dist[a] + c)

if dist[-1] < float('inf'):
  ans = max(0, dist[-1])
else:
  ans = -1

print(ans)

Measured memory_bytes: 57176
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A + B < 10) {
		cout << A + B << endl;
	}
	else {
		cout << "error" << endl;
	}
}


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

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll n, k;
    cin >> n >> k;
    vll d(k);
    REP(i, k) cin >> d[i];
    ll res = n, tmp, ng;
    while(1){
        ng = 0;
        tmp = res;
        while(tmp){
            REP(i, d.size()){
                if(tmp % 10 == d[i]) ng = 1;
            }
            tmp /= 10;
        }
        if(!ng){
            cout << res << endl;
            return 0;
        }
        res++;
    }
}


Measured memory_bytes: 256
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

def factorize(g):
  factor = []
  for i in range(2, int(np.sqrt(g))+2):
    if g % i != 0:
      continue
    while g % i == 0:
      g //= i
    factor.append(i)
  if g != 1:
    factor.append(g)
  return factor
print(len(factorize(g))+1)

Measured memory_bytes: 14352
#include<bits/stdc++.h>
using namespace std;
inline void read(int& x)
{
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
}
map<string, int> mp;
set<pair<int, string> >s;
string tp[200005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> tp[i], ++mp[tp[i]];
	for (int i = 1; i <= n; ++i) s.insert(make_pair(-mp[tp[i]], tp[i]));
	int num = (*s.begin()).first;
	for (auto it = s.begin(); it != s.end(); ++it)
	{
		if ((*it).first != num) break;
		cout << (*it).second << endl;
	}
	return 0;
}

Measured memory_bytes: 37888
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;

int N, H;

int main() {
  int N, H;
  vector<pii> vp;
  cin >> N >> H;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    vp.push_back(pii(a,b));
  }

  sort(all(vp));

  pii lastp = vp[N-1];

  vector<int> v;
  rep(i, N-1) v.push_back(vp[i].sc);
  sort(all(v), greater<int>());

  int ans = 0, ns = 0;
  while(H > 0) {
    if (H <= lastp.sc) {
      H -= lastp.sc; ++ans;
    } else if (ns <= N-2 && v[ns] > lastp.fi) {
      H -= v[ns]; ++ns; ++ans;
    } else {
      int t = (H-lastp.sc+lastp.fi-1)/lastp.fi;
      H -= t * lastp.fi; ans += t;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  k%=MOD;
  ll kk=(k*(k-1)/2)%MOD;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll result=0;
  rep(i,n){
    ll fn=0, rn=0;
    rep(j,n){
      if(a[i]>a[j]){
        rn++;
        if(j>i)fn++;
      }
    }

    result += fn*k + rn*kk;
    result %= MOD;
//cout<<(fn + rn*(k-1))<<' '<<fn<<' '<<rn<<' '<<rn*(k-1)<<endl;
  }

  cout<<result%MOD;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+10;
const LL mod = 1000000007;
int a[maxn];
int cnt[maxn]={0};
int main() {

    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        scanf("%d",a+i);
        ++cnt[a[i]];
    }
    int ans=0;
    for (int i=1;i<=n;++i) {
        if (cnt[a[i]]) {
            ans+=cnt[a[i]]-1;
            cnt[a[i]]=0;
        }
    }
    (ans&1)&&(++ans);
    printf("%d\n",n-ans);
    return 0;
}


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

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

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

  cout << a.at(n-1)-a.at(0) << endl;
  
}


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

int main() {
	int m, n, ans;
	cin >> n >> m;
	for (int i = 1; i*i <= m; i++) {
		if (m%i == 0) {
			if (i <= m / n) {
				if (m / i <= m / n) {
					ans = max(ans, m / i);
				} else {
					ans = max(ans, i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

const int N = 105;

int n, m, a[N], sum;

int main(){
	read(n, m);
	for(int i = 1; i <= n; i++){
		read(a[i]);
		sum += a[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++)
		if(a[i] * 4 * m >= sum)
			cnt++;
	puts(cnt >= m ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += sc.nextLong() - 1;
        }
        System.out.println(ans);
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;

  int all_voted = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    all_voted += a.at(i);
  }

  double base = all_voted / (4 * m);
  int count = 0;
  
  for (int i = 0; i < n; i++) {
    if (a.at(i) * 4 * m >= all_voted) count++;
  }
  
  cout << (count >= m ? "Yes" : "No") << endl;
}

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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  cnt=0;
  for(i=0;i<=7;i++){
    for(j=0;j<n;j++){
      if(400*i<=a[j] && a[j]<400*(i+1)){
        cnt++;
        break;
      }
    }
  }
  if(cnt==0)cout<<1<<endl;
  else cout<<cnt<<endl;
  for(i=0;i<n;i++){
    if(a[i]>=3200)cnt++;
  }
  cout<<cnt;
}

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

char solve(char a){
	if(a=='A')return 'a';
	if(a=='B')return 'b';
	if(a=='C')return 'c';
	if(a=='D')return 'd';
	
	if(a=='E')return 'e';
	if(a=='F')return 'f';
	if(a=='G')return 'g';
	if(a=='H')return 'h';
	if(a=='I')return 'i';
	if(a=='J')return 'j';
	if(a=='K')return 'k';
	if(a=='L')return 'l';
	if(a=='M')return 'm';
	if(a=='N')return 'n';
	if(a=='O')return 'o';
	
	if(a=='P')return 'p';
	
	if(a=='Q')return 'q';
	if(a=='R')return 'r';
	if(a=='S')return 's';
	
	if(a=='T')return 't';
	if(a=='U')return 'u';
	if(a=='V')return 'v';
	if(a=='W')return 'w';
	if(a=='X')return 'x';
	if(a=='Y')return 'y';
	if(a=='Z')return 'z';
}

int main(){
	int N,K;
	cin >> N >> K;
	string s;
	cin >> s;
	
	s[K-1]=solve(s[K-1]);
	
	cout << s<<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,dp[5][110];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	scanf("%d",&dp[i][j]);
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	dp[i][j]=dp[i][j]+max(dp[i-1][j],dp[i][j-1]);
	printf("%d",dp[2][n]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	string s; cin>>s;
	int n=s.length();
	bool ok=1;
	int id1=0, id2=n/2 - 1;
	while(id1<id2)
	{
	    if(s[id1]!=s[id2]){ ok=0; break; }
	    id1++; id2--;
	}
	if(!ok){ cout<<"No"; return 0; }
	id1=n/2 + 1, id2=n - 1;
	while(id1<id2)
	{
	    if(s[id1]!=s[id2]){ ok=0; break; }
	    id1++; id2--;
	}
	if(!ok){ cout<<"No"; return 0; }
	id1=0, id2=n-1;
	while(id1<id2)
	{
	    if(s[id1]!=s[id2]){ ok=0; break; }
	    id1++; id2--;
	}
	if(!ok){ cout<<"No"; return 0; }
	
	cout<<"Yes";
	
	return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
  ll N;
  cin >> N;
  ll a[1005] = {0};
  for(ll i = 2; i <= N; i++){
    ll target = i;
    for(ll j = 2; j <= target; j++){
      while(target > 0 && target % j == 0){
        a[j]++;
        target /= j;
      }
    }
  }
ll ans = 1;
for(int i = 0; i <= N; i++){
  if(a[i] == 0)continue;
  ans *= a[i] + 1;
  ans %= MOD;
}

print(ans);

}

Measured memory_bytes: 256
n=gets.to_i
s=gets.chomp
#cnt=0
#ans=0
#s.each do|c|
  #if cnt==0 and c=="A"
    #cnt+=1
  #elsif cnt==1 and c=="B"
    #cnt+=1
  #elsif cnt==2 and c=="C"
    #ans+=1
    #cnt=0
  #else
    #cnt=0
  #end
#end
#puts ans
puts s.scan(/(ABC)/).size


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	// int t;
	// cin>>t;
	// while(t--){
		
	// }
	int h, a;
	cin>>h>>a;
	cout<<(h + a - 1) / a<<endl;
	return 0;
}

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

#define ll long long int
#define hell 998244353
#define vi vector <ll>
#define pb push_back
#define pii pair<ll,ll>
#define vii vector <pii>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sep(i,a,b)  for(ll i=a-1;i>=b;i--)
#define inf (ll)(1e16)

using namespace std;

void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int  K,S,cnt;
  cin >> K >> S;
  cnt = 0;
  for (int i = 0; i <= K; i++){
      for (int j = 0; j <= K; j++){
          if (S - i - j <= K && S - i - j >= 0){
              cnt++;
          }
      }
  }
  cout << cnt << endl;
}


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

const ll inf = 1e18;

ll cal(ll a, ll b, ll c, ll d){
	ll mx = max(max(a,b),max(c,d));
	ll mn = min(min(a,b),min(c,d));
	return mx - mn;
}

int main(){
	int n;
	cin>>n;
	vector<ll> arr(n);
	for(int i = 0; i < n; i++) cin>>arr[i];
	for(int i = 1; i < n; i++) arr[i]+=arr[i-1];

	int p = 0;
	int s = 2;
	ll ans = inf;
	for(int i = 1; i < n-2; i++){
		while(p<=i && abs((arr[i]-arr[p]) - arr[p])>=abs((arr[i] - arr[p+1]) - arr[p+1])) p++;
		while(s<n-1 && abs((arr[n-1] - arr[s]) - (arr[s] - arr[i]))>=abs((arr[n-1] - arr[s+1]) - (arr[s+1] - arr[i]))) s++;
		ans = min(ans,cal(arr[p],arr[i]-arr[p],arr[s]-arr[i],arr[n-1]-arr[s]));
	}
	cout<<ans;
}

Measured memory_bytes: 1792
'''@masayoshi361   Qiita　　三重ループはTLE。要素固定⇒二分探索
こういういくつも要素が動く系の数え上げはいくつかを固定してあげると
うまくいくことがあります。今回、三角形に使う棒の長さをa<=b<=cとして、
b, cを固定すると、a>c-bとなるaの数え上げに帰着します。単調性から、
二分探索でlognで求められるので、全体ではO(N^2logN)です。
'''
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()#昇順ソート、小さいものから大きいものへ
#bisectを使う前にソートが必要
ans = 0
for i in range(N):
    for j in range(i):#jはi未満
        m = L[i]-L[j]#上記c-aを計算
        k = bisect_right(L, m)#二分探索
        #aに相当するkは、上記の通り、mよりも大きい(つまり、右側)
        #同じものがあったら右側
        n = max(0, j-k)#j-kの区間の数は大丈夫
        ans+=n
print(ans)

Measured memory_bytes: 3188
n = int(input())
num=[]
for i in range(120):
    num.append(0)

for i in range(n):
    b,f,r,v = map(int,input().split())
    room=30*(b-1)+10*(f-1)+(r-1)
    num[room]+=v


for b in range(1,5):
    for f in range(1,4):
        print(" ",end="")
        print(*num[30*(b-1)+10*(f-1):30*(b-1)+10*(f-1)+10])
    if b <4:
        print("#"*20)



Measured memory_bytes: 5624
import sys

def solve():
    for line in sys.stdin:
        inputs = list(map(int, line.split(',')))
        L = inputs[:10]
        v1, v2 = inputs[10], inputs[11]
        dL = sum(L)
        dv = v1 + v2
        hour = dL / dv
        distance = v1 * hour
        idx = 0
        while True:
            distance -= L[idx]
            if distance <= 0:
                print(idx+1)
                break
            idx += 1

if __name__ == "__main__":
    solve()



Measured memory_bytes: 5608
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    string S ;
    cin >> S ;
    // 出力
    int sizeS = S.length();
    int nMidS = sizeS -2;
    cout << S[0] << nMidS << S[sizeS-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll M;
    cin >> M;
    cout << 48 - M << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<iostream>
// #include<string>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 1; i <= n; i++)
#define INF 12345678912356
typedef pair<int, int> P;

int dxy[4] = {1, -1, 0, 0};

signed main(){
	int n, m, l, x;
	int count = 0,a[200] = {},  ans = 0; 
	
	 cin>>n>>x;
	
	
	rep(i, n){
		cin>>a[i];
	}
	
	sort(a+1, a+n+1);
	
	for(int i = 1; x > 0 && i <= n; i++){
		if(x >= a[i] && i != n) {
			x -= a[i], count++;
		} else if(x == a[i]){
			count++;
			break;
		}
		// cout<<a[i]<<endl;
	}
	
	cout<<count<<endl;
	// cout<<(ans?"Yes":"No")<<endl;
	// cout<<(ans?"YES":"NO")<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
char s[200100];
int n,ans=1,num;
int main(){
    int i,j,k;
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<2*n;i++)
      if(!(((s[i]=='W')^num)&1))num++;
        else ans=1ll*ans*num%mod,num--;
    if(num!=0){puts("0");return 0;}
    for(i=1;i<=n;i++)ans=1ll*ans*i%mod;
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
import itertools
while True:
    N = int(input())
    if not N:
        break
    D = [[] for _ in range(30)]
    for i in range(N):
        for x in map(int, input().split()[1:]):
            D[x - 1].append(i)
    C = [1 << i for i in range(N)]
    for d in range(30):
        for i, j in itertools.permutations(D[d], 2):
            C[i] = C[i] | C[j]
        if any(x == (1 << N) - 1 for x in C):
            print(d + 1)
            break
    else:
        print(-1)

Measured memory_bytes: 7628
import Data.Int
import Data.Array.IArray

solve :: Int -> Array Int (Int64,Int64,Int64) -> [Int64]
solve n a = map (go 0) [1..n]
  where
    go :: Int64 -> Int -> Int64
    go t i
      | i == n = t
      | t <= s = go (s+c) (i+1)
      | otherwise = let t' = if t `mod` f == 0
                               then t else t + f - (t `mod` f) 
                     in go (t' + c) (i+1)
      where
        (c,s,f) = a!i

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- listArray (1,n-1) . map ((\[a,b,c] -> (a,b,c)) . (map read . words))
       . lines <$> getContents :: IO (Array Int (Int64,Int64,Int64))
    mapM_ print $ solve n a

Measured memory_bytes: 1148
let f n k =
  let rec g i sum =
    if i = 0 then sum
    else
      let xi = Scanf.scanf "%d " (fun x -> x) in
      g (i - 1) (sum + min (abs (2 * xi)) (abs (k - xi) * 2))
  in
  g n 0


let () = Scanf.scanf "%d\n%d\n" f |> Printf.printf "%d\n"

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

long long gcd(long long x,long long y){
	if(x<y) swap(x,y);
	while(x%y!=0){
		x=x%y; swap(x,y);
	}
	return y;
}


int main() {
	long long n,i,j,ans;
	cin >> n;
	vector<long long> a(n),l(n),r(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	l[0]=a[0]; r[n-1]=a[n-1];
	for(i=1; i<n; i++){
		l[i]=gcd(l[i-1],a[i]);
		r[n-i-1]=gcd(r[n-i],a[n-i-1]);
	}
	ans=max(r[1],l[n-2]);
	for(i=1; i<n-1; i++){
		ans=max(gcd(l[i-1],r[i+1]),ans);
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;

int main() {
	int N, K;
	string S;
	cin >> N;
	cin >> S;
	cin >> K;
	for (int i = 0; i < N; i++) {
		if (S[i] != S[K - 1]) S[i] = '*';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
n=int(input());e=[[]for _ in[0]*-~n];q=[(1,0)];f=[-1]*n
for _ in[0]*~-n:v,w,c=map(int,input().split());e[v]+=(w,c),;e[w]+=(v,c),
while q:
 v,c=q.pop();f[v-1]=c%2
 for w,d in e[v]:
  if f[w-1]<0:q+=(w,c+d),
print(*f)

Measured memory_bytes: 40456
def f(x):
    cou = 0
    re = 0
    while True:
        if x < 2**cou:
            break
        if cou == 0:
            if 1 <= x % 4 <= 2:
                re += 1
        else:
            p = x % (2**(cou+1))
            if 2**cou <= p and p % 2 == 0:
                re += 2**cou
        cou += 1
    return re
a , b = map(int,input().split())

print(f(a-1) ^ f(b))

Measured memory_bytes: 38384
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int gcd_all(vi &A){int g = 0; for(int a:A) g = gcd(g, a);return g;}

bool is_pairwise(vi &A){
	#define MAX_A 1'000'001
	vi C(MAX_A, 0);
	for(int a:A) C[a]++;
	int c = 0;
	for(int j=2; j<MAX_A; j+=2){
		c += C[j];
		if(c > 1) return false;
	}
	for(int i=3; i<MAX_A; i+=2){
		int c = 0;
		for(int j=i; j<MAX_A; j+=i){
			c += C[j];
			if(c > 1) return false;
		}
	}
	return true;
}

int solve(vi &A){
	if(is_pairwise(A)) return 0;
	if(gcd_all(A) == 1) return 1;
	return 2;
}

int main(){
	int N; cin>>N;
	vi A(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< vector<string>{"pairwise","setwise","not"}[solve(A)] <<" coprime\n";
}


Measured memory_bytes: 11112
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n; cin >> n;
  map<int, int> mp;
  int maxNum = 0, semimaxNum = 0;
  rep(i, n){
    int a; cin >> a;
    mp[a]++;
  }
  for(auto x: mp){
    if(x.second >= 2){
      maxNum = x.first;
    }
  }
  mp[maxNum] -= 2;
  for(auto x: mp){
    if(x.second >= 2){
      semimaxNum = x.first;
    }
  }
  ll ans = (ll) maxNum * semimaxNum;
  cout << ans << endl;
  return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

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

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    int K,A,B;
    cin>>K>>A>>B;

    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI c(n), s(n), f(n);
    REP(i,n-1) cin >> c[i] >> s[i] >> f[i];

    REP(i,n){
        int ans = 0, x = i;
        while (x < n-1){
            if (ans < s[x]){
                ans = s[x];
            }else{
                ans = (ans + f[x] - 1) / f[x] * f[x];
            }
            ans += c[x];
            x++;
        }
        cout << ans << endl;
    }

    return 0;
}





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

int main() {
    int64_t n, w;
    cin >> n >> w;
    int64_t base, tmp;
    cin >> base >> tmp;
    map<int64_t, vector<int64_t>> wv;
    for (int64_t i = base; i <= base+3; i++) wv[i].push_back(0);
    wv[base].push_back(tmp);
    for (int64_t i = 1; i < n; i++) {
        int64_t ww, vv;
        cin >> ww >> vv;
        wv[ww].push_back(vv);
    }

    for (int64_t i = base; i <= base+3; i++) {
        sort(begin(wv[i])+1, end(wv[i]), greater<>());
        partial_sum(begin(wv[i]), end(wv[i]), begin(wv[i]));
    }

    int64_t ans = 0;
    for (size_t i = 0; i < wv[base].size(); i++) {
        for (size_t j = 0; j < wv[base+1].size(); j++) {
            for (size_t k = 0; k < wv[base+2].size(); k++) {
                for (size_t l = 0; l < wv[base+3].size(); l++) {
                    if (i*base+j*(base+1)+k*(base+2)+l*(base+3) <= w) ans = max(ans, wv[base][i]+wv[base+1][j]+wv[base+2][k]+wv[base+3][l]);
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
Imports System

Module Program
    Sub Main(args As String())

        Dim K As Integer = Integer.Parse(Console.ReadLine())
        Dim S As String = Console.ReadLine()

        Dim ans As String = ""
        If Len(S) <= K Then
            ans = S
        Else
            ans = Left(S, K) & "..."
        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 27980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int n,dat[2*MAX-1],lazy[2*MAX-1];

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        lazy[i]=0;
    }
}

void eval(int k,int l,int r){
    
    if(lazy[k]!=0){
        dat[k]+=lazy[k];
        
        if(r-l>1){
            lazy[k*2+1]+=lazy[k]/2;
            lazy[k*2+2]+=lazy[k]/2;
        }
        
        lazy[k]=0;
    }
}

void add(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    
    if(r<=a||b<=l) return;
    
    if(a<=l&&r<=b){
        lazy[k]+=(r-l)*x;
        eval(k,l,r);
    }
    
    else{
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        dat[k]=dat[2*k+1]+dat[2*k+2];
    }
}

int query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return 0;
    
    eval(k,l,r);
    
    if(a<=l&&r<=b) return dat[k];
    
    int vl=query(a,b,2*k+1,l,(l+r)/2);
    int vr=query(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
}

int main(){
    
    int N,M;cin>>N>>M;
    
    init(M+5);
    
    vector<int> A(N),cnt(M,0);
    
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]--;
        if(i) cnt[A[i]]+=((A[i]+M-A[i-1])%M-1);
    }
    
    for(int i=0;i<N-1;i++){
        if(A[i]<A[i+1]){
            add(A[i]+1,A[i+1],1,0,0,n);
        }else{
            if(A[i]==M-1){
                add(0,A[i+1],1,0,0,n);
            }else{
                add(A[i]+1,M,1,0,0,n);
                add(0,A[i+1],1,0,0,n);
            }
        }
    }
    
    ll sum=0;
    
    for(int i=0;i<N-1;i++){
        if(A[i]<A[i+1]) sum+=A[i+1]-A[i];
        else sum+=(A[i+1]+1);
    }
    
    ll ans=sum;
    
    for(int i=0;i<M-1;i++){
        sum=sum-query(i,i+1,0,0,n)+cnt[i];
        //cout<<sum<<endl;
        ans=min(ans,sum);
    }
    
    /*for(int i=0;i<M;i++){
        cout<<query(i,i+1,0,0,n)<<endl;
    }*/
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3072
import java.util.*;
public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		long n = sc.nextLong();//s型
		long m = sc.nextLong();//c型
		long count=0;
		if(n>=m) {//sが多いのでcが２個ずつある分しか作れない
			count=m/2;
		}else{
			if(n*2>m) {//c*2個分しか作れないため
				count=m/2;
			}else if(m>n*2) {
				count=n;//sは作れる分
				count=count+((m-2*n)/4);//sがなくてもcで作れる分を足す
			}
		}
		System.out.println(count);
	}
}


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

int n, k, d[10];

int main() {
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> d[i];
    }

    for (int i = n; i <= 1000000000; ++i) {
        string s = to_string(i);
        int si = s.size();
        bool flag = true;

        for (int j = 0; j < si; ++j) {
            if (!flag) break;
            for (int m = 0; m < k; ++m) {
                if (s[j] == char(d[m] + '0')) {
                    flag = false;
                    break;
                }
                if (!flag) break;
            }
        }

        if (flag) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

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

  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long j = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    long long k = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    ans += j * (c.size() - k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;

inline int read(){
	int x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}

int n,d[N],cnt,m;

int main(){
	n=read(),m=read();
	while(m--) d[read()]^=1,d[read()]^=1;
	for(int i=1;i<=n;cnt+=d[i],i++) if(cnt&d[i]){ puts("NO"); return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int S, s, m, h;
    
    scanf("%d", &S);
    
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
};

Measured memory_bytes: 592
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b; 
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
	int n;
  	cin >> n;
  	vi p(n);
  	rep(i,n) cin >> p[i];
  	int mn = n+1;
  	int count = 0;
  	rep(i,n){
    	if(chmin(mn, p[i])) count++;
    }
  	cout << count << endl;
	return;
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <stdlib.h>


int main(){
    
    
    ll n;
    cin >> n;
    ll sum = 0;
    for(ll i=0LL;i <= n;i++){
        if(i % 3 == 0LL && i % 5 == 0LL){

        }else if(i % 3 == 0LL){
        }else if(i % 5 == 0LL){
        }else {

            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
package main

import(
	"fmt"
	"os"
	"bufio"
)

func main(){
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	defer out.Flush()

	var n int

	fmt.Fscanf(in, "%d\n", &n)

	a := make([]int , n )

	for i := 0 ; i < n ; i ++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")

	m := make(map[int]int)

	for i := 0 ; i < n ; i ++ {
		m[a[i]] ++
	}

	output := 0

	for _, value := range m {
		output += (value * (value - 1)) / 2
	}

	for i := 0 ; i < n ; i ++ {
		ans := output

		ans -= (m[a[i]] - 1)
		fmt.Fprintf(out, "%d\n", ans)
	}









}



Measured memory_bytes: 14464
s = input()

n = len(s)
a = (n - 1) // 2
b = (n + 3) // 2

s_reverse = s[::-1]

s_first = s[:a]
s_first_reverse = s_first[::-1]

s_second = s[b-1:]
s_second_reverse = s_second[::-1]

if s == s_reverse and s_first == s_first_reverse and s_second == s_second_reverse:
  print('Yes')
else:
  print('No')


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

int A[200005], B[200005];

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

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;

        A[i] = B[i] = x;
    }

    sort(B+1, B+1+N);

    for(int i=1; i<=N; i++)
    {
        if(A[i] == B[N])
            cout << B[N-1] << "\n";
        else
            cout << B[N] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3200
n = gets.to_i
x = 0
for i in 1..n do
  if(i % 2 != 0)then
     c = 0
     for j in 1..i do
        if(i % j == 0)then
         c += 1;
         end
      end
          if(c == 8)then
            x += 1
            end
    end
end
puts x

Measured memory_bytes: 3836
import numpy as np
x,n=map(int,input().split())
p=np.array(list(map(int,input().split())))
p_abs=sorted(list(map(lambda k:abs(k-x),p)))
#print(p_abs)

if(len(p_abs)==0 or p_abs[0]!=0):
    print(x)
else:
    i=1
    while(True):
        if(2*i>=len(p)):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        elif(p_abs[2*i-1]!=i or p_abs[2*i]!=i):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        else:
            i+=1

Measured memory_bytes: 27292
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000;
long long matrix_chain_multiplication(vector<long long> &A){
    int n = A.size() - 1;
    vector<vector<long long>> dp(n, vector<long long>(n, INF));
    for (int i = 0; i < n; i++){
        dp[i][i] = 0;
    }
    for (int i = 1; i < n; i++){
        for (int j = 0; j < n - i; j++){
            for (int k = j; k < j + i; k++){
                dp[j][j + i] = min(dp[j][j + i], dp[j][k] + dp[k + 1][j + i] + A[j] * A[k + 1] * A[j + i + 1]);
            }
        }
    }
    return dp[0][n - 1];
}
int main(){
  int n;
  cin >> n;
  vector<long long> H(n + 1);
  for (int i = 0; i < n; i++){
    cin >> H[i] >> H[i + 1];
  }
  cout << matrix_chain_multiplication(H) << endl;
}


Measured memory_bytes: 3256
import sys

def gcd(a,b):
    if(b):
        return gcd(b,(a%b))
    else:
        return a

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

a = ""
for input in sys.stdin:
    a += input
l = a.split()
for i in range(0,len(l),2):
    if(int(l[i]) > int(l[i+1])):
        print gcd(int(l[i]),int(l[i+1])),lcm(int(l[i]),int(l[i+1]))
    else:
        print gcd(int(l[i+1]),int(l[i])),lcm(int(l[i+1]),int(l[i]))


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

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	vector<vector<int>> A;

	for(int i = 0; i < M; ++i) cin >> B[i];
	for(int i = 0; i < N; ++i){
		vector<int> IN(M);
		for(int j = 0; j < M; j++) cin >> IN[j];
		A.push_back(IN);
	}
	int count = 0;
	for(int i = 0; i < N; ++i){
		int sum = C;
		for(int j = 0; j < M; ++j) sum += A[i][j] * B[j];
		if(sum > 0) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//सत्यान्न प्रमदितव्यम्  ||

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

#define ll long long
#define ld long double
#define pb push_back
// #define mp make_pair
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define inf 0x3f3f3f3f

const ll mod = 1000000007;
#define mx 1000005
const ll mxi = 4e4+5;
// ll ar[mx][mx] = {0};

int main()
{
    fast_as_levi;
    ll n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes";
    else cout<<"No";
}

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


//A 2 2 5
//B 2 5

//decide from back
//0   0   10  10  10  23
//0  153  10  10  23

//A is stricted by i and i-1 

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n-1);
  rep(i,n-1) cin >> b[i];

  rep(i,n){
    if(i == 0){
      a[0] = b[0];
      continue;
    }
    if(i == n-1){
      a[i] = b[i-1];
      continue;
    }
    a[i] = min(b[i],b[i-1]);
  }

  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;

  
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    REP(i, S.size()) {
        if ((S.size() - i) % 2 == 1)continue;
        rep(j,(S.size() - i) / 2) {
            if (S.at(j) != S.at(j + (S.size() - i) / 2))break;
            if (j == (S.size() - i) / 2 - 1) {
                cout << S.size() - i << endl;
                return 0;
            }
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<vector<int>> cnt(n, vector<int>(26, 0));
  rep(i, n) {
    cin >> s[i];
    rep(j, s[i].size()) cnt[i][s[i][j] - 'a']++;
  }

  vector<int> ans(26, 1e9);
  rep(i, 26) {
    int min_v = 1e9;
    rep(j, n) min_v = min(min_v, cnt[j][i]);
    rep(j, min_v) cout << char('a' + i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import java.util.Scanner;
public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int x = (int)ceil((a*1.0 +b*1.0)/2.0);
            System.out.println(x);
        }
}

Measured memory_bytes: 22868
#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,d,x,y,ans=0;
    scanf("%lld %lld",&n,&d);
    while(n--)
    {
         scanf("%lld %lld",&x,&y);
        if(sqrt((x*x)+(y*y))<=d)
            ans+=1;
    }
    printf("%lld",ans);;
}

Measured memory_bytes: 2108
public class Main {
	public static void main(String[] args) {
		String input = new java.util.Scanner(System.in).nextLine();
		char serch; String str = "";
		for (int i = 0; i < input.length(); i++) {
			serch = input.charAt(i);
			if (Character.isLowerCase(serch)) {
				serch = Character.toUpperCase(serch);
			} else if (Character.isUpperCase(serch)) {
				serch = Character.toLowerCase(serch);
			}
			str += serch;
		}
		System.out.println(str);
	}

}

Measured memory_bytes: 31104
#include<iostream>
typedef unsigned long long int ll;
int main(){
  ll a, b, k;
  std::cin >> a >> b >> k;
  if(k <= a)
    std::cout << a - k << " " << b << std::endl;
  else if(k <= a + b)
    std::cout << 0 << " " << b + (a - k) << std::endl;
  else
    std::cout << 0 << " " << 0 << std::endl;
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, k; cin >> n >> k;
    V<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    map<int, double> mp;
    for(int i = 1; i <= 1000; i++){
        int j = i;
        while(0 < j){
            double t = (double)j * (1.0 / (double)i);
            mp[i] += t;
            j--;
        }
    }

    V<double> v(n + 1);
    for(int i = 0; i < n; i++){
        v[i + 1] = v[i] + mp[p[i]];
    }

    double ans = 0;
    for(int i = k - 1; i <= n; i++){
        ans = max(ans, (v[i] - v[i - k]));
    }
    cout << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 5628
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
deque<int> Q;
int n;

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int i, x; cin>>n;
	for(i=1 ; i<=n ; i++)
	{
		cin>>x;
		if(i%2==1) Q.push_front(x);
		if(i%2==0) Q.push_back(x);
	}
	if(n%2==1)
	{
		for(i=1 ; i<=n ; i++)
		{
			cout<<Q.front()<<" ";
			Q.pop_front();
		}
	}
	if(n%2==0)
	{
		for(i=1 ; i<=n ; i++)
		{
			cout<<Q.back()<<" ";
			Q.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main()
{
    int N = 0;
    cin >> N;
    double A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    double waru = 0;

    for (int i = 0; i < N; i++)
    {
        waru += (1/A[i]);
    }

    cout << 1/waru <<endl;
    
    

    return 0;
}

Measured memory_bytes: 256