akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b  freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
//const int X = 0x7f7f7f7f;
const double eps = 1e-4;
//////////////////////    Hi    ^_^  hack me if you can :P


int main()
{
    string s;
    cin>>s;
    s[5]=s[13]=' ';
    cout<<s;
}
/*

https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

class Solution
{
public:
    string odd_even(int a, int b)
    {
        int multi = a * b;
        string ans = (multi % 2 == 0) ? "Even" : "Odd";
        // return (multi % 2 == 0) ? "Even" : "Odd";
        return ans;
    }
};

int main()
{
    int a, b;
    cin >> a >> b;
    Solution s;
    cout << s.odd_even(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int K; cin >> K;
  string S; cin >> S;
  if(S.size()<=K){
    cout << S << endl;
  }else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 300005;
int n, a[MX], k, p[MX];
int st[4 * MX];

void build (int i, int j, int pos) {
	if (i == j) {
		p[i] = pos;
		return;
	}
	int m = (i + j) / 2;
	build(i, m, pos * 2);
	build(m + 1, j, pos * 2 + 1);
}

void update (int i, int k) {
	int pos = p[i];
	st[pos] = max(st[pos], k);
	pos /= 2;

	while (pos) {
		st[pos] = max(st[pos * 2], st[pos * 2 + 1]);
		pos /= 2;
	}
}

int query (int i, int j, int pos, int a, int b) {
	if (j < a || b < i) return 0;
	if (a <= i && j <= b) return st[pos];

	int m = (i + j) / 2;
	return max(
		query(i, m, pos * 2, a, b),
		query(m + 1, j, pos * 2 + 1, a, b)
	);
} 	

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	build(1, MX - 1, 1);

	cin >> n >> k;
	
	forn (i, n) {
		cin >> a[i];
		a[i]++;

		int mx = query(1, MX - 1, 1, max(a[i] - k, 1), min(a[i] + k, MX - 1)) + 1;
		update(a[i], mx);
	}

	cout << st[1] << endl;

	return 0;
}


Measured memory_bytes: 10096
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

int A,B;
  cin>>A>>B;
  int ans=(A+B)%24;
  cout<<ans<<endl;
  

  
  
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, i;
	int count = 1;

	scanf("%d %d", &a, &b);

	//電源タップと同数必要ならを出力する
	i = a;
	if (i == b) {
		printf("1\n");
		return 0;
	}

	if (b == a) //電源タップ一つで済む場合
	{
		printf("1\n");
		return 0;
	}
	else if (b == 1) //電源タップがいらない場合
	{
		printf("0\n");
		return 0;
	}

	//必要なタップ数をカウントする
	while (i < b)
	{
		i = i + (a - 1);
		count = count + 1;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define printDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

struct Flower
{
    int height;
    int beauty;
};

ll getBestOption(map<int,ll>& heightToBeauty, int height)
{
    auto it = heightToBeauty.lower_bound(height);
    if(it == heightToBeauty.begin())
        return 0;
    it--;
    return it->second;
}

void handleInsert(map<int,ll>& heightToBeauty, int height, ll beauty)
{
    heightToBeauty[height] = beauty;
    auto it = heightToBeauty.find(height);

    auto prev = it;
    auto next = it;
    prev--; next++;

    if(it != heightToBeauty.begin() && prev->second >= beauty)
    {
        heightToBeauty.erase(height);
        return;
    }

    while(next != heightToBeauty.end() && next->second <= it->second)
    {
            auto temp = next;
            temp++;
            heightToBeauty.erase(next->first);
            next = temp;
    }

}

ll solve(vector<Flower>& flowers)
{
    ll maxBeauty = flowers[0].beauty;
    map<int, ll> heightToBeauty;
    heightToBeauty[flowers[0].height] = flowers[0].beauty;

    for(int idx = 1; idx < flowers.size(); idx++)
    {
        ll beautyHere = flowers[idx].beauty + getBestOption(heightToBeauty,flowers[idx].height);
        maxBeauty = max(maxBeauty, beautyHere);
        handleInsert(heightToBeauty, flowers[idx].height, beautyHere);
    }

    return maxBeauty;
}

int main(){
    int n;
    cin>>n;
    vector<Flower> flowers(n);
    for(int i = 0 ; i < n; i++)
        cin>>flowers[i].height;
    for(int i = 0 ; i < n; i++)
        cin>>flowers[i].beauty;
    cout<<solve(flowers);
}


Measured memory_bytes: 14336
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())

ans = 0
for i in range(1,n+1):
    if i%2 != 0 and len(divisors(i)) == 8:
        ans += 1
print(ans)

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

int main() {
    int N;
    int A[220000];

    cin >> N;
    A[1] = 1;
    for (int i=2; i<=N; ++i) cin >> A[i];

    int B[N];
    for (int i=1; i<=N; ++i) {
        B[i] = 0;
    }
    for (int i=1; i<=N; ++i) {
        if (i != A[i]) B[A[i]] += 1;
    }
    for (int i=1; i<=N; ++i) {
        cout << B[i] << endl;
    }
}

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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const ll maxn = 2e5 + 10;
signed main(){
    db  x;
    cin >> x;
    db res = pow(x/3,3);
    cout << fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 256
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

print('Yes' if solve() else 'No')


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
    vector<int> a(4),b(4);
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
        int ans1=0,ans2=0;
        rep(i,0,4){
            rep(j,0,4){
                if(a[i]==b[j]){
                    if(i==j)ans1++;
                    else ans2++;
                }
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    
  
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
int h[125252];
ll dp[125252];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",h+i);
  fill(dp,dp+n,1ll<<60);
  dp[0] = 0;
  REP(i,n-1)FOR(j,i+1,i+k+1)if(j<n)CHMIN(dp[j],dp[i]+abs(h[i]-h[j]));
  printf("%lld\n",dp[n-1]);
  return 0;
}


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

map<vector<int>,int> mem;
int dfs(vector<int> &A){
  int n = A.size();  
  if(n<=1) return 0;
  if(mem.count(A)) return mem[A];
  
  int res = A.size()-1;
  for(int i=0;i<w;i++){
    vector<int> T,F;
    for(int j=0;j<n;j++) (A[j]>>i&1)? T.push_back(A[j]) : F.push_back(A[j]);
    if(T.empty() || F.empty()) continue;
    res = min(res,max(dfs(T),dfs(F))+1);
  } 
  return mem[A] = res;
}

int BtoI(string a){
  int res = 0;
  for(int i=0;i<(int)a.size();i++) res = res*2+a[i]-'0';
  return res;
}

int main(){

  while(1){
    int n;
    cin>>w>>n;
    if(w==0&&n==0)break;
    vector<int> A;
    A.resize(n);
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      A[i] = BtoI(s);
    }
    mem.clear();
    cout<<dfs(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5436
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = numeric_limits<ll>::min();
  ans = max(ans,a*c);
  ans = max(ans,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3676
import bisect

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0

for i in range(N-2) :
    for j in range(i+1,N-1) :
        a = L[i] + L[j]
        X =bisect.bisect_left(L,a)
        ans += X- j - 1
        
    
print(ans)

         


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  ll ans = 0;
  while (true) {
    bool ok = true;
    REP(i, n) {
      if (a[i] >= n) {
        ok = false;
      }
    }
    if (ok) {
      break;
    }
    ll s = 0;
    REP(i, n) { s += a[i] / n; }
    REP(i, n) {
      ll k = a[i] / n;
      a[i] += s - k - k * n;
    }
    ans += s;
  }
  cout << ans << endl;
}

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

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, K);

    int ans = 0;
    if ( K > 1 ) {
        ans = N - K;
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  for(int i=0;i<N;i++){
    cin >> c[i] >> t[i];
  }
  int highest=1000;
  for(int i=0;i<N;i++){
    if(highest > t[i]){
      highest=t[i];
    }
  }
  if(highest > T){
    cout << "TLE" << endl;
    return 0;
  }
  int lowest = 1000;
  for(int i=0;i<N;i++){
    if(t[i] <= T){
      if(lowest > c[i]){
        lowest = c[i];
      }
    }
  }
  cout << lowest << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:usize = read();
    let x:i32 = read();
    let l:Vec<i32> = (0..n).map(|_| read()).collect();

    let mut ans:i32 = 1;
    let mut d:i32 = 0;
    for i in 0..n {
        d += l[i];
        if d <= x {ans+=1}
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  cout << (A<=C && C<=B ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void merge(int * , int , int , int);
void mergeSort(int * , int , int);

int count = 0;

int main(){
  int S[1000000];
  int n,i;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ) {
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);

  for( i = 0 ; i < n ; i++ ) {
    if( i != n-1 ) {
      printf("%d ",S[i]);
    }

    else {
      printf("%d\n%d\n",S[i],count);
    }
  }
  
    return 0;
}

void merge(int *A, int left , int mid ,int right) {
  int n1,n2,i,j,k;
 
  n1 = mid - left;
  n2 = right - mid;
  
 int L[n1+1],R[n2+1];

 for( i = 0 ; i < n1 ; i++ ) {
    L[i] = A[left + i];
  }

  for( i = 0 ; i < n2 ; i++ ) {
    R[i] = A[mid + i];
  }

  L[n1] = 1000000000;
  R[n2] = 1000000000;

  i = 0;
  j = 0;

  for( k = left ; k < right ; k++ ) {
    count++;
    if( L[i] <= R[j] ) {
      A[k] = L[i];
      i += 1;
    }
    else {
      A[k] = R[j];
      j += 1;
    }
  }
}

  void mergeSort(int *A , int left, int right) {
    int mid;

    if( left + 1 < right ) {
      mid = ( left + right ) / 2;
      mergeSort(A,left,mid);
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
  }

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

int main(){
    int n, m; cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    for(int i=0; i<m; i++) cin >> p[i] >> s[i];

    int ac=0, pena=0;
    vector<int> wa(n);
    vector<bool> flg(n);
    for(int i=0; i<n; i++){
        flg[i] = false; wa[i]=0;
    }

    for(int i=0; i<m; i++){
        if(s[i]=="AC" && !flg[p[i]-1]){
            flg[p[i]-1] = true; ac++;
            pena += wa[p[i]-1];
        }
        if(s[i]=="WA" && !flg[p[i]-1]){
            wa[p[i]-1]++;
        }
    }
    printf("%d %d\n", ac, pena);
    return 0;
}

Measured memory_bytes: 7104
#include <iostream>
using namespace std;
 
int main(){
  
bool osou=false;
  int S,W;
  do{
cin>>S>>W;
  }while(0>S||0>W||S>100||W>100);
  
  if(S<=W){
    osou=true;
    cout<<"unsafe"<<endl;
  }
  if(!osou){
    cout<<"safe"<<endl;
  }
}

Measured memory_bytes: 3652
#include<stdio.h>

int mata[100][100],matb[100];

int main(void){
    int i,j,n,m,k;

    scanf("%d %d",&n,&m);
    for(i = 0;i < n;i++)
        for(j = 0;j < m;j++)
            scanf("%d",&mata[i][j]);
    for(i = 0;i < m;i++)
        scanf("%d",&matb[i]);

    for(i = 0;i < n;i++){
        k = 0;
        for(j = 0;j < m;j++)
            k += mata[i][j] * matb[j];
        printf("%d\n",k);
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


constexpr int b = 80 * 80 * 2 + 3;
constexpr int M = b * 2 + 3;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    cin >> A >> B;

    vector<vector<bitset<M>>> dp(H, vector<bitset<M>>(W));
    dp[0][0][b + A[0][0] - B[0][0]] = 1;
    REP(i, H) REP(j, W) {
        bitset<M> bs;
        if (i) bs |= dp[i - 1][j];
        if (j) bs |= dp[i][j - 1];
        int d = abs(A[i][j] - B[i][j]);
        dp[i][j] |= (bs << d) | (bs >> d);
    }
    int ret = M;
    REP(i, M) if (dp.back().back()[i]) ret = min(ret, abs(i - b));
    cout << ret << endl;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n';
//#define int ll
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e2 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;
const ll LOG = (ll) 25;


ll a[MAXN][MAXN];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll h, w;
	cin >> h >> w;
	ll l = 0, n, v;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> v;
		for(int j = 0; j< v; j++){
			a[l / w][l % w] = i;
			l++;
		}
	}
	for(int i = 0; i < h; i += 2){
		reverse(a[i], a[i] + w);
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++) cout << a[i][j] << " ";	
		cout << '\n';
	}
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s,t; cin >> s >> t;
    vec<int> si(26), ti(26);
    for(auto ch : s) {
        int i = ch - 'a';
        ++si[i];
        //debug(i);
    }
    for(auto ch : t) {
        int i = ch - 'a';
        ++ti[i];
    }
    sort(all(si));
    sort(all(ti));
    //for(auto i : si) debug(i);
    //for(auto t : ti) debug(t);
    if(si.size()!=ti.size()) {
        cout << "No" << '\n';
        return 0;
    }
    for(int i = 0; i < si.size(); ++i) {
        if(si[i]!=ti[i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int X, const set<int>& s)
{
    int ans = 0, dist = 300;

    for (int i = 0; i <= 101; ++i)
    {
        if (s.count(i))
            continue;

        if (abs(X - i) < dist)
        {
            ans = i;
            dist = abs(X - i);
        }
    }
        
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int X, N;
    cin >> X >> N;

    set<int> s;

    for (int i = 0; i < N; ++i)
    {
        int x;
        cin >> x;
        
        s.insert(x);
    }

    auto ans = solve(X, s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum,B[100001],l[100000],r[100000],Q;
LL ans;
LL no;
bool b,bb[100001];
string s,t;

int main() {
	cin >> N>>K>>Q;
	LL a[100000];
	for (int i = 1; i <= N; i++) {
		a[i] = 0;
	}
	for (int i = 0; i < Q; i++) {
		cin >> W;
		a[W]++;
	}
	for (int i = 1; i <= N; i++) {
		if (K - (Q - a[i]) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 1408
n=int(raw_input())
s=[int(raw_input()) for _ in xrange(n)]
dp=[[False]*(100*100+1) for _ in xrange(n+1)]
dp[0][0]=True
for i in xrange(n):
    for j in xrange(10000+1):
        if j>=s[i]:
            dp[i+1][j]|=dp[i][j-s[i]]
            dp[i+1][j]|=dp[i][j]
        else:
            dp[i+1][j]|=dp[i][j]
ans=0
for j in xrange(10000+1):
    if dp[n][j]:
        if j%10!=0:
            ans=j
print ans


Measured memory_bytes: 40556
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM = 
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	set<ll>RR,GG,BB;
	vector<ll>RR1,GG1,BB1;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			RR.insert(i);
			RR1.eb(i);
		}
		if(s[i]=='G')
		{
			GG.insert(i);
			GG1.eb(i);
		}
		if(s[i]=='B')
		{
			BB.insert(i);
			BB1.eb(i);
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			if(s[i]!=s[j])
			{
				set<char>wow;
				wow.insert('R');
				wow.insert('B');
				wow.insert('G');
				wow.erase(wow.find(s[i]));
				wow.erase(wow.find(s[j]));
				char hehe=*(wow.begin());
				if(hehe=='R')
				{
					ll val=RR1.end()-upper_bound(RR1.begin(),RR1.end(),j);
					ll del=j-i;
					if(RR.find(j+del)!=RR.end())
					{
						val--;
					}
					ans+=val;
				}
				else if(hehe=='G')
				{
					ll val=GG1.end()-upper_bound(GG1.begin(),GG1.end(),j);
					ll del=j-i;
					if(GG.find(j+del)!=GG.end())
					{
						val--;
					}
					ans+=val;
				}
				else
				{
					ll val=BB1.end()-upper_bound(BB1.begin(),BB1.end(),j);
					ll del=j-i;
					if(BB.find(j+del)!=BB.end())
					{
						val--;
					}
					ans+=val;
				}
			}
		}
	}
	cout<<ans;
    return 0;
}


//252908XL

/*
comments:-

*/


