akhauriyash/Code-Regression huggingface dataset:
use std::io::stdin;

fn main(){
    let ab = getvec();
    let a = (ab[0]+11)%13;
    let b = (ab[1]+11)%13;
    println!("{}", if a > b {"Alice"}else if a==b {"Draw"}else{"Bob"}) 
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
    // Your code here!
    int c[5];
    int d[5];
    int mind=0;
    int total = 0;
    int ts;
    bool check = true;
    for(int i =0 ; i < 5; i++){
        cin >> c[i];
        d[i] = (c[i]-1)%10;
        total += ((c[i]-1)/10 + 1)*10;
        //cout << ((c[i]-1)/10 + 1)*10 << endl;
        mind = *std::min_element(d,d+5);
    }
    cout << total + mind - 9 << endl;
    // for(int i = 0; i < 5; i ++ ){
    //     for(int j = 0; j < 5; j++){
    //         if(abs(c[i]-c[j]) > c[5]){
    //             check= false;
    //         }
    //     }
    // }
    // if(check){
    //     cout << "Yay!" << endl;
    // }else{
    //     cout<<":("<< endl;
    // }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<queue>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

#define pb push_back
#define PI acos(-1.0)
#define MAX 10000007 //1e7+7
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define __FastIO  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll arr[100005],brr[100005];
int main(){
  ll N,M,A,B,C,D,i,testCase,K;
  map<ll,ll>mp;
  cin>>N>>K>>A;
  for(i=0;i<A;i++){
    ll x;
    cin>>x;
    mp[x]++;
  }
  for(i=1;i<=N;i++){
    ll val=K-(A-mp[i]);
    if(val<=0){
      cout<<"No"<<endl;
    }
    else{
      cout<<"Yes"<<endl;
    }
  }
  mp.clear();
  /*string str;
  while(cin>>str){
    if(str=="Sunny"){
      cout<<"Cloudy"<<endl;
    }
    else if(str=="Cloudy"){
      cout<<"Rainy"<<endl;
    }
    else{
      cout<<"Sunny"<<endl;
    }
  }
  */
  return 0;
}


Measured memory_bytes: 6912
def main():

    s = input()
    K = int(input())
    n = len(s)
    t = ""
    for i in range(n):
        if s[i] == "a":
            t += s[i]
        elif ord("z") - ord(s[i]) + 1 <= K:
            K -= ord("z") - ord(s[i]) + 1
            t += "a"
        else:
            t += s[i]

    if K > 0:
        u = chr(97 + (ord(t[-1])-97 + K % 26) % 26)
        t = t[:-1] + u
    return t

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3444
#include <stdio.h>

int main()
{
    int n;
    int a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++)
    if(a[i]%2==0)
    if(a[i]%3!=0&&a[i]%5!=0)
    {
        printf("DENIED\n");
        return 0;
    }
    printf("APPROVED\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, N * A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int main() {
  int n;
  while(cin >> n){
    if(n==0) return 0;
    vector<string> v(n);
    rep(i, n) cin >> v[i];

    bool good=false;
    rep(i, n){
      int state=0, cur=0;
      if(good) break;
      REP(j, i, n){
        cur += v[j].size();
        if(cur==5 && (state==0 || state==2)){
          cur = 0; state += 1;
        }
        else if(cur==7 && (state==1 || state==3 || state==4)){
          cur = 0; state += 1;
        }
        else if(cur>7) break;
        if(state==5){
          cout << i+1 << endl;
          good = true;
          break;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

template<typename T>
struct Dijkstra {
    private:
        int V;
        struct edge { int to; T cost; };
        vector<vector<edge> > G;
    public:
        const T inf = numeric_limits<T>::max();
        // s から i の最小コスト
        // 経路がない場合は inf

    vector<T> d;
    Dijkstra(int V) : V(V) {
        G.resize(V);
    }

    // 辺の追加
    // 有向の場合　directed = true
    void add_edge(int from, int to, T weight, bool directed = false) { 
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }

    //最短経路探索, スタート:s
    //d[] : sからの最短距離
    void build(int s) {  
        d.assign(V, inf);
        typedef pair<T, int> P; //(cost,v)
        priority_queue<P, vector<P>, greater<P> > pq;
        d[s] = 0;
        pq.push(P(d[s], s));

        while (!pq.empty()) {
            P p = pq.top(); pq.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (const edge &e : G[v]){
                // 最小値が更新されるとき push
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    pq.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }
};

int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n >> x >> y; x--;y--;
  Dijkstra<ll> G(n);
  rep(i,n-1){
    G.add_edge(i,i+1,1);
  }
  G.add_edge(x,y,1);
  VI a(n);
  rep(i,n){
    G.build(i);  //i→jの最短距離の数
    for(int j=i+1; j<n; j++){
      a[G.d[j]]++;
    }
  }
  for(int i=1; i<n; i++)
    cout << a[i] << endl;
  return 0;
}

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

int main () {

	int n;
	cin >> n;

	bool flag = true;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf ("%d", &x);
		if (x & 1) continue;

		if (x % 3 != 0 && x % 5 != 0)
			flag = false;
	}

	if (flag)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

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

	sort(a.begin(),a.end());
	sort(c.begin(),c.end());
	ll ans=0;
	rep(i,n){
		auto itra=lower_bound(a.begin(),a.end(),b[i]);
		auto itrc=upper_bound(c.begin(),c.end(),b[i]);
		int l,r;
		if(itra!=a.end()) l=distance(a.begin(),itra);
		else l=n;
		if(itrc!=c.end()) r=distance(itrc,c.end());
		else r=0;

		ans+=(ll)r*l;

	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1536
/**
 * Created by hiramekun at 23:05 on 2019-10-29.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    for (ll i = 1; i <= 9; ++i) {
        for (ll j = 1; j <= 9; ++j) {
            if (i * j == n) {
                cout << "Yes" << '\n';
                return;
            }
        }
    }
    cout << "No" << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a,b,c;
int l[10];

int getcost(int mask, int target){
  for(int i=0;i<(n);i++){
    if(mask&(1<<i)){
      target-=l[i];
    }
  }
  return abs(target);
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++)cin>>l[i];
  int ans = 1e18;
  for(int i=1;i<(1<<n);i++){
    for(int j=1;j<(1<<n);j++){
      if(i&j)continue;
      for(int k=1;k<(1<<n);k++){
        if(i&k || j&k )continue;
        ll cur = 0;
        cur+=getcost(i,a);
        cur+=getcost(j,b);
        cur+=getcost(k,c);
        cur+=(__builtin_popcount(i)+__builtin_popcount(j)+__builtin_popcount(k)-3)*10;
        ans = min(ans,cur);
      }
    }
  }
  cout << ans << endl;


return 0;
}
///....


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

int main(){
	int N,K;
	string S;
	char a;

	cin>>N>>S>>K;
	a = S.at(K-1);

	for(int i=0;i<N;i++){
		if(S.at(i)!=a)
			S.at(i)='*';
	}

	cout<<S<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int n,m,ans=0;
vi date;
vector<bool> can;

int main(){
	cin>>n>>m;
	can=vector<bool>(n,0);
	can[0]=1;
	date=vi(n,1);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(can[x-1]==1){
			can[y-1]=1;
		}
		if(--date[x-1]==0){
			can[x-1]=0;
		}
		++date[y-1];
	}
	for(int i=0;i<n;i++){
		if(can[i]==1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
bool dp[100100];
int main(){
	ios_base::sync_with_stdio(false);
	int i,j;
	string s,t;
	cin>>s;
//	cout<<s.size()<<endl;
	dp[0]=1;
	for(i=0;i<s.size()-4;i++){
		if(dp[i]==1){
			t=s.substr(i,5);
//			cout<<t<<endl;
			if(t=="dream"||t=="erase"){
				dp[i+5]=1;
				if(i+5<s.size()&&s[i+5]=='r'&&t=="erase") dp[i+6]=1;
//				if(t=="dream") cout<<t<<" "<<s[i+5]<<" "<<s[i+6]<<endl;
				if(i+5<s.size()&&s[i+5]=='e'&&s[i+6]=='r'&&t=="dream") dp[i+7]=1;
			}
		}
	}
	if(dp[s.size()]==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

int main(){
    int h,w,resa,resb,resm=0;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        resa=h;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                resa=min(resa,j);
                resb=j;
            }
        }
        if(resa<resm){
            cout<<"Impossible"<<endl;
            return 0;
        }
        else resm=max(resm,resb);
    }
    cout<<"Possible"<<endl;
}

Measured memory_bytes: 256
N,X,Y =map(int,input().split())

count = [0] * (N-1)


for i in range(1,N):
    path = abs(X-i) +1
    for j in range(i+1,N+1):
        dist = min(j-i, path+abs(Y-j))
        count[dist-1] +=1


print("\n".join(map(str,count)))

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

void checkboard(void);
void startmove(void);
int checked(int i,int j);

char board[21][21];
int H,W,now[2];

int main(void){
	while(1){
		cin >> H >> W ;
		if (!H && !W) break;
		// count=0;
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				cin >> board[i][j];
				if(board[i][j]=='@'){
					now[0]=i;
					now[1]=j;
				}
			}
		}
		startmove();
		checkboard();
	}

}


void startmove(void){
	int n;
	do{
		n=0;
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				if(board[i][j]=='@')
					n+=checked(i,j);
			}
		}

	}while(n);
}

int checked(int i,int j){
	int a=0;
	if(i>0 && board[i-1][j]=='.'){
		board[i-1][j]='@';
		a=1;
	}
	if(i<W && board[i+1][j]=='.'){
		board[i+1][j]='@';
		a=1;
	}
	if(j>0 && board[i][j-1]=='.'){
		board[i][j-1]='@';
		a=1;
	}
	if(j<H && board[i][j+1]=='.'){
		board[i][j+1]='@';
		a=1;
	}
	// checkboard();
	return a;
}
void checkboard(void){
		int count=0;
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				if(board[i][j]=='@') count++; 
				// cout << board[i][j];
			}
		}
			cout << count << endl;

}

Measured memory_bytes: 2968
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> lightened;

    while (K--) {
        lightened.assign(N + 1, 0);

        rep(i, N) {
            lightened[max(i - A[i], 0)]++;
            lightened[min(i + A[i] + 1, N)]--;
        }

        bool allN = true;
        for (int i = 0, now = 0; i < N; ++i) {
            now += lightened[i];
            A[i] = now;
            if (now != N) allN = false;
        }

        if (allN) break;
    }

    rep(i, N) cout << A[i] << (!--N ? "\n" : " ");
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }
  vector<int> a(100001, 0);
  for (auto i : A) {
    if (i > 0) {
      a[i-1] += 1;
    }
    a[i] += 1;
    a[i+1] += 1;
  }
  rsort(a);
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 1280
n = gets.to_i
arr = Array.new(2){gets.chomp.split.map(&:to_i)}

candidates = Array.new

(0..n-1).each{ |i|
    sum  = arr[0].take(i+1).inject(0){|s,x|s+=x}
    sum += arr[1].drop(i).inject(0){|s,x|s+=x}
    candidates << sum
}

puts candidates.max

Measured memory_bytes: 1788
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

struct Card {
    char suit;
    int number;
    int pos;
};

static inline void Swap(struct Card* x, struct Card* y) {
    struct Card t = *x;
    *x = *y;
    *y = t;
}

static int Partition(struct Card A[], int p, int r) {
    int x = A[r].number;
    int i = p - 1;

    for ( int j = p; j < r; j++ ) {
        if ( A[j].number <= x ) {
            i = i + 1;
            Swap(&A[i], &A[j]);
        }
    }
    Swap(&A[i+1], &A[r]);

    return i + 1;
}

static void QuickSort(struct Card A[], int p, int r) {
    if ( p < r ) {
        int q = Partition(A, p, r);
        QuickSort(A, p, q-1);
        QuickSort(A, q + 1, r);
    }

    return;
}

static int IsStable(const struct Card A[], int n) {
    int i;
    struct Card last = A[0];

    for ( i = 1; i < n; i++ ) {
        if ( last.number == A[i].number ) {
            if ( last.pos > A[i].pos ) {
                return 0;
            }
        }
        last = A[i];
    }

    return 1;
}

int main(void) {
    int i;
    int n;
    struct Card *A;

    scanf("%d\n", &n);
    A = malloc(sizeof(struct Card) * n);

    for ( i = 0; i < n; i++ ) {
        int d;
        char s[2];
        scanf("%s %d", s, &d);
        A[i].suit   = s[0];
        A[i].number = d;
        A[i].pos    = i;
        (void)fgetc(stdin);
    }

    QuickSort(A, 0, n - 1);

    printf("%s\n", IsStable(A, n) ? "Stable": "Not stable");
    for ( i = 0; i < n; i++ ) {
        printf("%c %d\n", A[i].suit, A[i].number);
    }

    free(A);

    return 0;
}



Measured memory_bytes: 2508
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  map<int,int> mp;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    mp[tmp]++;
  }

  vector<int> cnt;
  for(auto it=mp.begin() ; it!=mp.end() ; it++){
    cnt.push_back(it->second);
  }

  sort(cnt.begin(),cnt.end());
  reverse(cnt.begin(),cnt.end());

  //for(int i=0;i<cnt.size();i++) cout << cnt[i];
  //cout << endl;

  int sum = 0;
  for(int i=K;i<cnt.size();i++){
    sum += cnt[i];
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 10748
N,K=map(int, input().split())

A = [list(map(int, input().split())) for i in range(K*2)]

C=[0]*N
for i in range(0,K*2,2):
  d=A[i][0]
  for j in range(d):
    C[A[i+1][j]-1]+=1
    
print(C.count(0))

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

using namespace std;
#define ll long long

ll INF = 1e18;

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

    int n,t;
    cin>>n>>t;

    int cnt = 0;

    for(int i=0;i<n;i++)
    {
        int a; cin>>a;

        if(a>=t)
        cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 99999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y,z, q, m, n, r, h, k, ans = 0, w;

vl A;
void input() {
	cin >> n;
	inputv(A, n);
}

void solve() {
	rep(i, n) {
		rep(j, i) {
			ans += A[i] * A[j];
		}
	}
	cout << ans << endl;
}

int main() {
	input();
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

ll solve(ll h){
    if(h>1) return 2*solve(h/2)+1;
    return 1;
}

int main(){
    ll h; std::cin >> h;
    std::cout << solve(h) << "\n";
    return 0;
}


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

typedef long long ll;


int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A<=C&&C<=B){
      cout<<"Yes"<<endl;
  }else{
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//[mint]
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
  assert(n < mod);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
  ifact[n] = fact[n].inv();
  for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
  if (k < 0 || k > n) return 0;
  return fact[n]*ifact[k]*ifact[n-k];
}
};

int main(){
  int x, y;
  cin >> x >> y;
  //到達しないマス
  if((x+y)%3 != 0 ){
    cout << 0 << endl;
    return 0;
  }

  int n = (x + y)/3;//段数-1

  if(x/n == 0 || y/n == 0){
    cout << 0 << endl;
    return 0;
  }

  int k = min(x%n,y%n); //左からk番目-1
  combination c(n);
  mint ans = c(n,k);
  cout << ans << endl;

  //cout << comb(n,k) << endl;


  return 0;
}

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

void solve(long long N, std::vector<long long> L){
    double a,b,c,ans;
    ans=0;
    rep(i,N){
        a=L[i];
        REP(j,i+1,N){
            b = L[j];
            REP(k,j+1,N){
                c=L[k];
                //cout<<a<<" "<<b<<" "<<c<<endl;
                if(a<c+b && b<a+c && c<a+b && a!=b && b!=c && c!=a){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 3832
h, w = map(int, input().split())
a = []
ans = []
for _ in range(h):
    aw = input()
    if set(aw) != {'.'}:
        a.append(aw)

for i in zip(*a):
    if set(i) != {'.'}:
        ans.append("".join(list(i)))
        
for j in zip(*ans):
    print("".join(list(j)))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;



int main()
{
    map<string, string> ct;
    ct["rr"] = "rr";
    ct["rb"] = "gg";
    ct["rg"] = "bb";

    ct["gr"] = "bb";
    ct["gg"] = "gg";
    ct["gb"] = "rr";

    ct["br"] = "gg";
    ct["bg"] = "rr";
    ct["bb"] = "bb";

    map<string, bool> dt;
    dt["rr"] = true;
    dt["gg"] = true;
    dt["bb"] = true;
    
    for(;;) {
        string in;
        cin >> in;

        if ( in == "0" )
            break;

        std::map<string, bool> correct;
        correct[string(in.size(), 'r')] = true;
        correct[string(in.size(), 'g')] = true;
        correct[string(in.size(), 'b')] = true;

        int result_times = 0;

        queue<pair<int, string> > q;
        q.push( make_pair( 0, in ) );

        map<string, bool> memo;
        bool goal = false;

        // loop
        while( !q.empty() ) {
            int const times = q.front().first;
            string const s = q.front().second;
            q.pop();

            //cout << gtimes << endl;
            if ( correct[s] ) {
                goal = true;
                result_times = times;
                break;
            } 

            //cout << "---" << endl;
            for( size_t i=0; i<s.size()-1; ++i ){
                string const pa = s.substr( i, 2 );
                string const t = s.substr( 0, i ) + ct[pa] + s.substr( i + 2 );

                if ( t == s )
                    continue;
                if ( memo[t] )
                    continue;

                memo[t] = true;

                q.push( make_pair( times + 1, t ) );
                //cout << t << endl;
            }
        }

        // put
        if ( goal ) {
            cout << result_times << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 3640
N = int(input())
v = list(map(int, input().split()))

value = 0
listed_v = sorted(v)
for i in range(N):
    if len(listed_v) > 1:
        value = (listed_v[0] + listed_v[1])/2
        listed_v = [(listed_v[0] + listed_v[1])/2] +  listed_v[2:]
print(value)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        
        int x = t * s;
        if (x >= d) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 35572
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
 
int main() {
    vector<string> abc(3);
    for (auto& e: abc) cin >> e;
    vector<int> idx(3, 0);
    int i = 0;
    while (abc[i].size() != idx[i]) {
        char t = abc[i][idx[i]];
        idx[i]++;
        i = t - 'a';
    }

    cout << (char)('A' + i) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).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;}

int main(){
    int n;cin>>n;
    string ans = ":(";
    for(int i=1; n<=50000; i++){
        int price = i*1.08;
        if(price>n) break;
        if(price == n) {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main() {
	FIO;
	int x;
	cin>>x;
	int sum = 0;
	sum += 1000*(x/500);
	x %= 500;
	sum += 5*(x/5);
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,a,b) for (int i = a; (i)<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main(){
  int n, m;
  scanf("%d %d",&n,&m);
  int l = 2;
  vector<vector<ll>> a(n,vector<ll>(l,0));
  rep(i,n){
  	rep(j,l){
  		ll b;
  		scanf("%lld",&b);
  		a[i][j] = b;
  	}
  }
  vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
  rep(i,n){
    rep(j,m+1){
      if(j >= a[i][0]){
        dp[i+1][j] = max(dp[i][j-a[i][0]]+a[i][1],dp[i][j]);
      }
      else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}


Measured memory_bytes: 80256
num, qnum, = gets.split.map(&:to_i)
str = gets.strip
ary = Array.new(num + 1, 0)
num.times do |t|
  ary[t + 1] = ary[t] + (str[t,2] == 'AC' ? 1 : 0)
end
qnum.times do
  ql, qr, = gets.split.map(&:to_i)
  puts ary[qr-1] - ary[ql-1]
end


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

ll getgcd(ll p, ll q){
        return q == 0 ? p : getgcd(q,p % q);
}

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

        ll gcd = getgcd(n,m);
        set<int> s;
        if(gcd == 1)
        {cout << 1 << endl;
         return 0;}
        for(int i = 2; i <= sqrt(gcd); i++) {
                if(gcd % i == 0) {
                        s.insert(i);
                        while(gcd % i == 0) gcd /= i;
                }

        }
        if(gcd != 1) s.insert(gcd);

        cout << s.size() + 1 << endl;
}


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

const int N = 5e5 + 5;
map<string,int>mp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int maxi = 0;
    for(int i = 0 ; i<n ; ++i)
    {
        string s;
        cin>>s;
        mp[s]++;
        maxi = max(maxi , mp[s]);
    }

    for(auto p : mp)
    {
        if(p.second == maxi) cout<<p.first<<endl;
    }

    return 0;
}


Measured memory_bytes: 23808
h, n = map(int, input().split())

a = []
b = []
m = []
for i in range(n):
    at, bt = map(int, input().split()) # a_tmp, b_tmp
    a.append(at)
    b.append(bt)

dp = [[0]*(h+1) for _ in range(n+1)]
for i in range(n):
    for j in range(h):
        if j - a[i] < 0:
            o = b[i]
        else:
            o = dp[i+1][j+1-a[i]] + b[i]
        if i != 0:
            dp[i+1][j+1] = min(dp[i][j+1], o)
        else:
            dp[i+1][j+1] = o

print(int(dp[n][h]))

Measured memory_bytes: 120940
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll N;
vector<ll> A;

bool can(ll x){
  vector<ll> B(x+1, 1);
  B[x] = INFL;
  rep(i, N){
    ll itr = upper_bound(B.begin(), B.end(), -A[i]) - B.begin();
    if(B[itr] == INFL) return 0;
    B[itr] = -A[i];
  }
  return 1;
}

int main(void){
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];

  ll ng = 0, ok = N;
  while(ok - ng > 1){
    ll mid = (ok + ng) / 2;
    if(can(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 1832
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void swap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
  return;
}

void push(int val,int *h){
  int n=h[0]+1;
  h[n]=val;
  while(n>1 && h[n]>h[n/2]){
    swap(h+n,h+n/2);
    n/=2;
  }
  h[0]++;
  return;
}

int pop(int *h){
  int res=h[1];
  swap(h+1,h+h[0]);
  h[0]--;
  int k=1;
  while(2*k+1<=h[0] && h[k]<MAX(h[2*k],h[2*k+1])){
    int next=(h[2*k]>h[2*k+1]?2*k:2*k+1);
    swap(h+k,h+next);
    k=next;
  }
  if(2*k<=h[0] && h[k]<h[2*k]) swap(h+k,h+2*k);
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*3*n);
  int i;
  for(i=0;i<3*n;i++) scanf("%d",a+i);
  int *h=(int *)malloc(sizeof(int)*3*n);
  h[0]=0;
  int64 sum=0;
  for(i=0;i<n;i++){
    sum+=a[i];
    push(-a[i],h);
  }
  int64 *front=(int64 *)malloc(sizeof(int64)*(n+1));
  front[0]=sum;
  for(i=n;i<2*n;i++){
    if(-h[1]<a[i]){
      sum+=pop(h);
      push(-a[i],h);
      sum+=a[i];
    }
    front[i-n+1]=sum;
  }
  h[0]=0;
  sum=0;
  for(i=3*n-1;i>=2*n;i--){
    sum+=a[i];
    push(a[i],h);
  }
  int64 *back=(int64 *)malloc(sizeof(int64)*(n+1));
  back[n]=sum;
  for(i=2*n-1;i>=n;i--){
    if(h[1]>a[i]){
      sum-=pop(h);
      push(a[i],h);
      sum+=a[i];
    }
    back[i-n]=sum;
  }
  int64 max=front[0]-back[0];
  for(i=1;i<=n;i++){
    max=MAX(max,front[i]-back[i]);
  }
  printf("%lld\n",max);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3328
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int x;
  cin >> x;
  x >= 30 ? cout << "Yes\n" : cout << "No\n";
  return 0;
}


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

void solve(long long N, std::string S) {
  long long uniq = 1;
  for (long long i = 0; i < N - 1; i++) {
    if (S[i] != S[i + 1]) {
      uniq += 1;
    }
  }
  cout << uniq << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<string> line(H); 
 
  for (int i = 0; i < H; i++) {
    cin >> line.at(i);
  }
  
  for (int i=0; i < H ; i++){
    for (int j =0 ; j < W ; j++){
         if  (line.at(i).at(j) != '#'){  // #じゃないとき
            int bmc = 0;  // count 0
            	if (i != 0){
                    if (j != 0){
	           			if (line.at(i-1).at(j-1) == '#'){
    	               	bmc++;
        	        	}
                    }
            	    if (line.at(i-1).at(j) == '#'){
                	   bmc++;
                	}
                    if (j != W-1){
						if (line.at(i-1).at(j+1) == '#'){
    	               	   bmc++;
        	        	}
                    }
                }
           		if (j != 0){
					if (line.at(i).at(j-1) == '#'){
                   		bmc++;
                	}
                }
           		if (j != W-1){
					if (line.at(i).at(j+1) == '#'){
    	               bmc++;
        	        }
                }
           		if( i !=H-1){
                    if (j != 0){
		           		if (line.at(i+1).at(j-1) == '#'){
    		               bmc++;
        		        }
                    }
					if (line.at(i+1).at(j) == '#'){
                	   bmc++;
                	}
                    if (j != W-1){
						if (line.at(i+1).at(j+1) == '#'){
                   			bmc++;
                		}
                    }
                } //if( i !=H-1){
            	cout << bmc;
         } // end if (line.at(i).at(j) != '#')
      	 else{
           cout << "#" ;
         }
       } // j のループ
       cout << endl;
    } // iのループ
    
//    for(int i= 0 ; i< H ; i++){
//      cout << line.at(i) << endl;
//    }
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdint>
using namespace std;

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

    int sum = 0;
    while(N) {
        sum += N % 10;
        N /= 10;
    }

    if(sum == 1) {
        cout << 10 << endl;
    }
    else {
        cout << sum << endl;
    }

    return 0;
}


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

string strplus(string lhs, string rhs){
	string ret;
	reverse(lhs.begin(), lhs.end());
	reverse(rhs.begin(), rhs.end());
	while(lhs.size() > rhs.size()){
		rhs += '0';
	}
	while(lhs.size() < rhs.size()){
		lhs += '0';
	}
	int up = 0;
	for(int i = 0; i < lhs.size(); i++){
		int val = (lhs[i]-'0')+(rhs[i]-'0')+up;
		up = val/10;
		if(up){
			val-=10;
		}
		ret+=(val+'0');
	}
	if(up){
		ret+='1';
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

void tokenize(string &s, const string &token){
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < token.size(); j++){
			if(s[i] == token[j]){
				s[i] = ' ';
			}
		}
	}
}

void replaceX(string &s, int x){
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'X'){
			s[i] = '0'+x;
		}
	}
}

bool check(const string &s){
	stringstream ss;
	ss << s;
	string a[3];
	string tmp;
	for(int i = 0; i < 3; i++){
		ss >> a[i];
		if(a[i].size() > 1 && a[i][0] == '0'){
			return false;
		}
	}

	return a[2] == strplus(a[0], a[1]);
}

int main(){
	string s;
	string token = "+=";

	while(cin >> s){
		tokenize(s, token);
		int n = -1;
		for(int i = 0; i <= 9; i++){
			string t = s;
			replaceX(t, i);
			if(check(t)){
				n = i;
			}
		}
		if(n == -1){
			cout << "NA" << endl;
		}else{
			cout << n << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
N, M = map(int, input().split())
PS = [input().split() for _ in range(M)]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)
ans = 0
pena = 0

for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    elif s == "WA":
        WA_cnt[p] += 1
        # pena = 1 これだと、AC確定時にpenalty加算されるというルールが守られない
    elif s == "AC":
        ans += 1
        pena += WA_cnt[p]
        AC[p] = True

print(ans, pena, sep=' ')

Measured memory_bytes: 33696
#include<stdio.h>
#include<ctype.h>
int main(void){
    char moji;
    while(1)
    {
        scanf("%c",&moji);
        if(moji == '\n') break;
        else if(isupper(moji))  moji = tolower(moji);
        else if(islower(moji))  moji = toupper(moji);
        putchar(moji);
    }
    printf("\n");
}


Measured memory_bytes: 1980
#include <stdio.h>

int sum(char li[10], int init, int i, int delta) {
	int n, s = 0;

	for (n = init; n > 0; n--) {
		while (!li[i]) {
			i += delta;
		}
		s += n * i;
	}
	return s;
}

void solve(char li[10], int n, int s, int total, int *cnt) {
	int i, j, value, minimum, maximum;
	char subli[10];

	for (i = 0; i < 10; i++) {
		if (!li[i])
			continue;

		value = i * n + total;
		if (n - 1) {
			for (j = 0; j < 10; j++) {
				subli[j] = li[j];
			}
			subli[i] = 0;

			minimum = value + sum(subli, n - 1, 0, 1);
			maximum = value + sum(subli, n - 1, 9, -1);

			if (minimum <= s && s <= maximum) {
				solve(subli, n - 1, s, value, cnt);
			}
		}
		else if(value == s) {
			*cnt += 1;
			break;
		}
	}
}

int main(void) {
	int cnt, n, s, i;
	char li[10];

	while (scanf(" %d %d ", &n, &s) != EOF) {
		cnt = 0;
		for (i = 0; i < 10; i++) {
			li[i] = 1;
		}
		solve(li, n, s, 0, &cnt);
		printf("%d\n", cnt);
	}
	return 0;
}

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

int main(){
  int n;
  int money = 100000;
  cin >> n;
  for(int i = 0;i < n;i++){
	money =(money *1.05);
	int kiri = money%1000;
	if(kiri > 0){
	  money -=kiri;
	  money +=1000;
	}
  }
  cout << money << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{
    int n,x[3];
    for(int i=0;i<3;i++)
    {
        cin>>x[i];
    }
    if (x[0]==x[1])
        n=x[2];
    else if(x[0]==x[2])
        n=x[1];
    else
        n=x[0];
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int X =sc.nextInt();
      int Y =sc.nextInt();
      int Z =sc.nextInt();
      
     System.out.println(Z+" "+X+" "+Y);
      
    }
}

Measured memory_bytes: 39300
program main
  implicit none
  integer CC, i, n, renzoku, CC2
  character(10**5) s
  character c
  read(*, *) s
  s = trim(s)
  n = len(s)
  CC = 0
  CC2 = 0
  !01010101010
  do i = 1,n
    if (s(i:i) == ' ') then 
      exit
    end if
    if (mod(i,2) == 1) then
      if (s(i:i) == '0') then
        CC = CC + 1
      else
        CC2 = CC2 + 1
      end if
    else
      if (s(i:i) == '1') then
        CC = CC + 1
      else
        CC2 = CC2 + 1
      end if
    end if
  end do
  write(*, '(i0)') min(CC,CC2)

end program main

Measured memory_bytes: 700
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val L = readLine().split(" ").map(_.toInt)

  def solve() = {
    var ans = 0
    for {
      i <- 0 until n
      j <- i until n
      k <- j until n
    } {
      val list = Seq(L(i), L(j), L(k))
      list.sum
      val max = Math.max(Math.max(L(i), L(j)), L(k))
      val isTriangle = max < (L(i)+L(j)+L(k)) - max
      val isUnique = L(i) != L(j) && L(i) != L(k) && L(j) != L(k)
      if(isTriangle && isUnique) ans += 1
    }
    ans
  }

  println(solve())

}



Measured memory_bytes: 58972
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

ll x[MAX_N], v[MAX_N], a[MAX_N], b[MAX_N];

int main() {
    ll n, c;
    cin >> n >> c;
    
    x[0] = 0;  v[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
    } 
    x[n+1] = c;  v[n+1] = 0;
    
    for(int i = 1; i <= n; i++) {
        a[i] = a[i-1] + v[i] - (x[i] - x[i-1]);
    }
    for(int i = 1; i <= n; i++) {
        a[i] = max(a[i], a[i-1]);
    } 
    
    for(int i = n; i >= 1; i--) {
        b[i] = b[i+1] + v[i] - (x[i+1] - x[i]);
    }  
    for(int i = n; i >= 1; i--) {
        b[i] = max(b[i], b[i+1]);
    } 
    
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, a[i]);
        ans = max(ans, a[i] - x[i] + b[i+1]);
        ans = max(ans, b[i]);
        ans = max(ans, b[i] - (c - x[i]) + a[i-1]);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
  double a,b,x;
  cin >> a >> b >> x;
  double s=x/a;
  double rad;
  if(s>=a*b/2){
     double h=(a*b-s)*2/a;
     rad=atan2(h,a);
  } else {
     double w=s*2/b;
     rad=atan2(b,w);
  }
  printf("%.10f\n",rad/M_PI*180);
}

Measured memory_bytes: 512