akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
#include <functional>
#include <cassert>
using namespace std;

typedef string::const_iterator Iterator;

Iterator matching_paren(Iterator it, const Iterator& last)
{
  for (int d = 1; it != last; ++it) {
    if (*it == ')') {
      --d;
      if (d == 0) {
        return it;
      }
    } else if (*it == '(') {
      ++d;
    }
  }
  throw "paren mismatch";
}

set<int> eval(const string& str)
{
  vector<string> terms;
  vector<char> ops;
  string term;
  for (string::const_iterator it(str.begin()), end = str.end(); it != end; ++it) {
    if ('0' <= *it && *it <= '9') {
      term += *it;
    } else if (*it == '(') {
      if (!term.empty()) {
        terms.push_back(term);
      }
      term = "";
      Iterator l = matching_paren(it+1, end);
      term = string(it, l+1);
      it = l;
    } else {
      if (!term.empty()) {
        terms.push_back(term);
      }
      term = "";
      assert(*it == '+' || *it == '-' || *it == '*' || *it == '/');
      ops.push_back(*it);
    }
  }
  terms.push_back(term);
  assert(ops.size()+1 == terms.size());

  if (ops.empty()) {
    if (terms[0][0] == '(') {
      return eval(terms[0].substr(1, terms[0].size()-2));
    } else {
      set<int> s;
      istringstream iss(terms[0]);
      int x;
      iss >> x;
      s.insert(x);
      return s;
    }
  } else {
    set<int> s;
    for (vector<char>::size_type i = 0; i < ops.size(); i++) {
      string lhs;
      for (vector<string>::size_type j = 0; j <= i; j++) {
        if (j != 0) {
          lhs += ops[j-1];
        }
        lhs += terms[j];
      }
      const set<int> l = eval(lhs);
      string rhs;
      for (vector<string>::size_type j = i+1; j < terms.size(); j++) {
        if (j != i+1) {
          rhs += ops[j-1];
        }
        rhs += terms[j];
      }
      const set<int> r = eval(rhs);
      for (set<int>::const_iterator jt(l.begin()); jt != l.end(); ++jt) {
        for (set<int>::const_iterator kt(r.begin()); kt != r.end(); ++kt) {
          switch (ops[i]) {
            case '+': s.insert(*jt + *kt);  break;
            case '-': s.insert(*jt - *kt);  break;
            case '*': s.insert(*jt * *kt);  break;
            case '/': if (*kt != 0) { s.insert(*jt / *kt); }  break;
          }
        }
      }
    }
    return s;
  }
}

int main()
{
  for (string s; cin >> s && s != "#";) {
    cout << eval(s).size() << endl;
  }
  return 0;
}

Measured memory_bytes: 988
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<ll> ans = vector<ll>(2001, 0);

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

