akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%c %c",&str[0],&str[1]);
	if (str[0] == str[1]) { printf("H"); }
	else { printf("D"); }
}

Measured memory_bytes: 128
global_count = 0

def sort(a):
    return merge_sort(a)

def merge_sort(a):
    n = len(a)
    if n <= 1:
        return a
    lo = 0
    hi = n
    med = (lo+hi)/2
    left = merge_sort(a[lo:med])
    right = merge_sort(a[med:hi])
    return merge(left, right)

def merge(a,b):
    global global_count
    c = []
    na = len(a)
    nb = len(b)
    i = 0
    j = 0
    while i < na and j < nb:
        if a[i] < b[j]:
            global_count += 1
            c.append(a[i])
            i += 1
        else:
            global_count += 1
            c.append(b[j])
            j += 1

    if i == na:
        while j < nb:
            global_count += 1
            c.append(b[j])
            j += 1
    if j == nb:
        while i < na:
            global_count += 1
            c.append(a[i])
            i += 1

    return c

n = int(raw_input())
a = map(int, raw_input().split(' '))
c = sort(a)
print ' '.join(map(str, c))
print global_count

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

int main() {
  string s,t;
  cin>>s>>t;
  vector<ll> table1(30, 0);
  vector<ll> table2(30, 0);
  rep(i,s.size()) {
    ll si = s[i]-'a';
    ll ti = t[i]-'a';
    table1[si]++;
    table2[ti]++;
    if(table1[si] != table2[ti]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

struct op{ int a,b,c,d; };

vector<op> vec;

signed main(){
	int h,w,a[510][510] = {};
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) cin >> a[i][j];
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			int _j = ((i % 2) ? w - j - 1 : j);
			if(a[i][_j] % 2){
				if(!(i == h - 1 && j == w - 1)){
					if(j == w - 1){
						a[i + 1][_j]++;
						vec.pb({i,_j,i + 1,_j});
					}else if(i % 2){
						a[i][_j - 1]++;
						vec.pb({i,_j,i,_j - 1});
					}else{
						a[i][_j + 1]++;
						vec.pb({i,_j,i,_j + 1});
					}
				}
			}
		}
	}
	cout << vec.size() << endl;
	for(op o : vec) printf("%lld %lld %lld %lld\n",o.a + 1,o.b + 1,o.c + 1,o.d + 1);
	return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc (i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

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

signed main() {
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    ll A;
    rep (i, N) {
        cin >> A;
        X = max(A, X);
    }
    rep (i, M) {
        cin >> A;
        Y = min(A, Y);
    }
    if (X < Y)
        cout << "No War\n";
    else
        cout << "War\n";
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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

int main(void){
  int n, room[4][3][10]; //room[棟][階][番目]の部屋
  //配列を初期化
  for (int x=0; x<4; x++) {
    for (int y=0; y<3; y++) {
      for (int z=0; z<10; z++) {
        room[x][y][z] = 0;
      }
    }
  }
  cin >> n; // 情報の件数
  int b, f, r, v;
  for (int s=0; s<n; s++) {
    cin >> b >> r >> f >> v;
    room[b-1][r-1][f-1] += v;
  }
  //入力終了
  //出力開始
  for (int a=0; a<4; a++) {
    for (int b=0; b<3; b++) {
      for (int c=0; c<10; c++) {
        // if (c!=0) {
        cout << " ";
        // }
        cout << room[a][b][c];
      }
      cout << endl;
    }
    if (a!=3) {
      for (int d=0; d<20; d++) {
        cout << "#";
      }
      // if (a!=3 && b!=2) {
      cout << endl;
      // }
    }
  }
  //出力終了
}



Measured memory_bytes: 3080
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;
struct A
{
    int a;
    int b;
};
int vis[105];
A e[105];
int ans = 0;
vector<int> v[105];
queue<int> q;
int n, m;
int huan[105];

int main()
{
    cin >> n >> m;
    memset(vis, 0, sizeof(vis));
    for(int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
        vis[x]++;
        vis[y]++;
    }
    bool ok = true;
    while(ok)
    {
        ok = false;
        for(int i = 1; i <= n; i++)
        if(vis[i] == 1)
        {
            ok = true;
            for(int j = 0; j < v[i].size(); j++)
            {
                int k = v[i][j];
                vis[k]--;
            }
            ans++;
            vis[i]--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    x = int(rl())
    a = 1000 * (x // 500)
    b = 5 * (x % 500 // 5) 
    print(a + b)
    
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Arrays;
class Main{
public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 
 String S = scan.next();
 String[] split = S.split("");
  
   if (split[0].equals(split[1]) && split[1].equals(split[2]))
 	 System.out.println("No");
   else {
     System.out.println("Yes");
  }
 }
}

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

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> points(256, 0);
    cin >> points['r'] >> points['s'] >> points['p'];

    string t;
    cin >> t;

    vector<char> mp(256);
    mp['r'] = 'p'; mp['p'] = 's'; mp['s'] = 'r';

    vector<char> sol(n, '-');
    for (int i = n-1; i >= k; i--) {
        if (sol[i] != '-') {
            continue;
        }
        if (t[i] != t[i-k]) {
            sol[i] = mp[t[i]];
        } else {
            sol[i] = mp[t[i]];
            sol[i-k] = t[i];
        }
    }
    for (int i = k-1; i >= 0; i--) {
        if (sol[i] == '-') {
            sol[i] = mp[t[i]];
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (sol[i] == mp[t[i]]) {
            ans += points[sol[i]];
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    set<int> a;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        a.insert(temp);
    }
    if(a.size()==n)
    cout<<"YES";
    else
    {
        cout<<"NO";
    }
    

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

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

int main() {
   short int n,i,d,c=0;
   cin>>n;
   for(i=n;i>0;i=i/10)
   {
      d=i%10;
      if(d==7)
      {
          c=1;
          break;
      }
      else
      c=0;
      
   }
   if(c==1)
   cout<<"Yes";
   else
   cout<<"No";
   
	
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>

using namespace std;

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

	priority_queue<pair<int, int>,
		vector<pair<int, int> >,
		greater<pair<int, int> > > q;

	for(int i=0; i<n; i++){
		int s, t;
		cin >> s >> t;
		q.push(make_pair(t, s));
	}

	int cur=0;
	while(!q.empty()){
		if(q.top().first<cur+q.top().second){
			cout << "No" << endl;
			return 0;
		}
		//cout << cur << " " << q.top().second << " " << q.top().first << endl;
		cur+=q.top().second;
		q.pop();
	}

	cout << "Yes" << endl;

	return 0;

}



Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0)
      break;
    int a[n];
    for(int i = 0;i<n;i++){
      cin>>a[i];
    }
    int sum[n+1];
    sum[0] = a[0];
    for(int i = 1;i<n;i++){
      sum[i] = sum[i-1]+a[i];
    }
    int ans = sum[k-1];
    for(int i = k;i<n;i++){
      ans = max(ans,sum[i]-sum[i-k]);
    }

    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1936
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int b[33];

int main() {
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;++i){
        int k;
        cin>>k;
        for(int j=0;j<k;++j){
            int a;
            cin>>a;
            b[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;++i){
        if(b[i]==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

 char a,b,c;
 
 cin>>a;
  
 b=a+1;
  
 if(a=='z')
 {
   cout<<'a'<<endl;
 }
 else{
   cout<<b<<endl;
 }


}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
cnt_x = [0] * (10**5 + 2)
for i in range(n):
    cnt_x[a[i] - 1] += 1
    cnt_x[a[i]] += 1
    cnt_x[a[i] + 1] += 1
print(max(cnt_x))

Measured memory_bytes: 13964
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

class Team
{
private:
  int m_id;
  int m_time;
  bool m_correct[10];
  int m_incorrect[10];
public:
  void setId(int id);
  void setTime(int time);
  void addTime(int time);
  void initCor();
  void success(int qid);
  void initIncor();
  void incIncor(int qid);
  int getId();
  int getTime();
  bool getCor(int qid);
  int getIncor(int qid);
  int getSolved();
  Team(int id) {
    setId(id);
    setTime(0);
    initCor();
    initIncor();
  }
};

void Team::setId(int id) {
  m_id = id;
}

void Team::setTime(int time) {
  m_time = time;
}

void Team::addTime(int time) {
  m_time += time;
}

void Team::initCor() {
  for (int i = 0; i < 10; i++) {
    m_correct[i] = false;
  }
}

void Team::success(int qid) {
  m_correct[qid-1] = true;
}

void Team::initIncor() {
  for (int i = 0; i < 10; i++) {
    m_incorrect[i] = 0;
  }
}

void Team::incIncor(int qid) {
  m_incorrect[qid-1]++;
}

int Team::getId() {
  return m_id;
}

int Team::getTime() {
  return m_time;
}

bool Team::getCor(int qid) {
  return m_correct[qid-1];
}

int Team::getIncor(int qid) {
  return m_incorrect[qid-1];
}

int Team::getSolved() {
  int count = 0;
  for (int i = 0; i < 10; i++) {
    if (m_correct[i]) {
      count++;
    }
  }
  return count;
}

int main() {
  int M, T, P, R, m, t, p, j;
  while (cin >> M >> T >> P >> R, M | T | P | R) {
    vector<Team> teams;
    for (int i = 0; i < T; i++) {
      teams.pb(Team(i+1));
    }
    while (R--) {
      cin >> m >> t >> p >> j;
      if (j == 0) {
        teams[t-1].success(p);
        teams[t-1].addTime(m);
      } else {
        teams[t-1].incIncor(p);
      }
    }
    for (int i = 0; i < T; i++) {
      for (int j = 1; j <= 10; j++) {
        if (teams[i].getCor(j)) {
          teams[i].addTime(teams[i].getIncor(j)*20);
        }
      }
    }
    for (int i = 0; i < T; i++) {
      for (int j = i+1; j < T; j++) {
        if ((teams[i].getSolved() < teams[j].getSolved()) || ((teams[i].getSolved() == teams[j].getSolved()) && (teams[i].getTime() > teams[j].getTime())) || ((teams[i].getSolved() == teams[j].getSolved()) && (teams[i].getTime() == teams[j].getTime()) && (teams[i].getId() < teams[j].getId()))) {
          swap(teams[i], teams[j]);
        }
      }
    }
    for (int i = 0; i < T-1; i++) {
      cout << teams[i].getId();
      if ((teams[i].getSolved() == teams[i+1].getSolved()) && (teams[i].getTime() == teams[i+1].getTime())) {
        cout << '=';
      } else {
        cout << ',';
      }
    }
    cout << teams[T-1].getId() << el;
  }
}

Measured memory_bytes: 1204
#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;
typedef long long ll;

int N;

void dfs(string s, char cmax) {
  if(s.size() == N) {
    cout << s << endl;
  } else {
    for(char c = 'a'; c <= cmax; c++) {
      dfs(s + c, c == cmax ? (char)(cmax + 1) : cmax);
    }
  }
}

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

  cin >> N;
  dfs("", 'a');
  return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    string S; cin >> S;
    
    
    // 0 : L / 1 : R
    vector<int> dir(S.length(),-1);
    dir[0] = 0;
    for(int i = 1; i < 2*N;i++){
        if(S[i] == S[i-1]){
            dir[i] = !dir[i-1];
        }else{
            dir[i] = dir[i-1];
        }
    }
    
    if(count(dir.begin(),dir.end(),0)!=N || S.front() == 'W' || S.back() == 'W') return 0;
    ll L = 0;
    ll R = 0;
    res = 1;
    for(int i = 0; i < 2*N;i++){
        if(dir[i]){
            (res*=(L-R))%=MOD;
            R++;
        }else{
            L++;
        }
    }
    for(int i = 1; i <= N;i++){
        (res *= i)%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1360
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+2,0);

    rep(i,n) { 
        ll tmp;
        cin >> tmp;
        a[i+1] = tmp;
    }

    vector<ll> gcd_l(n+2,0), gcd_r(n+2,0);

    gcd_l[0] = 0;
    gcd_r[n+1] = 0;

    for(int i = 0; i < n; i++) {
        gcd_l[i+1] = gcd(gcd_l[i], a[i]);
        gcd_r[n-i] = gcd(gcd_r[n+1-i], a[n-i]);
    }
    ll ans = -1;
    
    for(int i = 1; i <= n; i++) {
        ans = max(ans, gcd(gcd_l[i], gcd_r[i+1]));
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int k=0;
    int x[100100];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int y[100100]={};
    for(int i=0;i<n;i++){
        y[x[i]]+=1;
    }
    int z[100100]={};
    int w[100100]={};
    for(int i=0;i<100001;i++){
        z[i%m]+=y[i];
        w[i%m]+=(y[i]/2);
    }
    if(m%2==1){
        k+=z[0]/2;
        for(int i=1;i<=m/2;i++){
            if(z[i]>=z[m-i]){
                k+=z[m-i];
                if((z[i]-z[m-i])/2>=w[i]){
                    k+=w[i];
                }else
                {
                    k+=(z[i]-z[m-i])/2;
                }
            }else{   
                k+=z[i];
                if((z[m-i]-z[i])/2>=w[m-i]){
                    k+=w[m-i];
                }else
                {
                    k+=(z[m-i]-z[i])/2;
                }
            }
        }
        
    }else
    {
        k+=z[0]/2;
        k+=z[m/2]/2;
        for(int i=1;i<m/2;i++){
            if(z[i]>=z[m-i]){
                k+=z[m-i];
                if((z[i]-z[m-i])/2>=w[i]){
                    k+=w[i];
                }else
                {
                    k+=(z[i]-z[m-i])/2;
                }
            }else {
                k += z[i];
                if((z[m-i]-z[i])/2>=w[m-i]){
                    k+=w[m-i];
                }else
                {
                    k+=(z[m-i]-z[i])/2;
                }
            }

        }
    

    }

    cout<<k<<endl;
    

    

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  int p[N+1];
  for(int i=1;i<=N;i++){
    cin >> p[i];
  }
  vector<int> graph[N+1];
  for(int i=0;i<M;i++){
    int x, y; cin >> x >> y;
    graph[p[x]].push_back(p[y]);
    graph[p[y]].push_back(p[x]);
  }

  queue<int> Q;
  int color[N+1];
  memset(color, 0, sizeof color);
  int c = 1;
  for(int i=1;i<=N;i++){
    if(color[i] != 0) continue;
    // BFS
    color[i] = c;
    Q.push(i);
    while(!Q.empty()){
      int v = Q.front();
      Q.pop();
      color[v] = c;
      for(int g: graph[v]){
        if(color[g] != c){
          Q.push(g);
        }
      }
    }
    c++;
  }
  int cnt = 0;
  for(int i=1;i<=N;i++){
    if(color[i] == color[p[i]]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 6528
N = int(input())
H = [int (i) for i in input().split()]
flag = 1

if N == 1:
    flag = 1
else:
    for i in range(N-2,-1,-1):
        if H[i] > H[i+1]:
            H[i] -= 1
    for i in range(N-1):
        if H[i] > H[i+1]:
            flag = 0

if flag == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 63984
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<ll,ll>>pll(n);
  for(int i=1;i<=n;i++){
    ll a;cin>>a;
    pll[i-1]=mp(a,i);
  }
  sort(ALL(pll));
  for(auto a:pll)cout<<a.S<<" ";
  cout<<endl;
  return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  ll ok = 1e9, ng = 0;
  while(abs(ok-ng) > 1){
    ll mid = (ok+ng) / 2;
    int cnt = 0;
    REP(i, N){
      cnt += (A[i]+mid-1) / mid -1;
    }
    if(cnt <= K){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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 long long INF = 1LL << 60;

int main(){
    ll x,k,d;cin>>x>>k>>d;

    if(x<0){x=x*(-1);}//左右対称

    if(x!=0&&x/d<k&&(k-x/d)%2==1){cout<<abs(x%d-d)<<endl;}
    if(x!=0&&x/d<k&&(k-x/d)%2==0){cout<<x%d<<endl;}




    if(x!=0&&x/d>=k){cout<<x-d*k<<endl;}

    if(x==0&&k%2==1)cout<<d<<endl;

    if(x==0&&k%2==0)cout<<0<<endl;

}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int a = stdin.nextInt();
	int b = stdin.nextInt();
	int c = stdin.nextInt();
	int i = a;
	int r = 0,s = 0;
	while(i<=b){
	    s = c%i;
	    boolean t = (s == 0);
	    if(t){r++;}
	    else{}
	    i++;
	}
	System.out.println(r);
    }
}

Measured memory_bytes: 26276
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1

print(count)


Measured memory_bytes: 3064
s = input()
t = input()
s = sorted(s)
t = sorted(t,reverse=True)
flag = 0

for i in range(min(len(s),len(t))):
    if s[i] < t[i]:
        flag = 1
        break

if len(s) < len(t) and s == t[:len(s)]:
    flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
const int N = 13;

char s[N];
ll pw[N];
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    pw[0] = 1;
    REP(i, 1, N) pw[i] = pw[i - 1] * 2;
    scanf("%s", s);
    int n = strlen(s);
    ll res = 0;
    REP(i, 0, n){
        ll cur = s[i] - '0';
        REP(j, i, n - 1){
            res += pw[i + n - j - 2] * cur;
            cur *= 10;
            //printf("i = %d, j = %d, res = %lld\n", i, j, res);
        }
        res += pw[i] * cur;
    }
    printf("%lld\n", res);
    return 0;
}


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

void fnInput(vector<int>& rvnNode, vector<vector<int>>& rvvnEdge)
{
  int nNodeSiz, nEdgeSiz;
  cin >> nNodeSiz>> nEdgeSiz;
  rvnNode.resize(nNodeSiz);
//rvvnEdge.resize(nNodeSiz, vector<int>(nNodeSiz, 0));
  rvvnEdge.resize(nNodeSiz);

  for (int& rnNode : rvnNode)
    cin >> rnNode;

  for (int i = 0; i <= nEdgeSiz; i++)
  {
    int nLeft, nRigt;
    cin >> nLeft >> nRigt;
    rvvnEdge[ nLeft - 1 ].push_back( nRigt - 1 );
    rvvnEdge[ nRigt - 1 ].push_back( nLeft - 1 );
  }
}

int fnPeakCnt(const vector<int> cnrvnNode, const vector<vector<int>>& cnrvvnEdge)
{
  int nPeakCnt = 0;

  for (int nBgn = 0; nBgn < cnrvnNode.size(); nBgn++)
  {
    bool bPeak = true;
    for (int nEnd : cnrvvnEdge[nBgn])
      if (cnrvnNode[nBgn] <= cnrvnNode[nEnd])
      {
        bPeak =false;
        break;
      }

    if (bPeak) nPeakCnt++;
  }
  return nPeakCnt;
}
  
int main()
{
  vector<int> vnNode;
  vector<vector<int>> vvnEdge;

  fnInput(vnNode, vvnEdge);
  cout << fnPeakCnt(vnNode, vvnEdge) << endl;

  return 0;
}

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}

ll m[52],p[52];

ll solve(ll n,ll k){
  if(k<=0) return 0;

  if(n==0) return 1;

  if(k==1) return 0;
  if(k==1+m[n-1]) return p[n-1];
  if(k==2+m[n-1]) return p[n-1]+1;
  if(k==m[n]) return p[n];
  if(k<=m[n-1]) return solve(n-1,k-1);
  if(k>2+m[n-1]) return p[n-1]+1+solve(n-1,k-2-m[n-1]);
  return 0;
}

int main(){
  ll i,j;
  ll n,x;
  cin>>n>>x;
  
  m[0]=1;
  p[0]=1;
  for(i=1;i<51;i++) {
    m[i]=3+2*m[i-1];
    p[i]=1+2*p[i-1];
  }
  
  cout<<solve(n,x)<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    ll a[212345], f[212345];
    ll k;

    cin >> n >> k;
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> f[i];

    sort(a, a + n);
    sort(f, f + n);

    ll l = -1;
    ll r = a[n - 1] * f[n - 1];

    while (r - l > 1)
    {
        ll mid = (r + l) / 2;

        ll b[212345];

        ll kk = 0;

        for (int i = 0; i < n; i++)
        {
            b[i] = mid / f[n - i - 1];

            kk += max(0LL, a[i] - b[i]);
        }

        if (kk <= k)
            r = mid;
        else
            l = mid;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    cout << (accumulate(a.begin(), a.end(), 0) - n) << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    ll a[n];
    map<ll, ll> mp;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    ll q, b, c;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> b >> c;
        mp[c] += mp[b];
        sum += c * mp[b];
        sum -= b * mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    int n; cin >> n;
    vector<vi> v(n, vi(n));
    rep(i, 0, n) rep(j, 0, n) cin >> v[i][j];
    ll ans = 0;
    rep(i, 0, n) rep(j, i, n) ans += min(v[i][j], v[j][i]);
    cout << ans << endl;
}


Measured memory_bytes: 3192
n = int(input())
l = [0]*101
i = 2
for i in range(2,n+1):
    j = 2
    while i >= 2:
        while i % j == 0:
            i = i//j
            l[j] += 1
        j += 1

ans = sum(x >= 74 for x in l)

a = sum(x >= 2 for x in l)
b = sum(x >= 24 for x in l)
ans += b*(a-1)

a = sum(x >= 4 for x in l)
b = sum(x >= 14 for x in l)
ans += b*(a-1)

a = sum(x >= 2 for x in l)
b = sum(x >= 4 for x in l)
ans += b*(b-1)*(a-2)//2

print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int n,x;
int main()
{
	scanf("%d%d",&n,&x);
	if(x==1||x==2*n-1) {puts("No");return 0;}
	puts("Yes");
	int now=0;
	for(RI i=1;i<n-1;++i) {
		++now;while(now==x-1||now==x||now==x+1) ++now;
		printf("%d\n",now);
	}
	printf("%d\n%d\n%d\n",x-1,x,x+1);
	for(RI i=1;i<n-1;++i) {
		++now;while(now==x-1||now==x||now==x+1) ++now;
		printf("%d\n",now);
	}
	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int pre[N];

    for(int i = 0; i < N; i++)
        cin >> pre[i];

    int MAX = 0;
    int MIN = 10000;

    for(int i = 0; i < N; i++){
        MAX = max(MAX, pre[i]);
        MIN = min(MIN, pre[i]);
    }
    int ans = MAX - MIN;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long int n,k,x,y,f;
    
    cin>>n>>k;
    
    
    f=(n/k)+1;
    
    
    
    n=n-(k*f);
    
    
    
    
    x=-n;
    
    y=n+k;
    
    if(x<y)
    {
        
        cout<<x;
        
        
    }
    else
    {
    
        cout<<y;
    
    }
    
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1, 0, -1):
    diff = H[i] - H[i-1]
    if diff >= 0:
        continue
    elif diff == -1:
        H[i-1] -= 1
    elif diff < -1:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int main() {

	int a[11];
	rep(i,10)cin>>a[i];
	sort(a,a+10,greater<int>());
	rep(i,3)cout<<a[i]<<endl;

	return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    A[i]--;
  }
  
  vector<int> pos(N);
  REP(i, N) pos[A[i]] = i;

  int ans = 0;
  vector<bool> used(N, false);
  REP(i, N){
    if(used[i]) continue;
    int ret = 1;
    int now = i;
    while(now+1 < N && pos[now] < pos[now+1]){
      used[++now] = true;
      ret++;
    }
    chmax(ans, ret);
  }

  cout << N-ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<math.h>
int main()
{
	unsigned long long int K,N,t,a;
    scanf("%lld%lld",&N,&K);
    t=N%K;
    if(t*2>K) a=K-t;
    else a=t;
    printf("%lld",a);
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, D;
	cin >> N >> D;
	int64 cnt = 0;
	REP(i, N) {
	  int64 X, Y;
	  cin >> X >> Y;
	  if (X * X + Y * Y <= D* D) cnt++;
	}
	cout << cnt << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    // ifstream cin("code.in");
    int n, one = 0, two = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x % 4 == 0) {
            two++;
        } else if (x % 2 == 0) {
            one++;
        }
    }
    int i = 0;
    while (two > 0) {
        i += 2;
        two--;
    }
    if (i >= n - 1) {
        cout << "Yes\n";
        return 0;
    }

    // Need to cover pieces in range [i + 1, n);
    n = n - i;
    if (one >= n) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N,K;
int grid[2005][2005];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin>>K;
    vector<int> a(50);
    if(K%50==0){
        a=vector<int>(50,K/50+49);
    }else{
        rep(i,50){
            if(i<K%50){
                a.at(i)=50;
            }else{
                a.at(i)=50-K%50-1;
            }
            a.at(i)+=K/50;
        }
    }
    cout<<50<<endl;
    rep(i,49)cout<<a.at(i)<<' ';
    cout<<a.back()<<endl;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int ans = 0;

    if (a1 + a2 + a3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
info = [list(input().split()) for i in range(m)]

ans_flg = {}
wa_time = {}
wa = 0
ans = 0
for i in range(m):
    num, name = info[i]
    num = int(num)
    if num not in ans_flg:
        if name == "AC":
            ans_flg[num] = 1
            ans += 1
        else:
            if num not in wa_time:
                wa_time[num] = 1
            else:
                wa_time[num] += 1
wa = 0
for i in ans_flg:
    if i in wa_time:
        wa += wa_time[i]

print(ans, wa)


Measured memory_bytes: 75836
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a,b,x;
  cin >>a >>b >>x;
  if(x>a*a*b/2){
    double leng=(a*b-x/a)*2/a;
    printf("%.8f",atan(leng/a)/M_PI*180);
  }
  else{
    double leng=(x/a)*2/b;
    cerr <<leng<<endl;
    double ans=atan(b/leng);
    printf("%.8f",ans/M_PI*180);
  }
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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 (b<a) { a=b; return 1; } return 0; }




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  // cout<<fixed<<setprecision(10);


  string s; cin>>s;
  ll n = s.size();

  auto f = [](string t){
    ll m = t.size();
    rep(i, m/2){
      if(t[i] != t[m-1-i]) return false;
    }
    return true;
  };


  // cout<<s.substr(0, n/2)<<endl;
  // cout<<s.substr(n/2+1, n/2)<<endl;

  if(f(s) && f(s.substr(0, n/2)) && f(s.substr(n/2+1, n/2))) puts("Yes");
  else puts("No");


}






Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
const int maxn = 1e6 + 3;
bool pal(string s) {
	for(int i = 0; i < s.size(); i++) if(s[i] != s[s.size()-1-i]) return false;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int k = (s.size()-1)/2;
	cout << (pal(s)&&pal(s.substr(0, k))&&pal(s.substr((s.size()+3)/2 - 1))?"Yes":"No") << '\n';
	
}


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

using namespace std;

const int MaxN=100;
const int MaxW=10000;
int dp[MaxN+1][MaxW+1];


int main(){
    // Your code here!
    
    int N,W;
    cin>>N>>W;
    vector<int> val(N),wei(N);
    for(int i=0; i<N; ++i) cin>>val[i]>>wei[i];
        
    //initializing dp
    for(int i=0; i<MaxW+1; ++i) dp[0][i]=0;
    
    
    //dp開始
    for(int i=0; i<N; ++i){
        for(int j=0; j<=W; ++j){
            if(j-wei[i]<0) dp[i+1][j]=dp[i][j];
            else dp[i+1][j] = max(dp[i][j-wei[i]]+val[i], dp[i][j]);
        }
    }
    
    printf("%d\n", dp[N][W]);
    return 0;
}



Measured memory_bytes: 7060
a, b, t = map(int, input().split())
if a > t:
    print(0)
elif a == t:
    print(b)
else:
    t += 0.5
    tsum = 0
    ans = 0
    while (tsum < t):
        tsum += a
        if tsum > t:
            break
        else:
            ans += b
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int W,H,N;
    scanf("%d%d%d",&W,&H,&N);
    int bx,by,nx,ny;
    scanf("%d%d",&bx,&by);
    int ans=0;
    for(int i=1;i<N;i++){
        scanf("%d%d",&nx,&ny);
        int dx=nx-bx,dy=ny-by;
        if(dx*dy>0) ans+=max(abs(dx),abs(dy));
        else ans+=abs(dx)+abs(dy);
        bx=nx;by=ny;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1008
#include <stdio.h>

int main(void){
  float x,y;

  while(scanf("%f%f",&x,&y) != EOF){
    if(x<35.5 && y<71) printf("AAA\n");
    else if(x<37.5 && y<77)printf("AA\n");
    else if(x<40 && y<83) printf("A\n");
    else if(x<43 && y<89) printf("B\n");
    else if(x<50 && y<105) printf("C\n");
    else if(x<55 && y<116) printf("D\n");
    else if(x<70 && y<148) printf("E\n");
    else printf("NA\n");
  }

  return 0;
}

Measured memory_bytes: 0
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [x, a, b] = stdin.split('\n')[0].split(' ').map(Number)

const res = _ => {
  if(a>=b){
    return 'delicious'
  } else if(b-a <= x){
    return 'safe'
  } else {
    return 'dangerous'
  }
}

console.log(res())

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<(x-z)/(y+z)<<endl;
  return 0;
}






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

using namespace std;

typedef long long LL;

int main(int argc, const char * argv[]) {
//    freopen("4.in", "r", stdin);
    int n;
    cin >> n;
    vector<LL> a(n);
    for (int i = 0;i < n; i++) {
        cin >> a[i];
    }
    vector<vector<LL>> dp(n, vector<LL>(n));
    for (int i = 0; i < n; i++) {
        dp[i][i] = a[i];
    }
    
    for (int len = 2; len <= n; len++) {
        for (int i = 0; i <= n - len; i++) {
            dp[i][i+len-1] = max(a[i] - dp[i+1][i+len-1], a[i+len-1] - dp[i][i+len-2]);
        }
    }
    
//    for (int i = 0;i < n; i++) {
//        for (int j = 0; j < n; j++) {
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
//
    cout << dp[0][n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

bool comp(vll& l, vll& r)
{
    return l.at(0) < r.at(0);
}

int main()
{
    int N, M;
    cin >> N >> M;
    vvll A(N, vll(2));
    rep(i, N)
    {
        cin >> A.at(i).at(0) >> A.at(i).at(1);
    }
    sort(ALL(A), comp);
    ll need = M;
    ll ans = 0;
    rep(i, N)
    {
        if (A.at(i).at(1) > need)
        {
            ans += A.at(i).at(0) * need;
            break;
        }
        else
        {
            ans += A.at(i).at(0) * A.at(i).at(1);
            need -= A.at(i).at(1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760