akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc082/tasks/arc087_b


def run_length_encoding(s):
    '''
    連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx
    '''
    s_composed = []
    s_sum = []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx

# データに関しては事前にランレングス圧縮しておくと楽かもね


s = input()
x, y = map(int, input().split())
s_composed, s_sum, _ = run_length_encoding(s)

if s_composed[0] == 'T':  # 必ずTから始まるようにしたい
    s_composed.insert(0, 'F')
    s_sum.insert(0, 0)
# 前処理 xの移動履歴とyの移動履歴を作る
is_x = True
hist_x = []
hist_y = []
for s, n in zip(s_composed, s_sum):
    if s == 'T':
        if n & 1:  # xyの状態を反転させる
            is_x = not is_x
    else:
        if is_x:
            hist_x.append(n)
        else:
            hist_y.append(n)

'''
dpx[i][j]...x座標がjであることが可能か？ x方向の移動についてi回目の移動のあとに。
dpy[i][j]...y座標がjであることが可能か？ y方向の移動についてi回目の移動のあとに。

更新則
xについての移動,距離d移動するとすると
dpx[i+1][j+d]=dpx[i+1][j+d] or dpx[i][j]
dpx[i+1][j-d]=dpx[i+1][j-d] or dpx[i][j]
(配るDP)で更新すると楽かな？
yも同様

初期条件
dpx[:][:]=False
dpx[0][d_x0]=True #xの0回目の移動。

dpy[:][:] = False
dpy[0][d_y0]=True 簡単のために
dpy[0][-d_y0]=True
'''

try:
    if hist_x:
        x_range = 2 * (sum(hist_x) + 1500)  # ここが0になるときがある
        shift = x_range // 2
        dpx = [[False] * x_range for _ in range(len(hist_x))]
        dpx[0][hist_x[0] + shift] = True
        for i in range(1, len(hist_x)):
            d = hist_x[i]
            for j in range(x_range):
                if j + d < x_range:
                    dpx[i][j] = dpx[i][j] or dpx[i - 1][j + d]
                if -1 < j - d:
                    dpx[i][j] = dpx[i][j] or dpx[i - 1][j - d]
        ansx = dpx[-1][x + shift]
    # else:
    #     ansx = x == 0

    if hist_y:
        y_range = 2 * (sum(hist_y) + 1500)  # ここが0になるときがある
        shift = y_range // 2
        dpy = [[False] * y_range for _ in range(len(hist_y))]
        dpy[0][hist_y[0] + shift] = True
        dpy[0][-hist_y[0] + shift] = True
        for i in range(1, len(hist_y)):
            d = hist_y[i]
            for j in range(y_range):
                if j + d < y_range:
                    dpy[i][j] = dpy[i][j] or dpy[i - 1][j + d]
                if -1 < j - d:
                    dpy[i][j] = dpy[i][j] or dpy[i - 1][j - d]
        ansy = dpy[-1][y + shift]
    else:
        ansy = y == 0

    print('Yes' if ansx and ansy else 'No')
except:
    print('No')

# print(ansx, ansy)
# print(*dpy, sep='\n')


Measured memory_bytes: 254984
a = input()

ans = 0
s = 0

if a > 10 ** 5:
    ans = ((a + 10) / 11 - 5) * 2
    a -= ans / 2 * 11

cur = 6
while a > 0:
    ans += 1
    a -= cur
    cur = 5 if cur == 6 else 6

print ans


Measured memory_bytes: 2568
W = input()

dic = {}

for ch in W:
  if ch in dic:
    dic[ch] += 1
  else:
    dic[ch] = 1
  
ans = True
for k,v in dic.items():
  if v%2 != 0:
    ans = False
    break
    
print("Yes" if ans else "No")
  

Measured memory_bytes: 2940
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1
for i in range(n):
	print(ans[i+1])


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  map<ll, bool> mp;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (mp[a]) {
      cout << "NO\n";
      return 0;
    }
    mp[a] = true;
  }
  cout << "YES\n";

  return 0;
}



Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
int N;
char s[MAX_N];
char ans[MAX_N+2];

