akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll ans = 0,cnt = 0;
    string s;
    cin >> s;
    rep0(i, s.size()){
        if (s[i] == 'B') {
            ++cnt;
        }else{
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize("Ofast") 

////////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)

////////////////////////////////////////////////////////////////////////////////

typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si;
typedef map<int,int> mi;

////////////////////////////////////////////////////////////////////////////////



signed main() 
{
//bew;
    int n;
    cin>>n;
    long double dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    long double h[n],t[n];
    ip(h,n);
    
    loop(n)
    t[i]=1-h[i];
    
    
    dp[1][0]=t[0];
    dp[1][1]=h[0];
    for(int i=2;i<=n;++i)
    {
        dp[i][0]=dp[i-1][0]*t[i-1];
        for(int j=1;j<=i;++j)
        dp[i][j]=h[i-1]*dp[i-1][j-1]+t[i-1]*dp[i-1][j];
    }

    long double an=0;
    for(int i=n/2+1;i<=n;++i)
    an+=dp[n][i];

    printf("%0.12llf\n",an);
    



return 0;
}

Measured memory_bytes: 140928
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

X=lines[0][0]
N=lines[0][1]
line=lines[1]
if line==nil
  puts X
end
zettai_min=0
line=line.sort

k=0
loop do

 unless line.include? (X-k)
    p X-k
    break
  end 
  unless line.include? (X+k)
    p X+k
    break
  end
  k+=1
end

Measured memory_bytes: 14344
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,W;
  cin >> n >> W;
  vi v(n),w(n);
  REP(i,n) cin >> v[i] >> w[i];
  vvi dp(n+1,vi(1e5,0));
  REP(i,n)REP(j,W+1){
    maxs(dp[i+1][j+w[i]],dp[i][j]+v[i]);
    maxs(dp[i+1][j],dp[i][j]);
  }
  cout << dp[n][W] << endl;
}



Measured memory_bytes: 42748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


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


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a+2),t(b+2);
  for(int i=1;i<=a;i++)
  {
    cin>>s[i];
  }
  for(int i=1;i<=b;i++)
  {
    cin>>t[i];
  }
  s[0]=SE;t[0]=SE;
  s[a+1]=EE;t[b+1]=EE;
  long x;
  long res;
  for(int i=0;i<q;i++)
  {
    cin>>x;
    auto sr=lower_bound(s.begin(), s.end(), x);
    auto tr=lower_bound(t.begin(), t.end(), x);
    auto sl=sr-1,tl=tr-1;
    res=min(x-min(*sl,*tl),max(*sr,*tr)-x);
    res=min(res,*tr-*sl+min(*tr-x,x-*sl));
    res=min(res,*sr-*tl+min(*sr-x,x-*tl));

    cout<<res<<"\n";




  }

  return 0;

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    return 0*printf("%s\n",(c-a-b>=0 && 4*a*b<(c-a-b)*(c-a-b) ? "Yes" : "No"));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct state{
	int p,y,id;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<state> g(m);
	rep(i,m){
		cin>>g[i].p>>g[i].y;
		g[i].id=i;
	}
	sort(begin(g),end(g),[&](const state &a,const state &b){
		if(a.p!=b.p) return a.p<b.p;
		else return a.y<b.y;
	});
	vector<string> ans(m);
	int num=0,now=g[0].p;
	rep(i,m){
		int id=g[i].id;
		if(g[i].p==now){
			num++;
		}else{
			now=g[i].p;
			num=1;
		}
		ans[id]=to_string(num);
		while(ans[id].size()!=6){
			ans[id]="0"+ans[id];
		}
		string t=to_string(g[i].p);
		while(t.size()!=6){
			t="0"+t;
		}
		ans[id]=t+ans[id];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	int dig = n%10;
	if (dig == 2 || dig == 4 || dig == 5 || dig == 7 || dig == 9) cout << "hon\n";
	else if (dig == 0 || dig == 1 || dig == 6 || dig == 8) cout << "pon\n";
	else cout << "bon\n";
	
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  cout << (6 - a - b) << endl;
  
  return 0;
}

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

int N, A;
map<int, int> cnt;
LL answer;

int main() {
    cin >> N;

    answer = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A;

        int target = -(A - i);
        answer += cnt[target];

        cnt[A + i] += 1;
    }

    cout << answer << endl;
}


