akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int H, W; cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    rep(i, 0, H) {
        rep(j, 0, W) cin >> S[i][j];
    }
    rep(i, 0, (W+2)) cout << "#";
    cout << endl;
    rep(i, 0, H) {
        cout << "#";
        rep(j, 0, W) cout << S[i][j];
        cout << "#";
        cout << endl;
    }
    rep(i, 0, (W+2)) cout << "#";
    cout << endl;
    return 0;
}

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

int main() {
  int N,a1,a2,a3,a4;
  cin >> N;
  
  a1=N%10;
  a2=(N-a1)/10%10;
  a3=(N-a1-a2*10)/100%10;
  a4=(N-a1-a2*10-a3*100)/1000%10;

  if ((a1==a2 && a1==a3) || (a2==a3 && a2==a4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=45;
typedef long long LL;
LL dp[maxn][1<<18];
int n,x,y,z;
int main() {
    scanf("%d%d%d%d",&n,&x,&y,&z);
    int tmp=x+y+z-1;
    LL mask=(1<<tmp)-1;
    LL limit=1<<tmp;
    LL no=(1<<(x+y+z-1)) | (1<<(y+z-1)) | (1<<(z-1));
    dp[0][0]=1;
    for (int i=0;i<n;i++) {
        for (int j=0;j<limit;j++) {
            for (int k=1;k<=10;k++) {
                LL t=(j<<k) | (1<<(k-1));
                if ((no&t)==no) continue;
                dp[i+1][t&mask]=(dp[i+1][t&mask]+dp[i][j])%mod;
            }
        }
    }
    LL ans=1;
    for (int i=1;i<=n;i++) ans=ans*10%mod;
    for (int i=0;i<limit;i++) ans-=dp[n][i];
    printf("%lld\n", (ans%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 82048
n,m,q = map(int,input().split())
xy = []
for _ in range(q):
  a,b,c,d = map(int,input().split())
  a = n-a
  b = n-b
  xy.append([a,b,c,d])
time = [0 for _ in range(n)]
def nex(time):
  cnt = 0
  for d in range(n):
    if time[d] == m-1:
      cnt += 1
    else:
      break
  if cnt == n:
    return 'over'
  else:
    se = time[cnt] + 1
  for d in range(cnt):
    time[d] = se
  time[cnt] += 1
  return time
can = []
while time != 'over':
  tmp = 0
  #print(time)
  for x in xy:
    a,b,c,d = x
    #print(time,a,b,time[a]-time[b])
    if time[b] - time[a] == c:
      tmp += d
  can.append(tmp)  
  time = nex(time)
print(max(can))

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


int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;

	if (d2 == 1) {
		cout << '1' << endl;
	}
	else {
		cout << '0' << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
		public static void main(String[] args){
			
			Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			int a = s.nextInt();
			
			int res = n%500;
			
			if(res<=a)
				System.out.println("Yes");
			else
				System.out.println("No");	
			
			s.close();
		}		
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
    ll a, b ,c;
    cin >> a >> b >> c;
    ll abc = c - a - b;
    if(abc > 0 & 4 * a * b  < abc * abc)yes;
    else no; 
}


Measured memory_bytes: 256
import numpy as np
q = int(input())

def is_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return n > 1

s = [False] + [is_prime(i) for i in range(1, 10**5 + 1)]
s = [False] + [s[i] and s[(i + 1) // 2] for i in range(1, 10**5 + 1)]
cs = np.cumsum(s)

results = []
for i in range(q):
    l, r = list(map(int, input().split()))
    results.append(str(cs[r] - cs[l - 1]))
print("\n".join(results))



Measured memory_bytes: 21284
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut g: Vec<VecDeque<usize>> = vec![VecDeque::new(); n];
    for _ in 0..n {
        let u: usize = iterator.next().unwrap().parse().unwrap();
        let k: usize = iterator.next().unwrap().parse().unwrap();
        for _ in 0..k {
            let v: usize = iterator.next().unwrap().parse().unwrap();
            g[u - 1].push_back(v - 1);
        }
    }

    let mut t: usize = 1;
    let mut d: Vec<usize> = vec![0; n];
    let mut f: Vec<usize> = vec![0; n];
    let mut stack: Vec<usize> = Vec::new();
    while d.iter().any(|it| *it == 0) {
        let i = d.iter().enumerate().find(|&(_, &di)| di == 0).unwrap().0;
        stack.push(i);
        d[i] = t;
        t += 1;
        while !stack.is_empty() {
            if !g[*stack.last().unwrap()].is_empty() {
                let i2 = g[*stack.last().unwrap()].pop_front().unwrap();
                if d[i2] == 0 {
                    stack.push(i2);
                    d[i2] = t;
                    t += 1;
                }
            } else {
                let top = stack.pop().unwrap();
                f[top] = t;
                t += 1;
            }
        }
    }

    let mut result = String::new();
    for i in 0..n {
        result.push_str(&format!("{} {} {}\n", i + 1, d[i], f[i]));
    }
    return result.trim().to_string();
}



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

#define N 100

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

    int n;
    cin>>n;//データの数に入力
    int a[N], min = 0, count = 0;
    for(int i = 0; i < n; i++) cin>>a[i];//データの入力

    //選択ソート
    for(int i = 0; i < n-1; i++) {
        min = i;
        for(int j = i+1; j < n; j++) {
            if(a[min] > a[j]) min = j;
        }
        if(min != i) {
            int s = a[min]; //入れ替えのための値保持
            a[min] = a[i];
            a[i] = s;
            count++; //カウント
        }
    }

    //出力
    for(int i = 0; i < n-1; i++) cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
    cout<<count<<endl;

    return 0;
}




Measured memory_bytes: 3172
a,b,c,d=map(int,input().split())
if a%d ==0:
    if c%b==0:
        if a/d >= c/b:
            print("Yes")
        else:
            print("No")
    else:
        if a/d >= (c//b+1) :
            print("Yes")
        else:
            print("No")

else:
    if c%b==0:
        if (a//d+1) >= c/b:
            print("Yes")
        else:
            print("No")
    else:
        if (a//d+1) >= (c//b+1) :
            print("Yes")
        else:
            print("No")

   


Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		for (int i = 1; i <= 10000; i++) {
			String line = sc.nextLine();
			int n = Integer.parseInt(line);
			System.out.println("Case" + " " + i + ":" + " " + n);

			if (n == 0) {
				break;
			}

		}

	}

}

Measured memory_bytes: 59152
#include<iostream>
#include<cmath>
#include<string>
#include<list>
#include<vector>
#include<algorithm>
#include<numeric>
#include<queue>
#include<utility>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
	/*
	cin>>x;
	cout<<x<<endl;
	*/
	int a,b,c,i,j,k,l,n,m,ans=0;

	cin>>n>>m;
	vector<pair<int,int>> x;
	for(i=0;i<n;i++){
		cin>>a;
		x.push_back(make_pair(a,1));
	}
	for(i=0;i<m;i++){
		cin>>b>>c;
		x.push_back(make_pair(c,b));
	}
	sort(x.begin(),x.end());
	reverse(x.begin(),x.end());
	long long t=0;
	i=0;
	while(n>0){
		a=min(x[i].second,n);
		t+=(long long)a*x[i].first;
		n-=a;
		i++;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 2420
#coding: utf-8

def first_pop(l):
    if (len(l) <= 0):
        return 0
    else:
        return l.pop(0)

if __name__ == '__main__':

    n = int(input())
    a = sorted(map(int, (input().split())), reverse=True)
    alice, bob = 0, 0
    while len(a) > 0:
        alice += first_pop(a)
        bob += first_pop(a)

    print(alice - bob)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int MAXN = 1e6 + 5;

void cp()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k > a)
        ans += a, k -= a;
    else
        ans += k, k = 0;
    if(k > b)
        k -= b;
    else
        k = 0;
    if(k > 0)
        ans -= k;
    cout << ans;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define out(s) cout << (s) << endl
#define ll long long

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

void solve(){
  ll a,b;
  cin>>a>>b;
  out(gcd(a,b));
}

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



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

int main() {
	 int n;
	 cin >> n;
	 string s;
	 vector<string>ve;
	 for(int i = 0; i < n; i++ ){
	     cin >> s;
	     ve.push_back(s);
	 }
     
    int a = 0, b = 0, c = 0, d = 0;
    
    for(auto i: ve){
        if(i == "AC")
         a ++;
         if(i == "WA" )
         b++;
         if(i == "TLE")
         c++;
         if(i == "RE")
         d++;
    }
    
    cout << "AC" << " x " << a << endl;
    cout << "WA" << " x " << b << endl;
    cout << "TLE" << " x " << c << endl;
    cout << "RE" << " x " << d ;
    
  return 0;
}


Measured memory_bytes: 7460
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, V[20], C[20];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> V[i];
	rep(i, 0, N) cin >> C[i];

	int ans = 0;
	rep(msk, 0, 1 << N) {
		int X = 0, Y = 0;
		rep(i, 0, N) if (msk & (1 << i)) {
			X += V[i];
			Y += C[i];
		}
		chmax(ans, X - Y);
	}
	cout << ans << endl;
}


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

using namespace std;

using ll = long long;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

size_t a[2][2019];

void solve() {
    size_t a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;

        size_t i = min(k, a);
        k -= i;
        sum += i;
        i = min(k, b);
        k -= i;
        i = min(k, c);
        k -= i;
        sum -= i;
        cout << sum << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3652
import sys
readline = sys.stdin.readline
A, B, C, K = map(int,readline().split())
count = 0

if A >= K:
	print(K)
	sys.exit()

while(K>0):
	if A != 0:
		count += A
		K -= A
		A = 0
	elif B != 0:
		K -= B
		B = 0
	else:
		count -= K
		K = 0
			
print(count)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll m1,m2,d1,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(d2-d1==1){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    if(n == 3){
        cout << "2 5 63" << endl;
        return 0;
    }
    if(n == 4){
        cout << "3 9 2 4" << endl;
        return 0;
    }
    queue<int> a, b, c;

    inc(i, 2, 30001){
        if(i%2 == 0){
            if(i%3 == 0){
                b.push(i);
            }else{
                a.push(i);
            }
        }else{
            if(i%3 == 0){
                c.push(i);
            }
        }
    }

    vector<int> ans;

    int m = n-2;
    while(c.size() > 1 && m > 1){
        m-=2;
        ans.pb(c.front());
        c.pop();
        ans.pb(c.front());
        c.pop();
    }
    m+=2;

    inc(i, 0, m/3*3){
        if(i%3 == 0 || i%3 == 1){
            ans.pb(a.front());
            a.pop();
        }else{
            ans.pb(b.front());
            b.pop();
        }
    }

    if(m%3 == 2){
        ans.pb(a.front());a.pop();
        ans.pb(a.front());a.pop();
    }
    if(m%3 == 1){
        ans.pb(b.front());b.pop();
    }


    inc(i, 0, n){
        cout << ans[i];
        if(i != n){
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


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

#define int long long

#define MAX 110000

 int A[MAX], sum = 0;
signed main(){

  int A[MAX] = {}, sum = 0;
  int N;

  cin>>N;

  for(int i = 1; i <= N; i++){
    cin>>A[i];
    sum += abs(A[i]-A[i-1]);
  }
  sum += abs(A[N]);

  //cout<<sum<<endl;

  for(int i = 1; i <= N; i++){
    cout<<sum - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1])<<endl;
    // cout<<sum<<" "<< abs(A[i]-A[i-1])<<" "<<abs(A[i+1]-A[i])<<" "<<abs(A[i+1]-A[i-1])<<endl;
  }
  
  return 0;
}


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

    int n,m;
    cin >> n >> m;
    char mat[n+10][n+10],ara[m+10][m+10];

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            cin >> mat[i][j];
    }
    for(int i=0; i<m; i++)
        {for(int j=0; j<m; j++)
            {cin >> ara[i][j];}
        }


    //int si=0,sj=0;
    bool ans = 0, mrk = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(ara[0][0]==mat[i][j] && i+m-1<n && j+m-1<n)
            {
                mrk = 0;
                for(int ki = i,si=0; si<m; si++,ki++)
                {
                    for(int kj = j,sj=0; sj<m; sj++,kj++)
                    {
                        if(ara[si][sj]==mat[ki][kj])
                        {

                        }
                        else
                        {
                            mrk = 1;
                            break;
                        }
                    }
                    if(mrk)break;
                }
                if(!mrk)
                {
                    ans = 1;
                    break;
                }
//                si = 0, sj = 0;
                mrk = 0;

            }
        }
        if(ans ==1)
            break;
    }
    if(ans)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;







}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
    char b, result; cin >> b;
    if (b == 'A') {
        result = 'T';
    } else if (b == 'C') {
        result = 'G';
    } else if (b == 'G') {
        result = 'C';
    } else if (b == 'T') {
        result = 'A';
    }
    cout << result << endl; 
}       

Measured memory_bytes: 256
// ITP1_8_B:   Sum of Numbers
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	char buf[1250];
	char *p;
	int s;

	while (1) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		s = 0;
		while (isdigit(*p)) s += *p++ - '0';
		if (s == 0) break;
		printf("%d\n", s);
	}
	return 0;
}

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

using namespace std;
using ll=long long;

#define ip(i,w) for(int i=1;i<=w;i++)
#define ip2(j,h) for(int j=1;j<=h;j++)



int main()
{
    double a,t,r;
    cin >> a >> t >> r;
    cout <<fixed<< setprecision(6)<< (t/a)*r << endl;
    return(0);
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
string s;
long long n,t,ans;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B')t++;
		else ans+=t;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;

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

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

int area(vvi &v){
  int res = 0;
  int color = v[0][0];
  queue<P> open;
  bool closed[h][w];

  memset(closed,0,sizeof(closed));
  open.push(P(0,0));

  while(!open.empty()){
    P p = open.front(); open.pop();
    if(closed[p.second][p.first]) continue;
    closed[p.second][p.first] = true;

    res++;

    rep(i,4){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(nx>=0 && w>nx && ny>=0 && h>ny && v[ny][nx]==color){
        open.push(P(nx,ny));
      }
    }
  }

  return res;
}

vvi draw(vvi v,int nextColor){
  int firstColor = v[0][0];
  queue<P> open;
  bool closed[h][w];

  memset(closed,0,sizeof(closed));
  open.push(P(0,0));

  while(!open.empty()){
    P p = open.front(); open.pop();
    if(closed[p.second][p.first]) continue;
    closed[p.second][p.first] = true;

    v[p.second][p.first] = nextColor;

    rep(i,4){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(nx>=0 && w>nx && ny>=0 && h>ny && v[ny][nx]==firstColor){
        open.push(P(nx,ny));
      }
    }
  }

  return v;
}

int solve(vvi v,int rem){
  if(rem == 0){
    return area(v);
  }

  int res = 0;
  REP(i,1,7){
    if(rem == 1 && i != c) continue;
    res = max(res,solve(draw(v,i),rem-1));
  }
  return res;
}

int main(){
  while(cin>>h>>w>>c,h||w||c){
    vvi v(h);
    rep(i,h){
      v[i] = vi(w);
      rep(j,w) cin>>v[i][j];
    }
    cout<<solve(v,5)<<endl;
  }
}

Measured memory_bytes: 920
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Prime prime = new Prime();

        int count = 0;

        while (true){
            int num = prime.nextPrime();
            if(num % 5 == 1){
                count++;
                System.out.print(num);

                if(n == count){
                    break;
                }

                System.out.print(" ");
            }
        }

    }

    static class Prime {
        int last;
        List<Integer> primes = new ArrayList<>();

        Prime(){
            primes.add(2);
            primes.add(3);
            last = 3;
        }

        public boolean isPrime(int x) {
            for (int i = 2; i * i <= x; i ++) {
                if (x % i == 0) {
                    return false;
                }
            }
            return true;
        }

        public void createPrimeList(int x) {
            for (int i = 0; i < x; i++) {
                nextPrime();
             }
        }

        public int nextPrime(){
            int i = last + 2;
            while(true){
                if(isPrime(i)){
                    primes.add(i);
                    last = i;
                    return i;
                }
                i += 2;
            }
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int _max = 2e6 + 10;
const int mod = 1e9 + 7;
typedef long long ll;


int main() {
    int a;
    cin>>a;
    cout<<a*a+a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int N;
    cin >> N;
    int A[100000], B[100000];
    for(int i=0; i<N-1; i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    
    int num[100000]={};
    for(int i=0; i<N-1; i++){
        num[A[i]]++;
        num[B[i]]++;
    }
    
    int K=0;
    for(int i=0; i<N; i++){
        K = max(K,num[i]);
    }
    cout<<K<<endl;
    
    vector<int> ko[100000];
    int eda[100000];
    for(int i=0; i<N-1; i++){
        ko[min(A[i],B[i])].push_back(i);
        eda[max(A[i],B[i])]=i;
    }
    
    int ans[100000]={};
    for(int i=0; i<N; i++){
        int temp;
        if(i==0){
            temp=1;
        }else{
            temp = ans[eda[i]]+1;
        }
        
        if(temp>K){
            temp = 1;
        }
        
        for(auto x : ko[i]){
            ans[x] = temp;
            temp++;
            if(temp>K){
                temp=1;
            }
        }
    }
    
    for(int i=0; i<N-1; i++){
        cout<<ans[i]<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			flag=1;
			break;
		}
		else if(i<s.size()-2&&s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3<<endl;
			flag=1;
			break; 
		}
	}
	if(flag==0)
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

vector<vector<int> > vCon;
int suc_cnt = 0;

void nextnode(set<int>& visited, int now, int num, int final) {
	int cnt = 0;
	if (visited.size() == final) {
		suc_cnt++;
	}
	else {
		for (int i = 0; i != vCon[now].size(); ++i) {
			const int next = vCon[now][i];
			if (visited.find(next) != visited.end()) {
				continue;
			}

			else {
				set<int> newvisited = visited;
				newvisited.insert(next);
				nextnode(newvisited, next, num + 1, final);
			}
		}
	}
}


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

	//2013
	int N, M;
	cin >> N >> M;

	vector<int> vA(M);
	vector<int> vB(M);
	rep(i, M) cin >> vA[i] >> vB[i];
	rep(i, M) {vA[i]--; vB[i]--;}

	vCon.resize(N);

	for (int i = 0; i != M; ++i) {
		vCon[vA[i]].push_back(vB[i]);
		vCon[vB[i]].push_back(vA[i]);
	}

	set<int> visited;
	visited.insert(0);
	nextnode(visited, 0, 0, N);


	cout << suc_cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
template<class T>bool chmax(T &a, const T &b){
    if (a < b) {a = b; return true;}
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if (a > b) {a = b; return true;}
    return false;
}

int comb(int n, int k){
    if (n<k or k < 0) return 0;
    int ret = 1;
    for (int i = n; i> n-k; i--){
        ret *= i;
    }
    for (int i = 1;i<k+1;i++){
        ret /= i;
    }
    return ret;
}


int main()
{
    string N;
    cin >> N;
    int k;
    cin >> k;
    int m = N.size(), idx = 0;
    vi a(k,1000), b(k, 1000);
    rep(i, m){
        if (N[i] != '0') {
            a[idx] = stoi(N.substr(i, 1));
            b[idx] = i+1;
            idx++;
        }
        if (idx == k) break;
    }
    int ans = 0;
    rep(i, k){
        ans *= 9;
        ans += 9*comb(m-b[i], k-i);
        ans += (a[i]-1)*comb(m-b[i], k-i-1);
    }
    if (idx == k)ans++;
    cout << ans << endl;

    
}



Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    map<pair<string, string>, int> cnt;
    for(int i=0; i<n; ++i){
        int m;
        cin >> m;
        vector<string> s(m);
        for(int j=0; j<m; ++j)
            cin >> s[j];

        sort(s.begin(), s.end());
        for(int j=0; j<m; ++j){
            for(int k=j+1; k<m; ++k){
                ++ cnt[make_pair(s[j], s[k])];
            }
        }
    }

    vector<pair<string, string> > ans;
    for(const auto& p : cnt){
        if(p.second >= f)
           ans.push_back(make_pair(p.first.first, p.first.second));
    }

    cout << ans.size() << endl;
    for(const auto& p : ans){
        string s, t;
        tie(s, t) = p;
        cout << s << ' ' << t << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int D = sc.nextInt();

		sc.close();

		int d = 2 * D + 1;

		out.println((N + d - 1) / d);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

using namespace std;

#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 1000000001


void solve() {
	int x;
	for (int i = 1; i < 6; i++) {
		cin >> x;
		if (x == 0) {
			cout << i << endl;
			return;
		}
	}

}

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

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();



	return 0;

}


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

int main() {
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    if (((x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2) > 0 &&
         (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3) > 0 &&
         (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1) > 0) ||
        ((x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2) < 0 &&
         (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3) < 0 &&
         (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1) < 0))
      cout << "YES\n";
    else
      cout << "NO\n";
  }

  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int ans = 0;
	for(int l = 0; l <= n; l++) {
		for(int r = l; r <= n; r++) {
			int rest_count = k-l-(n-r);
			if(rest_count<0) continue;
			priority_queue<int,vector<int>,greater<int> > q;
			for(int i = 0; i < l; i++) {
				q.push(arr[i]);
			}
			for(int i = n-1; i >= r; i--) {
				q.push(arr[i]);
			}
			for(;;) {
				if(rest_count<=0) break;
				if(q.size()<=0) break;
				int tp = q.top();
				if(tp<0) {
					q.pop();
					rest_count--;
				}else {
					break;
				}
			}
			int temp_ans = 0;
			while(!q.empty()) {
				temp_ans += q.top();
				q.pop();
			}
			ans = max(ans,temp_ans);
			//cout << "(l,r,ans)=("<<l<<","<<r<<","<<temp_ans<<")"<<endl;
		}
	}
	cout << ans << endl;
	/*
	vector<int> sum_arr(n+1);
	for(int i = 0; i < n; i++) {
		sum_arr[i+1] = sum_arr[i]+sum_arr[i];
	}
	vector<int> sum_minus_arr(n+1);
	for(int i = 0; i < n; i++) {
		if(arr[i]<0) sum_minus_arr[i+1] = sum_minus_arr[i]+sum_minus_arr[i];
	}
	*/
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <set>
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()

int main() {
  int n;
  while(cin >> n, n) {
    set<int> se;
    
    REP(i,n-1){
      se.insert((i+1)*(i+1)%n);
    }
    vector<int> v((n-1)/2);
    FOR(it1,se) {
      for(set<int>::iterator it2 = it1; it2!=se.end(); it2++) {
        if (*it1==*it2) continue;
        int temp = abs(*it1-*it2);
        if (temp > (n-1)/2) temp = n-temp;
        v[temp-1]++;
      }
    }
    
    FOR(it,v) {
      cout << *it*2 << endl;
    }
  }
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    
    sort(a.begin(), a.end());
    int amax = a[a.size()-1];

    int c = lower_bound(a.begin(), a.end(), amax/2) - a.begin();
    int ans = a[c];
    if (c != 0){
        // a[c-1], a[c]
        int targ = amax/2;
        int targ2 = (amax/2)+(amax%2);

        int diffc = min(abs(a[c]-targ), abs(a[c]-targ2));
        int diffcm = min(abs(a[c-1]-targ), abs(a[c-1]-targ2));

        if (diffc < diffcm){
            ans = a[c];
        } else {
            ans = a[c-1];
        }
    }

    cout << amax << " " << ans << endl;
}



Measured memory_bytes: 892
#!/usr/bin/env python3
#
# FILE: abc046_a.py
#
# @author: Arafat Hasan Jenin <opendoor.arafat[at]gmail[dot]com>
#
# LINK: https://abc046.contest.atcoder.jp/tasks/abc046_a?lang=en
#
# DATE CREATED: 17-06-18 00:09:52 (+06)
# LAST MODIFIED: 17-06-18 00:19:32 (+06)
#
# VERDICT:
#
# DEVELOPMENT HISTORY:
# Date         Version     Description
# --------------------------------------------------------------------
# 17-06-18     1.0         Deleted code is debugged code.
#
#               _/  _/_/_/_/  _/      _/  _/_/_/  _/      _/
#              _/  _/        _/_/    _/    _/    _/_/    _/
#             _/  _/_/_/    _/  _/  _/    _/    _/  _/  _/
#      _/    _/  _/        _/    _/_/    _/    _/    _/_/
#       _/_/    _/_/_/_/  _/      _/  _/_/_/  _/      _/
#
##############################################################################

print(len(set(map(int, input().split()))))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,N, plan1, plan2;
  cin >> N >> A >> B;
  plan1 = A*N;
  plan2 = B;
  cout << (plan1 < plan2 ? plan1 : plan2) << endl; 
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var N = ReadInt();
            Dictionary<string, int> dic = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                var S = Read();
                if (dic.ContainsKey(S))
                {
                    dic[S]++;
                }
                else
                {
                    dic[S] = 1;
                }
            }
            var dic2 = dic.OrderByDescending(x => x.Value);
            HashSet<string> retList = new HashSet<string>();
            var max = dic2.Max(x => x.Value);
            foreach (var pair in dic2)
            {
                if (pair.Value == max)
                {
                    retList.Add(pair.Key);
                }
            }

            foreach (var ret in retList.OrderBy(x => x, StringComparer.OrdinalIgnoreCase))
            {
                Console.WriteLine(ret);
            }
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 57872
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    iota(2).map!(i => readln.chomp.to!int).reduce!((a, b) => a^^2 - b).writeln;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

x,k,d = map(int,readline().split())

x = abs(x)
if (x >= k*d):
    print(x-k*d)
elif ((k-x//d)%2):
    print(abs(x%d-d))
else:
    print(x%d)


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

int gcd(int a, int b) {
  int ret=1;
  int max = a < b ? b : a;
  for (int i = 1; i <= max; i++) {
    if (a%i==0 && b%i==0)
      ret = i;
  }
  return ret;
}
int gcd3(int a, int b, int c) {
  int ret = gcd(gcd(a, b), c);
  return ret;
}
int main() {
  int K, i, j, h, sum=0;
  cin >> K;
  int gcd2[K+10][K+10]={0};

  for (i = 1; i <= K; i++) {
    for (j = 1; j <= K; j++) {
      gcd2[i][j] = gcd(i, j);
    }
  }
  rep(i, K) {
    rep(j, K) {
      rep(h, K) {
        sum += gcd2[gcd2[i][j]][h];
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3792
<?php
fscanf(STDIN, "%s", $s);

$cnt = 0;
for ($i = 0; $i < floor(strlen($s) / 2); $i++) {
    if ($s[$i] != $s[strlen($s)-($i + 1)]) {
        $cnt++;
    }
}
echo $cnt . "\n";

?>

Measured memory_bytes: 4728
def main():

    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]

    MOD = 10**9 +7
    dp = [0] * (1<<n)

    pair_dic = {}
    for i in range(n+1):
        pair_dic[i] = []

    for i in range(1<<n):
        pair_dic[ bin(i).count('1') ].append(i)

    dp[0] = 1

    for i in range(n):
        for k in range(n):
            if(a[i-1][k] == 0):
                continue
            for j in pair_dic[i]:
                if(  ((j&(1<<k)) >>k == 0 ) ):
                    dp[j + (1<<k)] += dp[j]
                    dp[j + (1<<k)] = dp[j + (1<<k)] % MOD

    print(dp[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 132496
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    unsigned long long int M[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
        {
            char c;
            cin>>c;
            if(c=='.')
                M[i][j]=0;
            else
                M[i][j]=-1;
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
        cout<<M[i][j]<<" ";
    cout<<endl;
    }
    */

    for(int i=0;i<h;i++)
    {
        if(M[i][0]==-1)
            break;
        else
            M[i][0]=1;

    }

    for(int i=0;i<w;i++)
    {
        if(M[0][i]==-1)
            break;
        else
            M[0][i]=1;

    }

    


    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++)
        {
            if(M[i][j]==-1)
                continue;
            if(M[i-1][j]==-1 && M[i][j-1]==-1)
                M[i][j]=0;
            else if(M[i-1][j]==-1)
                M[i][j]=M[i][j-1];
            else if(M[i][j-1]==-1)
                M[i][j]=M[i-1][j];
            else
                M[i][j]=(M[i-1][j]+M[i][j-1])%1000000007;
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
        cout<<M[i][j]<<" ";
    cout<<endl;
    }
    */
    

    cout<<M[h-1][w-1]<<endl;
}



Measured memory_bytes: 8064
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
N = len(S)

cur = ''
prev = ''
cnt = 0
for i in range(N-1, -1, -1):
    cur = S[i] + cur
    if cur != prev:
        cnt += 1
        prev = cur
        cur = ''
print(cnt)


Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			for (int i = 0; i <= x; i++) {
				if (i * 2 + (x - i) * 4 == y) {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
	}
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int n;
    string s;
    cin >> s;
    n = s.size();
    ll cntb = 0;
    ll ans = 0;
    for (auto c : s) {
        if (c == 'B') {
            cntb++;
        } else {
            ans += cntb;
        }
    }
    cout << ans;
}

Measured memory_bytes: 720
package main

import (
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

type ByValue []float64

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i] < s[j] }

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	s := inputLn()
	t := input()
	sList := strings.Split(s, "")
	tList := strings.Split(t, "")
	cnt := 0
	for i := 0; i < 3; i++ {
		if sList[i] == tList[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    ll ans=0;
    for(int i=1;i<=n;++i){
        if(i%3&&i%5)ans+=i;
    }
    cout<<ans<<endl;
}


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

int main(){
    int n;
    cin>>n;
    int* array = new int[n];
    for(int i=0;i<n;i++){
        cin>>array[i];
    }
    for(int i=0;i<n;++i){
        int x=array[i];
        int j=i-1;
        while(j>=0 && array[j]>x){
            array[j+1]=array[j];
            --j;
        }
        array[j+1]=x;
        for(int k=0;k<n;++k){
            cout<<array[k];
            if(k!=n-1)
                cout<<" ";
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 3064