bool solve(){
    char init[8] = {'S', 'S', 'S', 'W', 'W', 'S', 'W', 'W'};
    char left,target,right;
    REP(k,4){
        left = init[2*k];
        target = init[2*k + 1];
        ans[0] = left;
        ans[1] = target;
        REP(i,N){
            right = (left == 'S' ^ target == 'S') ^ s[i] == 'o' ? 'S' : 'W';
            left = target;
            target = right;
            ans[i+2] = target;
            ans[i+1] = left;
        }
        if(ans[0] == ans[N] && ans[1] == ans[N+1]){
            return true;
        }
    }
    return false;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,N) cin >> s[i];
    if(solve()){
        REPS(i,N){
            cout << ans[i];
        }
        cout << "\n";
    }else{
        cout << -1 << "\n";
    }

    return 0;
}



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

const string YES = "Yes";
const string NO = "No";

void solve()
{
    ll N;
    cin >> N;

    vector<ll> inc; // 純粋に開き括弧が増加 (((())((((
    vector<pair<ll, ll>> inc2; // 一時的に閉じ括弧が増えるが最終的に開き括弧が増える (()))))(((((
    vector<ll> dec; // 純粋に閉じ括弧が増加 ))))()))))
    vector<pair<ll, ll>> dec2; // 一時的に閉じ括弧が最終的な閉じ括弧の数より多くなる )))))(((()
    for (ll i = 0; i < N; i++) {
        string S;
        cin >> S;
        ll min_diff = 0;
        ll max_diff = 0;
        ll diff = 0;
        for (auto ch : S) {
            if (ch == '(') {
                diff++;
            }
            if (ch == ')') {
                diff--;
            }
            min_diff = min(min_diff, diff);
            max_diff = max(max_diff, diff);
        }
        if (diff >= 0) {
            if (min_diff >= 0) {
                inc.push_back(diff);
            } else {
                inc2.emplace_back(min_diff, diff);
            }
        }else {
            if (min_diff >= diff) {
                dec.push_back(diff);
            } else {
                dec2.emplace_back(min_diff, diff);
            }
        }
    }

    sort(begin(inc2), end(inc2), greater<pair<ll,ll>>());
    sort(begin(dec2), end(dec2));

    ll open = 0;
    for (auto i : inc) {
        open += i;
    }
    for (auto&& i : inc2) {
        if (open + i.first < 0) {
            cout << NO << endl;
            return;
        }
        open += i.second;
    }
    for (auto&& i : dec2) {
        if (open + i.first < 0) {
            cout << NO << endl;
            return;
        }
        open += i.second;
    }
    for (auto i : dec) {
        open += i;
    }
    if (open == 0) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 11232
using System;
class M {
  static void Main(string[] _) {
    var A = int.Parse( Console.ReadLine() );
    var B = int.Parse( Console.ReadLine() );
    var C = int.Parse( Console.ReadLine() );
    var X = int.Parse( Console.ReadLine() );
    
    int cnt = 0;
    for(int a=0;a<=A;++a){
      for(int b=0;b<=B;++b){
        for(int c=0;c<=C;++c){
          int val = a * 500 + b * 100 + c * 50;
          if ( val == X ) cnt ++;            
        }
      }
    }
    Console.Write(cnt);
    
  }
}

Measured memory_bytes: 13140
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto S = readln.chomp;

    int x = 0;
    int cnt = 0;
    while (x+1 < S.length) {
        if (S[x] == S[x+1]) {
            x++;
        } else {
            S = S[0..x] ~ S[x+2..$];
            cnt += 2;
            x = max(x-1, 0);
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 5432
n, m = map(int, input().split())
g_o = [[] for x in range(n)]
g_i = [0] * n
for _ in range(m):
    p, c = map(int, input().split())
    g_o[p - 1].append(c - 1)
    g_i[c - 1] += 1
sor = [e for e in range(n) if g_i[e] == 0]
for node in sor:
    for i in g_o[node]:
        g_i[i] -= 1
        if g_i[i] == 0:
            sor.append(i)
dp = [0] * n
for node in sor:
    for c in g_o[node]:
        if dp[c] < dp[node] + 1:
            dp[c] = dp[node] + 1
print(max(dp))

Measured memory_bytes: 23616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,K;
string s,t;

signed main()
{
	IOS();
	cin>>N>>M;
	int ans = 0;
	int k[M][N]={};
	rep(i,0,M){
		int t ;
		cin>>t;
		rep(j,0,t){
			int tt;
			cin>>tt;
			k[i][tt-1]=true;
		}
	}
	vector<int>p(M);
	for(int i = 0;i < M;i++){
		cin>>p[i];
	}
	rep(i,0,1ll<<N){
		int flg = 1;
		rep(l,0,M){
			int cnt = 0;
			rep(j,0,N){
				if((i&(1ll<<j))&&k[l][j])cnt++;
			}
			if(cnt%2!=p[l]){
				flg = 0;
				break;
			}
		}
		if(flg)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b,c;
  int i,j=0;

  scanf("%d %d %d",&a,&b,&c);

  if(a<=b)
    for(i=a;i<=b;i++)
      if((c%i)==0)
	j+=1;

  printf("%d\n",j);
}



Measured memory_bytes: 2052
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  char s[4];
  int price = 700;
  scanf("%s", s);
  for (int i=0; i<3; i++) {
    if (s[i]=='o') {
      price += 100;
    }
  }
  cout << price << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){


	int n;
	cin >> n;

	map<pair<int,int>,int> ca,cb;
	for(int i = 1;i <= n;i++){
		string s = to_string(i);
		ca[make_pair(s[0],s[s.size()-1])]++;
		cb[make_pair(s[s.size()-1],s[0])]++;
	}
	int ans = 0;
	for(auto x:ca){
		ans += x.se*cb[x.fi];
	}
	cout << ans << endl;

	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc152.contest.atcoder.jp/tasks/abc152_d

Measured memory_bytes: 3704
def resolve():
    '''
    code here
    '''
    N, Q = [int(item) for item in input().split()]
    S = input()
    queries = [[int(item) for item in input().split()] for _ in range(Q)]

    memo = [0 for _ in range(N)]

    prev = S[0]
    for i in range(1, N):
        memo[i] = memo[i-1]
        if S[i] == 'C' and prev == 'A':
            memo[i] += 1
        prev = S[i]
    
    for l, r in queries:
        print(memo[r-1] - memo[l-1])




if __name__ == "__main__":
    resolve()


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

int main() {

	int n, m; cin >> n >> m;	
	vector<int> l(m), r(m);
	vector<int> num(n + 5, 0);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
		num[l[i]]++;
		num[r[i] + 1]--;
	}
	int ans = 0;
	for (int i = 1; i < n + 5; i++) {
		num[i] += num[i - 1];
		if (num[i] == m) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4516
#include<iostream>
#include<cctype>
#include<stdio.h>
using namespace std;

int main(){
    char ch;

    // while(1){
    //     cin >> ch;
    //     if(NULL == &ch){
    //         break;
    //     }
    //     cout << ch << endl;
    // }

    // while(cin >> ch){
    //     // cout << ch << endl;
    //     cout << ch;
    // }
    // cout << endl;

    // for(int i = 0; i < 50; i++){
    while(1){
        scanf("%c", &ch);
        if(ch == '\n'){
            break;
        }
        // アルファベット以外の文字はそのまま出力
        if(isalpha(ch)){
            // 小文字と大文字を入れ替え
            if(islower(ch)){
                printf("%c", toupper(ch));
            }else if(isupper(ch)){
                printf("%c", tolower(ch));
            }else{
                printf("%c", ch);
            }
            
        }else{
            printf("%c", ch);
        }
        
    }
    printf("\n");

    return 0;
}


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

int main() {
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(),B.end());
    for(int i = 0; i < N; i++) {
        if(A[i] != B[N-1]) {
            cout << B[N-1] << endl;
        }
        else {
            cout << B[N-2] << endl;
        }
    }
}



Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    int A[M],sum=0;
    rep(i,M){
        cin >> A[i];
        sum+=A[i];
    }
    int ans=N-sum;
    if(ans<0) cout << -1 << endl;
    else cout << ans << endl;
}

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

using namespace std;


map<string,int>cjt;
int main(){
    int a;
    string s;
    cin>>a;
    for (int i = 0; i < a; i++)
    {
        cin>> s;
        cjt[s]++;
    }
    int maxx;

    for(auto &x : cjt){
        int v = x.second;

        if( v > maxx) maxx = v;
    }
    
    for (auto it = cjt.begin(); it != cjt.end(); ++it){
        if(it->second == maxx) cout<<it->first<<"\n";

    }

    
    

    
    
    

    return 0;
}

Measured memory_bytes: 25272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int a, b, ans = 0;
	scanf("%lld%lld", &a, &b);
	if(a == 1 or b == 1){
		if(a > b)swap(a, b);
		if(b >= 2)ans = b-2;
		else ans = 1;
	}else ans = (a-2)*(b-2);
	printf("%lld\n", ans);
	return 0;
}






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

int main(){

  string str,z,x;

  while(1){

    stack < string > a;
    int count = -1,d;
    z = "0";
    a.push("0");
    d = a.size();

    getline(cin,str);

    if(str == ".") break;

    for(int i=0;i<str.size();i++){

      if((a.size() == d && str[i] == ')') || (a.size() == d && str[i] == ']')){
	count = 0;
        break;
      }

      if(str[i] == '(' || str[i] == '['){
	x = str[i];
	a.push(x);
	z = a.top();
      }

      else if((z == "(" && str[i] == ')') || (z == "[" && str[i] == ']')){
	a.pop();
	z = a.top();
      }

      else if((z == "(" && str[i] == ']') || (z == "[" && str[i] == ')')){
	count = 0;
	break;
      }

    }
    
    if(count == 0 || a.size() != d) cout << "no" << endl;
    else cout << "yes" << endl;
  }
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(){
  int i,j,n,minj,temp,c=0,f;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    f=0;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
	f=1;
      }
    }
    if(f==1){
    temp=a[i];
    a[i]=a[minj];
    a[minj]=temp;
    c++;
    }
  }
    for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,b;
    cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>b;
        a[i].first=b;a[i].second=i+1;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].second<<' ';
    }
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	cin>>N;
	vector<string> s(N);
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	for(int i=0; i<N; i++)
	{
		cin>>s[i];

		if(s[i] == "AC")
		{
			AC++;
		}
		if(s[i] == "WA")
		{
			WA++;
		}
		if(s[i] == "TLE")
		{
			TLE++;
		}
		if(s[i] == "RE")
		{
			RE++;
		}
	}

	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 6424
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
LL n,ans=0,t[2][20],f[20][20],top[2];
char s[40];
void solve(LL S)
{
	//printf("S:%lld\n",S);
	top[0]=top[1]=0;
	for(LL i=0;i<n;i++)
	{
		LL c=S&(1<<i)?1:0;
		t[c][++top[c]]=i+1;
	}
	//printf("1:");for(int i=1;i<=top[0];i++) printf("%lld ",t[0][i]);printf("\n");
	//printf("2:");for(int i=1;i<=top[1];i++) printf("%lld ",t[1][i]);printf("\n");
	memset(f,0,sizeof(f));
	f[0][0]=1;
	//printf("ok\n");
	for(LL i=0;i<=top[0];i++)
		for(LL j=0;j<=top[1];j++)
		{
			if(i==top[0]&&j==top[1]) continue;
			LL k=2*n-i-j;
			if(i<top[0]&&s[t[0][i+1]]==s[k]) f[i+1][j]+=f[i][j];//printf("f:%lld %lld %lld %lld\n",i,j,i+1,j);
			if(j<top[1]&&s[t[1][j+1]]==s[k]) f[i][j+1]+=f[i][j];//printf("f:%lld %lld %lld %lld\n",i,j,i,j+1);
		}
	ans+=f[top[0]][top[1]];
	//printf("ans:%lld\n",ans);
}
int main()
{
	scanf("%lld",&n);scanf("%s",s+1);
	for(LL i=0;i<(1<<n);i++) solve(i);
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX(a,b) (a) > (b) ? a:b
#define MIN(a,b) (a) < (b) ? a:b

int main(){
	float x;
	float min=1000001;
	float max=-1;
	
	while(scanf("%f",&x)!=EOF){
		max=MAX(max,x);
		min=MIN(min,x);
		
	}
	printf("%f\n",max-min);
	
	return 0;
	
}


Measured memory_bytes: 2056
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long long x,y;
	cin >> x >> y;
	int cnt = 0;
	
	long long a = x;

	while( a <= y ){
		a *= 2;
		cnt++;
	} 
	
	P(cnt);
	ret 0;
}

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

