akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;

int r,c,m;
char ba[50][50];
map<pii, int> mp;

vector<int> dfsres;
bool visited[50][50];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
bool dfs(int y1, int x1, int y2, int x2) {
  visited[y1][x1] = 1;
  if (y1==y2 && x1==x2) return 1;
  REP(k,4) {
    int yy = y1+dy[k];
    int xx = x1+dx[k];

    if (yy<0||yy>=r||xx<0||xx>=c) continue;
    if (ba[yy][xx] == '.' && !visited[yy][xx]) {
      dfsres.push_back(mp[pii(yy,xx)]);
      if (dfs(yy,xx,y2,x2))
        return 1;
      dfsres.pop_back();
    }
  }
  return 0;
}

int main() {
  cin >> r >> c >> m;

  int ct = 0;
  REP(i,r) {
    REP(j,c) {
      cin >> ba[i][j];
      if (ba[i][j] == '.') {
        mp[pii(i,j)] = ct++;
      }
    }
  }
  int a[ct], b[ct], c1[ct];
  REP(i,r) {
    REP(j,c) {
      int x;
      cin >> x;
      if (mp.count(pii(i,j))) {
        a[mp[pii(i,j)]] = x;
      }
    }
  }
  REP(i,r) {
    REP(j,c) {
      int x;
      cin >> x;
      if (mp.count(pii(i,j))) {
        b[mp[pii(i,j)]] = x;
      }
    }
  }
  REP(i,r) {
    REP(j,c) {
      int x;
      cin >> x;
      if (mp.count(pii(i,j))) {
        c1[mp[pii(i,j)]] = x;
      }
    }
  }
  vector<int> root;
  int maey, maex;
  REP(i,m) {
    int y,x;
    cin >> y >> x;
    if (i == 0) {
      root.push_back(mp[pii(y,x)]);
    } else {
      if (maey==y&&maex==x) {
        root.push_back(mp[pii(y,x)]);
      }
      memset(visited,0,sizeof(visited));
      dfsres.clear();
      dfs(maey, maex, y, x);
      FOR(it, dfsres) {
//        cout << *it << " ";
        root.push_back(*it);
      }
//      cout << endl;
    }
    maey = y; maex = x;
  }
  
  
  // cout << "root" << endl;
  // FOR(it, root)
  //   cout << *it << " ";
  // cout << endl;
  vector<int> v[ct];


  int mae[ct];
  memset(mae,-1,sizeof(mae));
  REP(i, root.size()) {
    int id = root[i];
    if (mae[id] != -1) {
      v[id].push_back(i-mae[id]);
    }
    mae[id] = i;
  }

    
  long long res = 0;
  REP(i,ct) {
    bool on = 0;
//    cout << "i = " << i << endl;
    REP(j, v[i].size()) {
      int mean = v[i][j];
//      cout << v[i][j] << " ";
      if (!on) {
        res += b[i]; 
      }
      if (a[i]*mean < b[i]+c1[i]) {
        on = 1;
        res += a[i]*mean;
      } else {
        res += c1[i];
        on = 0;
      }
    }
//    cout << endl;
    if (mae[i] != -1) {
      if (!on) {
        res += b[i] + c1[i];
      } else
        res += c1[i];
    }
    //cout << "res = " << res << endl;
  }
  cout << res << endl;
}

Measured memory_bytes: 10000
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

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

void getZarr(string& str, int Z[]) {
  int n = str.length();
  int L, R, k;

  L = R = 0;
  for (int i = 1; i < n; ++i) {
    if (i > R) {
      L = R = i;
      while (R < n && str[R - L] == str[R]) {
        R++;
      }
      Z[i] = R - L;
      R--;
    } else {
      k = i - L;

      if (Z[k] < R - i + 1) {
        Z[i] = Z[k];
      } else {
        L = i;
        while (R < n && str[R - L] == str[R]) {
          R++;
        }
        Z[i] = R - L;
        R--;
      }
    }
  }
}


