akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

int main(){
  int n, p;

  while(cin >> n >> p, n != -1 || p != -1){
    vector<int> v;

    for(int i = n + 1; v.size() != 100; i++){
      if(isPrime(i)){
        v.push_back(i);
      }
    }

    vector<int> vp;

    for(int i = 0; i < v.size(); i++){
      for(int j = i; j < v.size(); j++){
        vp.push_back(v[i] + v[j]);
      }
    }
    sort(vp.begin(), vp.end());

    cout << vp[p - 1] << endl;
  }
}

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

string s[100];
int n, m, arr[100][100];

int main(){
  cin >> n >> m;
  for(int i = 1; i <= n; i++){
    cin >> s[i];
    s[i] = "0" + s[i];
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(s[i][j] == '#'){
        for(int k = -1; k <= 1; k++){
          for(int l = -1; l <= 1; l++){
            arr[i+k][j+l]++;
          }
        }
      }
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(s[i][j] == '#'){
        cout << "#";
      }else{
        cout << arr[i][j];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
#define PI 3.14159265359
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vector<ll> S(N+1,0);
    for(int i=0;i<N;i++){
        S[i+1] = S[i]+A[i];
    }
    ll ans = INF;
    for(int i=1;i<N;i++){
        ans = min(ans,abs((S[N]-S[i])-S[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N;
string S;
int dp[201][201];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    char c;
    cin >> c;
    if (c != '-') S += c;
  }
  N = S.length();

  dp[0][0] = 1;
  rep(i, N) {
    if (S[i] == 'U') {
      rep(j, N) add(dp[i+1][j+1], dp[i][j]);
      rep(j, N) add(dp[i+1][j], (1LL*j*dp[i][j])%MOD);
    }
    else {
      rep(j, N) if (j) add(dp[i+1][j-1], (1LL*j*j*dp[i][j])%MOD);
      rep(j, N) add(dp[i+1][j], (1LL*j*dp[i][j])%MOD);
    }
  }
  cout << dp[N][0] << "\n";
  return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-96;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    string s;
    cin>>s;
    s=s+'0';
    int n=s.size();
    int m=0;
    int count=0;
    for(int i=0;i<n;i++)
    {    
        if(s[i]!='R')
        {
            if(count!=0)
            {
                m=max(m,count);
                count=0;
            }
        }
        else
        {
            count++;
        }
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	int a[MAX];
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	int d=INF,r;
	rep(i,n){
		if(a[i]<=a[n-1]/2&&d>a[n-1]/2-a[i]){
			d=a[n-1]/2-a[i];
			r=a[i];
		}
		else if(a[i]>=a[n-1]/2+a[n-1]%2&&d>a[i]-a[n-1]/2-a[n-1]%2){
			d=a[i]-a[n-1]/2-a[n-1]%2;
			r=a[i];
		}
	}
	cout<<a[n-1]<<' '<<r<<endl;
}


Measured memory_bytes: 640
// abco54c: One-stroke Path
#include <bits/stdc++.h>

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int n,m;
vvi v(8);
vi visit(8);

void dfs(int p, int c, int distance, int &count){
  if(distance==n-1){ count++; return; }
  visit[c] = true;
  for(auto cc:v[c])
    if(!visit[cc]) dfs(c,cc,distance+1,count);
  visit[c] = false;
}

int main(){
  in(n);in(m);
  rep(i,m){
    int a,b; in(a);in(b);
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int count = 0;
  dfs(-1,0,0,count);
  oute(count);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

using pqg = priority_queue<ll,vector<ll>, greater<ll> >; // 1,3,5..
using pql = priority_queue<ll,vector<ll> >; //5, 3, 1...

using pqg_p = priority_queue<P,vector<P>, greater<P> >; // 1,3,5..
using pql_p = priority_queue<P,vector<P> >; //5, 3, 1...

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


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

  int N,M;
  cin >> N;

  map<string,ll> s;
  map<string,ll> r;

  REP(i,N) {
    string st;
    cin >> st;
    s[st]++;
  }

  cin >> M;
  REP(i,M) {
    string st;
    cin >> st;
    r[st]++;
  }

  ll ans = 0;
  for(auto i: s) {
    ans = max(ans, i.second - r[i.first]);
  }

  cout << ans << "\n";


}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    H = {2, 4, 5, 7, 9}
    P = {0, 1, 6, 8}
    B = {3}
    if N % 10 in H: print("hon")
    elif N % 10 in P: print("pon")
    elif N % 10 in B: print("bon")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    int max_d = 0;
    bool flg = 0;
    rep(i, n) {
        int tmp_d;
        cin >> tmp_d;
        if ( i == 0 && tmp_d != 0 ) {
            flg = 1;
        }
        ++d[tmp_d];
        max_d = max(max_d, tmp_d);
    }
    if ( flg || d[0] != 1 ) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for ( int i = 1; i <= max_d; ++i ) {
        int loop_num = d[i];
        while(1) {
            if ( loop_num == 0 ) {
                break;
            }
            ans = ans * d[i-1] % mod;
            --loop_num;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
import sys
R = lambda:map(int,raw_input().split())

while 1:
    n = int(raw_input())
    if n == 0: break
    lst = []
    for i in xrange(n):
        lst.append(R())
        lst[i].append(sum(lst[i]))
    s = []
    for i in xrange(n+1):
        t = 0
        for j in xrange(n):
            t += lst[j][i]
        s.append(t)

    for i in xrange(n):
        for j in xrange(n+1):
            lst[i][j] = str(lst[i][j]).rjust(5)
    for i in xrange(n+1):
        s[i] = str(s[i]).rjust(5)
    lst.append(s)
    #print lst
    for i in xrange(n+1):
        print "".join(lst[i])

Measured memory_bytes: 4260
N=int(input())
A=list(map(int, input().split()))
count=0
tmp=A
flag=True
while flag:
  for i in range(N):
    if tmp[i]%2!=0:
      flag=False
      break
  if flag:
    tmp = list(map(lambda x: x / 2, tmp))
    count+=1
print(count)   

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/8;

const int MAX_D = 100010;
const int MAX_C = 30;

double dp[MAX_D][MAX_C]; // i日目にj回連続で得る確率
double ans[MAX_D];

int main(){
    memset(dp,0,sizeof(dp));
    memset(ans,0,sizeof(ans));
    dp[1][0] = 1;
    for(int i = 1; i < MAX_D; i++){
        double today = 0;
        for(int j = 0; j < MAX_C; j++){
            double win = pow(0.5, j);
            double lose = 1 - win;
            today += dp[i][j] * win;
            dp[i+1][j+1] += dp[i][j] * win;
            dp[i+1][0] += dp[i][j] * lose;
        }
        ans[i] = today + ans[i-1];
    }
    int n;
    while(scanf("%d", &n), n != 0){
        printf("%.10lf\n", ans[n]);
    }
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	  int ac=0,tle=0,re=0,wa=0;
    while(n--)
    {
        string s;
        cin>>s;
      
        if(s[0]=='A')ac++;
        if(s[0]=='T')tle++;
        if(s[0]=='W')wa++;
        if(s[0]=='R')re++;
    }
	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
		cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
			cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
				cout<<"RE"<<" "<<"x"<<" "<<re;
	
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
class Main {
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int s , w;
    s = sc.nextInt();
    w = sc.nextInt();
    if(s <= w){
      System.out.println("unsafe");
    }else{
      System.out.println("safe");
    }
  }
}


Measured memory_bytes: 35728
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

typedef pair<ll, ll> P;
struct edge {
    ll to;
    ll cost;
};
vector<vector<edge>> G;

vec d;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    ll N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    G.assign(N, vector<edge>());
    Rep (i, N-1) {
        G[i].push_back({i+1, 1});
        G[i+1].push_back({i, 1});
    }
    G[X].push_back({Y, 1});
    G[Y].push_back({X, 1});

    vec ans(N, 0);
    Rep (i, N) {
        dijkstra(i, N);
        Rep (j, N) {
            ans[d[j]]++;
        }
    }

    for (ll i = 1; i < N; i++) {
        cout << ans[i] / 2 << "\n";
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
// #include <iostream>
// #include <iomanip>
// #include <sstream>
using namespace std;
// const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
// const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
// const int dy[] = {-1, 1, 1, -1, 2, -2, 2, -2};
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false)
#define boost2 cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
ll on_bit(ll x, int pos) {x |= (1ll << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(ll x, int pos) {return ((x & (1ll << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int MOD = 1e9+7;
int add(ll a, ll b){return ((a%MOD)+(b%MOD))%MOD;}
int sub(ll a, ll b){return ((a%MOD)-(b%MOD))%MOD;}
int mult(ll a, ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll powmod(ll a,ll b){ll res=1;assert(b>=0);a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

const int N=55;
ll len[N];

ll f(int n, ll x);

ll f_right(int n, ll x){
	if(n==0)return 1LL;
	if(x==1)return 0LL;
	if(x==(len[n])/2+1)return (1ll<<n);
	return f(n-1,x-1);
}

ll f(int n, ll x){
	if(n==0)return 1LL;
	if(len[n]==x)return (1ll<<(n+1))-1;
	ll res=f_right(n,min((len[n])/2+1,x));
	if(x>(len[n])/2+1)res+=f(n-1,x-((len[n])/2+1));
	return res;
}

int main(){
	int n;
	ll x;
	sf("%d%lld",&n,&x);
	len[0]=1;
	fr(i,1,51)len[i]=len[i-1]+len[i-1]+3;
	pf("%lld\n",f(n,x));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define llINF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
int a,b;
signed main(){
	cin>>a>>b;
	if(a<=9&&b<=9)cout<<a*b<<endl;
	else puts("-1");
	return 0;
}


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

typedef long long ll;

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

    string s; cin >> s;
    for(int i=0;i<s.size()-1;i+=2){
        if(!(s[i]=='h'&&s[i+1]=='i')){
            cout << "No" << endl;
            return 0;
        }
    }
    if(!(s.back()=='i'&&s[s.size()-2]=='h')){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
	char k;
	int num, n;
	int c[4][13];
	
	for(int i = 0; i < 4 ; i++) {
		for(int j = 0; j < 13 ; j++)
			c[i][j] = 1;
	}
	
	cin >> num;
	
	for (int i = 0; i < num; i++) {
		cin >> k >> n;
		if(k=='S')
			c[0][n-1] = 0;
		else if (k=='H')
			c[1][n-1] = 0;
		else if (k=='C')
			c[2][n-1] = 0;
		else
			c[3][n-1] = 0;	
	}

	for(int i = 0; i < 4 ; i++) {
		for(int j = 0; j < 13 ; j++) {
			if(c[i][j]) {
				if(i==0)
					cout << "S " << j + 1;
				else if(i==1)
					cout << "H " << j + 1;
				else if(i==2)
					cout << "C " << j + 1;
				else
					cout << "D " << j + 1;
				cout << endl;
			}
		}	
	}
	return 0;
}

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

using namespace std;

const long long MAXN = 310;
const long long MOD = 998244353;
long long dp[MAXN][MAXN][MAXN];
long long b[MAXN][MAXN];
long long n;
long long c[MAXN][MAXN];
long long arr[MAXN];
int main(){
    string s;
    cin>>s;
    long long m;
    cin>>m;
    m = min(m,(long long)s.length());
    long long len = s.length();
    long long last = -1;
    n++;
    for(long long i=0;i<s.length();i++){
        if(s[i] == '0'){
           
            arr[n] = i-last - 1;
             n++;
            last = i;
        }
    }
    arr[n] = s.length() - last - 1;
    dp[0][0][0] = 1;
    //dp[i][j][k] = i one segments, difference between pref[i] and newpref[i] = j, k operations performed
    for(long long i=1;i<=n;i++){
        for(long long j=0;j<=len;j++){
            for(long long k=0;k<=m;k++){
                b[j][k] = 0;
                c[j][k] = 0;
            }
        }
        
        for(long long j=0;j<=len;j++){
            for(long long k=0;k<=m;k++){
                long long hold = dp[i-1][j][k];
                if(hold == 0){
                    continue;
                }
                b[j-min(j,arr[i])][k]+=hold;
                b[j-min(j,arr[i])][k]%=MOD;
                b[j+1][k]-=hold;
                b[j+1][k]+=MOD;
                b[j+1][k]%=MOD;
                c[j+1][k+1]+=hold;
                c[j+1][k+1]%=MOD;
                
                //b[j][k] = transfers from the ith segment to earlier segments(b[j][k] holds dp[i-1][j+arr[i]][k]+dp[i-1][j+arr[i]-1][k]+dp[i-1][j+arr[i]-2][k]+...+dp[i-1][j][k])
                //c[j][k] = transfers before the ith segement, new ones added to the current segment is added from the right(c[j][k] holds dp[i-1][j-1][k-1]+dp[i-1][j-2][k-2]+dp[i-1][j-3][k-3]+....)
                
                
            }
        }
        for(long long j=0;j<=len;j++){
            for(long long k=0;k<=m;k++){
                if(j){
                    b[j][k] += b[j-1][k];
                    b[j][k]%=MOD;
                }
                if(j && k){
                    c[j][k]+=c[j-1][k-1];
                    c[j][k]%=MOD;
                }
                dp[i][j][k] = b[j][k]+c[j][k];
                dp[i][j][k]%=MOD;
            }
        }
    }
    long long ans = 0;
    for(long long i=0;i<=m;i++){
        ans+=dp[n][0][i];
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 223496
n = input()
taro = 0
hanako = 0
for i in range(n):
    t,h = map(str, raw_input().split())
    if t > h: taro += 3
    elif t < h: hanako += 3
    else: taro += 1; hanako += 1;
print "%d %d" % (taro,hanako) 

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
const int P = 1e9 + 7;
int a[N], inv[N];

int Pow(int x, int t)
{
	int res = 1;
	for (; t; t >>= 1, x = 1LL * x * x % P)
		if (t & 1) res = 1LL * res * x % P;
	return res;
}

int main()
{
	int n = read(), ans = 0;
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i) inv[i] = Pow(i, P - 2);
	for (int i = 1; i <= n; ++i) (inv[i] += inv[i - 1]) %= P;
	for (int i = 1; i <= n; ++i) (ans += 1LL * a[i] * (inv[i] + inv[n - i + 1] - 1) % P) %= P;
	for (int i = 1; i <= n; ++i) ans = 1LL * ans * i % P;
	printf("%d\n", ans); 
	return 0;
}


Measured memory_bytes: 4416
// Problem : B - Trained?
// Contest : AtCoder - AtCoder Beginner Contest 065
// URL : https://atcoder.jp/contests/abc065/tasks/abc065_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vi a(n,-1);
	int flag=1;
	loop(i,n)
	{
		cin>>a[i];
		a[i]--;
	}
		int i=0;
		int count=0;
		while(n--)
		{
			int t=a[i];
			count++;
			if(t==1)
			{
				cout<<count<<nl;
				return 0;
			}
			i=t;
		}
		cout<<-1<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int zero() { return 0; }
int sets(int A, int B, int C, int G) {
    if(B == 0 || C == 0) {
        return 0;

    } else if(A <= B) {
        return G;

    } else {
        return 0;
    }
}

int dia(int D, int E, int F, int H) {
    if(E - F < 0) {
        return 0;
    } else {
        return H;
    }
}

int main() {
    int N;                     //ナップザックの容量
    int M;                     //個数
    vector<vector<int>> Array; //容量と価値まとめ

    cin >> M >> N;

    int Array1[M + 1][N + 1]; //価値の状況

    for(int i = 0; i < M + 1; i++) {
        if(i == 0) {
            vector<int> Temp;
            Temp.push_back(0);
            Temp.push_back(0);
            Array.push_back(Temp);

        } else {
            int temp1, temp2; // temp1  容量     //temp2価値
            vector<int> Temp;
            cin >> temp2 >> temp1;
            Temp.push_back(temp1);
            Temp.push_back(temp2);
            Array.push_back(Temp);
        }
    }

    for(int i = 0; i < M + 1; i++) //縦
    {
        for(int n = 0; n < N + 1; n++) {
            if(i == 0 || i == 1) {
                if(i == 0) {
                    Array1[i][n] = zero();
                } else {

                    Array1[i][n] = sets(Array[i][0], n, i, Array[i][1]);
                }
            }

            else {
                int DOWN, DIA;
                DOWN = Array1[i - 1][n];
                DIA = dia(i, n, Array[i][0],
                          Array1[i - 1][n - Array[i][0]] + Array[i][1]);

                if(DOWN >= DIA) {
                    Array1[i][n] = DOWN;
                } else if(DIA > DOWN) {
                    Array1[i][n] = DIA;
                }
            }
        }
    }

    cout << Array1[M][N] << endl;
}


Measured memory_bytes: 7088
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int mod = (int)1e9 + 7;
int n, t, d[100000];

int main(){
	cin >> n >> t;
	rep(i, n) cin >> d[i];
	sort(d, d + n);
	ll ans = 1;
	
	for(int i = 0, j = 0; j < n; j++){
		while(i < j && d[i] + t < d[j]) i++;
		ans = ans * (j - i + 1) % mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1560
using System;
using System.Linq;

namespace AtCoder
{
    public class ABC096B
    {
        public static void Main(string[] args)
        {
            string[] lineArgs = Console.ReadLine().Split(' ');
            int[] abc = lineArgs.Select<string, int>(stringValue => int.Parse(stringValue)).ToArray<int>();
            int K = int.Parse(Console.ReadLine());

            int maxIndex = 0;
            for (int index = 0; index < abc.Length; index++)
            {
                if (abc[maxIndex] < abc[index])
                {
                    maxIndex = index;
                }
            }

            int others = 0;
            for (int index = 0; index < abc.Length; index++)
            {
                if (index != maxIndex)
                {
                    others += abc[index];
                }
            }

            Console.WriteLine(abc[maxIndex] * Math.Pow(2, K) + others);
        }
    }
}


Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
// #ifdef DEBUG 
// #define
int main(){
    int m,n;
    cin >> n >> m;
    vector<int> A(m);
    vector<ll> DP(n+1,INF);
    DP[0]= 0;
    DP[1]= 1;
    REP(i,m) cin >> A[i];
    REP(i,n+1){
        REP(j,m){
            if(i<A[j]) continue;
            DP[i]= min(DP[i],DP[i-A[j]]+1);
        }
    }
    // for(auto x:DP){
    //     cerr << x << endl;
    // }
    cout << DP[n] << endl;
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,a[500][500];
    cin>>n>>m;
    rep(i,n)rep(j,m){
        cin>>a[i][j];
    }
    ll ans=n;
    bool used[400]={};
    rep(i,m){
        map<ll,ll> mp;
        ll cnt=0;
        rep(j,n){
            rep(k,m){
                if(used[a[j][k]]==0){
                    mp[a[j][k]]++;
                    break;
                }
            }
        }
        rep2(j,1,m+1){
            cnt=max(cnt,mp[j]);
        }
        rep2(j,1,m+1){
            if(mp[j]==cnt&&used[j]==0){
                used[j]=1;
                break;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
# coding: utf-8

# https://atcoder.jp/contests/abc121


def main():
    A, B = map(int, input().split())

    def xor_1_to_x(x):
        output = [0] * 40

        for k in range(40):
            output[k] = (2**k)*((x+1)//(2**(k+1)))
            output[k] += max(0, (x+1) - ((2**(k+1))*((x+1)//(2**(k+1))) + (2**k)))

        return output

    xor_B = xor_1_to_x(B)
    xor_A_m1 = xor_1_to_x(A-1)
    xor_AtoB = [None] * 40
    for k in range(40):
        xor_AtoB[k] = xor_B[k] - xor_A_m1[k]
        xor_AtoB[k] %= 2

    ans = 0
    for k in range(40):
        ans += xor_AtoB[k] * (2**k)

    return ans


print(main())


Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while(sc.hasNext()){
            sb.append(sc.next());
        }
        int[] nums = new int[26];
        for(int i = 0; i < sb.length(); i++){
            char ch = sb.charAt(i);
            if(ch >= 65 && ch <= 90) nums[ch - 65]++;
            else if(ch >= 97 && ch <= 122) nums[ch - 97]++;
        }
        for(int i = 0; i < nums.length; i++){
            System.out.println(String.format("%c : %d", (char)(i + 97), nums[i]));
        }
    }
}



Measured memory_bytes: 26280
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void printv(vector<int> &v)
{
  for (auto item : v)
    cout << item << " ";
  cout << endl;
}
int main()
{
  int N;
  string s;
  cin >> N;
  cin >> s;
  int r = 0;
  int b = 0;
  for (auto c : s)
  {
    if (c == 'R')
    {
      r++;
    }
    else
    {
      b++;
    }
  }
  cout << ((r > b) ? "Yes" : "No")
       << endl;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

ll a,b,di,ans;
ll A[50],B[50];

int main(){
	scanf("%lld%lld",&a,&b);
	ll c=a-1ll;
	for(rint i=0;(1ll<<i)<=c;++i){
		di=c+1ll;
		A[i]=(ll)(di/(1ll<<i+1))*(1ll<<i);
		di%=(1ll<<i+1);
		di-=(1ll<<i);
		if(di>0)A[i]+=di;
	}
	for(rint i=0;(1ll<<i)<=b;++i){
		di=b+1ll;
		B[i]=(ll)(di/(1ll<<i+1))*(1ll<<i);
		di%=(1ll<<i+1);
		di-=(1ll<<i);
		if(di>0)B[i]+=di;
		B[i]=(B[i]-A[i])&1ll;
		ans+=(1ll<<i)*B[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve (){
    
    Scanner scanner = new Scanner (System.in);
    
    int X = scanner.nextInt();
    int Y = scanner.nextInt();
    
    Y/=2;
    
    System.out.println(X+Y);
  }
}

Measured memory_bytes: 23892
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

struct S{
	mint value;
	int size;
};

S op(S x, S y) {
	return S{x.value + y.value, x.size + y.size};
}

S e() {
	return S{0, 1};
}

struct F{
	mint b;
	mint c;
};

S mapping(F f, S x) {
	return S{f.b * x.value + f.c * x.size, x.size};
}

F composition(F f2, F f1) {
	return F{f1.b * f2.b, f1.c * f2.b + f2.c};
}

F id() {
	return F{1, 0};
}

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	vector<S> a(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		a[i] = S{x, 1};
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> st(a);
	for (int z = 0; z < q; ++z) {
		int k; cin >> k;
		if (k == 0) {
			int l, r, b, c; cin >> l >> r >> b >> c;
			st.apply(l, r, F{b, c});
		} else {
			int l, r; cin >> l >> r;
			cout << st.prod(l, r).value.val() << "\n";
		}
	} 
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<ll> A;
vector<ll> B;
vector<ll> C;

int main(void) {

    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    rep(i, N) {
        int a;
        cin >> a;
        B.push_back(a);
    }
    rep(i, N) {
        int a;
        cin >> a;
        C.push_back(a);
    }

    sort(ALLOF(A));
    sort(ALLOF(B));
    sort(ALLOF(C));

    // 愚直にやるとA B Cの三重ループ探索になる
    ll count = 0;

    REP(i, 0, N) {
        ll b = B[i];
        auto aItr = lower_bound(ALLOF(A), b);
        ll aCount = distance(A.begin(), aItr);

        auto cItr = upper_bound(ALLOF(C), b);
        ll cCount = distance(cItr, C.end());

        count += aCount * cCount;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3316
#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);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int a, b; cin >> a >> b;
    Out(a * b);

    return 0;
}


Measured memory_bytes: 3636
n, k = map(int, input().split())
s = input()
cur = "1"
sum_ = [0]
ans = -1
for i, c in enumerate(s):
    if cur != c:
        sum_.append(i)
        if c == "0":
            if len(sum_) >= 2 + k + k:
                ans = max(ans, sum_[-1] - sum_[-2-k-k])
        cur = c
sum_.append(len(s))
if s[-1] == "0":
    sum_.append(len(s))
if len(sum_) > 2 + k + k:
    ans = max(ans, sum_[-1] - sum_[-2-k-k])
else:
    ans = n
print(ans)

Measured memory_bytes: 7188
#include <bits/stdc++.h>
using namespace std;
const int N = 30;

int n, d;
int a[N][N];

inline int cal (int x, int y) {
    int res = 0;
    for (int i = 1; i <= d; i++) {
        res = res + (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
    }
    if ((int)sqrt(res) * (int)sqrt(res) == res) return 1;
    else return 0;
}

int main() {
    scanf("%d%d", &n, &d);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= d; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (cal(i, j)) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryC = readLine()!.map { String($0) }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let rStones = aryC.filter { $0 == "R"}.count
    let ans = aryC[..<rStones].filter { $0 == "W"}.count
    
    print(ans)
}
main()


Measured memory_bytes: 19252
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    string str;
    cin >> str;
    int x=0;
    int mx=0;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='I') {
            x++;
        } else {
            x--;
        }
        mx = max(mx, x);
    }
    cout << mx << endl;


    return 0;
    
}

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

int main(void){
  char s[100],t[100];
  int i,j,n,m,l=100,a,slen,tlen;

  scanf("%s %s",s,t);

  slen = strlen(s);
  tlen = strlen(t);

  for(i=slen - tlen;i>=0;i--){
    a=0;
    for(j=0;j<tlen;j++){
      if(s[i+j]==t[j]||s[i+j]=='?') a++;
    }
    if(a==tlen){
      l=i; break;
    }
  }

  if(l==100)
    printf("UNRESTORABLE\n");

  else{
    for(i=0;i<slen;i++){
      if(i==l){
        printf("%s",t);
        i+=tlen-1;
      }
      else if(s[i]=='?')
        printf("a");
      else
        printf("%c",s[i]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 128
M, D = map(int, input().split())

count = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1*d10 == m:
            count += 1

print(count)


Measured memory_bytes: 2940
//============================================================================
// Name        : abc130_b.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 B - Bounding

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 200 点

 問題文
 数直線上を N + 1 回跳ねるボールがあり、1 回目は 座標 D_1 = 0,
 i 回目は 座標 D_i = D_{i-1} + L_{i-1} (2 <= i <= N+1) で跳ねます。
 数直線の座標が X 以下の領域でボールが跳ねる回数は何回でしょうか。

 制約

 ・1 <= N <= 100
 ・1 <= L_i <= 100
 ・1 <= X <= 10000
 ・入力は全て整数である
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, x;
	cin >> n >> x;
	int l, d = 0, bounce = 0;
	if (d <= x) {
		++bounce;
	}
	rep(i, 1, n)
	{
		cin >> l;
		d += l;
		if (d <= x) {
			++bounce;
		}
	}

	cout << bounce << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		if (K==1||N ==K) {
			System.out.println(0);
			return ;
		}
		System.out.println(N-K);
	}

}


Measured memory_bytes: 21844
import sys

n = int(sys.stdin.readline())
values =[ [ int(val) for val in num[:-1].split() ] for num in sys.stdin.readlines() ]

nyukyo =[ [ [ 0 for _ in range(10) ] for _ in range(3) ] for _ in range(4) ]

for value in values:
    nyukyo[value[0]-1][value[1]-1][value[2]-1] += value[3]
    if nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] < 0:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 0
    elif nyukyo[value[0]-1][value[1]-1][value[2]-1] > 9:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 9

for j in range(4):
    for n in range(3):
        for m in range(10):
            print( ' ' + str(nyukyo[j][n][m]), end='')
        print('')
    if j < 3:
        print('#' * 20)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    string s[n];
    int a[n];
    for (int i = 0; i < n; i++) cin >> s[i] >> a[i];
    string x;
    cin >> x;
    bool flag = false;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (flag) sum += a[i];
        if (s[i] == x) flag = true;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int x1=int.Parse(str[0]);
      int y1=int.Parse(str[1]);
      int x2=int.Parse(str[2]);
      int y2=int.Parse(str[3]);
      int a=x2-x1;
      int b=y2-y1;
      
      int x3=x2-b;
      int y3=y2+a;
      int x4=x3-a;
      int y4=y3-b;
      Console.WriteLine(x3+" "+y3+" "+x4+" "+y4+"\n");
    }
    
  }

}


Measured memory_bytes: 27484
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    S=input()
    T=input()
    for i in range(len(S)):
        S=S[-1]+S[:-1]
        if S==T:
            print("Yes")
            break
    else:print("No")
#%%submit!
resolve()

Measured memory_bytes: 38324
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N, C, K;
    cin >> N >> C >> K;
    int T[110000];
    REP(i, N) cin >> T[i];
    sort(T, T + N);
    int tlim = T[0] + K;
    int cur = 1, ans = 0;
    for(int i = 1; i < N; ++i){
        //時間内に乗れるか判定
        if (T[i] <= tlim){
            cur += 1;
        } else{
            ans += 1;
            tlim = T[i] + K;
            cur = 1;
        }
        //定員に達した時
        if (cur > C){
            ans += 1;
            tlim = T[i] + K;
            cur = 1;
        }
    }
    //最後のバスを発車させるのを忘れない
    cout << ans + 1 << '\n';
    return 0;
}

Measured memory_bytes: 640