using namespace std;

int main(){
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	if (x + x == w&&y + y == h){
		cout << w*h / 2 << " " << 1 << endl;
	}
	else {
		cout << w*h / 2 << " " << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	if (a==b) cout<<c;
	else if (a==c) cout<<b;
	else if (b==c) cout<<a;
	else cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include<set>
#include<map>
using namespace std;

int main()
{
	long long N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	sort(A.rbegin(), A.rend());

	long long sum=0;
	int t = N - 1;
	for (int i = 0; i < A.size(); ++i)
	{
		int lim = 2;
		if (i == 0) lim = 1;
		for (int j = 0; j < lim; ++j)
			if (t > 0)
			{
				sum += A[i];
				--t;
			}
	}
	cout << sum << endl;
}


Measured memory_bytes: 4024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<vector<pair<i64, i64>>> e;
vector<i64> c;

void dfs(i64 u, i64 x, i64 d) {
  c[u] = d % 2;
  for (auto p : e[u]) {
    i64 v = p.first, w = p.second;
    if (v != x) {
      dfs(v, u, d + w);
    }
  }
}

int main() {
  cin >> n;
  init_n(e, n + 1);
  for (i64 i = 0; i < n - 1; ++i) {
    i64 u, v, w; cin >> u >> v >> w;
    e[u].emplace_back(v, w);
    e[v].emplace_back(u, w);
  }
  init_n(c, n + 1);
  dfs(1, -1, 0);

  for (i64 u = 1; u <= n; ++u) {
    cout << c[u] << '\n';
  }
  return 0;
}


Measured memory_bytes: 9984
N, M, X = map(int, input().split())
cost = []
cont = []
INF = float('inf')
for _ in range(N):
    C, *A = map(int, input().split())
    cost.append(C)
    cont.append(A)
    
def calc(bit):
    price = 0
    skill = [0]*M
    for i in range(N):
        if (bit >> i) & 1:
            price += cost[i]
            for j, la in enumerate(cont[i]):
                skill[j] += la
    if min(skill) >= X:
        return price
    else:
        return INF
    
ans = INF
for bit in range(1 << N):
    price = calc(bit)
    ans = min(ans, price)
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9240
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	ll q, h, s, d;	cin >> q >> h >> s >> d;
	ll n;	cin >> n;
	ll val = min(4 * q, min(2 * h, s));
	ll ret = n*val;
	ll num = n / 2;
	val = num*d + (n - num * 2)*val;
	cout << min(val, ret) << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
for n in range(N):
    s.append(input())

M = int(input())
t = []
for m in range(M):
    t.append(input())


ans = 0
for n in range(N):
    count = 0
    for j in range(N):
        if s[n] == s[j]:
            count += 1
    for j in range(M):
        if s[n] == t[j]:
            count -= 1
    ans = max(ans, count)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;

struct node
{
    ll id;
    ll cost;
    ll parent;
    node(ll _id, ll _cost)
    {
        id = _id;
        cost = _cost;
    }
};

bool operator<(const node &left, const node &right)
{
    return left.cost < right.cost;
}

bool operator>(const node &left, const node &right)
{
    return left.cost > right.cost;
}

struct edge
{
    ll to;
    ll cost;
    edge(ll _to, ll _cost)
    {
        to = _to;
        cost = _cost;
    }
};

struct Graph
{
    ll V;
    vector<vector<edge>> edges;

    // V is the number of vertices
    Graph(ll _V)
    {
        // init
        V = _V;
        rep(i, V)
        {
            edges.push_back({});
        }
    }

    void addEdge(ll u, ll v, ll w)
    {
        edges[u].push_back(edge(v, w));
    }

    // O((E+N)logN)
    vector<ll> dijkstra(ll s) // s: starting vertex
    {

        // using node = pair<int, int>; // node.second can be reached by cost n.first

        // init min distance vector
        // d[i] is the minimum distance from s to i
        vector<ll> d(V);
        rep(i, V)
        {
            d[i] = LLONG_MAX;
        }

        // the top element is the vertex with the smallest cost
        priority_queue<node, vector<node>, greater<node>> q;

        // init start vertex
        d[s] = 0;
        q.push(node(s, 0));

        // update
        while (!q.empty())
        {
            node n = q.top();
            q.pop();

            // cout << "Now at node " << n.id << endl;

            // Check all the node which connects with n
            for (edge e : edges[n.id])
            {
                // cout << "Searching edge from " << n.second << " to " << e.to << endl;
                ll cand = d[n.id] + e.cost; // Cost via n
                // cout << "Candidate cost to " << e.to << " is " << cand << endl;

                if (cand < d[e.to])
                {
                    // cout << "Update cost for " << e.to << " to " << cand << endl;
                    d[e.to] = cand;
                    q.push(node(e.to, cand)); // If via n is better, this may improve the shortest cost so need check
                }
            }
        }

        return d;
    }
};

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;

    // Init
    Graph G = Graph(N);
    rep(i, N - 1)
    {
        G.addEdge(i, i + 1, 1);
        G.addEdge(i + 1, i, 1);
    }
    G.addEdge(X - 1, Y - 1, 1);
    G.addEdge(Y - 1, X - 1, 1);

    vector<ll> shortest = G.dijkstra(0);

    // Search
    vector<vector<ll>> shortestpath;
    rep(i, N)
    {
        shortestpath.push_back(G.dijkstra(i));
    }

    vector<ll> ans(N);
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans[shortestpath[i][j] - 1] += 1;
        }
    }

    rep(i, N - 1)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const lli mod = 1e9 + 7;