void search(string& text, string& pattern, vector<int> *result) {
  string s = pattern + "$" + text;
  int l = s.length();

  int Z[l];
  getZarr(s, Z);

  int p = pattern.length();

  vector<int> res;
  for (int i = 0; i < l; ++i) {
    if (Z[i] == p) {
      result->push_back(i - p - 1);
    }
  }
}

int sch(int i, int stop, const string& s, const string& t, vector<int>& vm) {
  int j = (i + t.size()) % s.size();  // The dst of next hop.
  if (j == stop) { return -1; }  // Loop exists

  if (vm[j] < 0) { // s[j..?] matches with t
    if (sch(j, stop, s, t, vm) < 0) {
      return -1;
    }
  }
  // By calling sch, now, the positive value is set to vm[j].

  vm[i] = vm[j] + 1;
  return vm[i];
}

int main(int argc, char** argv) {
  string s, t;
  cin >> s;
  cin >> t;

  int l = s.size();

  // repeat count
  int r = 1 + ((s.size() - 1 + t.size()) / s.size());
  string reps;
  reps.reserve(r * s.size());
  rep(i, r) {
    reps += s;
  }

  // For Debug
  // cout << reps << endl;

  vector<int> matches;
  search(reps, t, &matches);

  vector<int> vm(s.size());

  for (auto i : matches) {
    if (i >= s.size()) { break; }  // Treat only i <= s.size() - 1
    vm[i] = - 1;
  }

  int loopExists = false;
  int maxSize = 0;
  for (auto i : matches) {
    if (i >= s.size()) { break; }  // Treat only i <= s.size() - 1
    int x = sch(i, i, s, t, vm);
    if (x == -1) { // There is loop
      loopExists = true;
      break;
    }
    maxSize = max(maxSize, x);
  }

  if (loopExists) {
    cout << -1 << endl;
  } else {
    cout << maxSize << endl;
  }

  // int l = s.size();
  // vector<int> vec;
  // search(s, t, &vec);
  // for (auto e : vec) {
  //   cout << e << endl;
  // }

  // cout << s << endl;
  // cout << t << endl;
}


Measured memory_bytes: 24172
import bisect
A, B, Q = map(int,input().split())
S = [-float("inf")] + sorted([int(input()) for k in range(A)]) + [float("inf")]
T = [-float("inf")] + sorted([int(input()) for k in range(B)]) + [float("inf")]
X = [int(input()) for k in range(Q)]

for x in X:
    p = bisect.bisect_left(S,x)
    q = bisect.bisect_left(T,x)
    t1 = max(abs(S[p]-x),abs(T[q]-x))
    t2 = max(abs(S[p-1]-x),abs(T[q-1]-x))
    t3 = abs(S[p-1]-x)+abs(S[p-1]-T[q])
    t4 = abs(T[q-1]-x)+abs(S[p]-T[q-1])    
    t5 = abs(S[p]-x)+abs(S[p]-T[q-1])    
    t6 = abs(T[q]-x)+abs(S[p-1]-T[q])
    print(min(t1,t2,t3,t4,t5,t6))

Measured memory_bytes: 16752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

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


const int N = 1111111;
bool prime[N + 1];
vector<int> primes;

