akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数


int main()
{
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  vector<ll> a(n+1) ;
  ll ans = 0 ;
  a.at(0)= 0 ;
  
  REP(i,n-1){
    if(s.at(i)=='>' && s.at(i+1)=='<'){
      a.at(i+1) = 0 ;
    }
  }
  
  REP(i,n){
    if(s.at(i)=='<'){
      a.at(i+1) = a.at(i)+1 ;
    }
  }
  
  RREP(i,n){
    if(s.at(i)=='>'){
      a.at(i) = max(a.at(i),a.at(i+1)+1) ;
    }
  }
  
  REP(i,n+1){
    ans += a.at(i) ;
  }
  
  cout << ans <<endl ;
  


  return 0 ;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

vll divisors[10000001];
int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll k;
	cin>>k;
	ll len = 0;
	ll p = k;
	ll curr = 0;
	while(p>0){
		len++;
		p = p/10;
		curr = curr*10 + 7;
	}
	ll mod = curr%k;
	if(mod == 0){
		cout<<len;
		return 0;
	}
	ll c = 1;
	curr = mod;
	repA(i,1,1000000){
		curr = (curr*10 + 7)%k;
		if(curr == 0){
			cout<<len+i;
			c = 0;
			break;
		}
	}
	if(c){
		cout<<-1;
	}
	return 0;
}