lli a, b, fac[500050];
lli mypow(lli x, lli y)
{
	lli res = 1;
	while(y)
	{
		if(y & 1) res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}
lli C(lli m, lli n)
{
	if(n == m || n == 0) return 1;
	lli one = fac[m];
	lli two = mypow(fac[n], mod - 2);
	lli three = mypow(fac[m - n], mod - 2);
	return ((one * two) % mod * three) % mod;
}
int main()
{
	cin >> a >> b;
	fac[0] = fac[1] = 1;
	for(lli i=2; i <= 500000; i++)
		fac[i] = (fac[i - 1] * i) % mod;
	lli ans = (C(b, a) * fac[a]) % mod;
	ans = (ans * ans) % mod;
//	cout << ans << '\n';
	for(int i=1; i <= a; i++)
	{
		lli one = C(b, i) * fac[i] % mod;
		lli two = C(b - i, a - i) * fac[a - i] % mod;
		lli three = C(a, i);
		lli res = (((one * two) % mod * two) % mod * three) % mod;
//		cout << res << ' ';
		if(i & 1) ans = (ans - res + mod) % mod;
		else	  ans = (ans + res) % mod;
//		cout << one << ' ' << two << ' ' << three << ' ' << ans << '\n';
	}
	cout << ans << '\n';
}

Measured memory_bytes: 7548
lis=[0 for i in range(1000000)]
s=int(input())
k=1
lis[s]+=1
while True:
    k+=1
    if s%2==0:
        s=s//2
    else:
        s=3*s+1
    if lis[s]==1:
        break
    lis[s]=lis[s]+1

print(k)

Measured memory_bytes: 10904
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let K = buf_it.next().unwrap().parse::<usize>().unwrap();

    let W = (0..N).map(|_| buf_it.next().unwrap().parse::<usize>().unwrap()).collect::<Vec<_>>();

    let f = |i| {
        let mut cnt = 1;
        let mut cur_w = 0;
        for &w in &W{
            if w > i {
                return false;
            }
            if cur_w + w <= i{
                cur_w += w;
            } else {
                cnt += 1;
                cur_w = w;
            }
        }
        cnt <= K
    };
    let ans = binary_search(1_000_000_000_000, 0, f);
    println!("{}",ans);

}