void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for (int i = 2; i*i < N; i++)
	{
		if (!prime[i]) continue;
		for (int j = i; i*j < N; j++)
		{
			prime[i*j] = false;
		}
	}
	REP(i, N + 1)
	{
		if (prime[i]) primes.push_back(i);
	}
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	hurui();
	ll a, b;
	cin >> a >> b;
	ll g = b / gcd(a, b);
	ll t = g;
	set<int> st;
	for (auto p : primes)
	{
		if (p > sqrt(g)) break;
		if (t % p == 0) st.insert(p);
		while (t % p == 0) t /= p;
	}
	st.insert(t);
	ll ans = 1;
	for (auto i : st) ans *= i;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	string S;
	cin >> S;

	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	int num = 0;
	int c_site;
	for (int i = 2; i < S.length() - 1; i++) {
		if (S[i] == 'C') {
			c_site = i;
			num++;
		}
	}
	if (num != 1) {
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 1; i < S.length(); i++) {
		if (i == c_site) {
			continue;
		}
		if (S[i] >= 'A' && S[i] <= 'Z') {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;

	return 0;
}

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

int main(){
	int in;
	while (cin >> in, !cin.eof()){
		int ans = 0;
		for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
		for (int k = 0; k < 10; k++)
		for (int l = 0; l < 10; l++)
		if (i + j + k + l == in)	ans++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= (int)(1e19+10LL);
void solve()
{
  int a,b,x;
  sl(a);sl(b);sl(x);
  int cnt=b/x-a/x;
  if(a%x==0){
	  cout<<cnt+1<<endl;
	  return;
  }
  cout<<cnt<<endl;

		
}
 
signed main(){
   int test=1;
  // sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int n;
    while(scanf("%d", &n) != EOF) {
        if (n % 39 > 9) {
            printf("3C%d\n", n % 39);
        } else if (n % 39 > 0) {
            printf("3C0%d\n", n % 39);
        } else {
            puts("3C39");
        }
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	ll n,W;
	cin >> n >> W;
	ll weight[n];
	ll val[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> val[i];
	}
	ll dp[n+1][W+1];
	mem(dp,0);
	for(int i=1;i<n+1;i++){
		for(int j=1;j<W+1;j++){
			if(weight[i-1]<=j){
				dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-weight[i-1]]);
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}

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

int main()
{
	string S;
	int ans = 0;
	cin >> S;

	if (S == "SUN") ans = 7;
	else if (S == "MON") ans = 6;
	else if (S == "TUE") ans = 5;
	else if (S == "WED") ans = 4;
	else if (S == "THU") ans = 3;
	else if (S == "FRI") ans = 2;
	else if (S == "SAT") ans = 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, m: usize,
        s: [[usize1]; m],
        p: [i32; m],
    }
    let mut ans = 0;
    for bits in 0..1 << n {
        let mut ok = true;
        for i in 0..m {
            let s = &s[i];
            let mut sum = 0;
            for &p in s {
                if (bits & 1 << p) != 0 {
                    sum ^= 1;
                }
            }
            if sum != p[i] { ok = false; }
        }
        if ok { ans += 1; }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {
  int time[5];
  for (auto &v : time) cin >> v;
  int ans = 0, tmp = 0;
  for (auto &v : time) {
    ans += (v-1)/10 + 1;
    v %= 10;
    if (v) tmp = max(tmp, 10-v);
  }
  cout << ans*10 - tmp << endl;
}


Measured memory_bytes: 256
def num_alpha(num):
    if num <= 26:
        return chr(64 + num)
    elif num%26 ==0 :
        return num_alpha(num//26-1) + chr(90)
    else:
        return num_alpha(num//26) + chr(64 + num%26)
n = int(input())
print(num_alpha(n).lower())


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main(){
  long h;
  long n;
  cin>>h>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long hit=0;
  bool ans=false;
  for(int i=0;i<n;i++){
    hit+=a[i];
    if(hit>=h){
      ans=true;
      break;
    }
  }
  if(ans==true)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  
}


Measured memory_bytes: 640
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
h,w=map(int,input().split())
n=10
d = [list(map(int,input().split())) for i in range(n)] 
wf=warshall_floyd(d)
ans=0
for i in range(h):
    l=map(int,input().split())
    for j in l:
        if j!=-1:ans+=wf[j][1]
print(ans)

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

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


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
typedef long double ld;
const ld eps = 1e-8;
#define rep(i,n) for(int i=0;i<n;i++)
#define stop char nyaa;cin>>nyaa;
int main(){
	int a[3];
	rep(i, 3)cin >> a[i];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

vvll mem;
int ng = 0;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, x, y, z; cin >> n >> x >> y >> z;

  ll MAX = 1ll << (x + y + z - 1);

  const ll NG_BITS = (1ll<<(x+y+z-1)) | (1ll<<(y+z-1)) | (1ll<<(z-1));

  vvll dp(n+1, vll(MAX, 0));
  dp[0][0] = 1;

  for(int i=0;i<n;++i) {
    for(ll j=1;j<=10;++j) {
      for(ll k=0;k<MAX;++k) {
        ll t = (k << j) | (1ll << (j - 1));

        if((NG_BITS & t) != NG_BITS) {
          t &= (MAX - 1);
          dp[i+1][t] += dp[i][k];
          dp[i+1][t] %= MOD;
        }
      }
    }
  }

  ll ans = 1;
  for(int i=0;i<n;++i) {
    ans *= 10;
    ans %= MOD;
  }

  for(int i=0;i<MAX;++i) {
    ans += MOD - dp[n][i];
    ans %= MOD;
  }
  cout << ans << endl;


}


Measured memory_bytes: 21888
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> a(N * 3);
	rep(i, N * 3) scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, N) ans += a[N + i * 2];
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int coin[4] = {1,5,10,50};
int main(void){
  int money;
  int oturi[2000];
  REP(i,2000){
    int o = 0;
    int m = i;
    REP(j,4){
      o += m/coin[3-j];
      m %= coin[3-j];
    }
    oturi[i] = o;
  }
  bool f= false;
  while(cin>>money,money){
    if(f)cout<<endl;
    else f = true;
    money/=10;
    int k[4];
    int ans[4];
    int mina=(int)1e8;
    REP(i,4)cin>>k[i];
    REP(a,21)REP(b,21)REP(c,21)REP(d,21){
      if(a>k[0]||b>k[1]||c>k[2]||d>k[3]) continue;
      int count = a+b+c+d;
      int sum = a+5*b+10*c+50*d;
      if(sum<money)continue;
      int answer = -count+oturi[sum-money];
      if(mina>answer){
        mina = answer;
        ans[0] = a;
        ans[1] = b;
        ans[2] = c;
        ans[3] = d;
      }
    }
    REP(i,4){
      if(ans[i]){
        printf("%d %d\n",coin[i]*10,ans[i]);
      }
    }
  }

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

bool a[1010][1010];
ll dp[1010][1010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 1010)REP(j, 1010) dp[i][j] = 0;
    dp[0][0] = 1;

    ll H, W;
    cin >> H >> W;

    REP(i, H){
    	string s;
    	cin >> s;
    	REP(j, W){
    		a[i][j] = (s[j] == '#');
    	}
    }

    REP(i, H){
    	REP(j, W){
    		if(a[i][j]) continue;
    		dp[i+1][j] += dp[i][j];
    		dp[i+1][j] %= mod;
    		dp[i][j+1] += dp[i][j];
    		dp[i][j+1] %= mod;
    	}
    }
    /*
    REP(i, H){
    	REP(j, W){
     		cout << dp[i][j] << " ";
    	}
    	cout << endl;
    }
    */
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 9216
S = input()
AKBList = ["AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA",
           "AKIHABR", "AKIHBRA", "KIHBARA", "AKIHBAR", "KIHABRA", "KIHABAR",
           "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR"]
if S in AKBList:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38384
#include<stdio.h>
int Euclid(long int c, long int d){
  long int tmp;
  if(c<d){
    tmp=c;
    c=d;
    d=tmp;
  }
  long int r=c%d;
  while(r!=0){
  c=d;
  d=r;
  r=c%d;
  }
  return d;
}
int main(){
  long int a, b, c, d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
  long int r, div;
  r=Euclid(c,d);
  div=c*d/r;
  long int n=b-b/c-b/d+b/div-(a-1-(a-1)/c-(a-1)/d+(a-1)/div);
  printf("%ld", n);
  return 0;
}

Measured memory_bytes: 128
int main()
{
  char s[11];
  scanf("%s", s);
  int i, num, min = 1000, tmp;
  for (i = 0; s[i + 2] != '\0'; i++)
  {
    num = 100 * ((int)(s[i] - '0')) + 10 * ((int)(s[i + 1] - '0')) + ((int)(s[i + 2] - '0'));
    if (num >= 753)
      tmp = num - 753;
    else
      tmp = 753 - num;
    if (tmp < min)
      min = tmp;
  }
  printf("%d", min);
}

Measured memory_bytes: 1728
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);

        int N = Integer.valueOf(s.next());
        //int K = Integer.valueOf(s.next());
        //int k = K-1;
        int hoge = N % 1000;
        if(hoge != 0){
            hoge = 1000- hoge;
        }

        System.out.println(hoge);
        //部下持ち数
        /* int hoge=N-K+2;
		for(int i = K; i <= N+1; i++) {
            for(int i2 =0; i2<= i-1;i2++){
                hoge += N-(2*i2);50
            }
        } */

        

    }
}
    

Measured memory_bytes: 35516
n, p = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 1

for i, e in enumerate(a, 1):
    if e % 2:
        dp[i][0] = dp[i-1][0] + dp[i-1][1]
        dp[i][1] = dp[i-1][1] + dp[i-1][0]
    else:
        dp[i][0] = dp[i-1][0] * 2
        dp[i][1] = dp[i-1][1] * 2

print(dp[n][p])


Measured memory_bytes: 3064
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, m = I()
cities = UnionFind(n)
for _ in range(m):
  a, b = I()
  cities.union(a-1, b-1)

print(cities.group_count() - 1)


Measured memory_bytes: 75100
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define N 1001
#define HP 30020

using namespace std;
// input
ll h,n;
ll a[N],b[N];
ll memo[HP];

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

  rep(i,HP) memo[i] = -1;
  
  cin >> h >> n;
  rep(i,n) {
    cin >> a[i] >> b[i];
    if(memo[a[i]] > b[i] || memo[a[i]] == -1)
      memo[a[i]] = b[i];
  }

  rep(i,HP) {
    if(memo[i] == -1 || i >= h) continue;
    rep(j,n) {
      int mp = memo[i] + b[j];
      int damage = i + a[j];
      if(memo[damage] > mp || memo[damage] == -1)
        memo[damage] = mp;
    }
  }

  ll ans = 10000000000;
  for(int i = h;i < HP;i++) { 
    if(i >= h && memo[i] != -1) {
      ans = min(ans,memo[i]);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<string> s(n);
  for(int i=0;i<n;i++)
    cin >> s.at(i);
  sort(s.begin(),s.end());
  
  int count=1;
  for(int j=1;j<n;j++){
    count++;
    if(s.at(j)==s.at(j-1))
      count--;
  }
  cout << count << endl;
}


Measured memory_bytes: 9600
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

#ifdef LOCAL
#define cerr cout
#else
#endif
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int mod = 1e9 + 7;
const int N = 4e5 + 5;

int a[N];
 
inline void solve() {
  int x(0), s(0);
   rep(i,1,3)cin >> x, s+=x;
   cout << ((s<22)?"win":"bust");
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL); 
  //int t = 1;cin >> t; while(t--)
  solve();
  E;
  return 0;
}

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

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (auto &x : A) {
        cin >> x;
        x--;
    }

    ll s;
    vector<int> used(N, 0);
    ll pnt = 0;
    while (!used.at(pnt)) {
        used.at(pnt) = 1;
        pnt = A.at(pnt);
    }
    s = pnt;
    pnt = 0;
    ll tos = 0;
    vector<ll> U;
    while (pnt != s) {
        U.push_back(pnt);
        pnt = A.at(pnt);
        tos++;
    }
    vector<ll> V;
    V.push_back(s);
    pnt = s;
    while (A.at(pnt) != s) {
        V.push_back(A.at(pnt));
        pnt = A.at(pnt);
    }
    ll len = V.size();

    if (K < tos) {
        cout << U.at(K) + 1 << endl;
    } else {
        cout << V.at((K - tos) % len) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 7676
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	double []hairetu1=new double[N];
	String []hairetu2=new String[N];
	double sum =0;
	for(int i=0;i<N;i++){
		hairetu1[i]=sc.nextDouble();
		hairetu2[i]=sc.next();
		
		if("JPY".equals(hairetu2[i])){
			sum=sum+hairetu1[i];
		}
		else if("BTC".equals(hairetu2[i])){
			sum=sum+hairetu1[i]*380000;
		}
	}
	System.out.println(sum);
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    LL n,m;cin >> n >> m;
    vector<LL> a(n),b(m),c(m);
    map<LL,LL> ma;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i] >> c[i];
        ma[c[i]]+=b[i];
    }
    LL ans=0,k=n;
    for(auto p = ma.rbegin();p!=ma.rend();p++){
        if(k<=p->second){
            ans+=k*p->first;
            break;
        }
        else{
            ans+=p->first*p->second;
            k-=p->second;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define pb push_back

using namespace std;

const int MAXN = 3e4 + 10;

int a[MAXN];

vector<int> adj[MAXN];

bool dfs(int u) {
	for (int v : adj[u]) {
		if (a[v] < a[u] && !dfs(v))
			return true;
	}
	return false;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for (int i = 0; i < n; i++) {
		if (dfs(i))
			cout << i + 1 << " ";
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,arr[100009][3];
int dp[100009][3];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>arr[i][j];
		}
	}
	for(int i=0;i<3;i++) dp[0][i] = arr[0][i];
	for(int i=1;i<n;i++){
		dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
	}
	int mx = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<mx<<endl;
}


Measured memory_bytes: 2560
#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()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n, k;
  cin >> n >> k;
  int res = 1;
  for (int i = 0; i < n; i++)
  {
    if(res > k) res += k;
    else res *= 2;
  }
  cout << res << endl;

}

Measured memory_bytes: 256
import sys

a = raw_input()
b = raw_input()
c = raw_input()

n = {}

n['a'] = [i for i in a]
n['b'] = [i for i in b]
n['c'] = [i for i in c]

def p(s,people):
#    print n['a']
#    print n['b']
#    print n['c']
    if(len(s)==0): 
       print people.upper()
       return

    ret = n[people][0]
#    print ret
    s.pop(0)
#    print "remove",ret,"from",people
    p(n[ret],ret)


p(n['a'],'a')

Measured memory_bytes: 2820
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
const char l[10]={'p','p','h','b','h','h','p','h','p','h'};
int n;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	cout<<l[n%10]<<"on"<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<iostream>
#include <iomanip>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod  100000007
long double dp[3000][3000];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    long double a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
        dp[i][j]=0.0;
    //dp[0][0]=1.0;
    dp[1][0]=1-a[0];
    dp[1][1]=a[0];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==i) dp[i][j]+=(dp[i-1][j-1]*a[i-1]);
            else if(j>0)dp[i][j]+=(dp[i-1][j-1]*a[i-1])+(dp[i-1][j]*(1-a[i-1]));
            else dp[i][j]+=(dp[i-1][j]*(1-a[i-1]));
        }
    }
    long double sum=0.0;
    for(int i=(n/2)+1;i<=n;i++)
        sum+=dp[n][i];
cout<<setprecision(10)<<sum;
}