Measured memory_bytes: 238024
import java.math.BigDecimal;
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] A = new long[N];
        boolean flg = false;
        for(int i = 0; i < N; i++) {
            A[i] = scanner.nextLong();
            if(A[i] == 0) flg = true;
        }
        if(flg) {
            System.out.println(0);
            return;
        }
        BigDecimal sum = new BigDecimal(A[0]);
        for(int i = 1; i < N; i++) {
            sum = sum.multiply(new BigDecimal(A[i]));
            if(sum.compareTo(new BigDecimal("1000000000000000000") ) > 0 ){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 62084
#include<stdio.h>
int main() 
{
	int a,b,d,r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = a * 1.00000 / b * 1.00000;
	printf("%d %d %f", d, r, f);
	return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

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

    int r; cin>>r;
    long double c = 2*3.14159265359;
    cout<<c*r<<"\n";

    return 0;
}

Measured memory_bytes: 3792
//linear search

#include<stdio.h>
#define N 10000
#define M 500

//int sear(int);

int n1 = 0;
int n2 = 0;

int main()
{
  int i,j;
  int arr1[N];
  int arr2[M];
  int count = 0;
  int res = 0;

  //input data(be searched)
  scanf("%d",&n1);
  for(i = 0;i < n1; i++)
    {
      scanf(" %d",&arr1[i]);
    }

  //input data(search data)
  scanf("%d",&n2);
  for(j = 0;j < n2; j++)
    {
      scanf(" %d",&arr2[j]);
    }

  //search time
  for(j = 0; j < n2;)
    {
      for(i = 0; i < n1;)
	{
        
	  if(arr1[i] == arr2[j])
	    {
	      count++;
	      j++;
	      break;
	    }

	  else if(arr1[i] != arr2[j])
	    {
	      i++;
	    }
	  if(i == n1) j++;
 
	}
    }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
S = gets.chomp

orig = 'AKIHABARA'
valid = []
[true,false].repeated_permutation(4).each do |a,b,c,d|
  s = orig.dup
  s[0] = ' ' if a
  s[4] = ' ' if b
  s[6] = ' ' if c
  s[8] = ' ' if d
  valid << s.delete(' ')
end

puts (valid.include?(S) ? 'YES' : 'NO')


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

typedef long long ll;

int main(void)
{
    //freopen("input.txt", "r", stdin);

    int i, n;
    cin >> n;
    string a;
    map <string, int> m;
    vector <string> v;

    int cnt = 1;
    for(i = 0; i < n; i++)
    {
        cin >> a;

        auto it = m.find(a);
        if(it != m.end())
        {
            m[a]++;
            if(m[a] > cnt)
                cnt = m[a];
        }
        else
        {
            m.insert(make_pair(a, 1));
        }
    }

    for(auto it = m.begin(); it != m.end(); it++)
    {
        if(it->second == cnt)
            cout << it->first << "\n";
    }

    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  vector<bool> a(s.size());
  rep(i,s.size()){
    if(s[i]=='0') a[i] = false;
    else a[i] = true;
  }

  int ans = 0;
  for(int i = 0;i<s.size();i++){
    if(i+1==s.size()) continue;
    if(a[i+1]==a[i]){
      a[i+1] = !a[i];
      ans++;
    }
  }
  
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define strwspaces(s) getline(cin,s)
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'
#define inp(n) int n;cin>>n;

using namespace std;

int i,j,k,l;

void solve()
{
    int x,y;
    cin>>x>>y;
    int n=(4*x -y)/2;
    int m=(y-2*x)/2;
    //give(n,m);
    if(n>=0 && m>=0 && n+m==x && 2*n +4*m==y)
    {
      cout<<"Yes\n";
    }
    else
      cout<<"No\n";
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count = 0;
    rep(i, A + 1) { // O(N^3) -> 50^3 -> 125000
        rep(j, B + 1) {
            rep(k, C + 1) {
                if (X == 500 * i + 100 * j + 50 * k) count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}


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


void solve(long long N){
  long long mymin = LLONG_MAX;

  for(long long i = 1; i <= N-1; i++) {
    long long tmpi = i;
    long long x = 0;
    while(tmpi > 0) {
      x += (tmpi % 10);
      tmpi /= 10;
    }

    long long tmpj = (N-i);
    long long y = 0;
    while(tmpj > 0) {
      y += (tmpj % 10);
      tmpj /= 10;
    }
    //cout << i << " " << (N-i) << endl;
    //cout << x << " " << y << endl;
    //cout << "====================" << endl;
    mymin = min(mymin, x + y);
  }

  cout << mymin << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
int main() 
{
    scanf("%d",&n);
    cin>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='W')
            cnt++;
    for(int i=n-cnt;i<n;i++)
        if(s[i]!='W')
            ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3896
from fractions import gcd

n, k = map(int, input().split())
a = list(map(int, input().split()))

if k > max(a):
    ans = "IMPOSSIBLE"

else:
    g = a[0]
    for e in a:
        g = gcd(g, e)

    if (max(a) - k) % g == 0:
        ans = "POSSIBLE"
    else:
        ans = "IMPOSSIBLE"

print(ans)


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> p(n);
  for (ll i = 0; i < n; ++i) {
    cin >> p[i];
  }

  double ans = 0;
  double sum = 0;
  queue<double> q;
  for (ll i = 0; i < n; ++i) {
    auto l = p[i];
    auto avg = ((l + l*l) / 2) / double(l);
    sum += ((l + l*l) / 2) / double(l);
    q.push(avg);
    if (q.size() == k) {
      ans = max(ans, sum);
      auto avg = q.front();
      sum -= avg;
      q.pop();
    }
  }

  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int max_a = MAX(a);

  vector<ll> b(max_a+10, 0);
  rep(i, n) {
    b[a[i]]++;
  }

  ll ans = 0;
  for (int i = 0; i < max_a + 3; i++) {
    chmax(ans, b[i] + b[i+1] + b[i+2]);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string s, t;
    cin >> s >> t;

    int ans = INF;
    int lens = (int)s.size(), lent = (int)t.size();
    for (int i=0; i<lens-lent+1; ++i) {
        int tmp = 0;
        for (int j=0; j<lent; ++j) {
            if (s[i+j] != t[j]) ++tmp;
        }
        chmin(ans, tmp);
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    double sum=0;
    cin >> N;
    double W[N];
    double A=0;
    double res1, res2;
    int res;
    for(int i=0; i<N; i++){
        cin >> W[i];
        sum = sum + W[i];
    }
    sum = sum / 2;
    for (int k=0; k<N; k++){
        A = A+W[k];
        if(A > sum){
            res1 = (A-sum);
            res2 = (sum+W[k]-A);
            res = (min(res1, res2)*2);
            cout << res;
            exit(0);
        }
    }

}

Measured memory_bytes: 888
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            else:
                values[i][cp] = values[i - 1][cp]
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    item_list = [Item(v=int(v), w=int(w)) for v, w in items]

    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

Measured memory_bytes: 27848
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define inf (int)1e18 + 7
const int nmax = (int)1e5+10;
const int mod = (int)1e9+7;

int n, k;
int a[nmax];
int dp[110][nmax];
int prefix[110][nmax];

int calc(int i, int beg, int fin) {
  if (beg == 0) {
    return prefix[i][fin];
  }
  int res = prefix[i][fin] - prefix[i][beg - 1];
  if (res < 0) res += mod;
  return res % mod;
}

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

  cin >> n >> k;

  for (int i = 1; i <= n; i ++) {
    cin >> a[i];
  }
  memset(dp, 0, sizeof dp);
  memset(prefix, 0, sizeof prefix);
  for (int i = 0; i <= n; i ++) {
    dp[i][0] = 1;
    prefix[i][0] = 1;
  }

  for (int i = 1; i <= k; i ++) {
    prefix[0][i] = (prefix[0][i - 1] + dp[0][i]) % mod;
  }

  for (int i = 1; i <= n; i ++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = calc(i - 1, max(0LL, j - a[i]), j);
      prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % mod;
    }
  }
  cout << dp[n][k] << endl;

  return 0;
}

Measured memory_bytes: 172288
#include <stdio.h>

const long long mod = 1000000007;
int N,K; long long D[2002][2002],inv[4004004]={0,1},fact[4004004]={1,1},ifact[4004004]={1,1};

long long comb(int n, int k)
{
	return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}

int main()
{
	scanf ("%d %d",&N,&K);
	if (K == 1){
		puts("1");
		return 0;
	}

	for (int i=2;i<N*K;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}

	D[0][0] = 1;
	for (int i=0;i<=N;i++) for (int j=0;j<=i;j++){
		if (i + 1 <= N) D[i+1][j] = (D[i+1][j] + D[i][j]) % mod;
		if (j + 1 <= i) D[i][j+1] = (D[i][j+1] + D[i][j] * comb(N*K-i-j*(K-1)-1,K-2)) % mod;
	}

	printf ("%lld\n",D[N][N]*fact[N]%mod);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 10007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> e(n+1, vector<bool>(n+1, false));
  rep(i, m) {
    int a, b; cin >> a >> b;
    e[a][b] = e[b][a] = true;
  }
  vector<int> v;
  for(int i = 1; i <= n; ++i) v.push_back(i);
  ll ans = 0;
  do {
    if(v[0] != 1) continue;
    bool ok = true;
    rep(i, n-1) if(!e[v[i]][v[i+1]]) ok = false;
    if(ok) ++ans;
  } while(next_permutation(ALL(v)));
  cout << ans << endl;
}

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

int main(){
  char s[60],t[60];
  //int sign=0;
  char ans[60]="UNRESTORABLE";
  scanf("%s",s);
  scanf("%s",t);
  for(int i=strlen(s)-strlen(t);i>=0;i--){
    if(s[i]==t[0] || s[i]=='?'){
      for(int j=0;j<strlen(t);j++){
        if(s[i+j]!=t[j] && s[i+j]!='?')goto reset;
      }
      for(int j=0;j<strlen(t);j++)s[i+j]=t[j];
      for(int l=0;l<60;l++)ans[l]='\0';
      for(int j=0;j<strlen(s);j++){
        if(s[j]=='?')s[j]='a';
        ans[j]=s[j];
      }
      reset:;
    }
  }
  printf("%s\n",ans);
  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(A[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;
int main(){
    ll N, M;
    ll ans;
    cin >> N >> M;

    if (M > 2 * N) {
    	ans = N + (M - 2 * N) / 4;
    }
    else {
    	ans = M / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char HD1,HD2;
    scanf("%c %c",&HD1,&HD2);
    if(HD1=='H'){
        if(HD2=='H'){
            printf("H\n");
        }
        else{
            printf("D\n");
        }
    }
    else{
        if(HD2=='H'){
            printf("D\n");
        }
        else{
            printf("H\n");
        }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb emplace_back
#define pii pair<int,int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
const int N=1e4+10;
ll vis[N], n;
ll f(ll x)
{
    return x * x;
}
int main()
{
    n=read();
    for(int i = 1; i <= 100; ++i){
        for(int j = 1; j <= 100; ++j){
            for(int k = 1; k <= 100; ++k){
                ll now = f(i + j) + f(i + k) + f(j + k);
                now = now / 2;
                if(now >= N) break;
                vis[now]++;
            }
        }
    }
    //ll ans = 0;
    for(int i = 1; i <= n; ++i) printf("%lld\n", vis[i]);
    //cout<<ans<<endl;
}


Measured memory_bytes: 3768
import copy

N,M = map(int,input().split(' '))
graph_releation = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split(' '))
    graph_releation[a-1].append(b-1)
    graph_releation[b-1].append(a-1)
#print(graph_releation)

result_list = []

def search_graph(graph_releation,result_list,current_idx=0,path=[0]):
    for i in range(len(graph_releation[current_idx])):
        next_idx = graph_releation[current_idx][i]
        tmp_path = copy.deepcopy(path)
        if next_idx in tmp_path:
            continue
        tmp_path.append(next_idx)
        if len(tmp_path) == len(graph_releation):
            result_list.append(tmp_path) #確定
            continue
        else:
            search_graph(graph_releation,result_list,next_idx,tmp_path)

search_graph(graph_releation,result_list)
print(len(result_list))

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

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


int main()
{
    string S, T;
    cin >> S;
    cin >> T;
    int q;
    cin >> q;
    vector<int> a(q), b(q), c(q), d(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    int n = S.size(), m = T.size();
    vector<int> num_S(n+1), num_T(m+1);
    FOR(i, 1, n+1){
        num_S[i] += num_S[i-1];
        if(S[i-1] == 'A') num_S[i] += 1;
        if(S[i-1] == 'B') num_S[i] += 2;
    }
    FOR(i, 1, m+1){
        num_T[i] += num_T[i-1];
        if(T[i-1] == 'A') num_T[i] += 1;
        if(T[i-1] == 'B') num_T[i] += 2;
    }

    REP(i, q){
        if((num_S[b[i]]-num_S[a[i]-1])%3 == (num_T[d[i]]-num_T[c[i]-1])%3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

ll x;
int main() {
	cin >> x;

	ll ret = 0;
	ret += (x / 11) * 2;
	x %= 11;
    if(x > 0) ret++;
    if(x > 6) ret++;

	cout << ret << endl;

}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

// ====================================================================

int main() {
  string s;
  cin >> s;
  vector<int> v(s.size());
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      int n = 0;
      for (int n = 0; s[i - n] == 'R'; n++) v[i + n % 2]++;
      for (int n = 1; s[i + n] == 'L'; n++) v[i + n % 2]++;
      i++;
    }
  }
  cout << v << endl;
}


Measured memory_bytes: 1024
using namespace std;

#include <iostream>
#include <vector>
#include <algorithm>


int main() {
    vector<int> v;
    int N;
    cin >> N;
    int i;
    for( i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end());
    cout << (- v[0] + v[N - 1]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int sosu[150000],sum,flg=0;
main(){
  int n=150000,i,j;
  while(1){
  scanf("%d",&n);
  if(n==0)break;
  flg=0;
  for(i=0;i<=150000;i++)sosu[i]=0;
    sum=0;
    for(i=2;flg<n;i++){
    if(sosu[i]==0){
      flg++;
      sum+=i;
    for(j=2;i*j<=150000;j++){
      sosu[i*j]=1;
    }
    }
  }

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

Measured memory_bytes: 1184
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+10;
int n,cnt,ans,a[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n+1;i++)
	{
		if(a[i]==i)cnt++;
		else
		{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	printf("%d",ans);
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    string s;
    cin >> s;
    int n = s.size();
    vector<char> v;
    rep(i, s.size()) {
        if (!v.empty() && v.back() == 'S' && s[i] == 'T') {
            v.pop_back();
        } else {
            v.push_back(s[i]);
        }
    }
    cout << v.size() << endl;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int cnt[200];

char s[MAXN];

void solve(){
	int n;
	scanf("%d%s", &n, &s[0]);
	REP(i, 0, n) {
		cnt[s[i]]++;
	}
	ll ans = 1ll;
	REPN(i, 'a', 'z') {
		ans = (ans * (cnt[i] + 1)) % MOD;
	}
	ans = (ans + MOD - 1) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
a, b, c = list(map(int, input().split()))
if a > b:
    d = b
    b = a
    a = d
if b > c:
    d = c
    c = b
    b = d
if a > b:
    d = b
    b = a
    a = d
if b > c:
    d = c
    c = b
    b = d
print(a, b, c)



Measured memory_bytes: 5596
#include<cstdio>
#include<map>
#include<iostream>
#include<queue>
using namespace std;
map<string,int>f;
map<string,bool>ff;
queue<string>Q;
int main()
{
	string s,t;
	int ans=0;
	int a,b;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) {
		cin>>s;
		f[s]++;
		if(!ff[s]) {
			ff[s]=1;
			Q.push(s);
		}
	}
	scanf("%d",&b);
	for(int i=1;i<=b;i++) {
		cin>>t;
		f[t]--;
		if(!!ff[t]) {
			ff[t]=1;
			Q.push(t);
		}
	}
	while(!Q.empty()) {
		string fff=Q.front();
		Q.pop();
		ans=max(ans,f[fff]);
	}
	printf("%d",ans);
}

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

using namespace std;

int main(){
	int ba=0,a=0,b=0;
	int n; cin >> n;
	string s;
	int ans=0;
	for(int i=0;i<n;i++){
		cin >> s;
		for(int j=0;j<s.size()-1;j++){
			if(s[j]=='A' && s[j+1]=='B'){
				ans++;
			}
		}
		if(s[0]=='B' && s.back()=='A'){
			ba++;
		}
		if(s[0]=='B'){
			b++;
		}
		if(s.back()=='A'){
			a++;
		}
	}
	if((ba==b) && (ba==a) && (ba>0)){
		cout << ans+ba-1 << endl;
	}
	else{
		cout << ans + min(a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //




// - library ------------- //




// --------- library end - //



// - main() -------------- //

int main(){

  string str = is();
  
  for (char c : str){
    if (c == '?') cout << 'D';
    else cout << c;
  }
  br();


// ---------- main() end - //
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

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

signed main(){

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;

        string s;
        cin >> s;

        vector<int> a(n);
        int ba = 0;
        for(int i = 0; i < n; ++i){
            a[i] = 0;
        }
        for(int i = 0; i < 100; ++i){
            int idx = i % n;
            if(s[i] == 'M'){
                a[idx]++;
            }else if(s[i] == 'S'){
                ba += a[idx] + 1;
                a[idx] = 0;
            }else{
                a[idx] += ba + 1;
                ba = 0;
            }
        }

        sort(a.begin(), a.end());
        for(int i = 0; i < n; ++i)
            cout << a[i] << " ";

        cout << ba << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, K, inputs):
    candles = string_to_int(inputs[0])
    min_distance = -1
    for i in range(0, N-K+1):
        left = candles[i]
        right = candles[i+K-1]
        distance = 0
        if left <= 0 and right <= 0:
            distance = abs(left) - abs(right) + abs(0 - right)
        elif left >= 0 and right >= 0:
            distance = right
        else:
            if abs(right) > abs(left):
                distance = abs(left) + abs(left) + abs(right)
            else:
                distance = abs(right) + abs(right) + abs(left)
        if min_distance == -1 or min_distance > distance:
            min_distance = distance

    return min_distance


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, K] = string_to_int(input())
    ret = solve(N, K, inputs(1))
    print(ret)


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 1001
#define int ll
int N,K;
int A[maxn];

int32_t main(){
	fast;
	
	cin>>N>>K;
	
	FOR(i,0,N-1) cin>>A[i];
	sort(A,A+N);
	cout<<accumulate(A,A+K,0);
}



Measured memory_bytes: 3664
#include <stdio.h>
int main(){
	long int a=0,b=0;
	char c;
	scanf(" %ld %c %ld",&a,&c,&b);
	if (c=='+') {
		printf("%ld\n",a+b);
	} else if (c=='-') {
		printf("%ld\n",a-b);
	}
	return 0;
}

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

int n,m;
bool ch[3] ={0};

int main(){
  int i,j;
  char str[3];

  for(i=0;i<3;i++){
    cin >> str[i];
    if(str[i]=='a')ch[0]++;
    if(str[i]=='b')ch[1]++;
    if(str[i]=='c')ch[2]++;
  }
  
  if(ch[1]==1&&ch[2]==1&&ch[0]==1)cout<< "Yes"<<endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 998244353;
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (t == 0)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(p - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    vector<int> c(n, 0);
    rep(i, n)
    {
        cin >> d[i];
        c[d[i]]++;
    }

    if (d[0] != 0)
    {
        cout << 0 << endl;
        return 0;
    }

    mint ans = 1;
    for (int i = 1; i < n; ++i)
    {
        ans *= c[d[i] - 1];
    }

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    int64_t n;
    int a[4];
    pair <int, int> b[4];
    for (int i = 0; i < 4; i++) {
        scanf("%d", &a[i]);
        b[i].first = a[i] << (3 - i);
        b[i].second = i;
    }
    sort(b, b + 4);
    scanf("%lld", &n);
    n *= 4;
    int64_t ans = 0;
    while (n) {
        if (n <= 4 && b[0].second == 3) {
            ans += a[b[1].second];
            n -= 1 << b[1].second;
        }
        else {
            int div = 1 << b[0].second;
            ans += n / div * a[b[0].second];
            n %= div;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define LL long long

using namespace std;

const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const int B = sqrt(1e5);

int n;
int ans;
int pos;
map < string , bool > m;
string s = "111";

void solve()
{
    ans++;
    m[s] = true;
    for( int i = 0; i < 3; i++ ){
        char c = s[i];
        for( int j = 1; j <= n; j++ ){
            s[i] = j + '0';
            if( !m[s] )solve();
        }
        s[i] = c;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> n;
    solve();
    cout << ans;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut ans = 0;

    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }

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


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int C = 0;
  for(int i = 0;i<N-2;i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      C++;
    }
  }
  cout << C << endl;
  }
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		String ans;
		if(a<b && b<c) {
			ans="Yes";
		}else {
			ans="No";
		}
		
		System.out.printf("%s%n",ans);
	}

}



Measured memory_bytes: 26076
n,k,q=map(int,input().split())
i=0
a=[0 for i in range(n+3)]
while(i<q):
    num=int(input())
    a[num]+=1
    i+=1

i=1
while(i<=n):
    if(k-(q-a[i])>0):
        print("Yes")
    else:
        print("No")
    i+=1



Measured memory_bytes: 50848
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	lli n;
	cin>>n;
	lli x=(n*(n-1))/2;
	cout<<x<<'\n';
	return 0;
}

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

using namespace std;

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

    #ifdef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    int x; cin>>x;
    int temp = x /500;
    int ans = 1000*(temp);
    x -= 500*temp;
    x /= 5;
    ans += 5*(x);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n, num[200000];
    cin >>n;
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    int minv = num[0], maxv = -2000000000;
    for(int i = 1; i<n; i++){
        maxv = max(maxv, num[i] - minv);
        minv = min(minv, num[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3840
#include <iostream>

using namespace std;
#define max 1260-540

bool times[10000][max+1];

int main(void){
	int N,M,r,q;
	while(cin >> N  >> M, N|M){
		for(int i=0;i<M;i++)
			for(int j=0;j<=max;j++)
				times[i][j]=false;

		cin >> r;
		int start[1001];
		for(int i=0;i<r;i++){
			int t,n,m,s;
			cin >> t >> n >> m >> s;
			if(s)
				start[n]=t-520;
			else{
				for(int k=start[n];k<t-520;k++)
					times[m][k]=true;
			}
		}
		cin >> q;
		for(int i=0;i<q;i++){
			int ts,te,m;
			cin >> ts >> te >> m;
			int num=0;
			for(int i=ts-520;i<te-520;i++){
				if(times[m][i])
					num++;
			}
			cout << num << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 7980
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }
    }
}







Measured memory_bytes: 21716
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
problems = [False] * N
AC = [0] * N
WA = [0] * N
for _ in range(M):
    p, S = sr().split(); p = int(p) - 1
    if not problems[p] and S == 'WA':
        WA[p] += 1
    if not problems[p] and S == 'AC':
        problems[p] = True
        AC[p] += 1

AC_total = sum(AC)
WA_total = sum(y for x, y in zip(AC, WA) if x)
print(AC_total, WA_total)


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  CIN(int, a, b);
  COUT(a * b);
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>


using namespace std;

int main()
{
    int N,K,X,Y;
    int fee;
    cin >> N >> K >> X >> Y;
    if(N <= K){
        fee = N * X;
    }else{
        fee = X * K + (N - K) * Y;
    }
    cout << fee << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

long long int b[1000000];
long long int n,i,k=0;

scanf("%lld",&n);

for(i=1;i<=n;i++)
{
scanf("%lld",&b[i]);
if(b[i]!=i)
{
k++;
}

}
if(k==0 || k==2)
{
printf("YES\n");
}
else 
printf("NO\n");  
return 0;
}    

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		int s[3];
		s[0]=a;s[1]=b;s[2]=c;
		sort(s,s+3);
		if(s[0]*s[0]+s[1]*s[1]==s[2]*s[2])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168