fn binary_search<F>(ok:usize,ng:usize,isOk:F) -> usize
where F : Fn(usize) -> bool{
    let mut ok = ok as isize;
    let mut ng = ng as isize;
    while (ok-ng).abs() > 1{
        let i = (ok+ng)/2;
        if isOk(i as usize) { ok = i;} else {ng = i;}
    }
    ok as usize
}


Measured memory_bytes: 5032
s=input()
a,b=map(int,[s[:2],s[-2:]])
if 0<a<13:
    if 0<b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<b<13:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 2940
def solve():
    H, W = [int(x) for x in input().split(" ")]
    snake = []
    for _ in range(H):
        snake.append(list(map(str, input().split(" "))))

    for i in range(H):
        for j in range(W):
            if snake[i][j] == "snuke":
                print("".join([chr(65 + j), str(i + 1)]))


solve()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  ll n;
  cin >> n;
  ll ans = n/500 * 1000;
  ll rem = n % 500;
  ans += rem/5 * 5;
  cout << ans;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && a[i] == c[i]) continue;
        if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) ans += 1;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort()
B.sort()

SA = set(A)
SB = set(B)

if len(A) != len(SA):
    print(0)
    exit()

if len(B) != len(SB):
    print(0)
    exit()

ans = 1
mod = 10**9+7
import bisect
for i in reversed(range(1, n*m+1)):
    if i in SA and i in SB:
        ans *= 1
    elif i in SA and i not in SB:
        k = bisect.bisect_left(B, i)
        ans *= m-k
        ans %= mod
    elif i not in SA and i in SB:
        j = bisect.bisect_left(A, i)
        ans *= n-j
        ans %= mod
    else:
        j = bisect.bisect_left(A, i)
        k = bisect.bisect_left(B, i)
        ans *= (n-j)*(m-k)-(n*m-i)
        ans %= mod
    #print(ans)