Measured memory_bytes: 140928
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * if you are interested in the reference code here,
 * see https://github.com/georeth/OJLIBS for more information
 *
 * Solution Author : Georeth Chow <georeth2010@gmail.com>
 */
#include <cstdio>
#include <cmath>
#include <climits>      // INT_MIN LLONG_MIN
#include <cfloat>       // DBL_MIN DBL_MAX
#include <cstring>      // memset
#include <cstdlib>      // malloc
#include <cstdint>      // int64_t
#include <cinttypes>    // PRId64 SCNd64
#include <cassert>      // assert
#include <limits>       // numeric_limits
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <tuple>        // pair, tuple
#include <iostream>     // be careful.
                        // mix with cstdio: slowwww...
                        // mix with cstdio + fastio: bug
#include <sstream>
#include <algorithm>
using namespace std;    // use as solution header. name polution is fine.
#ifdef LOCAL_JUDGE
#  define pr_debug(...) fprintf(stderr, __VA_ARGS__)
#  define pr_line() fprintf(stderr, "%s: %d\n", __FILE__, __LINE__)
#else
#  define pr_debug(...)
#  define pr_line()
#endif
template <typename T>
bool chmax(T &m, const T &v) { if (v > m) return m = v, true; return false; }
template <typename T>
bool chmin(T &m, const T &v) { if (v < m) return m = v, true; return false; }
static const int HMAX32 = INT32_MAX / 2;
static const int HMIN32 = -HMAX32;
static const int64_t HMAX64 = INT64_MAX / 2;
static const int64_t HMIN64 = -HMAX64;
void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
#define read_int(id) scanf("%d", &id)
#define read_int64(id) scanf("%" PRId64, &id)
#define new_int(id) int id; read_int(id)
#define new_int64(id) int64_t id; read_int64(id)
#define ALL(x) begin(x), end(x)
/* =====  SOLUTION START  ===== */
int main() {
    string s;
    cin >> s;
    vector<bool> visit(260);
    for (char c : s) {
        visit[c - 'a'] = true;
    }
    for (int i = 0; i < 26; ++i) {
        if (!visit[i]) {
            printf("%c\n", 'a' + i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a = 0;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    a += r - l + 1;
  }
  cout << a << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


signed main(){
	int N;cin>>N;
	vint X(N),Y(N);
	rep(i,N)cin>>X[i]>>Y[i];

	auto f=[&](int i,int j)->double{
		return sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
	};

	vint ord(N);iota(all(ord),0);
	double sum=0;
	do{
		rep(i,N-1)sum+=f(ord[i],ord[i+1]);
	}while(next_permutation(all(ord)));
	rep(i,N)sum/=i+1;
	printf("%.20f\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the set
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map< string,set<pair<ll,ll> > > mmap;
    ll n;
    cin>>n;
    string str[n],temp;
    for(int i=0;i<n;i++)
    {
        string s;
        ll l;
        cin>>s>>l;
        mmap[s].insert(mp(l,i));
        str[i]=s;
    } 
    for(int i = 0; i < n-1; ++i)
       for( int j = i+1; j < n; ++j)
       {
          if(str[i] > str[j])
          {
            temp = str[i];
            str[i] = str[j];
            str[j] = temp;
          }
    }
   // map< string,set<pair<ll,ll> > >::iterator itr;
    set< pair<ll,ll> >::iterator itr;
    for(int i=0;i<n;i++)
    {
        itr=mmap[str[i]].end();
        itr--;
        cout<<itr->second+1<<endl;
        mmap[str[i]].erase(itr);
    }
   // cout<<endl;
}

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

void solve()
{
	int n;
	cin>>n;
	set<string>items;
	for(int i=0;i<n;++i){
		string item;
		cin>>item;
		items.insert(item);
	}
	cout<<items.size();
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 19232
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    map<int, int> wa;
    set<int> ac;
    int pena = 0;
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            if(ac.find(p) != ac.end()) continue;
            pena += wa[p];
            ac.insert(p);
        }
        else{
            wa[p]++;
        }
    }
    cout << ac.size() << " " << pena << endl;
    return 0;
}


Measured memory_bytes: 12844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("?")) {
                break;
            } else if (op.equals("+")) {
                System.out.println(a + b);
            } else if (op.equals("-")) {
                System.out.println(a - b);
            } else if (op.equals("*")) {
                System.out.println(a * b);
            } else {
                System.out.println(a / b);
            }
        }
    }
}