bool comp(pair<int,pair<int,int>> a, pair<int, pair<int, int>> b){
	return a.first <= b.first;
}

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

	int n;
	cin >> n;

	int cnt = 0;
	REP(i, n) {
		int d1, d2;
		cin >> d1 >> d2;

		if (d1 == d2) {
			cnt++;
			if (cnt == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			cnt = 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, x, ans = 1;
    cin >> n >> x;
    vi d(n+1, 0);
    repf(i, n){
        ll l; cin >> l;
        d[i] = d[i-1] + l;
        if(d[i] <= x) ans++;
    }
    auto it = upper_bound(all(d), x);
    cout << it-d.begin() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
char s[10][10]={{0}};
int X[8]={-1,0,1,1, 1, 0,-1,-1};
int Y[8]={ 1,1,1,0,-1,-1,-1, 0};
int f(char w,char c,int y,int x){
  int a=0,i,j;
  for(i=0;i<8;i++){
    for(j=1;s[y+Y[i]*j][x+X[i]*j]==c;j++);
    if(s[y+Y[i]*j][x+X[i]*j]==w)a+=j-1;
  }
  return a;
}
void g(char w,char c,int y,int x){
  int i,j;
  s[y][x]=w;
  for(i=0;i<8;i++){
    for(j=1;s[y+Y[i]*j][x+X[i]*j]==c;j++);
    if(s[y+Y[i]*j][x+X[i]*j]==w){
      for(;j>0;j--)s[y+Y[i]*j][x+X[i]*j]=w;
    }
  }
}
int main(){
  int i,j,mi,mj,max,a,c;
  for(i=0;i<8;i++){
    scanf("%s",s[i+1]+1);
  }
  //printf("%c",s[1][1]);
  a=0;
  while(1){
    max=0;
    for(i=1;i<9;i++){
      for(j=1;j<9;j++){
	if(s[i][j]=='.'){
	  c=f('o','x',i,j);
	  if(max<c){
	    mi=i;
	    mj=j;
	    max=c;//printf("%d : %d : %d\n",mi,mj,c);
	  }
	}
      }
    }
    //if(i==9&&j==9)break;
    a++;
    if(max!=0){//printf("%d:%d\n",mi,mj);
      g('o','x',mi,mj);
      a=0;
    }
    if(a==2)break;
    max=0;
    for(i=8;i>0;i--){
      for(j=8;j>0;j--){
	if(s[i][j]=='.'){
	  c=f('x','o',i,j);
	  if(max<c){
	    mi=i;
	    mj=j;
	    max=c;
	  }
	}
      }
    }
    //if(i==0&&j==0)break;
    a++;
    if(max!=0){
      g('x','o',mi,mj);
      a=0;
    }
    if(a==2)break;	
  }
  for(i=1;i<9;i++){
    for(j=1;j<9;j++){
      printf("%c",s[i][j]);
    }
    printf("\n");
    
  }
  return 0;
}

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

using namespace std;

int main() {
    int k ; cin>>k;
    int a , b ; cin>>a>>b;
    for(int i = a ; i <= b; ++i){
      if(i % k == 0 ){
        return cout<<"OK" , 0;
      }
    }
    cout<<"NG";
    return 0;
}

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

int main()
{
    int iPerW = 0;
    int iPerH = 0;
    
    while (cin >> iPerH >> iPerW)
    {
        if ((0 == iPerH) && (0 == iPerW))
        {
            break;
        }
        
        for (int i = 0; i < iPerH; i++)
        {
            for (int j = 0; j < iPerW; j++)
            {
                if ((0 == i) || (iPerH - 1 == i) || (j == 0) || (iPerW - 1 == j))
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3080
#include  <iostream>
using namespace std;
using i64 = long long;
int main() {
  i64 n, k;
  cin >> n >> k;
  i64 ans = 0;
  i64 bfr;
  cin >> bfr;
  for(int i = 1;i < n;i++) {
    i64 a;
    cin >> a;
    ans += min(a - bfr, k);
    bfr = a;
  }
  cout << ans + k << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();
        sc.close();

        int cnt = 0;
        boolean day1 = s[0] == 'R';
        boolean day2 = s[1] == 'R';
        boolean day3 = s[2] == 'R';

        if(day1 && day2 && day3) cnt = 3;
        else if((day1 && day2) || (day2 && day3)) cnt = 2;
        else if(day1 || day2 || day3) cnt = 1;
        else cnt = 0;
        System.out.println(cnt);
    }
}


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

using ll = long long;
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> foods(n + 1);
    for (int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        foods[i] = pair<int, int>{a, b};
    }
    sort(foods.begin(), foods.end());
    int dp[n][t] = {};
    for (int i = 1; i < n; i++) {
        for (int l = 0; l < t; l++) {
            if (l >= foods[i].first) {
                dp[i][l] = max(dp[i][l], dp[i - 1][l - foods[i].first] + foods[i].second);
            }
            dp[i][l] = max(dp[i][l], dp[i - 1][l]);
        }
    }
    int ans = -1;
    for (int i = 0; i < n; i++) {
        for (int l = 0; l < t; l++) {
            ans = max(ans, dp[i][l] + foods[i + 1].second);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

main(){
  int data[15];
  string in;
  while(cin >> in){
    for(int i=0;i<10;i++){
      data[i]=(int)(in[i]-'0');
    }
    data[11]=-1;
    for(int i=0;i<9;i++){
      for(int j=0;j<10;j++){
	if(data[j+1]==-1){
	  data[j]=-1;
	  break;
	}
	data[j]=(data[j]+data[j+1])%10;
      }
    }
    cout << data[0] << endl;
  }
  return 0;
}

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 3e3 + 21, LG = 20, inf = 1e18;

int n;
int a[MAXN];
bool dp[MAXN];
vector<int> adj[MAXN];

void dfs(int v, int par = -1){
    dp[v] = 0;
    for(auto &y: adj[v])
        if(y ^ par && a[v] > a[y]) {
            dfs(y, v);
            dp[v] |= (!dp[y]);
        }
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    for(int i = 1; i <= n; i++){
        dfs(i);
        if(dp[i]) 
            cout << i << ' ';
    }
    cout <<'\n';
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i,a;
  ll dp[100005]={};
  const int mod=1e9+7;
  
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> a;
    dp[a]=-1;
  }
  
  dp[0]=1;
  if (dp[1]==0) dp[1]=1;
  for (i=2;i<=n;i++){
    if (dp[i]!=-1){
      if (dp[i-2]>0) dp[i]=(dp[i]+dp[i-2])%mod;
      if (dp[i-1]>0) dp[i]=(dp[i]+dp[i-1])%mod;
    }
  }
  
  cout << dp[n] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> List.rev (s :: acc)
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let print_array a =
  Array.iteri (fun i s -> Printf.printf (if i = 0 then "%s" else " %s") s) a;
  print_newline ()

let bubble_sort a n cmp =
  let rec bubble j flag =
    if j <= 0 then flag
    else begin
      if cmp a.(j - 1) a.(j) <= 0 then bubble (j - 1) flag
      else begin
        let tmp = a.(j) in a.(j) <- a.(j - 1); a.(j - 1) <- tmp;
        bubble (j - 1) true
      end
    end
  in
  let rec doit flag =
    if not flag then ()
    else doit (bubble (n - 1) false)
  in
  doit true

let selection_sort a n cmp =
  let rec select j minj =
    if j >= n then minj
    else select (j + 1) (if cmp a.(j) a.(minj) < 0 then j else minj)
  in
  let rec doit i =
    if i >= n then ()
    else begin
      let minj = select i i in
      if minj <> i then begin
        let tmp = a.(i) in
        a.(i) <- a.(minj);
        a.(minj) <- tmp;
      end;
      doit (i + 1)
    end
  in
  doit 0

let cmp_card x y =
  let num_of_char c = Char.code c - Char.code '0' in
  compare (num_of_char x.[1]) (num_of_char y.[1])

let stable_p a b n =
  let rec doit i =
    if i >= n then true
    else if a.(i) <> b.(i) then false
    else doit (i + 1)
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.of_list (split (read_line ()) ' ') in
  let b = Array.copy a in
  bubble_sort a n cmp_card;
  selection_sort b n cmp_card;
  print_array a;
  Printf.printf "Stable\n";
  print_array b;
  Printf.printf (if stable_p a b n then "Stable\n" else "Not stable\n")

Measured memory_bytes: 2216
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		
		
		while(scan.hasNext())
		{
			
			String s,s1 ;
			s=scan.next();
			char arr[]=s.toCharArray();
			int c1=((arr[0]-48)*10)+(arr[1]-48);
			int c2=((arr[2]-48)*10)+(arr[3]-48);
			if((c1>0 && c1<=12 && c2>=0) && (c1>=0 && c2>0 && c2<=12))
				System.out.println("AMBIGUOUS");
			else if(c1>0 && c1<=12 && c2>=0)
				System.out.println("MMYY");
			else if(c1>=0 && c2>0 && c2<=12)
				System.out.println("YYMM");
			else
				System.out.println("NA");
			
			
			
			
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i, 0, n) cin >> x[i];

  ll ans = 0;
  rep(i, 0, n - 1) {
    ll aa = (x[i + 1] - x[i]) * a;
    ans += min(aa, b);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
<?php
$x = explode(" ",fgets(STDIN));
$n=trim($x[0]);
$k=trim($x[1]);
$a = explode(" ",fgets(STDIN));
if($n==$k){
	echo "1";
}elseif($k==2){
	echo $n-1;
}elseif($k!=2){
	if($n%($k-1)==1){
		echo ceil($n/($k-1))-1;
	}else{
		echo ceil($n/($k-1));
	}
}

Measured memory_bytes: 21876
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int N,M;

	while(1){
		cin>>N>>M;if(N==0&&M==0)break;
		int n[20003]={};

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


		sort(n,n+N+M);
		
		int max=n[0];
		for(int i=0;i<N+M;i++){//cout<<n[i]<<endl;
			if(n[i+1]-n[i]>max)max=n[i+1]-n[i];}
		cout<<max<<endl;
	}
	return 0;
}
	
		

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007

const ll mod = 1e9 + 7;

ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

long long inv(long long x)
{
	return power(x, mod - 2);
}

long long divide(long long x, long long y)
{
	return (x * inv(y)) % mod;
}

long long fact[200009];

void precalc()
{
	fact[0] = 1;
	for (long long i = 1; i < 200009; i++)
		fact[i] = (fact[i - 1] * i) % mod;
}

long long C(long long n, long long k)
{
	return divide(fact[n], (fact[k] * fact[n - k]) % mod);
}

bool comp(pair <ll, ll>& a, pair <ll, ll>& b) {
	return a.first + a.second < b.first + b.second;
}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	precalc();
	ll h, w, n;
	cin >> h >> w >> n;
	vector <pair<ll, ll> > v(n);
	for (ll i = 0; i < n; i++)
		cin >> v[i].first >> v[i].second;
	sort(all(v), comp);
	v.pb({h, w});
	vector <ll> dp(n + 1);
	for (ll i = 0; i <= n; i++) {
		ll a, b;
		a = v[i].first - 1;
		b = v[i].second - 1;
		ll temp = C(a + b, b);
		for (ll j = 0; j < i; j++) {
			ll x, y;
			x = v[j].first - 1;
			y = v[j].second - 1;
			if (a >= x && b >= y)
				temp = (temp - (dp[j] * C(a + b - x - y, a - x)) % mod + mod) % mod;
		}
		dp[i] = temp;
	}
	cout << dp[n] << "\n";
}


Measured memory_bytes: 5284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;

//dp[i][j]->i個目の鍵まで使ったときどの宝箱が開けられたかとそのときのコスト
int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> a(m);
  vector<vector<int> > c(m);
  rep(i,m) {
    int b;
    cin >> a[i] >> b;
    a[i];
    rep(j,b) {
      int p;cin >> p;
      --p;
      c[i].push_back(p);
    }
  }
  vector<ll> dp(1<<12+1,INF);
  dp[0] = 0;
  rep(i,m) {
    int now = 0;
    rep(j,c[i].size()) {
      now |= (1<<c[i][j]);
    }
    rep(bit,1<<n) {
      dp[bit | now] = min(dp[bit | now],dp[bit] + a[i]);
    }
  }
  
  if(dp[(1<<n)-1] == INF)puts("-1");
  else cout << dp[(1<<n)-1] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){

    char s[4];
    rep(i,4){cin>>s[i];}
    int a[4];
    rep(i,4){a[i]=s[i]-'0';}
   
    
    for(int b=0;b<(1<<3);b++){
        
        int ans=a[0];
        
        vector<char> h(3);
        for(int j=0;j<3;j++){
            if((b>>j)&1){
                ans=a[j+1]+ans;
                h[j]='+';
            }else{
                ans=ans-a[j+1];
                h[j]='-';
            }
        }
        if(ans==7){
        
            printf("%d%c%d%c%d%c%d=7",a[0],h[0],a[1],h[1],a[2],h[2],a[3]);
            
            return 0;
            
        }
        
    }
    
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

const int mx = 100005;
int dp[6][mx];

int main(){
    int x;
    cin >> x;
    
    for (int i=0; i<6; i++) {
        int j=0;
        while (j*(100+i)<=x) {
            dp[i][j*(100+i)] = 1;
            j++;
        }
        if (i<5) {
            for (int k=0; k<x+1; k++) {
                int l=0;
                while (k+l*(100+i+1)<=x) {
                    dp[i+1][k+l*(100+i+1)] |= dp[i][k];
                    l++;
                }
            }
        }
    }
    int ans = 0;
    if (dp[5][x]>0) {
        ans = 1;
    }
    
    cout << dp[5][x] << endl;
    return 0;
}


Measured memory_bytes: 2560
n = gets.chomp.to_i
 a = gets.chomp.split(" ").map(&:to_i)
 b = gets.chomp.split(" ").map(&:to_i)
atr = [*1..n]
arr = []
atr.permutation (n) do |i|
    arr << i
end
ans1 = 0
ans2 = 0
arr.each_with_index do |item,i|
    ans1 = i if a == item
    ans2 = i if b == item
end
puts (ans1-ans2).abs

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

using namespace std;
using vi = vector<int>;

int main(){
    int n;
    cin >> n;
    int64_t sum = 1000, k=0;
    int wh=0;
    vi Ai(n);
    vi kabu(n);
    rep(i,n){
        cin >> Ai.at(i);
    }
    if (Ai.at(0) < Ai.at(1)){
        k = sum / Ai.at(0);
        sum %= Ai.at(0);
    }
    /*for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            if (Ai.at(j) < Ai.at(j+1)){
                wh = 1;
            }
        }
        kabu.at(i) = wh;

    }*/
    for (int i=1; i<n; i++){
        if (i==n-1){
            sum += k * Ai.at(i);
        }
        else if (Ai.at(i) < Ai.at(i+1)){
            k = k + sum / Ai.at(i);
            sum %= Ai.at(i);
        }
        else if (Ai.at(i) > Ai.at(i+1)){
            sum  += k*Ai.at(i);
            k = 0; 
        }
    }
    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 3600
package main

import "fmt"

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	r := lcm(c, d)
	p := b/c + b/d - b/r
	q := (a-1)/c + (a-1)/d - (a-1)/r
	fmt.Println(b - a + 1 - (p - q))

}


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

int main(){
  int n = 5;
  vector<int> wait;
  vector<int> next_order;

  int max_dif = 0;
  for(int i = 0; i < n; ++i) {
    int temp; cin >> temp;
    wait.push_back(temp);
    next_order.push_back( (wait[i]%10) ? (wait[i]/10 + 1)*10 :(wait[i]/10)*10 );
    max_dif = max(max_dif, next_order[i] - wait[i]);
  }
  sort(wait.begin(), wait.end());
  sort(next_order.begin(), next_order.end());

  int ans = 0;
  for(int i = 0; i < n; ++i){
   // cout << "next_order "<<next_order[i]<<endl;
   // cout << "wait "<<wait[i]<<endl;
    ans += next_order[i];
  }
  ans -= max_dif;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
n = int(input())
listH = list(map(int, input().split()))
listNull=[0]*n
sumW=0
while True:
    if listH == listNull:
            break
    currentL=[]
    index=0
    minM=100
    startI=0
    while index < n:
        if listH[index]!=0:
            if listH[index] < minM:
                minM = listH[index]
            currentL.append(listH[index])
        else:
            if len(currentL)>0:
                index2=startI
                sumW += minM
                while index2 < index:
                    if listH[index2]!=0:
                        listH[index2]-=minM
                    index2+=1
                startI = index+1
                currentL = []
            else:
                pass
        index+=1
    if len(currentL) != 0:
        index2 = startI
        sumW += minM
        while index2 < index:
            if listH[index2] != 0:
                listH[index2] -= minM
            index2 += 1
        startI = index+1
        currentL = []
    else:
        pass

print(sumW)

Measured memory_bytes: 3064
let sumdigit n =
  let rec sumd c n' len =
    if n' / 10 = 0 then (c+n', n', len)
    else sumd (c+(n' mod 10)) (n'/10) (len+1)
  in
  sumd 0 n 0
;;

let ()=
  let n = Scanf.scanf "%d\n" (fun x ->x) in
  let sumd, hd, len = sumdigit n in
  let sum9 = len*9 + (hd-1) in
  let ans = if sumd > sum9 then sumd else sum9 in
  print_int ans
;;

Measured memory_bytes: 384
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

lli power(lli x, lli y) {
    // log y complexity
    // return (x^y) % MOD
    lli ans = 1;
    x = x % MOD;
    while (y > 0) {
        if (y & 1) {
            ans *= x;
            ans %= MOD;
        }
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return ans;
}

void solve() {
    lli n, a;
    cin >> n;
    lli ans = (power(9, n) * 2) % MOD;
    ans -= power(8, n);
    ans += MOD;
    ans %= MOD;
    lli tot = power(10, n);

    tot -= ans;
    tot += MOD;
    tot %= MOD;
    cout << tot << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

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

int main() {
  int a;
  int64_t b,n;
  cin>>a>>b>>n;
  int64_t p;
  if(n<b){
    p=n;
  }
  else{
    p=b-1;
  }
  cout << a*p/b << endl;
    
}
  

  

  


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using I = long long;
int main() {
  I N;
  cin >> N;
  vector<I> A(N);
  for(auto& i: A) cin >> i;
  vector<I> X(N+1), S(N+1);
  for(auto i=0; i<N; ++i) {
    X[i+1] = X[i] ^ A[i];
    S[i+1] = S[i] + A[i];
  }

  auto sum  = [&](auto l, auto r) {return S[r+1] - S[l];};
  auto xsum = [&](auto l, auto r) {return X[r+1] ^ X[l];};
  auto ok = [&](auto i, auto x) {
    return sum(i, x) == xsum(i, x);
  };
  I res = N * (N+1) / 2;
  for(auto i=0; i<N; ++i) {
    I l=i, h=N-1;
    while(l+1 < h) {
      auto m = (l + h) / 2;
      if(ok(i, m)) l = m;
      else         h = m;
    }
    if(ok(i, h)) l = h;
    res -= N-1 - l;
  }
  cout << res << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  vector<pair<i64, i64>> vec;
  i64 N;
  cin >> N;
  for(int i = 0;i < N;i++) {
    i64 x, y;
    cin >> x >> y;
    vec.push_back({x, y});
  }
  sort(all(vec));
  vector<pair<i64, i64>> diff;
  for(auto v: vec) for(auto w: vec) {
    diff.push_back({v.first - w.first, v.second - w.second});
    if(diff.back().first < 0) {
      diff.back().first *= -1;
      diff.back().second *= -1;
    }
  }
  map<pair<i64,i64>, i64> mp;
  for(int i = 0;i < N;i++) {
    mp[vec[i]] = i;
  }
  sort(all(diff));
  diff.erase(unique(all(diff)), end(diff));
  i64 res = N;
  for(auto pp: diff) {
    i64 p = pp.first;
    i64 q = pp.second;
    if(p == 0 && q == 0) continue;
    vector<bool> used(N, false);
    i64 ans = 0;
    for(int i = 0;i < N;i++) {
      if(mp.count(pair<i64,i64>(vec[i].first - p, vec[i].second - q))) {
      }
      else {
        ans++;
      }
    }
    res = min(res, ans);
  }
  cout << res << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

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



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

int main(){
    long double W, H, X, Y;
    cin >> W >> H >> X >> Y;
    cout << fixed <<setprecision(9) << W*H / 2<< " " <<  (2*Y == H && 2*X == W) << endl;
}


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

int main() {

    vector<int> vec;
    int t;
    while(cin >> t) {
       vec.push_back(t);
    }

    sort(vec.begin(), vec.end(), greater<int>());

    for(int i = 0; i < 3; i++) {
        cout << vec[i] << endl;
    }

    return 0;
}


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

using namespace std;

vector <vector <int> > graph;
vector <int> dp;

int dfs(int u){
  if(dp[u] != -1) return dp[u];
  int maxv = 0;
  for(int v: graph[u]){
    maxv = max(maxv, dfs(v));
  }
  dp[u] = 1 + maxv;
  return dp[u];
}

int main(){
  int n,m;
  cin >> n >> m;
  dp.assign(n + 1, -1);
  graph.assign(n + 1, vector<int>());
  for(int i = 0;i < m;i++){
    int u,v;cin >> u >> v;
    graph[u].push_back(v);
  }
  int maxv = 0;
  for(int i = 1;i <= n;i++){
    maxv = max(maxv, dfs(i));
  }
  cout << maxv - 1;
}

Measured memory_bytes: 8192
import heapq

def dijkstra(s):
    inf = 1145141919810
    dist = [inf] * v
    dist[s] = 0
    c = [0] * v
    p = []
    heapq.heapify(p)
    heapq.heappush(p, (dist[s], s))
    while p:
        d, u = heapq.heappop(p)
        if dist[u] < d:
            continue
        c[u] = 1
        for g in G[u]:
            if c[g[0]] == 0 and dist[u] + g[1] < dist[g[0]]:
                dist[g[0]] = dist[u] + g[1]
                heapq.heappush(p, (dist[g[0]], g[0]))
    return dist

n, m = map(int, input().split())
v = n
G = [[] for _ in range(v)]
E = []
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append([b, c])
    G[b].append([a, c])
    E.append([a, b, c])
mindist = [dijkstra(i) for i in range(v)]
ans = m
for e in E:
    for i in range(n):
        if mindist[i][e[0]] - mindist[i][e[1]] == e[2]:
            ans -= 1
            break
print(ans)

Measured memory_bytes: 9348
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dfs(s,g,p):
    global tmp
    if s == g:
        tmp = []
        return True
    for (v,i) in edge[s]:
        if v == p:
            continue
        if dfs(v,g,s):
            tmp.append(i)
            return True
    return False

n = I()
edge = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    edge[a].append((b,i))
    edge[b].append((a,i))

m = I()
lst = []
tmp = []
for _ in range(m):
    u,v = LI()
    u -= 1
    v -= 1
    dfs(u,v,-1)
    lst.append(tmp)

"""m個の制約がどの辺を通るかbitで管理"""
e = [0]*m
for i in range(m):
    x = 0
    for j in lst[i]:
        x |= 1<<j
    e[i] = x

"""包除原理"""
ans = 0
for i in range(1<<m):
    black = 0 #制約の通る辺をbitで管理
    cnt = 0 #使う制約の個数
    """どの制約を使うか"""
    for j in range(m):
        if i>>j & 1:
            cnt += 1
            black |= e[j]

    cnt2 = 0 #制約内の辺の本数
    for j in range(n-1):
        if black >> j & 1:
            cnt2 += 1
    if cnt % 2: #制約奇数個の場合
        ans -= 1<<(n-1-cnt2) #-2**((n-1本の辺)-(制約内の辺の本数))
    else:
        ans += 1<<(n-1-cnt2) #+2**((n-1本の辺)-(制約内の辺の本数))
print(ans)

Measured memory_bytes: 43388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int n, m , x1, y1;
  cin >> n >> m >> x1 >> y1;

  vector<int> ax(n), ay(m);

  REP(i, n) cin >> ax[i];
  REP(i, m) cin >> ay[i];

  int bb = *min_element(ay.begin(), ay.end());
  int aa = *max_element(ax.begin(), ax.end());

  //cout << aa << bb << endl;
  aa = max(aa, x1);
  bb = min(bb, y1);

  //cout << aa << bb << endl;
  if (aa < bb) {
    cout << "No War" << endl;
  }else {
    cout << "War" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:usize, k:usize,
        xycs: [(usize,usize,chars); n]
    };

    let mut xy = vec![vec![0;k*2];k*2];
    for (x,y,c) in xycs {
        if c[0]=='W' { xy[x % (k*2)][y % (k*2)] += 1; } 
        else { xy[(x+k) % (k*2)][y % (k*2)] += 1; }
    }
    for x in 0..2*k { for y in 1..2*k { xy[x][y] += xy[x][y-1]; } }
    for y in 0..2*k { for x in 1..2*k { xy[x][y] += xy[x-1][y]; } }

    let mut ans=0;
    for x in 0..k { for y in 0..k {
        let ck = checker(&xy, x, y, k);
        ans = std::cmp::max(ans, ck);
        ans = std::cmp::max(ans, n - ck);
    }};
    println!("{}", ans);
}

fn checker(xy: &Vec<Vec<usize>>, x: usize, y: usize, k: usize) -> usize {
    let kk = k*2-1;
    let r1 = xy[kk][kk];
    let r2 = xy[x+k-1][kk];
    let r3 = xy[kk][y+k-1];
    let r4 = if x>0 { xy[x-1][kk] } else { 0 };
    let r5 = if y>0 { xy[kk][y-1] } else { 0 };
    let r6 = xy[x+k-1][y+k-1];
    let r7 = if x>0 { xy[x-1][y+k-1] } else { 0 };
    let r8 = if y>0 { xy[x+k-1][y-1] } else { 0 };
    let r9 = if x>0 && y>0 { xy[x-1][y-1] } else { 0 };

    r1 + r4 + r5 + 2*r6 + 2*r9 - r2 - r3 - 2*r7 - 2*r8 
}

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

using std::cout;
using std::cin;
using std::endl;

/*  テンプレここから */
typedef long long ll;

#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;
    std::vector<int> lens(n);
    for(int i = 0; i < n; ++ i) cin >> lens[i];
    std::sort(all(lens));

    int cnt = 0;
    for(int a = 0; a < n; ++ a){
        for(int b = a+1; b < n; ++ b){
            for(int c = b+1; c < n; ++ c){
                int A = lens[a];
                int B = lens[b];
                int C = lens[c];
                cnt += (A<B+C && B<C+A && C<A+B);
            }
        }
    }

    cout << cnt << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1];

            Console.WriteLine(A * B - (A + B - 1));
        }
    }
}


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

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

// template<class T> void chmin(T& a, T b) {
//     if (a > b) {
//         a = b;
//     }
// }

// template<class T> void chmax(T& a, T b) {
//     if (a < b) {
//         a = b;
//     }
// }

vector<ll> a(51);
vector<ll> p(51);

ll solve(ll n, ll x) {
    if(n==0) return 1;
    else if(x==1) return 0;
    else if(1<x&&x<=1+a.at(n-1)) return solve(n-1, x-1);
    else if(x==2+a.at(n-1)) return p.at(n-1)+1;
    else if(2+a.at(n-1)<x&&x<=2+2*a.at(n-1)) return p.at(n-1)+1+solve(n-1, x-2-a.at(n-1));
    else return 2*p.at(n-1)+1;
}

int main(void) {
    ll n, x;
    cin >> n >> x;

    a.at(0) = 1;
    p.at(0) = 1;
    for(int in=1;in<=50;in++) {
        a.at(in) = 2*a.at(in-1) + 3;
        p.at(in) = 2*p.at(in-1) + 1;
    }

    cout << solve(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
from scipy.misc import comb
import math
n,a,b=list(map(int,input().split()))
mod=10**9+7

inv_t = [0]+[1]
for i in range(2,10**6+1):
  inv_t += [inv_t[mod % i] * (mod - int(mod/ i)) % mod]
#n=10**9
def binary(n):
    return bin(n)[2:]

# モンゴメリ冪乗法
def pow_by_montgomery_ladder(a, x, n): # a^x mod n
    x = [int(b) for b in binary(x)[::-1]]
    k = len(x)
    a1 = a
    a2 = a**2
    for i in range(k - 2, -1, -1):
        if x[i] == 0:
            a2 = (a1 * a2) % n
            a1 = (a1**2) % n
        else:
            a1 = (a1 * a2) % n
            a2 = (a2**2) % n
    return a1

if n<3:
    print(0)
    exit()

ans=pow_by_montgomery_ladder(2,n,mod)
hoge=1
for i in range(1,a+1):
    hoge=(hoge*(n+1-i))%mod
    hoge=(hoge*inv_t[i])%mod
ans-=hoge

hoge=1
for i in range(1,b+1):
    hoge=(hoge*(n+1-i))%mod
    hoge=(hoge*inv_t[i])%mod
ans-=hoge
ans%=mod
print(ans-1)

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

int main()
{
  int n;

  cin >> n;

  int flag1 = 0;
  int flag2 = 0;
  int flag3 = 0;
  int flag4 = 0;

  vector<string> s(n);

  rep(i, n)
  {
    cin >> s.at(i);
    if(s.at(i) == "AC")
      flag1++;
    else if(s.at(i) == "WA")
      flag2++;
    else if (s.at(i) == "TLE")
      flag3++;
    else if (s.at(i) == "RE")
      flag4++;
  }

  cout << "AC x " << flag1 << endl;
  cout << "WA x " << flag2 << endl;
  cout << "TLE x " << flag3 << endl;
  cout << "RE x " << flag4 << endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

string akiba = "AKIHABARA";
set<string> st;
void rec(int index, string s)
{
  if (index == akiba.size()) {
    st.insert(s);
    return;
  }
  if (akiba[index] == 'A') {
    rec(index + 1, s);
  }
  rec(index+1, s + akiba[index]);
}
int main() {
  rec(0, "");
  // for (auto s : st)
  // {
  //   cout << s << endl;
  // }
  string s;
  while (cin >> s) {
    cout<< (st.count(s) != 0 ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      VEC(char,c,4);


      
      int memo;
      for(int bit = 0;bit < (1 << 4);bit++){
        int res = c[0]-'0';
        rep(i,3){
          if(bit & (1 << i))res += c[i+1]-'0';
          else res -= c[i+1]-'0'; 
        }

        if(res == 7){
          string ans(1,c[0]);
          rep(j,3){
            if(bit & (1<<j))ans += '+';
            else ans += '-';
            ans += c[j+1];
          }

          ans += "=7";
          cout << ans <<endl;
          return 0;
        }
      }

      

    }

    


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long int a,i,n,min=1000000,max=-1000000,sum=0;
	
	scanf("%d", &n);
	
	for(i=0;i<n;i++)
	{
		scanf("%ld ", &a);
		sum += a;
		
		if(a>max)
		{
			max=a;
		}
		if(a<min)
		{
			min=a;
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N,sum = 0,min = 2000000000,count = 0;
	cin >> N;

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

		if (a < 0) {
			count++;
		}

		CHMIN(min, abs(a));
		sum += abs(a);
	}

	if (count % 2 == 1)
		COUT(sum - 2 * min);
	else
		COUT(sum);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll S;

void solve() {
	cin >> S;
	ll y = 1000000000, x = 1;
	ll rx = (S + y - 1) / y;
	ll ry = rx * y - S;
	cout << 0 << " " << 0 << " " << x << " " << y << " " << rx << " " << ry << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main() {
	LL n, p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	LL ans = 1;
	for (LL i = 2; i * i <= p; i++) if (p % i == 0) {
		int cnt = 0;
		while (p % i == 0) {
			p /= i;
			cnt++;
		}
		for (int j = 1; j <= cnt / n; j++) ans *= i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(sorted(map(int, input().split())))
v.append(2000)
total = n*(n-1)*(n-2) / 6



def bs(left, s):
    right = n+1
    while left < right-1:
        m = (right+left)//2

        if v[m]>=s:
            right = m
        else:
            left = m
    return right






for i, x in enumerate(v[:-2]):
    for j, y in enumerate(v[i+1:-1]):
        k = bs(j+1, y+x)
        total -= (n-k)

print(int(total))

Measured memory_bytes: 47068
a = [int(input()) for i in range(4)]
count = 0

for i in range(a[0]+1) :
  for j in range(a[1]+1) :
    for k in range(a[2]+1) :
      sum = 500*i + 100*j + 50*k
      if sum == a[3] :
        count += 1
print(count)


Measured memory_bytes: 9124