Measured memory_bytes: 20636
import sys
n=int(input())
s=input()
S=[]
for i in range(n):
  if s[i]=="o":
    S.append(1)
  else:
    S.append(-1)
A=[1,1]
for i in range(1,n-1):
  A.append(S[i]*A[-2]*A[-1])
if S[-1]==A[-2]*A[-1]*A[0]:
  if S[0]==A[-1]*A[0]*A[1]:
    for i in range(n):
      if A[i]==1:
        print("S",end="")
      else:
        print("W",end="")
      if i==n-1:
        print()
        sys.exit()
A=[1,-1]
for i in range(1,n-1):
  A.append(S[i]*A[-2]*A[-1])
if S[-1]==A[-2]*A[-1]*A[0]:
  if S[0]==A[-1]*A[0]*A[1]:
    for i in range(n):
      if A[i]==1:
        print("S",end="")
      else:
        print("W",end="")
      if i==n-1:
        print()
        sys.exit()
A=[-1,1]
for i in range(1,n-1):
  A.append(S[i]*A[-2]*A[-1])
if S[-1]==A[-2]*A[-1]*A[0]:
  if S[0]==A[-1]*A[0]*A[1]:
    for i in range(n):
      if A[i]==1:
        print("S",end="")
      else:
        print("W",end="")
      if i==n-1:
        print()
        sys.exit()
A=[-1,-1]
for i in range(1,n-1):
  A.append(S[i]*A[-2]*A[-1])
if S[-1]==A[-2]*A[-1]*A[0]:
  if S[0]==A[-1]*A[0]*A[1]:
    for i in range(n):
      if A[i]==1:
        print("S",end="")
      else:
        print("W",end="")
      if i==n-1:
        print()
        sys.exit()
print(-1)

Measured memory_bytes: 6476
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = a[0]
for i in range(n-1):
    res = fractions.gcd(res,a[i+1])
print(res)


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

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    int cnt = 0;
    rep(i, n-1){
        if(s.at(i) == s.at(i+1)){
            cnt++;
        }
    }
 /*   rep(i, s.size() - 1)
    {
        if (s.at(i) == 'R' && s.at(i + 1) == 'L') {
            cnt+=2;
            k--;
        }
        if(k == 0){
            break;
        }
    }
*/
    int ans = min(cnt+2*k, n-1);
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/mod.hpp
#ifndef MOD_HPP
#define MOD_HPP


/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T mod(const T lhs, const T rhs) {
    return lhs - quo(lhs, rhs) * rhs;
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;

  const i64 mod = tools::mod(N, K);
  std::cout << std::min(mod, std::abs(mod - K)) << std::endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000

int prim(int);
int n,M[MAX][MAX];

int main(){
  int i,j,e;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1)M[i][j]=INF;
      else M[i][j]=e;
    }
  }

  printf("%d\n",prim(0));

  return 0;

}