Measured memory_bytes: 26076
#include <iostream>
#include <algorithm>
using namespace std;
    
int main(){
	int data,m[10];

	
	for (int j=0;j<=9;j++){
			while(cin >> data){
			if (data<=10000 && data >= 0 ) {
			m[j]=data;
			break;
		}
			}
	}

for (int i=0;i<=8;i++){

	if (m[i] < m[i+1]){
		swap(m[i],m[i+1]);
	for (int j=i;j>0;j--){
	if (m[j] > m[j-1])
		swap(m[j],m[j-1]);
	}
	}
}


 
for (int i=0;i<=2;i++){
cout <<  m[i] <<'\n';
}

    return 0;
}

Measured memory_bytes: 1164
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1

print(cnt)

Measured memory_bytes: 39892
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll ans=0;
  rep(i,s.size()){
    ll tmp=0;
    for(ll j=i;j<s.size();j++){
      if(s[j]=='A' || s[j]=='G' || s[j]=='C' || s[j]=='T'){
        tmp++;
      }else{
        break;
      }
    }
    chmax(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      
      // 操作
      int len = S.length();
      int count = 0;
      for(int i = 0; i < len; i++){
        if(S.charAt(i) != T.charAt(i)){
          count++;
        }
      }
      
      // 出力
      System.out.println(count);
    }
    

}