Measured memory_bytes: 3784
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>c+d) printf("Left");
    else if(a+b==c+d) printf("Balanced");
    else printf("Right");
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny")
  {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy")
  {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;


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

    vector<long long> fac(N+1);

    for(int i=1; i<=N; ++i)
    {
        for(int k=1; k*i<=N; ++k)
        {
            ++fac[k*i];
        }
    }

    long long ans = 0;
    for(int i=1; i<=N; ++i)
    {
        ans += fac[i] * i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 81404
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int n;

    scanf("%d", &n);

    long long a[n];

    for(int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }

    mergeSort(a, 0, n);

    long long min = 1000000000000;
    long long ans;

    for(int i = 0; i < n-1; i++){
        if(llabs(a[i] * 2 - a[n-1]) < min){
            min = llabs(a[i] * 2 - a[n-1]);
            ans = a[i];
        }
    }

    printf("%lld %lld\n", a[n-1], ans);

    return 0;
}

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    vll d(N); d[0] = abs(a[0]);
    ll sum = d[0];
    for(int i=1; i<N; i++){
        d[i] = abs(a[i] - a[i-1]);
        sum += d[i];
    }
    sum += abs(a[N-1]);
    cout << sum - d[0] - d[1] + abs(a[1]) << endl;
    for(int i=1; i<N-1; i++){
        cout << sum - d[i] - d[i+1] + abs(a[i+1] - a[i-1]) << endl;
    }
    cout << sum - d[N-1] - abs(a[N-1]) + abs(a[N-2]) << endl;
}

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

int same(char a[], char b[]);

int main(){
  int i,j,lent,lenw,en=0,count=0;
  char Tword[100],w[12];
  char e[12]="END_OF_TEXT";
  
  scanf("%s",w);
  for(i=0;i<strlen(w);i++){
  w[i]=toupper(w[i]);
  } 
  
  while(1){
  scanf("%s",Tword);
  en = same(Tword,e);
  if(en) break;
    for(i=0;i<strlen(Tword);i++){
  Tword[i]=toupper(Tword[i]);
  }
  //printf("%s\n",Tword);
  count += same(w,Tword);

  }

  printf("%d\n",count);
  
  return 0;
}

int same(char a[],char b[]){
	int j,lena,lenb;
	j=0;
	lena=strlen(a);
	lenb=strlen(b);
	if(lena==lenb){
     while(a[j]==b[j]){
      j++;
      if(j==lena)	return 1;
     }
  }
  return 0;
}

Measured memory_bytes: 548
w,h,n = map(int,input().split())
nums = [list(map(int,input().split())) for i in range(n)]
s = w*h
x1 = 0
x2 = w
y1 = 0
y2 = h
for num in nums:
    if num[2]==1 and x1<num[0]:
        x1 = num[0]
    elif num[2]==2 and x2>num[0]:
        x2 = num[0]
    elif num[2]==3 and y1<num[1]:
        y1 = num[1]
    elif num[2]==4 and y2>num[1]:
        y2 = num[1]
if x2<=x1 or y2<=y1:
    print(0)
else:
    print((x2-x1)*(y2-y1))


Measured memory_bytes: 3064
def is_kaibun(mojiretsu):
    half_point = len(mojiretsu)//2
    zenhan = mojiretsu[:half_point]
    if len(mojiretsu) % 2 == 1:
        kouhan = mojiretsu[half_point+1:]
    else:
        kouhan = mojiretsu[half_point:]

    if zenhan == kouhan[::-1]:
        return 'Yes'
    else:
        return 'No'


def strong_kaibun(mojiretsu):

    joken_1 = is_kaibun(mojiretsu)
    joken_2 = is_kaibun(mojiretsu[:((len(mojiretsu)-1)//2)])
    joken_3 = is_kaibun(mojiretsu[((len(mojiretsu)+3)//2)-1:])

    if joken_1 == 'Yes' and joken_2 == 'Yes' and joken_3 == 'Yes':
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    mojiretsu = input()
    print(strong_kaibun(mojiretsu))

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

long long backtrack(long long H){
    if(H == 1){
        return 1;
    }
    else{
        return 2*backtrack(H / 2) + 1;
    }
}

int main() {
    long long H;
    cin >> H;

    cout << backtrack(H) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cctype>
using namespace std;

typedef long long lli;

lli modPow(lli x, lli n, lli mod) {
  if(n == 0) return 1;
  lli tmp = modPow(x, n/2, mod);
  if(n % 2 == 0) return tmp*tmp % mod;
  else return tmp*tmp % mod * x % mod;
}


int pos;
string str;
lli P;

lli exp();
lli term();
lli fact();

lli exp() {
  lli x = term();
  while(1) {
    if(str[pos] == '+') {
      ++pos;
      x = (x + term()) % P;
    } else if(str[pos] == '-') {
      ++pos;
      x = x - term();
      while(x < 0) x += P;
      x %= P;
    } else {
      break;
    }
  }
  return x;
}

lli term() {
  lli x = fact();
  while(1) {
    if(str[pos] == '*') {
      ++pos;
      x = (x * fact()) % P;
    } else if(str[pos] == '/') {
      ++pos;
      lli y = fact();
      if(y == 0) throw "";
      lli d = modPow(y, P-2, P);
      x = (x * d) % P;
    } else {
      break;
    }
  }
  return x;
}

lli fact() {
  lli x = 0;
  if(str[pos] == '(') {
    ++pos;
    x = exp();
    ++pos;
  } else {
    string num = "";
    while(isdigit(str[pos])) {
      num += str[pos++];
    }
    x = atoll(num.c_str()) % P;
  }
  return x;
}

int main() {
  string line;
  while(getline(cin, line) && line != "0:") {
    int k = line.find(':');
    P = atoll(line.substr(0, k).c_str());
    string tmp = line.substr(k+1);
    str = "";
    for(int i = 0; i < tmp.size(); ++i) {
      if(tmp[i] == ' ') continue;
      str += tmp[i];
    }
    pos = 0;
    try {
      lli val = exp();
      cout << str << " = " << val << " (mod " << P << ")" << endl;
    } catch(const char *err) {
      cout << "NG" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1532
import bisect

N = int(input())
L = list(map(int, input().split(" ")))
L.sort() #小さい順
counter = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    index = bisect.bisect_left(L, L[i]+L[j], 0, N)
    counter = counter + index - j - 1
       
print(counter)

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

ll n;
ll ans = 0;

int f(ll x){
	ll m = n/x-1;
	if(m != 0) if(n/m == n%m) ans += m;
	return 0;
}

int main(){
	cin >> n;
	ll n_ya = n;//in
	for(ll i_ya = 1; i_ya * i_ya <= n_ya; i_ya++){
		if(n_ya % i_ya == 0){
			f(i_ya);
			if(i_ya != n_ya/i_ya){
				f(n_ya/i_ya);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> Paint;
int main(){
  int n;cin>>n;
  char mp[n][n];
  for(int i = 0; n > i; i++){
    for(int j = 0; n > j; j++){
      cin>>mp[i][j];
    }
  }
  int ans = -1;
  for(int i = 0; n > i; i++){
    int tmp[n];
    bool lock[n];
    for(int j = 0; n > j; j++)tmp[j] = -1,lock[j]=false;
    queue<Paint> z;
    z.push(make_pair(i,0));
    tmp[i]=0;lock[i]=true;
    bool tsumi = false;


    while(!z.empty() && !tsumi){


      for(int j = 0; n > j; j++){
        if(mp[z.front().first][j] == '1'){

          if(!lock[j]){
            if(!(z.front().second+1==tmp[j] || tmp[j]==-1)){
              tsumi = true;
              break;
            }else if(tmp[j]==-1){
              z.push(make_pair(j,z.front().second+1));
            }
          }
          tmp[j] = z.front().second+1;
        }
      }
      if(z.size()==1)ans = max(ans,z.front().second);
      lock[z.front().first]=true;
      z.pop();
      
    }
    while(!z.empty())z.pop();
  }
  cout << ans+(ans!=-1?1:0) << endl;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
without_x = s.reject { |c| c == "x" }
unless without_x == without_x.reverse
  puts -1
  exit
end
x_counts = []
current = 0
s.each do |c|
  if c == "x"
    current += 1
  else
    x_counts << current
    current = 0
  end
end
x_counts << current
x_counts_reverse = x_counts.reverse
ans = 0
x_counts.size.times do |i|
  ans += (x_counts[i] - x_counts_reverse[i]).abs
end
puts ans / 2


Measured memory_bytes: 25924
ns=gets.chomp.split("").map(&:to_i)
sum=0
i=0
flag=false
case ns.size
when 1
  puts ns[0]
else
  ns.each do |n|
    sum+=n-1 if i==0
    sum+=9 if i!=0
    flag=true if n!=9 && i!=0
    i+=1
  end
  puts sum if flag==true
  puts sum+1 if flag!=true
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

char c;

int main() {
  std::cin >> c;

  if ('A' <= c && c <= 'Z') {
    std::cout << "A" << std::endl;
  }
  else {
    std::cout << "a" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int k, t;
	cin >> k >> t;
	vector<int> a;
	if (t == 1) {
		cout << k - 1 << endl;
		return 0;
	}
	for (int i = 0;i < t;i++) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	
	sort(a.begin(), a.end(), greater<int>());
	int b=2*a[0]-k-1;
	if (b > 0) cout << b << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX_V 1010
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void init(){
  for(int i=0;i<MAX_V;i++){
    G[i].clear();
    used[i]=0;
  }
}

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int main(){
  int m,n;
  int b[500],r[500];
  while(cin>>m>>n,n){
    init();
    for(int i=0;i<m;i++)cin>>b[i],add_edge(1001,i,1);
    for(int i=0;i<n;i++)cin>>r[i],add_edge(i+500,1002,1);
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++){
	if(__gcd(b[i],r[j])>1){
	  add_edge(i,j+500,1);
	}
      }
    cout<<max_flow(1001,1002)<<endl;
  }
  return 0;
}



Measured memory_bytes: 9376
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
    int ans,n,r;
    cin >> n >> r;
    if(n >= 10){
      cout << r;
    }else{
      cout << r + (100*(10-n));
    }
    return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
human,check,result = [], [], []
flag = 10**9
n.times do
	human.push(gets.chomp.split(" ").map(&:to_i))
end

m.times do
	check.push(gets.chomp.split(" ").map(&:to_i))
end

for i in 0..n-1
	for j in 0..m-1
		kyori = (human[i][0] - check[j][0]).abs + (human[i][1] - check[j][1]).abs
		if flag > kyori
			flag = kyori
			result[i] = j+1
		end
	end
	flag = 10**9
end


puts result.join("\n")

Measured memory_bytes: 1916
from fractions import gcd
a,b=[int(i) for i in input().split()]

N=gcd(a,b)
res = set()
x = N
y = 2
while y*y <= x:
    while x % y == 0:
        res.add(y)
        x //= y
    y += 1
if x > 1:
    res.add(x)


print(len(res)+1)

Measured memory_bytes: 5048
def main():

    N = int(input())
    p = list(map(float, input().split()))

    dp = [[0 for _ in range(N+1)] for _ in range(N)]
    dp[0][0] = 1-p[0]
    dp[0][1] = p[0]
    for i in range(1, N):
        for j in range(i+2):
            if j == 0:
                dp[i][j] = dp[i-1][j] * (1-p[i])
            else:
                dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i]
    ans = 0
    for j in range((N+1)//2, N+1):
        ans += dp[N-1][j]
    return ans

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

Measured memory_bytes: 275848
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, X;
    in2(N, X);

    vi L(N);
    rep(i, N) in(L[i]);

    vi D(N + 1);
    rep(i, N) D[i + 1] = D[i] + L[i];

    int count = 0;
    rep(i, D.size())
    {
        if (D[i] <= X) count++;
    }

    outl(count);

    return 0;
}

Measured memory_bytes: 3556
chomp (my $n = <STDIN>);

my $ans = 0;
for my $i (1..$n) {
  my $c = 0;
  for my $j (1..$i) {
    $c++ if $i % (2 * $j - 1) == 0;
  }
  $ans++ if $c == 8;
}
print "$ans\n";

Measured memory_bytes: 512
def main():
    n, m = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(n)]
    count = 0
    data.sort(key=lambda x: x[0])
    ans = 0
    for i in range(n):
        if count + data[i][1] >= m:
            ans += data[i][0] * (m - count)
            break
        else:
            count += data[i][1]
            ans += data[i][0] * data[i][1]
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 29020