print(ans%mod)


Measured memory_bytes: 44588
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;

int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());

	if(s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#h,w
def main():
	x = int(input())
	s = 0
	i = 1
	while s<x:
		s += i
		i += 1
	print(i-1)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct Edge{
  int to;
  long long cost;
};

struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
const int S = 100005;
vector<Edge> g[S],rg[S];

int N;
const ll INF = 1e15;
int n,m,k,s;
ll p,X;
bool F = false;
vector<int> dan(S);
vector<ll> cost(S);
vector<ll> dijkstra(vector<Edge> g[S], int start){
  priority_queue<NODE> Q;
  Q.push({start,0});
  vector<ll> res(N,INF);
  while(Q.size()){
    NODE q= Q.top();Q.pop();
    if(res[q.pos] == INF){
      res[q.pos] = q.cost;
      if(F && q.cost <= s){
        if(cost[q.pos] == p)
          cost[q.pos] = X;
      }
    }
    else{
      continue;
    }
    for(auto n : g[q.pos]){
      if(!F){
        Q.push({n.to,q.cost+n.cost});
      }
      else if(q.cost + n.cost <= s){
        Q.push({n.to,q.cost+n.cost});
      }
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k >> s ;
  N = n;
  cin >> p >> X;
  rep(i,k){
    cin >> dan[i];
    dan[i]--;
  }
  vector<int> a(m),b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    --a[i],--b[i];
    g[a[i]].push_back({b[i],1});
    g[b[i]].push_back({a[i],1});
  }
  fill(all(cost),p);
  F = true;
  rep(i,k){
    auto d = dijkstra(g,dan[i]);
    cost[dan[i]] = inf;
  }
//   rep(i,n){
//     cout << cost[i] << endl;
//   }
  F = false;
  rep(i,m){
    rg[a[i]].push_back({b[i],cost[b[i]]});
    rg[b[i]].push_back({a[i],cost[a[i]]});
  }
  auto d = dijkstra(rg,0);
  cout << d[n-1] - cost[n-1]<<endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  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-1; i++) cin >> c[i];

  int ans=0;
  int prev = -10;
  for (int i = 0; i < n; i++)
  {
    ans+=b[a[i]-1];
    if(a[i]-prev == 1) ans+=c[prev-1];
    prev = a[i];
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>


using namespace std;


using namespace std;

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


   if(A==3){

       cout<<A * 60<<endl;
   }

   if(4<=A){

       cout<<(A-2)*180<<endl;


   }


   }


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

int main(){
    int h,w,count;
    while(true){
        cin >> h >> w;
        count=0;
        if(h==0&&w==0)
        break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
            if(count%2==0)
            cout << '#';
            else
            cout << ".";
            count++;
            }
            cout << endl;
            if(w%2==0)
            count++;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
  const int N; scanf("%d", &N);

  int prime[N];
  int size = 0;
  prime[size++] = 2;
  for(int i = 3, k = 0; i < N; i++){
    int b = 1;
    if(prime[k]*prime[k] < i) k++;
    for(int j = 0; j <= k; j++){
      if(i%prime[j] == 0){
        b = 0;
        break;
      }
    } if(b) prime[size++] = i;
  }

  const int M = size;
  int count[M];
  for(int i = 0; i < M; i++){
    int j = 0;
    int p = prime[i];
    int tmp = 0;
    while(p < N){
      tmp += N/p;
      p *= prime[i];
      j++;
    }
    count[i] = tmp;
  }

  int ans = 0;

  for(int i = 0; 74 <= count[i]; i++) ans++;

  for(int i = 0; 24 <= count[i]; i++)
    for(int j = 0; 2 <= count[j]; j++)
        if(i != j) ans++;

  for(int i = 0; 14 <= count[i]; i++)
    for(int j = 0; 4 <= count[j]; j++)
        if(i != j) ans++;

  for(int i = 0; 4 <= count[i]; i++)
    for(int j = i+1; 4 <= count[j]; j++)
        for(int k = 0; 2 <= count[k]; k++)
            if(k != i && j != k) ans++;

  printf("%d", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <complex>
#include <ctime>
#include <unordered_map>
#pragma comment (linker, "/STACK:256000000")

using namespace std;

const int maxN = 110000;
int n, k;
int a[maxN];

long long l[maxN], r[maxN], s[maxN];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		s[i] = a[i];
		s[i] += s[i - 1];
	}

	for (int i = 1; i <= n; ++i) {
		l[i] = max(0, a[i]);
		l[i] += l[i - 1];
	}
	for (int i = n; i >= 1; --i) {
		r[i] = max(0, a[i]);
		r[i] += r[i + 1];
	}

	long long res = 0;

	for (int i = 1; i <= n - k + 1; ++i) {
		long long cur = l[i - 1] + r[i + k];
		cur += max(0LL, s[i + k - 1] - s[i - 1]);
		res = max(res, cur);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2944
n,k,q = map(int,input().split())
arr = [int(input()) for i in range(q)]

diff = k-q
solution = [diff]*n    
for i in range(q):
    solution[arr[i]-1] += 1
    
bool_solution = [True if solution[i] > 0 else False for i in range(n)]

for i in range(n):
    if bool_solution[i]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11240
import sys
sys.setrecursionlimit(100000)

N = int(input())

edges = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    edges[u-1].append((v-1, w))
    edges[v-1].append((u-1, w))

dist = [-1 for _ in range(N)]
def measure(src):
    """
    srcを根とした木に対し、根から各頂点までの距離を求める
    """
    for v, w in edges[src]:
        if dist[v] == -1:
            dist[v] = dist[src] + w
            measure(v)

dist[0] = 0
measure(0)

for i in range(N):
    if dist[i] % 2:
        print(1)
    else:
        print(0)


Measured memory_bytes: 82300
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    print(max(a, b, c) * 10 + a + b + c - max(a, b, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61828
import math
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split(','))
    except:
        break
    vecs = [(xb - xa, yb - ya), (xc - xb, yc - yb), (xd - xc, yd - yc), (xa - xd, ya - yd)]
    angles = [(math.atan2(*vecs[(i + 1) % 4][::-1]) - math.atan2(*vecs[i][::-1])) % (2 * math.pi) for i in range(4)]
    print('YES' if max(angles) < math.pi or min(angles) > math.pi else 'NO')

Measured memory_bytes: 7800
s = [s for s in input()]
l = len(s)//2

s_1 = s[:l]
s_2 = s[l+1:]

if s!=s[::-1]:
  print('No')
elif s_1!=s_1[::-1]:
  print('No')
elif s_2!=s_2[::-1]:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3060
import math

a,b,C = map(int, input().split())
S = (1/2)*a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = 2*S/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5712