Measured memory_bytes: 41128
N = int(input())
c = input()

right = N - 1
left = 0
ans = 0
flag = False

while True:
  if c[right]=='W':
    if (right>=1)and(right>left+1):
      right -= 1
      continue
    else:
      break
    
  else:
    while True:
      if c[left]=='R':
        if (left<N)and(left<right-1):
          left += 1
          continue
        else:
          flag = True
          break
        
      else:
        ans += 1
        left += 1
        right -= 1
        break
    if flag:
      break
      
print(ans)

Measured memory_bytes: 73112
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

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

  string s, t; cin >> s >> t;
  REP(i, s.length()) {
    string temp;
    FOR(j, i, s.length()) temp += s[j];
    REP(j, i) temp += s[j];
    if (temp == t) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  string s = "";
  rep(i,ty-sy)s.push_back('U');
  rep(i,tx-sx)s.push_back('R');
  s.push_back('U');
  rep(i,tx-sx+1)s.push_back('L');
  rep(i,ty-sy+1)s.push_back('D');
  s.push_back('R');
  rep(i,tx-sx)s.push_back('R');
  rep(i,ty-sy)s.push_back('U');
  s.push_back('R');
  rep(i,ty-sy+1)s.push_back('D');
  rep(i,tx-sx+1)s.push_back('L');
  s.push_back('U');
  cout << s << endl;
  
}




