akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	A = inputList()

	to = 0
	for i in A:
		to += i

	to = to // 2
	manaka = 0
	tmp = 0
	for i,val in enumerate(A):
		tmp += val
		if tmp >= to:
			manaka = i
			break

	#print(to)
	#print(manaka)

	to1 = 0
	to11 = 0
	to2 = 0
	to22 = 0

	to111 = 0
	to222 = 0

	for i,val in enumerate(A):
		if i >= manaka+1:
			to2 += val
		else:
			to1 += val

		if i >= manaka-1:
			to22 += val
		else:
			to11 += val

		if i >= manaka:
			to222 += val
		else:
			to111 += val

	ans = min(abs(to1-to2),abs(to11-to22),abs(to111-to222))
	print(ans)


if __name__ == "__main__":
	main()


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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int c[3][3];
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin>>c[i][j];
		}
	}
	if(c[1][0] - c[0][0] != c[1][1] - c[0][1] || c[1][0] - c[0][0] != c[1][2] - c[0][2]){
		cout<<"No"<<endl;
		exit(0);
	}
	if(c[2][0] - c[0][0] != c[2][1] - c[0][1] || c[2][0] - c[0][0] != c[2][2] - c[0][2]){
		cout<<"No"<<endl;
		exit(0);
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N, M;
	cin >> N >> M;
	vector<unordered_set<int>>lang_graph(M);
	vector<int>speaker_num(M);
	rep(i, N) {
		int K;
		cin >> K;
		vector<int>lang_list(K);
		rep(j, K)cin >> lang_list[j];
		rep(j, K)lang_list[j]--;//0-origin
		rep(j, K)speaker_num[lang_list[j]]++;
		rep(j, K - 1) {
			//lang_list[j]とlang_list[x]を話せる人がいるので辺を引く
			lang_graph[lang_list[j]].insert(lang_list[j + 1]);
			lang_graph[lang_list[j + 1]].insert(lang_list[j]);
		}
	}

	//通訳を2人以上挟んでもいいと解釈して解く
	vector<int>searched(M);
	stack<int>dfs;
	rep(i, M)if (speaker_num[i]) { dfs.push(i); break; }
	while (!dfs.empty()) {
		auto x = dfs.top(); dfs.pop();
		if (searched[x])continue;
		searched[x] = 1;
		for (auto y : lang_graph[x]) {
			dfs.push(y);
		}
	}
	rep(i, M)if (searched[i] == 0 && speaker_num[i]) {
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;



}

Measured memory_bytes: 17152
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
ll n,a[10],ans;
string s;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='M')
		a[1]++;
		if(s[0]=='A')
		a[2]++;
		if(s[0]=='R')
		a[3]++;
		if(s[0]=='C')
		a[4]++;
		if(s[0]=='H')
		a[5]++;
	}
	for(int i=1;i<=5;i++){
		for(int j=i+1;j<=5;j++){
			for(int k=j+1;k<=5;k++){
				ans+=a[i]*a[j]*a[k];
			}
		}
	}
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void output_yn(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}


