akhauriyash/Code-Regression huggingface dataset:
import numpy as np
problem, answer = map(int, input().split())
ac_count = np.array([0]*problem)
wa_count = np.array([0]*problem)
for i in range(answer):
    a,b = input().split()
    if ac_count[int(a) - 1] == 0 and b == "WA":
        wa_count[int(a) - 1] += 1
    else:
        ac_count[int(a) - 1] = 1

print("{} {}".format(sum(ac_count), sum(ac_count * wa_count)))

Measured memory_bytes: 16744
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto &it : a)
    cin >> it;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0 && a[i] % 2 != 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int MAX=1e5+10;
const ll INF=1e18;
 
 
 
int main(){
	int N;
	cin>>N;
	vll B(N);
	rep(i,N)cin>>B[i];
	sort(B.begin(), B.end());
  	vll sm(N+1);
	sm[0]=0;
	rep1(i,N)sm[i]=sm[i-1]+B[i-1];
	ll ans=-INF;
	int c=0;
	rep1(i,N-1){
		ll tmp=sm[N]-2*sm[i];
		if(ans<tmp){
			ans=tmp;
			c=i;
		}
	}
	cout<<ans<<endl;
	
	if(c!=N-1){
		ll t=B[c-1];
		for(int i=c; i<=N-2; i++){
			cout<<t<<" "<<B[i]<<endl;
			t=t-B[i];
		}
		cout<<B[N-1]<<" "<<t<<endl;
		t=B[N-1]-t;
		rep(i,c-1){
			cout<<t<<" "<<B[i]<<endl;
			t=t-B[i];
		}
	}
	else{
		ll t=B[N-1];
		rep(i,N-1){
			cout<<t<<" "<<B[i]<<endl;
			t=t-B[i];
		}
	}
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <set>
#include <string>
#include <cmath>

using namespace std;

int sits[11];
int n;

multiset<int> analysis(string str){
  if(str[0]!='('){
	  multiset<int> si;
	  si.insert(sits[atoi(str.c_str())]);
	  return si;
  }
  else{
	  multiset<int> si;
    stack<char> s;

	for(int i = 0; i < str.size(); i++){
      if(str[i]=='('){
	s.push('(');
      }
      else if(str[i]==')'){
	s.pop();
      }
      else{
	if(s.size()==1&&str[i]==' '){
	  // ツ閉ェツ環つオツづ催帰
		string str1=str.substr(1,i-1);
		string str2=str.substr(i+1,str.size()-i-2);

		multiset<int> s1 = analysis(str1);
		multiset<int> s2 = analysis(str2);
	  // union
	  {
	    for(multiset<int>::iterator it = s1.begin(); it!=s1.end(); it++){
	      for(multiset<int>::iterator iit = s2.begin(); iit!=s2.end(); iit++){
		si.insert((*it)|(*iit));
	      }
	    }
	  }
	  // partition
	  {
	    for(multiset<int>::iterator it = s1.begin(); it!=s1.end(); it++){
	      for(multiset<int>::iterator iit = s2.begin(); iit!=s2.end(); iit++){
		si.insert((*it)&(*iit));
	      }
	    }
	  }
	  // diff
	  {
	    for(multiset<int>::iterator it = s1.begin(); it!=s1.end(); it++){
	      for(multiset<int>::iterator iit = s2.begin(); iit!=s2.end(); iit++){
		si.insert((*it)^(*iit));
	      }
	    }
	  }
	  return si;
	}
      }
    }
  }
}

int main(){

  string str;
  while(getline(cin,str)&&str!="END"){
	  cin>>n;
    for(int i = 0; i < n; i++){
      int s=0;
      for(int j = 0; j < 4; j++){
	int b;
	cin>>b;
	if(b==1)
	  s+=(int)pow(2.0,j);
      }
      sits[i+1]=s;
    }
	multiset<int> ms = analysis(str);
	int cnt=0;
	for(multiset<int>::iterator it = ms.begin(); it!= ms.end(); it++){
		if(*it==15)
			cnt++;
	}
	cout<<cnt<<endl;
	getline(cin,str);
  }
  

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int a[N] ;
int work()
{
  int n , k ;
  scanf("%d%d" , &n , &k) ;
  for(int i = 1; i <= n ;i ++ ) scanf("%d" , &a[i]) ;
  for(int i = k + 1; i <= n ;i ++ )
   if(a[i] > a[i - k]) puts("Yes") ;
   else puts("No") ;
  return 0 ;
}
int main()
{

  work() ;
  return 0 ;
}
/*
*/


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

#define F first
#define S second
const long long mod = 1000000007;
#define ll long long
 
ll N, L;
string s;

const int TS = 222222;
int NN = 1;
int trie[TS][2];

void addTrie() {
    int cnode = 0;
    for(auto ch : s) {
        int bn = ch - '0';
        if(trie[cnode][bn] == -1) {
            trie[cnode][bn] = NN++;
        }
        cnode = trie[cnode][bn];
    }
}

vector<ll> hts;
void update_hts(int s, ll th) {
    if(trie[s][0] != -1 && trie[s][1] != -1) {
        update_hts(trie[s][0], th-1);
        update_hts(trie[s][1], th-1);
    }
    if(trie[s][0] == -1 && trie[s][1] != -1) {        
        update_hts(trie[s][1], th-1);
        hts.push_back(th);
    }
    if(trie[s][0] != -1 && trie[s][1] == -1) {
        update_hts(trie[s][0], th-1);
        hts.push_back(th);        
    }
}

int main() {
    cin >> N >> L;
    for(int i = 0;i < TS;i++) {
        trie[i][0] = trie[i][1] = -1;
    }
    for(int i = 0;i < N;i++) {
        cin >> s;
        addTrie();
    }
    update_hts(0, L);
    ll txor = 0;
    for(auto height : hts) {        
        ll ans = 1;
        while(height % 2 == 0) {
            height >>= 1;
            ans <<= 1;
        }
        txor ^= ans;
    }

    if(!txor) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
 
    return 0;
}

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

class P
{
    static void Main()
    {
        Console.ReadLine();
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long asum = a.Sum();
        long[] sum = new long[a.Length - 1];
        sum[0] = a[0];
        for (int i = 1; i < sum.Length; i++)
        {
            sum[i] = sum[i - 1] + a[i];
        }
        long res = long.MaxValue;
        foreach (var i in sum)
        {
            res = Math.Min(res, Math.Abs(asum - i * 2));
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 33860
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  int n,a,b;
  string s;

  cin >> n >> a >> b;  

  cout << min(n*a, b) << endl;
  
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);

	int D, T, S; cin >> D >> T >> S;
	if (S*T >= D) cout << "Yes";
	else cout << "No";

}


Measured memory_bytes: 3632
import math

def order(A):
  l=len(A)
  acu=[0 for _ in range(l+1)]
  res=1
  num=l-1
  for a in A:
    res+=(a-1-acu[a])*math.factorial(num)
    num-=1
    for i in range(a, l+1):
      acu[i]+=1
  return res

N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
print(abs(order(P)-order(Q)))


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

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

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

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

int X, A;


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

    cin >> X >> A;


    cout << ((X < A) ? 0 : 10) << "\n";

    return 0;
}



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

int main() {
  int n;
  cin >> n;
  if (n % 1110 <= 9) {
    cout << "Yes" << endl;
  }
  else if ((n % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <chrono>
#include <random>

using namespace std;
typedef long long ll;

int DAYS;
const int TYPES = 26;
mt19937 engine(random_device{}());

vector<int> c;
vector<vector<ll>> s;

ll point;
vector<ll> penalty;

chrono::system_clock::time_point startTime, endTime;
int elapsed = 0;

void simulate(vector<int> &t) {
    vector<int> last(TYPES, -1);
    point = 0, penalty.assign(TYPES, 0);
    for (int i = 0; i < DAYS; i++) {
        point += s[i][t[i]], last[t[i]] = i;
        for (int j = 0; j < TYPES; j++) {
            penalty[j] += c[j] * (i - last[j]);
        }
    }
}

void update(vector<int> &t, int x, int y) {
    int lastx = -1, lasty = -1;
    penalty[x] = 0, penalty[y] = 0;
    for (int i = 0; i < DAYS; i++) {
        if (t[i] == x)lastx = i;
        if (t[i] == y)lasty = i;

        penalty[x] += c[x] * (i - lastx), penalty[y] += c[y] * (i - lasty);
    }
}

ll scoring() {
    ll ret = point;
    for (auto &x:penalty)ret -= x;
    return ret;
}


ll mod_rnd(ll mod) { return engine() % mod; }

int main() {
    startTime = chrono::system_clock::now();

    cin >> DAYS;
    c.resize(TYPES);
    for (int i = 0; i < TYPES; i++)cin >> c[i];
    s.assign(DAYS, vector<ll>(TYPES));
    for (int i = 0; i < DAYS; i++) {
        for (int j = 0; j < TYPES; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(DAYS);
    for (int i = 0; i < DAYS; i++) t[i] = i % TYPES;

    simulate(t);
    ll currentScore = scoring();

    while (elapsed < 1950) {
        int ope = mod_rnd(elapsed / 18 + 1);
        int day1 = -1, day2 = -1;
        int type1 = -1, type2 = -1;

        if (ope == 0) {
            do {
                day1 = mod_rnd(DAYS), type2 = mod_rnd(TYPES);
            } while (t[day1] == type2);

            type1 = t[day1];
            t[day1] = type2;
            point -= s[day1][type1], point += s[day1][type2];
        } else {
            do {
                day1 = mod_rnd(DAYS), day2 = mod_rnd(DAYS);
            } while (day1 == day2);

            type1 = t[day1], type2 = t[day2];
            point -= s[day1][type1], point -= s[day2][type2];
            swap(t[day1], t[day2]);
            point += s[day1][type2], point += s[day2][type1];
        }

        update(t, type1, type2);
        ll changedScore = scoring();

        ll add = (1800 - elapsed);
        if (currentScore < changedScore + add)currentScore = changedScore;
        else {
            if (ope == 0) {
                t[day1] = type1;
                point += s[day1][type1], point -= s[day1][type2];
            } else {
                point -= s[day1][type2], point -= s[day2][type1];
                swap(t[day1], t[day2]);
                point += s[day1][type1], point += s[day2][type2];
            }
            update(t, type1, type2);
        }

        endTime = chrono::system_clock::now();
        elapsed = chrono::duration_cast<chrono::milliseconds>(endTime - startTime).count();
    }

    for (auto &x:t)cout << x + 1 << endl;
    return 0;
}

Measured memory_bytes: 3724
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrT = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			arrT[i] = x;
			total += x;
		}
		int m = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			sb.append(total - arrT[p - 1] + x).append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#define N 1000000007
using namespace std;
typedef long long ll;

int mod_pow(int m,int n){
  ll a=1,x=m;
  while(n){
    if(n%2)a=a*x%N;
    x=x*x%N;
    n=n/2;
  }
  return a;
}

int main(){
  int m,n;
  cin>>m>>n;
  cout<<mod_pow(m,n)<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <queue>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, long long int>>> graph(n);
    for(int i = 0; i < n - 1; i++)
    {
        int a, b;
        long long int c;
        cin >> a >> b >> c;
        graph[a - 1].push_back({b - 1, c});
        graph[b - 1].push_back({a - 1, c});
    }
    int q, k;
    cin >> q >> k;
    vector<pair<int, int>> query(q);
    for(int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        query[i] = {x - 1, y - 1};
    }
    //幅優先探索で距離をkから各頂点への距離を計算
    queue<int> queue1;
    queue1.push(k - 1);
    vector<bool> flags(n, false);
    vector<long long int> dists(n, 0);   //距離
    flags[k - 1] = true;
    while(!queue1.empty())
    {
        int current = queue1.front();
        queue1.pop();
        for(int i = 0; i < graph[current].size(); i++)
        {
            pair<int, long long int> next = graph[current][i];
            if(!flags[next.first])
            {
                queue1.push(next.first);
                flags[next.first] = true;
                dists[next.first] = dists[current] + next.second;
            }
        }
    }
    for(auto e : query)
    {
        cout << dists[e.first] + dists[e.second] << endl;
    }
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int l,r,d;
  cin>>l>>r>>d;
  int ans = 0;
  for(int i=l;i<=r;++i)if(i%d==0)ans++;
  cout<<(ans)<<endl;

}

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

int main(){
	int n,m; cin >>n >>m;
    long long sum=0, tmp=0;
    	for(int i=0; i<m; i++){
    	cin >>tmp;
        sum+=tmp;
    }
    if(sum>n)cout <<-1 <<endl;
    else cout << n-sum <<endl;
}

Measured memory_bytes: 3632
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

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

    int x, a;
    cin >> x >> a;
    if (x >= a) cout << 1;
    cout << 0;

    return 0;
}


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

Measured memory_bytes: 9596
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int N;
	cin >> N;
	int A[100000],D[100000];
	int pos = 0;
	int output = 0;

	
	REP(i, N) {
		int memo;
		cin >> memo;
		A[i] = memo;
		D[i] = abs(A[i] - pos);
		output += D[i];
		pos = A[i];
	}
	D[N] = abs(pos);
	output += D[N];

	REP(i, N) {
		int result = output;
		if (i == 0) {
			result -= (D[0] + D[1] - abs(A[i + 1]));
		}
		else if (i == (N-1)) {
			result -= (D[N] + D[N-1] - abs(A[i - 1]));
		}
		else {
			result -= (D[i + 1] + D[i] - abs(A[i + 1] - A[i - 1]));
		}
		cout << result << endl;
	}


	system("pause");
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[2];
int main(){
	scanf("%s",in);
	if(in[0]=='A')printf("T\n");
	if(in[0]=='T')printf("A\n");
	if(in[0]=='G')printf("C\n");
	if(in[0]=='C')printf("G\n");
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int cnt[3];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        cnt[x%2]++;
    }
    if(cnt[1] % 2 != 0) {
        cout << "NO";
    } else cout << "YES";
}


Measured memory_bytes: 384
// SeeAlso: https://atcoder.jp/contests/abc124/tasks/abc124_c

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <limits>

#define MAX 4

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

using namespace std;

int main() {
    string S;

    cin >> S;

    int a = 0;
    int b = 0;

    REP(i, S.size()) {
        string x;
        if ((i % 2) == 0) {
            x = "0";
        } else {
            x = "1";
        }

        if (S.substr(i, 1) != x) {
            a++;
        }
    }

    REP(i, S.size()) {
        string x;
        if ((i % 2) == 0) {
            x = "1";
        } else {
            x = "0";
        }

        if (S.substr(i, 1) != x) {
            b++;
        }
    }

    cout << min(a, b) << endl;

    return 0;
}


Measured memory_bytes: 512
def main():
    a, b, c = map(int, input().split())
    k = int(input())

    abc = [a, b, c]
    max_index = abc.index(max(a, b, c))
    ans = 0
    for i in range(3):
        num = abc[i]
        if i == max_index:
            for _ in range(k):
                num *= 2
            ans += num
        else:
            ans += num

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int w,h,n;
int sx,sy;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int F[15][15], id[15][15];

int dfs(int S, int y, int x) {

    // bitset<7> bit(S);
    // cout << bit << " " << y << " " << x<< endl;
    if(__builtin_popcount(S) == n) {
        if(y == sy || x == sx) {
            // cout << "ADD ++ ";
            // rep(i,v.size()) {
            //     cout << v[i] << " ";
            // }
            // cout << endl;
            return 1;
        }

        return 0;
    }

    int ret = 0;

    REP(i,y+1,h) {
        if(F[i][x] == 1) {
            if(S & (1<< id[i][x])) continue;
            else {
                // vector<int> t(v.begin(), v.end());
                // t.push_back(id[i][x]);
                // ret += dfs(S | (1<<id[i][x]), i, x, t);
                ret += dfs(S | (1<<id[i][x]), i, x);
                break;
            }
        }
    }

    for(int i=y-1; i>=0; i--) {
        if(F[i][x] == 1) {
            if(S & (1<< id[i][x])) continue;
            else {
                // vector<int> t(v.begin(), v.end());
                // t.push_back(id[i][x]);
                // ret += dfs(S | (1<<id[i][x]), i, x, t);
                ret += dfs(S | (1<<id[i][x]), i , x);
                break;
            }
        }
    }

    REP(j,x+1,w) {
        if(F[y][j] == 1) {
            if(S & (1<<id[y][j])) continue;
            else {
                // vector<int> t(v.begin(), v.end());
                // t.push_back(id[y][j]);
                // ret += dfs(S | (1<<id[y][j]) , y, j, t);
                ret += dfs(S | (1<<id[y][j]), y, j);
                break;
            }
        }
    }

    for(int j=x-1; j>=0; j--) {
        if(F[y][j] == 1) {
            if(S & (1<<id[y][j])) continue;
            else {
                // vector<int> t(v.begin(), v.end());
                // t.push_back(id[y][j]);
                // ret += dfs(S | (1<<id[y][j]) , y, j, t);
                ret += dfs(S | (1<<id[y][j]), y , j);
                break;
            }
        }
    }

    return ret;
}
int main() {
    while(cin >> w >> h) {
        if(w == 0 && h == 0) break;

        memset(F,0,sizeof(F));
        memset(id,0,sizeof(id));
        n = 0;

        rep(i,h) {
            rep(j,w) {
                cin >> F[i][j];

                if(F[i][j] == 2) {
                    sy = i;
                    sx = j;
                } else if(F[i][j] == 1) {
                    id[i][j] = n;
                    n++;
                }
            }
        }

        vector<int> v;
        cout << dfs(0, sy, sx) << endl;
    }


    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define const INF 10000000000

ll a, b, c, n, x, y, z, w, h, ans = 0, cnt = 0, max = 0;
string s;

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

    cin >> n;
    rep(i, n / 4 + 1){
        rep(j, n / 7 + 1){
            if (4 * i + 7 * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
	cout << "No" << endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
k=A%4
AA=A+4-k
l=B%4
BB=B-l
AAA=[]
BBB=[]
for i in range(A,AA):
    AAA+=[i]
for i in range(BB,B+1):
    BBB+=[i]

def henkan(A):
    if len(A)==4 or len(A)==0:
        return 0
    elif len(A)==3:
        return A[0]^A[1]^A[2]
    elif len(A)==2:
        return A[0]^A[1]
    elif len(A)==1:
        return A[0]
print(henkan(AAA)^henkan(BBB))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		for(int i=0; i<5; i++){
			int A = sc.nextInt();
			if(A==0){
				System.out.println(i+1);
				return;
			}
		}

		System.out.println("0");
		return;
	}
}

Measured memory_bytes: 35704
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
ll l[10];
ll n, a, b, c, ans = 0;

ll dfs(ll x, ll A, ll B, ll C) {
	if (x == n) {
		if (min(A, min(B, C)) > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		else return M;
	}
	vll ret(4);
	ret[0] = dfs(x + 1, A, B, C);
	ret[1] = dfs(x + 1, A + l[x], B, C) + 10;
	ret[2] = dfs(x + 1, A, B + l[x], C) + 10;
	ret[3] = dfs(x + 1, A, B, C + l[x]) + 10;
	sort(all(ret));
	return ret[0];
}

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

	while (cin >> n >> a >> b >> c) {
		ans = 0;
		rep(i, n) cin >> l[i];
		cout << dfs(0, 0, 0, 0) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<bool> ac(N, false);
	vector<int> wa(N, 0);
	for (int i = 0; i < M; i++)
	{
		int p;
		string S;
		cin >> p >> S;
		p--;
		if (S == "AC")
			ac[p] = true;
		else if (ac[p] == false)
			wa[p]++;
	}

	int cnt_ac = 0;
	int cnt_wa = 0;
	for (int i = 0; i < N; i++)
	{
		if (ac[i])
		{
			cnt_ac++;
			cnt_wa += wa[i];
		}
	}
	cout << cnt_ac  << " " << cnt_wa << endl;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int i,l;
long long m,K,a[50];
cin >> K;
l = K%50;
m = K/50;
cout << 50 << endl;
if(K<=50){
	for(i=0;i<K;i++){
		a[i] = 50;
	}
	for(i=K;i<50;i++){
		a[i] = 0;
	}
}else{
	for(i=0;i<l;i++){
    	a[i] = m+50;
	}
	for(i=l;i<50;i++){
		a[i] = 49 - l + m ;
	}
}
for(i=0;i<50;i++){
cout << a[i] << " " ;
}
cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# B - Battle
def takahashi_win():
	A, B, C, D = map(int, input().split())
	i = 0

	while True:
		if i % 2 == 0:
			if C-B <= 0:
				return True
			else:
				C -= B
		else:
			if A-D <= 0:
				return False
			else:
				A -= D
		
		i += 1


if takahashi_win():
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9200
k = int(input())

def gcd(x,y):
    while y:
        x ,y = y ,x%y
    return x

total = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        subg = gcd(a,b)
        subtotal = 0
        for c in range(1,k+1):
            subtotal += gcd(subg, c)
        total += subtotal

print(total)

Measured memory_bytes: 9200
//management

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int inf = 1000000000;

int main (){
    int N; cin >> N;
    vector<int> A(N-1);
    rep(i,0,N-1)cin >> A[i];
    map<int,int> josi{};
    rep(i,0,N-1){
        josi[A[i]]++;
    }
    rep(i,1,N+1){
        cout << josi[i] << endl;
    }
    return 0;
}

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

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

int main() {
  ll x;
  cin >> x;
  for(ll i=-118;i<=119;i++){
    for(ll j=-119;j<=118;j++){
      if((i*i*i*i*i-j*j*j*j*j) == x){
        cout << i << endl << j << endl;
        x=0;
        break;
      }
    }
    if(x==0) break;
  }
  
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n;
	while (cin >> n, n)
	{
		set<pii> empty({ {0,INF} });
		map<int, vector<pii>> mp;
		REP(i, n)
		{
			char c; cin >> c;
			if (c == 'W')
			{
				int a, b; cin >> a >> b;
				vector<pii> v;
				vector<pii> era;
				for (auto it = empty.begin(); b > 0; it++)
				{
					if (it->second - it->first > b)
					{
						v.emplace_back(it->first, it->first + b);
						era.push_back(*it);
						empty.insert(pii(it->first + b, it->second));
						b = 0;
					}
					else
					{
						v.emplace_back(*it);
						b -= it->second - it->first;
						era.push_back(*it);
					}
				}
				REP(i, era.size()) empty.erase(era[i]);
				mp[a] = v;
			}
			else if (c == 'D')
			{
				int a; cin >> a;
				vector<pii> v = mp[a];
				mp.erase(a);
				REP(i, v.size()) empty.insert(v[i]);
			}
			else
			{
				int a; cin >> a;
				int res;
				for (auto j : empty)
				{
					if (a >= j.first&&a < j.second)
					{
						res = -1;
						goto end;
					}
				}
				for (auto j : mp)
				{
					vector<pii> tmp = j.second;
					REP(k, tmp.size())
					{
						if (a >= tmp[k].first&&a < tmp[k].second)
						{
							res = j.first;
							break;
						}
					}
				}

			end:;
				cout << res << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, R = read_ints()

if N >= 10:
    print(R)
else:
    print(R + (100 * (10 - N)))


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

using namespace std;

int main(void)
{
    int n, k;
    int d[101];
    int a[101][101];

    cin >> n >> k;

    for (int i = 1; i <= k; i++) {
        cin >> d[i];
        for (int j = 1; j <= d[i]; j++) {
            cin >> a[i][j];
        }
    }

    int table[101];
    for (int i = 1; i <= n; i++) {
        table[i] = 0;
    }

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= d[i]; j++) {
            table[a[i][j]]++;
        }
    }

    int count = 0;

    for (int i = 1; i <= n; i++) {
        // cout << table[i] << endl;
        if (table[i] == 0) count++;
    }

    cout << count;

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

int main(void){

  int a=0,b=0;
  int d[6]={0};
  int n[2]={0};
  int k=0;//d_index

  scanf("%d %d", &n[1], &n[0]);

  int i=0;
  while(i<=1){
      //n=d[i]/10;
    while(n[i]>0){
      d[k]=n[i]%10;
      n[i]=n[i]/10;
      k++;
    }
    i++;
  }

  /*for(i=0; i<=k-1; i++){
    printf("%d", d[i]);
  }
  putchar('\n');*/

  //a bがb,aの順で配列に入った状態
  //整数iに変換して、i以下にi=k*kを満たすkの存在の有無を確かめる
  i=0;
  int j=0,sum=0,tenbeki=0;
  while(i<=k-1){
    j=0;
    tenbeki=1;
    while(j!=i){
      tenbeki=tenbeki*10;
      j++;
    }
    sum=sum+d[i]*tenbeki;
    //printf("sum:%d\n", sum);
    i++;
  }
  //sumにiが格納できた
  i=-1;
  int num=0;
  while(num<=sum){
    i++;
    num=i*i;
    if(num==sum){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
  return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
		if(a == b && a == c){
			cout << "No\n";
		}
		else if(a == b || a == c || b == c){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s = S()
    print("Yes" if len(set(s)) == 2 else "No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
# -*- coding: utf-8 -*-

N = int(input())

X_list = list(map(int, input().split()))

ave = 0

for n in range(N):
	ave = ave + X_list[n]
ave = ave / N

answer_size = max(X_list)

answer = 0

for n in range(N):
	if answer_size > abs(ave - X_list[n]):
		answer_size = abs(ave - X_list[n])
		answer = n

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;



int main(){
  string s;
  int nq;
  int hanten=1;//1の場合，順． -1の場合逆
  int num,num2;
  char s1;
  cin >>s>>nq;
  
  deque<char> d;
  rep(i,s.size()) d.push_back(s[i]);
  
  rep(i,nq){
    cin >>num;
    switch(num){
      case 1://反転
        hanten *= (-1);
        
        break;
      case 2:
        cin >>num2>>s1;
        if((num2*2-3)*hanten>0){// まつび
          d.push_back(s1);
        }else{//先頭
          d.push_front(s1);
        }
        
        break;
    }
    
  }
  
  if(hanten==1){
	  while(!d.empty()){
    	s1=d.front();
    	d.pop_front();
    	cout<<s1;
	  }
  }else{
    while(!d.empty()){
    	s1=d.back();
    	d.pop_back();
    	cout<<s1;
	  }
  }
  
}


Measured memory_bytes: 896
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] f;
    int i;

    f = new int[45];
    n = sc.nextInt();
    f[0] = 1;f[1] = 1;
    for(i = 2;i < n + 1;i++)f[i] = f[i - 1] + f[i - 2];

    System.out.println(f[n]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17352
n,m = list(map(int, input().split()))
ps = []
for i in range(m):
    p,s = list(map(str, input().split()))
    ps.append([int(p), s])

pe = 0
acset = set()
peset = {}

if m > 0:
    for i,name in enumerate(ps):
        p1,s1 = name
        if s1 == "AC" and p1 not in acset:
            acset.add(p1)
            if p1 in peset:
                pe += peset[p1]
        elif p1 not in acset:
            if p1 not in peset:
                peset[p1] = 0
            peset[p1] += 1

ac = len(acset)
print(" ".join(list(map(str, [ac, pe]))))

Measured memory_bytes: 28560
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr int dy[] = { -1, 0, 1, 0 };
constexpr int dx[] = { 0, 1, 0, -1 };
const string dirs( "NESW" );

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

	for ( LL H, W, L; cin >> H >> W >> L && ( H | W | L ); )
	{
		VS board( H );
		cin >> board;

		int y = 0, x = 0, d = 0;
		REP( i, H )
		{
			REP( j, W )
			{
				if ( isupper( board[i][j] ) )
				{
					y = i;
					x = j;
					d = dirs.find( board[i][j] );
					board[i][j] = '.';
				}
			}
		}

		VT( VVI ) visited( H, VVI( W, VI( 4, -1 ) ) );

		for ( int i = 0; i < L; ++i )
		{
			if ( visited[y][x][d] != -1 && ( L - i ) % ( i - visited[y][x][d] ) == 0 )
			{
				break;
			}

			visited[y][x][d] = i;

			while ( true )
			{
				const int ny = y + dy[d];
				const int nx = x + dx[d];

				if ( 0 <= ny && ny < H && 0 <= nx && nx < W && board[ ny ][ nx ] == '.' )
				{
					break;
				}
				else
				{
					++d %= 4;
				}
			}

			y += dy[d];
			x += dx[d];
		}

		cout << y + 1 << ' ' << x + 1 << ' ' << dirs[d] << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
int n;
int a[105];
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector < int > ans;
    for (int i = n; i >= 1; i--) {
        int ind = -1;
        for (int j = 1; j <= i; j++) {
            if (a[j] == j) ind = j;
        }
        if (ind == -1) {
            cout << -1;
            return 0;
        }
        ans.push_back(ind);
        for (int j = ind + 1; j <= i; j++) {
            a[j - 1] = a[j];
        }
    }
    reverse(ans.begin(), ans.end());
    for (int v : ans) {
        cout << v << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	private static int count(int n)
	{
		int cnt=0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if(i+j+k+l==n){
							cnt++;
						}
					}
				}
			}
		}
		return cnt;
	}
	public static void main(String[] args)
	{
		int n;
		Scanner scan=new Scanner(System.in);
		while(scan.hasNext()){
			n=scan.nextInt();
			System.out.println(count(n));
		}
		scan.close();
	}
}

Measured memory_bytes: 26464
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    int max = n-k+1;
    int ans = max-1;
    if(k == 1)
        ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

"""
まずはn+nまでの数の中で、kの倍数が何個あるのか？何か？を調べる
足してそれになる組み合わせを調べる（このとき、２つの数字は同じor 違うときがある）
"""
"""
kが奇数の時,abcは全てkの倍数出ないと無理
kが奇数の時、abcはk/2の倍数でないと無理
"""

if k%2 == 1:
	ans = (n//k)**3
else:
	ans = (n//k)**3 + ((n + k//2) //k) ** 3

print(ans)



Measured memory_bytes: 2940
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto &i:a)
#define rvl(a,n) vl a;FOR(i,0,n){IN(in); a.pb(in);}
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	IN(x)IN(y)IN(c)IN(d);
	ll ans = max(y * d,max( x * d,max(y*c,x*c)));
	cout << ans;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 3620
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

void dijkstra(){
  int i, u, v, minv, sum = 0;
  int d[N], color[N];

  for( i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for( i = 0; i < n ; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if( u == -1 ) break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++){
      if( color[v] != BLACK && A[u][v] != INFTY ){
        if( d[v] > d[u] + A[u][v] ){
          d[v] = d[u] + A[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n", i, (d[i] == INFTY ? -1 : d[i]));
  }
}


int main(){
  int i, j, s;
  int u, v, c, k;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j ++){
      A[i][j] = INFTY;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d", &u, &k);
    for( j = 0 ; j < k ; j ++){
      scanf("%d%d", &v, &c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 2060