Measured memory_bytes: 256
K = int(input())
A,B = map(int,input().split())
ans = 'NG'
if A % K == 0:
    ans = 'OK'
elif B % K == 0:
    ans = 'OK'
x = A // K
y = B // K
if y > x:
    ans = 'OK'
print(ans)


Measured memory_bytes: 9172
#include<stdio.h>

int main (){
	int A, B;
	A=1; 
	A=2; 
	A=3;
	
	B=1; 
	B=2; 
	B=3;
	
	scanf ("%d",&A);
	getchar ();
	scanf ("%d",&B);
	
	if (A==1 && B==2){
		printf ("3\n");
		
		}else if (A==2 && B==1){
		printf ("3\n");
		
		}else if (A==1 && B==3){
		printf ("2\n");
		
		}else if (A==3 && B==1){
		printf ("2\n");
		
		}else if (A==2 && B==3){
		printf ("1\n");
			
		}else {
		printf ("1\n");
	}
	return 0;
}

Measured memory_bytes: 3144
n,h=map(int, input().split())
w=[]
for i in range(n):
    a,b=map(int, input().split())
    w.append([a,b])
w.sort(key=lambda x:x[0],reverse=True)
m=w[0][0]
w.sort(key=lambda x:x[1],reverse=True)

count=0
for i in range(n):
    if w[i][1]>=m:
        count+=1
        h -= w[i][1]
        
    if h<=0:
        print(count)
        break
else:
    print(count+(h+m-1)//m)

Measured memory_bytes: 21188