int main()
{
	int n, ans = 0;
	cin >> n;

	vector<long long> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	long long sum = 0;
	for (int i = 0; i < n; i++)
		sum = (sum + a[i]) % MOD;

	for (int i = 0; i < n; i++) {
		sum -= a[i];
		if (sum < 0)
			sum += MOD;
		ans += (sum * a[i]) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(c)      \
	for (auto i : c) \
		cout << i << ' ';

void solve()
{
	ll n;
	cin >> n;
	map<ll, ll> m;
	rep(i, 0, n)
	{
		ll x;
		cin >> x;
		m[x]++;
	}
	vector<ll> r(2, 0);
	ll k = 0;
	for (auto it = m.rbegin(); it != m.rend() && k < 2; it++)
	{
		auto x = *it;
		if (x.second >= 2)
		{
			if (x.second >= 4 && k == 0)
			{
				r[0] = r[1] = x.first;
				break;
			}
			r[k] = x.first;
			k++;
		}
	}
	ll res = r[0] * r[1];
	cout << res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>

using namespace std;

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

#define fs first
#define sc second

ll si[51];
ll pa[51];


int main(){
    int N, K;
    int h[200000];
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h, h+N);
    int res = 1000000007;
    for(int i = 0; i < N; i++){
        if(i+K-1 >= N)  break;
        res = min(res, h[i+K-1] - h[i]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int cnt[26] = {};
    for (string::iterator itr = S.begin(); itr != S.end(); itr++)
    {
        cnt[(int)*itr - 97] += 1;
    }

    int ans = 0;
    while (0 != cnt[ans] && ans <= 25)
    {
        ans++;
    }
    
    if (26 == ans)
    {
        cout << "None" << endl;
    }else
    {
        cout << (char)(ans + 97) << endl;
    }
    
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b%2==1 && (c+d)%2==1){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
 
  return 0;
}
   
  
	
	  
	  
	  
	  
	  
	  
     
  
  
  
  
  

  

 
  


 

    
  



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int n;
    cin >> n;
    int cnt=0;
    for (int a = 1; a * a < n;a++){
        for (int b = a; a * b < n;b++){
            if(a==b)
                cnt++;
            else
                cnt += 2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import numpy as np
 
nm = list(map(int,input().split()))
n, m = nm[0], nm[1]

H = list(map(int,input().split()))
#print(H)

check_H = [1]*n
count = 0

for i in range(m):
  cmp = list(map(int,input().split()))
  #print(cmp)
  
  if( H[ cmp[0]-1 ] > H[ cmp[1]-1 ] ):
    if( check_H[ cmp[1]-1 ] == 1 ):
      check_H[ cmp[1]-1 ] = 0
      count += 1
    #print(check_H)

  elif( H[ cmp[0]-1 ] < H[ cmp[1]-1 ] ):
    if( check_H[ cmp[0]-1 ] == 1 ):
      check_H[ cmp[0]-1 ] = 0
      count += 1
    #print(check_H)
  
  else:
    if( check_H[ cmp[1]-1 ] == 1 ):
      check_H[ cmp[1]-1 ] = 0
      count += 1
    if( check_H[ cmp[0]-1 ] == 1 ):
      check_H[ cmp[0]-1 ] = 0
      count += 1
    #print(check_H)


ans = n - count
print(ans)

Measured memory_bytes: 38500
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c)) 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>h(n+1);
    for(int i=1;i<=n;i++)
        cin>>h[i];


    vector<int>dp(n+5,inf);
    dp[1]=0;

    for(int i=1;i<=n;i++)
    {
        if(i+1<=n)
            dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2<=n)
            dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));

    }

    cout<<dp[n];

    return 0;
}


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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

  double ans = 0;
  for(int n=1; n<=N; n++){
    if(n >= K){ ans += 1.0/N; continue;}
    int k = (K+n-1)/n;
    int cnt = 0;
    double tmp = 1;
    while(k!=1){ k=(k+2-1)/2; tmp/=2;}
    ans += tmp/N;
    // cout << " n: " << n << " k: " << (K+n-1)/n << " tmp: " << tmp << endl;
  }
  cout << fixed;//小数点を確実に10桁で表示するためのもの
  cout << setprecision(10); 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

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

    string s, t;
    ll ans = 0;
    cin >> s;
    cin >> t;
    REP(i, s.length())
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


template <class K, class V>
struct RadixHeap {
    static constexpr int bit_length = sizeof(K)*8;
    K last;
    size_t sz, cnt;
    RadixHeap() : last(0), sz(0), cnt(0) {}
    array<vector<pair<K, V>>, bit_length> v;
    static inline int bsr(int x){
        return x ? bit_length-__builtin_clzll(x) : 0;
    }
    static inline int bsr(ll x){
        return x ? bit_length-__builtin_clzll(x) : 0;
    }
    void emplace(K x, V val){
        sz++;
        v[bsr(x^last)].emplace_back(x, val);
    }

    void pull() {
        if(cnt < v[0].size()) return;;
        int i = 1;
        while(v[i].empty()) i++;
        last = min_element(v[i].begin(),v[i].end())->first;
        for (auto &&x : v[i]) v[bsr(x.first ^ last)].push_back(x);
        v[i].clear();
    }

    pair<K, V> top() {
        pull();
        return v[0][cnt];
    }

    void pop() {
        pull();
        sz--;
        cnt++;
    }