int prim(int a){
  int b,c,sum=0;//u,minv
  int d[MAX],e[MAX],f[MAX];//d,p,color
  int i,j;

  for(i=0;i<n;i++){
    d[i]=INF;
    e[i]=-1;
    f[i]=WHITE;
  }

  d[0]=0;

  while(1){
    c=INF;
    b=-1;
    for(i=0;i<n;i++){
      if(c>d[i]&&f[i]!=BLACK){
	b=i;
	c=d[i];
      }
    }
    if(b==-1)break;
    f[b]=BLACK;
    for(j=0;j<n;j++){
      if(f[j]!=BLACK&&M[b][j]!=INF){
	if(d[j]>M[b][j]){
	  d[j]=M[b][j];
	  e[j]=b;
	  f[j]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(e[i]!=-1)sum+=M[i][e[i]];
  }
  return sum;
}



Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int main(){
  string s;
  cin >> s;
  bool flag = true;
  if(s[0]==s[s.size()-1])flag = !flag;
  if(s.size() %2 == 0)flag = !flag;
  if(flag) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	char a[500][500];
	for(int i=0; i<h; i++){
		scanf("%s", a[i]);
	}
	char a1[500][500], a2[500][500];
	for(int i=0; i<h; i++){
		if(i==0){
			for(int j=0; j<w; j++){
				a1[0][j]='#';
			}
		}else if(i==h-1){
			for(int j=0; j<w; j++){
				a1[h-1][j]='.';
			}
		}else{
			for(int j=0; j<w; j++){
				if(j%2!=0 || a[i][j]=='#'){
					a1[i][j]='#';
				}else{
					a1[i][j]='.';
				}
			}
		}
	}
	for(int i=0; i<h; i++){
		if(i==0){
			for(int j=0; j<w; j++){
				a2[0][j]='.';
			}
		}else if(i==h-1){
			for(int j=0; j<w; j++){
				a2[h-1][j]='#';
			}
		}else{
			for(int j=0; j<w; j++){
				if(j%2==0 || a[i][j]=='#'){
					a2[i][j]='#';
				}else{
					a2[i][j]='.';
				}
			}
		}
	}
	for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        printf("%c", a1[i][j]);
      }
      printf("\n");
	}
	printf("\n");
	for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        printf("%c", a2[i][j]);
      }
      printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
  public static void main(String[] args){
    
    int five_count = 0;
    int seven_count = 0;
    int a = -1;
    
    Scanner sc = new Scanner(System.in);
    
    for(int i = 0; i<3; i++){
      a = sc.nextInt();
      if(a == 5){
        five_count++;
      }else if(a == 7){
        seven_count++;
      }else{
        System.out.println("NO");
        break;
      }
    }
    
    if(five_count == 2 && seven_count == 1){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 35536
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i,N)cin >> L[i];
    ll ans = 0;
    rep(i,N)rep(j,N)rep(k,N){
        if(i < j && j < k){
            set<int> st;
            st.insert(L[i]);
            st.insert(L[j]);
            st.insert(L[k]);
            if(st.size() == 3){
                vector<int> v;
                v.emplace_back(L[i]);
                v.emplace_back(L[j]);
                v.emplace_back(L[k]);
                sort(all(v));
                ans += (abs(v[2] - v[1]) < v[0] && v[0] < v[2] + v[1]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
n=int(input())
s=input()
q=int(input())
query=list(map(int,input().split()))
for k in query:
  ds=0
  ms=0
  dms=0
  ans=0
  for i in range(n):
    if s[i]=='D':
      ds+=1
    elif s[i]=='M':
      ms+=1
      dms+=ds
    elif s[i]=='C':
      ans+=dms
    if i>=k-1:
      if s[i-k+1]=='D':
        dms-=ms
        ds-=1
      elif s[i-k+1]=='M':
        ms-=1
  print(ans)

Measured memory_bytes: 70840
def my_turn(card_list):
    global cont_game
    global your_turn
    if card_list:
        your_turn = card_list[0]
        card_list.pop(0)
    else:
        cont_game = False

card_a = [ _ for _ in input()]
card_b = [ _ for _ in input()]
card_c = [ _ for _ in input()]

your_turn = 'a'
cont_game = True

while cont_game:
    if your_turn == 'a':
        my_turn(card_a)
    if your_turn == 'b':
        my_turn(card_b)
    if your_turn == 'c':
        my_turn(card_c)

print(your_turn.upper())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,k,d;
    cin>>x>>k>>d;
    ll ans=1e18;
    x=abs(x);
    ll ci=x/d;
    if(k>ci)
    {
        k-=ci;
        if(k%2)
            ans=abs(x%d-d);
        else
            ans=x%d;
    }
    else
    {
        ans=x-k*d;
    }
    cout<<ans<<'\n';

}


Measured memory_bytes: 3648
hash = {}
group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]
group_a.each { |num| hash[num] = "group_a" }
group_b.each { |num| hash[num] = "group_b" }
group_c.each { |num| hash[num] = "group_c" }
x, y = gets.split.map(&:to_i)
if hash[x] == hash[y]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m=1000000007;
int main() {
	ll n,k,i,j,w;
	cin>>n>>w;
	ll a[n+1],b[n+1];
	for(i=1;i<=n;i++)
	{
	    cin>>a[i]>>b[i];
	}
	vector<vector<ll>>dp(100005,vector<ll>(n+2,-1));
	for(i=0;i<=n;i++)
	dp[0][i]=0;
    dp[0][0]=0;
	ll ans=-1;
	for(i=1;i<=100003;i++)
	{
	    for(j=1;j<=n;j++)
	    {//if(i==4&&j==n)cout<<dp[i-b[j]][j-1]<<"\n";
	        
	        if(b[j]<=i)
	        {
	           // if(i==2 && j==6)
	           // {
	           // cout<<dp[i-b[j]][j-1]<<"\n";
	           // }
	            if(dp[i-b[j]][j-1]!=-1)
	            {
	                if(dp[i-b[j]][j-1]+a[j]<=w)
	                {
	                    if(dp[i][j]==-1)
	                    dp[i][j]=dp[i-b[j]][j-1]+a[j];
	                    else
	                    dp[i][j]=min(dp[i][j],dp[i-b[j]][j-1]+a[j]);
	                    ans=max(ans,i);
	                }
	                //else dp[i][j]=dp[i][j-1];
	                
	            }
	            if(dp[i][j-1]!=-1&&dp[i][j]==-1)
	            dp[i][j]=dp[i][j-1];
	        }
	        else dp[i][j]=dp[i][j-1];
	        if(dp[i][j]!=-1&&dp[i][j-1]!=-1)
	        dp[i][j]=min(dp[i][j],dp[i][j-1]);
	    }
	   // if(i==4)
	   // for(j=0;j<=n;j++)
	   // cout<<dp[i][j]<<" ";
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 86916
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	vector<char> ans;
	rep(i, n)
	{
		if(s[i]=="AB"){
			if(a<b){
				a++;
				b--;
				ans.pb('A');
			}
			else if(a>b){
				b++;
				a--;
				ans.pb('B');
			}
			else{
				if((i<n-1)&&(s[i+1]=="AC")){
					a++;
					b--;
					ans.pb('A');
				}
				else if((i<n-1)&&(s[i+1]=="BC")){
					b++;
					a--;
					ans.pb('B');
				}
				else{
					a++;
					b--;
					ans.pb('A');
				}
			}
		}
		if(s[i]=="AC"){
			if(a<c){
				a++;
				c--;
				ans.pb('A');
			}
			else if(a>c){
				c++;
				a--;
				ans.pb('C');
			}
			else{
				if((i<n-1)&&(s[i+1]=="AB")){
					a++;
					c--;
					ans.pb('A');
				}
				else if((i<n-1)&&(s[i+1]=="BC")){
					c++;
					a--;
					ans.pb('C');
				}
				else{
					a++;
					c--;
					ans.pb('A');
				}
			}
		}
		if(s[i]=="BC"){
			if(b<c){
				b++;
				c--;
				ans.pb('B');
			}
			else if(b>c){
				c++;
				b--;
				ans.pb('C');
			}
			else{
				if((i<n-1)&&(s[i+1]=="AB")){
					b++;
					c--;
					ans.pb('B');
				}
				else if((i<n-1)&&(s[i+1]=="AC")){
					c++;
					b--;
					ans.pb('C');
				}
				else{
					b++;
					c--;
					ans.pb('B');
				}
			}
		}
		if((a<0)||(b<0)||(c<0)){
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	rep(i,n){
		cout << ans[i] << "\n";
	}
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 6696
n=int(input())
a=[input()for i in range(n)]
import itertools
c_0=c_1=c_2=c_3=c_4=0
for i in a:
    if i[0]=="M":
        c_0+=1
    elif i[0]=="A":
        c_1+=1
    elif i[0]=="R":
        c_2+=1
    elif i[0]=="C":
        c_3+=1
    elif i[0]=="H":
        c_4+=1
total=list(itertools.combinations((c_0,c_1,c_2,c_3,c_4),3))
ans=0
for i in range(10):
    ans+=(total[i][0]*total[i][1]*total[i][2])
print(ans)


Measured memory_bytes: 9752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> p(n), q(n), iden(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    for (int i = 0; i < n; ++i) cin >> q[i];
    for (int i = 0; i < n; ++i) iden[i] = i+1;
    int a = 0, b = 0, i = 0;
    while (next_permutation(all(iden)))
    {
        i++;
        if (iden == p) a = i;
        if (iden == q) b = i;
    }
    cout << abs(a - b) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
int a,b,c,d;
  cin >> a >> b >>c >>d;
  if(a+b>c+d){
  
  cout << "Left" << endl;
  }
  else if(a+b==c+d){ cout << "Balanced" << endl;}
 else{ cout << "Right" << endl;}
}

Measured memory_bytes: 256
def main():
    s = input()
    N = len(s)
    # 方針: アルファベット各文字の前回出現位置を記録
    nums = [-1] * 26
    for i in range(N):
        x = ord(s[i]) - ord('a')
        if nums[x] == -1:
            nums[x] = i
        else:
            # 差が2以下ならダメ
            if i - nums[x] < 3:
                print(nums[x]+1, i+1)
                exit()
            else:
                nums[x] = i
    print(-1,-1) 

if __name__ == "__main__":
    main()

Measured memory_bytes: 64220
--fromEnum c
-- | c == 'a'  = 97
-- | c == 'z'  = 122
-- | c == 'A'  = 65
-- | c == 'Z'  = 90
-- | c == '.'  = 46
-- | c == ' '  = 32
-- | c == '\n' = 10

rotate :: Int -> Char -> Char
rotate i c
  | fromEnum c == 46 = c  -- c == '.'
--  | fromEnum c == 10 = c  -- c == '\n'
  | otherwise        = toEnum $ (fromEnum c - 65 + i) `mod` 26 + 65

caesar :: Int -> String -> String
caesar _ [] = []
caesar i (x:xs) = rotate i x : caesar i xs

main :: IO()
main = do
  line <- getLine
  putStrLn $ caesar (-3) line

Measured memory_bytes: 3844
# Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
    items.append(tuple(int(x) for x in input().split()))


DP = [0] * (W+1)
for i in range(N):
    v, w = items[i]
    for j in range(w, W+1):
        DP[j] = max(DP[j], v + DP[j-w])

print(DP[-1])

Measured memory_bytes: 5724
N = int(input())
A = list(map(int, input().split()))
absMin = float('inf')
absSum = 0
numMinus = 0
for a in A:
  if a < 0:
    numMinus += 1
  ab = abs(a)
  absSum += ab
  absMin = absMin if absMin < ab else ab

if numMinus % 2 == 0:
  print(absSum)
else:
  print(absSum - 2 * absMin)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using P = pair<int, int>;

int main() {
    int n, l;
    while(cin >> n >> l, n) {
        vector<P> v(n);
        for(int i=0; i<n; ++i) {
            char c; int pos;
            cin >> c >> pos;
            v[i].second = c == 'R' ? 1 : -1;
            v[i].first = pos;
        }
        int id = -1, length = 0;
        while(true) {
            int ret_id = -1;
            for(int i=0; i<n; ++i) {
                if(v[i].first == -1) {
                    continue;
                }
                v[i].first += v[i].second;
            }
            for(int i=0; i<n; ++i) {
                if(v[i].first == 0 || v[i].first == l) {
                    if(v[i].first == 0 || ret_id == -1 && v[i].first == l) {
                        ret_id = i+1;
                    }
                    v[i].first = -1;
                    continue;
                }
                for(int j=i+1; j<n; ++j) {
                    if(v[i].first == v[j].first) {
                        v[i].second = -v[i].second;
                        v[j].second = -v[j].second;
                    }
                }
            }
            id = ret_id;
            length++;
            if(all_of(v.begin(), v.end(), [](auto const& p) { return p.first == -1; })) {
                break;
            }
        }
        cout << length << " " << id<< endl;
    }
}


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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> board(H);
    for (int i = 0; i < H; i++){
        cin >> board.at(i);
    }

    vector<int> dx(8);
    dx = {0, 1, 0, -1, -1, 1, 1, -1};
    vector<int> dy(8);
    dy = {1, 0, -1, 0, 1, -1, 1, -1};

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (board.at(i).at(j) == '#') continue;
            int num = 0;
            for (int d = 0; d < 8; d++){
                int nx = j + dx.at(d);
                int ny = i + dy.at(d);
                if (nx < 0 || nx >= W) continue;
                if (ny < 0 || ny >= H) continue;
                if (board.at(ny).at(nx) == '#') num++;
            }
            board.at(i).at(j) = (num + '0');
        }
    }

        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
            cout << board.at(i).at(j);
            if (j == W - 1){
                    cout << endl;
                }
             }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  int x = stoi(S.substr(0, 2));
  int y = stoi(S.substr(2, 2));
  if( (x > 12 || x < 1) && ( y > 12 || y < 1)) {
    cout << "NA" << endl;
  } else if (x > 12 || x < 1) {
    cout << "YYMM" << endl;
  } else if (y > 12 || y < 1) {
    cout << "MMYY" << endl;
  } else {
    cout << "AMBIGUOUS" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
 int main(void)
{
	int n,m,i,a;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	{
		scanf("%d",&a);
		n=n-a;
	}
	if(n<0)	printf("-1\n");
	else printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int r; cin >> r;
    cout << r*r << endl;
    return 0;
    return 0;
}

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


 
using namespace std;
 
int main()
{
  int input[3];
  cin >> input[0] >> input[1] >> input[2];
  sort(input, input + 3);
  cout << input[0] << " " << input[1] << " " << input[2] << endl;
  return 0;
}

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

int main ()
{
  int n,k; cin >> n >> k;
  string s; cin >> s;
  int a = 0;
  for(int i =1 ; i<n ; i++){
  	if(s[i] != s[i-1]){
  		a++;
  	}
  }

  a = n - a - 1;

  cout << min(n-1,a + 2*k);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define SZ(x) ((int)(x).size())
#define prts(x) return puts(x),0
#define pirtf(x) return printf("%d\n",x),0
#define re return
typedef long long LL;
#define mod 1000000007
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL B,LL E,LL M){if(!(B%=M))return 0;LL A=1;for(;E;E>>=1,B=B*B%M)E&1?A=A*B%M:0;return A;}
const int INF=0x3f3f3f3f;

map<int,int> mp;
set<int> st;

int H,W,K;

int c[10];
int f[105][10];

int main(){
	
	c[0]=1;
	c[1]=2;
	F(i,2,9) c[i] = c[i-1]+c[i-2];
	
	scanf("%d%d%d",&H,&W,&K);
	f[0][1]=1;
	F2(i,0,H){
		F(j,1,W){
			f[i+1][j]=(f[i+1][j]+(LL)c[j>1?j-2:0]*c[j<W?W-j-1:0]%mod*f[i][j])%mod;
			if(j>1) f[i+1][j-1]=(f[i+1][j-1]+(LL)c[j>2?j-3:0]*c[j<W?W-j-1:0]%mod*f[i][j])%mod;
			if(j<W) f[i+1][j+1]=(f[i+1][j+1]+(LL)c[j>1?j-2:0]*c[j<W-1?W-j-2:0]%mod*f[i][j])%mod;
		}
	}
	printf("%d\n",f[H][K]);
	return 0;
}

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


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep1(i, n) cin >> a[i];
    rep1(i, n){
        if (a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3612
using System;
class Program
{
    static void Main()
    {
        int[] input = new int[10];
        for (int i = 0; i < input.Length; i++)
        {
            input[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(input);
        Array.Reverse(input);
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(input[i]);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 9300
n = int(input())
s = input()

r_count=0
g_count=0
b_count=0

ans = 0

for i in range(n):
    if s[i]=="R":
        r_count+=1
    if s[i]=="G":
        g_count+=1
    if s[i]=="B":
        b_count+=1
ans+=r_count*g_count*b_count

t=int(n-(0.1)//2)
for i in range(1,t):
    for j in range(n-2*i):
        s_1 = s[j]
        s_2 = s[j+i]
        s_3 = s[j+i+i]
        if s_1 !=s_3 and s_2!=s_3 and s_1!=s_2:
            ans-=1
print(ans) 

Measured memory_bytes: 67980
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    string s;
    int ans = 0;
    cin >> s;
    rep(i,sz(s)){
        if(i%2 == 0){
            if(s[i] == 'L'){
                ans = 1;
            }
        }
        else{
            if(s[i] == 'R'){
                ans = 1;
            }
        }
    }
    if(ans == 0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();




		System.out.println((A-1)*(B-1));

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21200
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int a[300005];
int pre[300005];
int main()
{
   int n,k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
       a[i] = a[i]%k;

       a[i]-=1;
       a[i]+=k;
       a[i]%=k;
   }

   for(int i=1;i<=n;i++)
   {
       pre[i]+=pre[i-1];
       pre[i]+=a[i];
       pre[i]%=k;
   }
   map<int,int > my;
   my[0]++;

   for(int i=1;i<min(k,n+1);i++)
   {
       my[pre[i]]++;
   }
   ll ans = 0;
   for(int i=1;i<=n;i++)
   {
       my[pre[i-1]]--;
       ans+=my[pre[i-1]];
       if(i+k-1 <= n)
        my[pre[i+k-1]]++;
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;cin >> n;
 int p;
 string s;
 vector<tuple<string ,int, int>> vec;
 for(int i=0;i<n;i++){
     cin >> s >> p;
     p=-1*p;
     vec.push_back(make_tuple(s, p, i));
 }
 sort(vec.begin(), vec.end());
 int a;
 for(int i=0;i<n;i++){
     tie(ignore, ignore, a) = vec.at(i);
     cout << a+1 << endl;
 }
 return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int A, B, T;
    cin >> A >> B >> T;

    int ans = 0;
    for (int t = A; t <= T; t += A) {
        ans += B;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n, a, b;
const int N = 100000;
int h[N];

bool check(long long t) {
  long long times = 0LL;
  long long small = t * (long long)b;
  int delta = a - b;
  for (int i = 0; i < n; ++i) {
    if (h[i] <= small) continue;
    int tmp = h[i] - (int)small;
    int bigTime = tmp / delta;
    if (tmp % delta) bigTime++;
    times += bigTime;
    if (times > t) return false;
  }
  return true;
}

int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> h[i];
  int l = 1, r = 1e9, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (check(mid)) r = mid;
    else l = mid + 1;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line = sc.nextInt();
		int sum = 0;
		if (line % 2 == 0) {
		    sum += line / 2;
		} else {
		    sum += line / 2 + 1;
		}
		
		System.out.println(sum);
    }
}



Measured memory_bytes: 35792
#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i

# true;"Yes",false;"No"
ans = false 
(0..n/4).each do |i|
  if (n-4*i)%7 == 0 
    ans = true
    break
  end
end

if ans == true 
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1916
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
N = max(a)

if N % 2 == 0:
    ans = N // 2
    dis = 10**18
    ans_ = N
    for i in a:
        if abs(i - ans) <= dis:
            dis = abs(i - ans)
            ans_ = i
    print(N, ans_)

else:
    ans1 = N // 2
    ans2 = ans1 + 1
    ans_ = N
    dis = 10**18
    for i in a:
        if abs(i -ans1) <= dis:
            dis = abs(i - ans1)
            ans_ = i
        if abs(i - ans2) <= dis:
            dis = abs(i - ans2)
            ans_ = i
    print(N, ans_)


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

bool dp[ 5010 ];
int A[ 5010 ];

int main()
{
int i;
int j;
int N, K;
int iCnt;
long long iSum;

	cin >> N;
	cin >> K;

	iSum = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> A[ i ];

		iSum += A[ i ];
	}

	sort( A, A + N );

	dp[ 0 ] = true;
	iCnt = 0;
	for( i = N - 1; i >= 0; i-- )
	{
		for( j = 0; j < K; j++ )
		{
			if( dp[ j ] && j + iSum >= K ) break;
		}

		if( j == K ) iCnt++;

		iSum -= A[ i ];
		for( j = K - 1; j >= A[ i ]; j-- )
			dp[ j ] |= dp[ j - A[ i ] ];
	}

	cout << iCnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int minw = 10005;
bool seen[1005];


ll calcost(vector<pair<int, int> >& w, int id) {
  if (seen[id] || id == w[id].second) {
    seen[id] = true;
    return 0;
  }
  int k = id;
  int wsum = 0;
  int n = 0;
  int minpw = 100005;
  while(!seen[k]) {
    seen[k] = true;
    int value = w[k].first;
    minpw = min(minpw, value);
    wsum += value;
    k = w[k].second;
    n++;
  }
  ll cost1 = wsum + (n-2) * minpw;
  ll cost2 = wsum + minpw + (n+1) * minw;
  ll cost = min(cost1, cost2);
  return cost;
}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > w(n);
  rep(i, n) {
    cin >> w[i].first;
    minw = min(minw, w[i].first);
    w[i].second = i;
  }
  sort(w.begin(), w.end());
  ll ans = 0;
  rep(i, n) {
    ans += calcost(w, i);
  }
  cout << ans << endl;
  
  return 0;
}


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


int main()
{
   int n;
   cin>>n;
   long sum=0;
   vector<long>s(1000005);
   
   for(int i=0;i<n;i++){
     int k;
   cin>>k;
   sum+=k;
   s[k]++;}
   int q;
   cin>>q;
   while(q--){
       int b,c;
       cin>>b>>c;
       sum-=(s[b]*b);
     sum+=(s[b]*c);
     s[c]+=s[b];
     s[b]=0;
     cout<<sum<<endl;}
   return 0;
}


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

/*
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;
    }
};
*/

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    //初期化
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    //親
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 　　
    //併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
    
    //集合のサイズ
    int size(int x) {
        return -r[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3644
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            string s = line[1];
            char s1 = s[0];
            Console.WriteLine("A" + s1 + "C");
        }
    }
}

Measured memory_bytes: 13140