    size_t size() const { return sz; }
    bool empty() const { return !sz; }
};

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    using P = pair<int, int>;
    vector<vector<P>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--; b--;
        if(c <= l){
            G[a].emplace_back(b, c);
            G[b].emplace_back(a, c);
        }
    }
    constexpr ll M = ((ll)INF<int> << 31) + INF<int>;
    vector<vector<ll>> ans(n, vector<ll>(n, M));
    for (int i = 0; i < n; ++i) {
        ans[i][i] = 0;
        RadixHeap<ll, int> Q;
        Q.emplace(0, i);
        ll mask = (1LL << 31)-1;
        while(!Q.empty()){
            ll p; int x;
            tie(p, x) = Q.top(); Q.pop();
            if(ans[i][x] < p) continue;
            for (auto &&e : G[x]) {
                auto cost2 = p + e.second;
                if((cost2 & mask) > l){
                    cost2 = (((p >> 31) + 1) << 31) + e.second;
                }
                if(ans[i][e.first] <= cost2) continue;
                ans[i][e.first] = cost2;
                Q.emplace(ans[i][e.first], e.first);
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (ans[s][t] == M ? -1 : ans[s][t] >> 31) << "\n";
    }
    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int ans;
char before;
int main()
{
	cin>>s;
	int t=s.size();
	rep(i,t)
	{
		if(i!=0)
		{
			if(before!=s[i])ans++;
		}
		before=s[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define*********************************/
ll N, C;

//区間[a,b]におけるcの倍数の最小値、最大値
ll minc(ll a, ll b, ll c) {
	if (a %c == 0) return a;
	else {
		ll ans = (a / c)*c + c;
		if (ans <= b) return ans;
		else return -1;
	}
}
ll maxc(ll a, ll b, ll c) {
	if (b%c == 0) return b;
	else {
		ll ans = (b / c)*c;
		if (ans >= a) return ans;
		else return -1;
	}
}
/*****************************functions********************************/

/****************************main function*****************************/
int main(void) {

	//input
	ll K; cin >> K;
	//vector:A input
	vector<ll> A(K);
	for (ll i = 0; i < K; i++) {
		cin >> A[i];
	}

	ll a = 2, b = 2; // a:max,b:min
	for (int i = K - 1; i >= 0; i--) {
		a = maxc(b, a, A[i]) + A[i] - 1;
		b = minc(b, a, A[i]);
		//printf("a = %d,b = %d\n", a, b);
		if (a == -1 || b == -1) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << b << " " << a << endl;
	return 0;
}


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

int main() {
	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 3124
import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main 
{
	public static void main(String[] args) throws IOException
	{
		int n=ni();
		int a[]=nia(n);
		int b[]=new int[n];
		for(int i=0; i<n; i++)
			b[i]=a[i];
		Arrays.sort(a);
		int te=a[n/2];
		int te1=a[n/2-1];
		for(int i=0; i<n; i++)
		{
			if(b[i]<=te1)
			{
				pr(te);
			}
			else
			{
				pr(te1);
			}
		}
		System.out.println(ans);
	}
	static final long mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=false;
	static Reader in=new Reader();
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] ria(int n){int a[]=new int[n];for(int i=0; i<n; i++){a[i]=rn.nextInt(100);p(a[i]+" ");}pr();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static node[] graph(int n) {
		node[] ho=new node[n];
		for(int i=0; i<n; i++)
			ho[i]=new node();
		return ho;
	}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}
class node
{
	Set<Integer> adj=new HashSet<Integer>();
}   

Measured memory_bytes: 73816
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

string s;
ll cnt[10];
int main(){
  cin >> s;
  rep(i,s.size()){
    cnt[s[i]-'a']++;
  }
  if(abs(cnt[0] - cnt[1]) <= 1 && abs(cnt[0] - cnt[2]) <= 1 && abs(cnt[1] -cnt[2]) <= 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt();
        long sum=0;
        for(int i=1;i<=n;i++)
        {
            if((i%3!=0) && (i%5!=0))
                sum+=i;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 32900
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
//using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX
 





void solve()
{
  int n;
  cin >> n;
  int arr[n];
  inp(arr, n);
  sort(arr, arr+n);
  int ans = 0;
  rep(i,0,n-1)
    rep(k,i+1,n-1)
      rep(j,k+1,n-1)
        if(arr[i]+arr[k] > arr[j] and arr[i]!=arr[k] and arr[k]!=arr[j])
        {
          ans++;
        }
  cout << ans << endl;
}

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

Measured memory_bytes: 3652
S = input()

def check_palindrome(txt):
  return txt == ''.join(list(txt)[::-1])

ep1 = len(S) // 2
txt1 = S[0:ep1]

sp2 = len(S) // 2 + 1
txt2 = S[sp2:]

if check_palindrome(S):
  if check_palindrome(txt1):
    if check_palindrome(txt2):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

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

void output();

int A[100], N;

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

  for(int i = 1; i < N; ++i){
    int v = A[i];
    int j = i-1;
    while((j >= 0)&&(A[j] > v)){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    output();
  }
  return 0;
}

void output(){
for(int i = 0; i < N; ++i){
  if(i==(N-1))
    cout << A[i] << endl;
  else
    cout << A[i] << " ";
  }
}



Measured memory_bytes: 3088
#include<stdio.h>

#define N_MAX 2000005
#define k 10005

int A[N_MAX];
int B[N_MAX];
int C[k];
int n;

int main()
{
  int i, j, x, r, work;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  
  i = 0;
  r = n-1;
  x = A[r];
  
  for(j=0; j<r; j++){
    if(A[j] <= x){
      work = A[i];
      A[i] = A[j];
      A[j] = work;
      i+=1;
    }
  }

    work = A[i];
    A[i] = A[r];
    A[r] = work;

  for(j=0; j<n; j++){

    if(j==i){
      printf("[%d] ", A[j]);
      continue;
    }
      
    printf("%d", A[j]);
        
    if(j!=(n-1))
      printf(" ");
    else
      printf("\n");
  }

  return 0;
}

Measured memory_bytes: 4700
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N,ans=0;
  cin >> N;
  char S[N][N];
  rep(i,N) cin >> S[i];
  rep(i,N){
    bool check=true;
    rep(j,N) rep(k,N) if(j!=(k+i)%N) if(S[j][(k+i)%N]!=S[k][(j+i)%N]) check=false;
    if(check) ans+=N;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",(1000-(N%1000))%1000);

	return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int s = 0;
    if(a < b)
        s += a;
    else
        s += b;
    if(c < d)
        s+= c;
    else
        s+= d;
    printf("%d\n", s);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var e = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = Solve(e);
            Console.WriteLine(ans);
        }

        private static int Solve(int[] current)
        {
            var set = new HashSet<string>();

            for (int count = 0; ; count++)
            {
                string rep = string.Join("-", current);
                if (!set.Add(rep))
                {
                    return -1;
                }

                for (int i = 0; i < current.Length; i++)
                {
                    if (current[i] % 2 != 0)
                    {
                        return count;
                    }
                }

                int[] next = new int[3];
                for (int i = 0; i < current.Length; i++)
                {
                    for (int j = 0; j < current.Length; j++)
                    {
                        if (i != j)
                        {
                            next[j] += current[i] / 2;
                        }
                    }
                }

                current = next;
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    string N;
    cin >> N;
    ll sum = 0;
    for (auto digit : N)
    {
        sum += (digit - '0');
    }
    cout << ((sum % 9 == 0)?"Yes":"No");
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define int long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define re(x) cout<<(#x)<<" is "<<(x)<<"\n"; 
#define gif(a,b) ((a)/(b)+((a)%(b)?1:0))
using namespace std;

int32_t main()
{
	IOS
	int T = 1; 
	//cin >> T;  
	for (int t = 0; t < T; ++t)
	{
		int n;
		cin >> n;
		if(n >= 30)
			cout << "Yes";
		else
			cout << "No";

		

	}
	return 0;
}
//if not working? go ahead.


Measured memory_bytes: 3636
#include<stdio.h>

void insertionSort(int A[],int N);
void Show(int A[],int N);

void insertionSort(int A[],int N)
{
	int i,j,key;
	for(i=1;i<=N-1;i++)
	{
		key=A[i];
		j=i-1;
		while(j>=0&&A[j]>key)
		{
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=key;
		Show(A,N);
	}
}

void Show(int A[],int N)
{
	int i;
	for(i=0;i<N-1;i++)
	{
		printf("%d ",A[i]);
	}
	printf("%d",A[i]);
	printf("\n");
}

int main()
{
	int N,A[200],i;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	Show(A,N);
	insertionSort(A,N);
	return 0;
} 


Measured memory_bytes: 2052
Imports System

Module Program
    Sub Main(args As String())

        Dim N As String = Console.ReadLine()

        Dim wa As Integer = 0
        For i As Integer = 1 To Len(N)
            wa += Integer.Parse(Mid(N, i, 1))
        Next

        Dim ans As String = ""
        If wa Mod 9 = 0 Then
            ans = "Yes"
        Else
            ans = "No"
        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 33772
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string ans;
  cin >> s;
  for(int i = 0; i < s.size() ; i++){
    if(s[i] =='B' && ans.size() != 0)
      ans.erase(ans.size() - 1);
    else if(s[i] != 'B')
      ans = ans + s[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 9999999
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	
	int D[36][36];/*Adjacency matrix*/
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j)continue;
			D[i][j] = INF;
		}
	}
	
	for(int i = 0; i < m; i++){
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		D[a][b] = c;
		D[b][a] = d;
	}
	int ans = 0;
	int go,back,y1,y2;
	scanf("%d,%d,%d,%d",&go,&back,&y1,&y2);
	ans = y1-y2;
	int cost = 0;
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				D[i][j] = min(D[i][j],D[i][k]+D[k][j]);
			}
		}
	}
	cost = D[go][back] + D[back][go];
	
	printf("%d\n",ans-cost);
	return 0;
}

Measured memory_bytes: 1032
SA=list(input())
SB=list(input())
SC=list(input())


p=SA.pop(0)
while True:
    if p == 'a':
        if SA:
            p = SA.pop(0)
        else:
            print('A')
            break
    elif p == 'b':
        if SB:
            p = SB.pop(0)
        else:
            print('B')
            break
    else:
        if SC:
            p = SC.pop(0)
        else:
            print('C')
            break



Measured memory_bytes: 3060
#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 <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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  bool f = true;
  if(a > c) f = false;
  if(b < c) f = false;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin >> a >> b;
  int cnt = 0;
  if(a[0] == b[0] )
  {
    cnt++;
  }
  if(a[1] == b[1])
  {
    cnt++;
  }
  if(a[2] == b[2])
  {
    cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}

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

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

ll f(ll x, int c, int d){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c, d);
    return res;
}

void solve(ll a, ll b, int c, int d){
    ll ans = f(b, c, d) - f(a-1, c, d);
    cout << ans << endl;
}

int main(){
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        // input N S
        // 文字列長　N である文字列 S について、 S = T + T なる T から構成されるなら Yes 、そうでなければ No
        Scanner sc = new Scanner(System.in);
        int strLen = sc.nextInt();
        String str = sc.next();
        if(strLen % 2 == 0){
            String firstStr = str.substring(0, strLen / 2);
            String lastStr = str.substring(strLen / 2, strLen);
            if(firstStr.equals(lastStr)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


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

int main()
{
 string s;
 int flag=0,flag1=0,flag2=0;
 cin >> s;
 if (s[0] == 'A')
 {
  for (int i = 2; i < s.length()-1; i++)
  {
   if (s[i] <= 'z'&&s[i] >= 'a')
   {
    flag = flag + 1;
   }
   else if(s[i]=='C')
   {
    flag1 = flag1 + 1;
    flag = flag + 1;
   }
  }
  if (s[s.length()-1] <= 'z'&&s[s.length()-1] >= 'a')
  {
   flag2 = flag2 + 1;
  }
  if (s[1] <= 'z'&&s[1] >= 'a')
  {
   flag2 = flag2 + 1;
  }

 };
 if (flag == s.length() - 3 && flag1 == 1&&flag2==2)
 {
  cout << "AC";
 }
 else
 {
  cout << "WA";
 }
 return 0;
}

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

int main(){
    string input;
    cin >> input;
    int c = 0;
    
    if (input[0] == '1'){
    c++;
    }
    if (input[1] == '1'){
    c++;
    }
    if (input[2] == '1'){
    c++;
    }

    cout << c << endl;


}



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

int main() {
	string s;
	cin >> s;
	int i;
	for (i = 0;i < s.length();i++) {
		if (s[i] == 'A')
			break;
	}
	int j;
	for (j = s.length() - 1;j >= 0;j--) {
		if (s[j] == 'Z')
			break;
	}
	cout << (j - i) + 1 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll> > p(n);
    rep(i, n)
    {
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(ALL(p), greater<PII>());
    VVL dp(n + 1, VL(n + 1, -1));
    dp[0][0] = 0;
    //dp[0][1] = abs(n - p[0].second) * p[0].first;
    //dp[1][0] = abs(p[0].second) * p[0].first;
    //    cerr << dp[0][n] << endl;
    rep(i, n)
    {
        rep(j, n)
        {
            if (i + j >= n)
            {
                continue;
            }
            chmax(dp[i + 1][j], dp[i][j] + llabs(p[i + j].second - i) * p[i + j].first);
            //cout << "dp[i+1][j]:" << i+1 << "," << j  << " "<< dp[i+1][j] << endl;
            chmax(dp[i][j + 1], dp[i][j] + llabs(n - 1 - j - p[i + j].second) * p[i + j].first);
            //cout << "dp[i][j+1]:" << i << "," << j+1 << " "<< dp[i][j+1] << endl;
        }
        //cout << "i:" << i << "ループ終わり" << endl << endl;
    }
    ll ans = 0;
    rep(i, n + 1)
    {
      //cout << "dp[]" << i << ":" << dp[i][n-i] << endl;
        chmax(ans, dp[i][n - i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	set<int> a, b;//1,3,4,5,7,8,10,12
				 //4,6,11,9
	int a1[] = {1,3,5,7,8,10,12};
	int b1[] = {4, 6, 9, 11};
	
	for(int i=0; i<8; i++){a.insert(a1[i]);}
	for(int i=0; i<4; i++){b.insert(b1[i]);}
	
	int c = 2;
	int x, y;
	cin>>x>>y;
	
	if(x == c || y==c)cout<<"No\n";
	else{
	 if((a.find(x) == a.find(y)) || (b.find(x) == b.find(y)))
	 cout<<"Yes";
	 else
	 cout<<"No";
	}
return 0;
	}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    A=LI()
    LR = []
    for _ in range(M):
        l,r = MI_()
        LR.append((l,r))
    LR.sort()
    NG_left = [i for i in range(N)]
    index = 0
    for l,r in LR:
        for i in range(max(index, l), r+1):
            NG_left[i] = l
            index = i+1
    # print(NG_left)
    dp = [0]*N #dp[i]:= i番目までの木で実現できる明るさ
    dp[0] = A[0]
    for i in range(1,N):
        if NG_left[i]==0:
            dp[i] = max(dp[i-1], A[i])
        else:
            dp[i] = max(dp[i-1], A[i] + dp[NG_left[i]-1])
    print(dp[-1])

if __name__ == '__main__':
    main()



"""##GREEDY check -> NG
N,M=MI()
A=LI()
LR = []
for _ in range(M):
    l,r = MI_()
    LR.append((l,r))
ng = set()
B=[(a,i) for i,a in enumerate(A)]
B.sort(reverse=True)
ans = 0
for a,i in B:
    if i in ng:
        continue
    for l,r in LR:
        for j in range(l,r+1):
            ng.add(j)
    ans+=a
print(ans)"""


Measured memory_bytes: 50172
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    ll n, i, a[100003], ans;

    scanf("%lld", &n);
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }

    sort(a, a + n);

    if (a[0] == 0) {
        printf("0\n");
        return 0;
    }

    ans = 1;
    for (i = 0; i < n; i++) {
        if (ans > (ll)1e18 / a[i]) {
            printf("-1\n");
            return 0;
        }
        ans *= a[i];
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4612
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int N = Integer.parseInt(br.readLine());
        String[] A = br.readLine().split(" ");

        int max = 0;
        boolean onCheck = false;
        int cl = 1; // 現在地点？

        for(String x : A){
            if(x.equals("1")){
                cl++; //2,1
                onCheck = true;
            }else if(onCheck){           //0100
                max = Math.max(cl,max);  //2,
                cl = 1;
                onCheck = false;
            }
        }

        max = Math.max(cl,max);

        System.out.println(max);
    }
}


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

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
}

inline int mul(int x, int y) {
  return (int) ((long long) x * y % md);
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> invs(n + 1);
  invs[0] = invs[1] = 1;
  for (int i = 2; i <= n; ++i) {
    invs[i] = mul(md - md / i, invs[md % i]);
  }
  int inv_3 = (md + 1) / 3;
  int coef = invs[n];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    coef = mul(coef, inv_3);
    add(ans, mul(coef, invs[n - i]));
  }
  cout << ans << "\n";
  return 0;
}


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

namespace ABC136B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int ans = 0;
            for(int i = 1; i <= N; i++)
            {
                int ketasuu = (int)Math.Log10(i);
                if (ketasuu % 2 == 0) ans++;
            }


            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140