akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

ll bnp( ll x , ll y )
{
    if( y == 0 )return 1;
    if( (y & 1) ){
        return x * bnp( x , y - 1 ) % mod;
    }else{
        ll b = bnp( x , y / 2 );
        return b * b % mod;
    }
}

void solve1()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = bnp( 2 , n ) - 1;
    ll cnt = 0;
    ll p = 1;
    ll pp = 1;
    for( ll i = 1; i <= a; i++ ){
        p = p * (n - i + 1) % mod;
        pp = pp * i % mod;
    }
    p = p * bnp( pp , mod - 2 ) % mod;
    ans = ( ans - p + mod ) % mod;
    p = 1;
    pp = 1;
    for( ll i = 1; i <= b; i++ ){
        p = p * (n - i + 1) % mod;
        pp = pp * i % mod;
    }
    p = p * bnp( pp , mod - 2 ) % mod;
    ans = ( ans - p + mod ) % mod;
    cout << ans;
}

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

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int divide_num(int N){
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if ( N % i == 0 ) {
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int N = 0;
  cin >> N;

  int cnt = 0;
  for (int i = 1; i <= N; i += 2) {
    if ( divide_num(i) == 8 ) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
const int maxn=1005+5;
char a[maxn],b[maxn];
int main()
{
int len_a,len_b;
	scanf("%s",a);
	scanf("%s",b);
	len_a=strlen(a);		
	len_b=strlen(b);
	if(len_a>len_b)
		printf("GREATER\n");
	if(len_a<len_b)
		printf("LESS\n");
	if(len_a==len_b)
	{	if(strcmp(a,b)>0)
			printf("GREATER\n");
		if(strcmp(a,b)<0)
			printf("LESS\n");
		if(strcmp(a,b)==0)
			printf("EQUAL\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left; k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }
        else {
            A[k]=R[j++];
        }
    }
}

void mergeSort(int A[],int n,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}
int main(){
    int A[MAX],n,i;
    cnt=0;
    cin >> n;
    for(i=0;i<n;i++)cin >> A[i];
    mergeSort(A,n,0,n);

    for(i=0;i<n;i++){
        if(i)cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt <<endl;

    return 0;
    }


Measured memory_bytes: 6920
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  int a, b, c; cin >> a >> b >> c;
  if (a+c == 2*b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

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

int like2017(ll n){
    ll n2=(n+1)/2;
    bool ok1=true,ok2=true;
    for(ll i=2;i<n;++i){
        if(n%i==0) ok1=false;
    }
    for(ll i=2;i<n2;++i){
        if(n2%i==0) ok2=false;
    }
    if(ok1&&ok2) return 1;
    else return 0;
}

int main(void)
{
    int max=1e5+1;
    vector<ll> is_prime(max,1);
    is_prime[0]=is_prime[1]=0;
    for(int i=2;i<max;++i){
        if(!is_prime[i]) continue;
        for(int j=i*2;j<max;j+=i) is_prime[j]=0;
    }

    vector<ll> a(max,0);
    for(int i=0;i<max;i++){
        if(i%2==0) continue;
        if(is_prime[i]&&is_prime[(i+1)/2]) a[i]=1;
    }

    vector<ll> s(max+1,0);
    rep(i,max) s[i+1]=s[i]+a[i];

    ll q; cin>>q;
    rep(i,q){
        ll l,r; cin>>l>>r;
        cout<<s[r+1]-s[l]<<endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const string NG = "invalid";

// ??°????????¢?????¨????????\??????
bool num(string s)
{
    bool ret = true;
    rep(i,s.size())if(s[i]<'0' || '9'<s[i]) ret = false;
    if(s[0]=='0') ret = (s=="0");
    return ret;
}

string MAX(string a, string b)
{
    int A = a.size(), B = b.size();
    if(A>B) return a;
    if(A<B) return b;
    rep(i,A)
    {
        if(a[i]>b[i]) return a;
        if(a[i]<b[i]) return b;
    }
    return a;
}

map<string,string> dp;
string E(string s)
{
    int S = s.size();
    if(S==0) return NG;

    if(dp.count(s)) return dp[s];

    string ret = NG;
    if(s[0]=='L' || s[0]=='R' || ('0'<=s[0] && s[0]<='9') || s[0]=='?')
    {
        if(s[0]=='L' || s[0]=='R')
        {
            if(S<6) return NG;
            if(!(s[1]=='('||s[1]=='?')) return NG;
            if(!(s[S-1]==')'||s[S-1]=='?')) return NG;

            string y = s.substr(2,S-3);
            int Y = y.size();
            for(int i=1; i<Y-1; ++i)
            {
                if(y[i]=='?' || y[i]==',')
                {
                    string l = E(y.substr(0,i));
                    string r = E(y.substr(i+1));

                    if(l!=NG && r!=NG)
                    {
                        string x;
                        if(s[0]=='L') x=l;
                        if(s[0]=='R') x=r;

                        if(ret==NG) ret = x;
                        else ret = MAX(ret,x);
                    }
                }
            }
        }
        else if('0'<=s[0] && s[0]<='9')
        {
            rep(i,S)if(s[i]=='?') s[i]='9';
            if(num(s)) return s;
            else return NG;
        }
        else if(s[0]=='?')
        {
            string candidate = "LR9";
            rep(i,3)
            {
                s[0] = candidate[i];
                string x = E(s);
                if(x!=NG)
                {
                    if(ret==NG) ret = x;
                    else ret = MAX(ret,x);
                }
            }
        }
    }
    return dp[s]=ret;
}

int main()
{
    string s;
    cin >>s;
    cout << E(s) << endl;
    return 0;
}

Measured memory_bytes: 3448
package main

import "fmt"

func sort(a []int) int {
	n := len(a)
	c := 0
	for i := range a {
		minj := i
		for j := i; j < n; j++ {
			if a[j] < a[minj] {
				minj = j
			}
		}
		a[i], a[minj] = a[minj], a[i]
		if minj != i {
			c++
		}
	}
	return c
}

func main() {
	n := 0
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	x := sort(a)
	for i, e := range a {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", e)
	}
	fmt.Printf("\n")
	fmt.Println(x)
}



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,w; cin>>n>>w;
  vpll a(n,{0,INF+1}), b(n,{0,INF+1}), c(n,{0,INF+1}), d(n,{0,INF+1});
  ll pa=0,pb=0,pc=0,pd=0;
  ll prev=-1;
  rep(i,n){
    ll w,v; cin>>w>>v;
    if(prev==-1) prev=w;
    if(w-prev==0){
      a[pa]={v,w};
      pa++;
    }
    if(w-prev==1){
      b[pb]={v,w};
      pb++;
    }
    if(w-prev==2){
      c[pc]={v,w};
      pc++;
    }
    if(w-prev==3){
      d[pd]={v,w};
      pd++;
    }
  }
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());
  sort(d.rbegin(),d.rend());
  
  ll ans=0;
  ll avsum=0, awsum=0;
  irep(i,-1,n){
    if(i!=-1) avsum+=a[i].first, awsum+=a[i].second;
    ll bvsum=0, bwsum=0;
    irep(j,-1,n){
      if(j!=-1) bvsum+=b[j].first, bwsum+=b[j].second;
      ll cvsum=0, cwsum=0;
      irep(k,-1,n){
        if(k!=-1) cvsum+=c[k].first, cwsum+=c[k].second;
        ll dvsum=0, dwsum=0;
        irep(l,-1,n){
          if(l!=-1) dvsum+=d[l].first, dwsum+=d[l].second;
          if(awsum+bwsum+cwsum+dwsum>w) break;
          chmax(ans,avsum+bvsum+cvsum+dvsum);
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int a, b;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        a = int.Parse(input[0]);
        b = int.Parse(input[1]);
        int x = b;
        if (a <= 5) x = 0;
        else if (a <= 12) x = b / 2;

        Console.WriteLine(x);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <utility>
#include <fstream>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define IO ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const int N = 1e4 + 5, inf = 1e9, mod = 998244353;
using namespace std;

int main()
{
    IO
    int r, c, n, a[N], ans[105][105], x = 0, y = 0, t = 0, mn;
    cin >> r >> c >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; )
    {
        if(!t)
        {
            mn = min(a[i], c - y);
            for(int j = y; j < y + mn; j++)
                ans[x][j] = i + 1;
            y += mn; a[i] -= mn;
            if(y == c)
                x++, t ^= 1;
        }
        else
        {
            mn = min(a[i], y);
            for(int j = y - 1; j >= y - mn; j--)
                ans[x][j] = i + 1;
            y -= mn; a[i] -= mn;
            if(!y)
                x++, t ^= 1;
        }
        if(!a[i]) i++;
    }
    for(int i = 0; i < r; i++, cout << '\n')
        for(int j = 0; j < c; j++)
            cout << ans[i][j] << ' ';
    return 0;
}

Measured memory_bytes: 3700
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int x;
    cin >> x;
    int k = x / 100;
    if(x >= 100 * k && x <= 105 * k)cout<< 1 << endl;
    else cout<< 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N,D[52],ma=-1,X=0;

void hantei(ll chek[]){
    ll mi = INF,T=0;
    Rep(i,1,25){
        if(chek[i%24]==0){
            T++;
        }
        else{
            mi=min(T+1,mi);
            T=0;
        }
    }
    ma=max(ma,mi);
}

void dfs(ll key,ll chek[]){
    if(key==N){
        hantei(chek);
        return;
    }
    if(chek[D[key]]==1 && chek[24-D[key]]==1){
        X=1;
        return;
    }
    if(chek[D[key]]==0){
        chek[D[key]]=1;
        dfs(key+1,chek);
        chek[D[key]]=0;
    }
    if(chek[24-D[key]]==0){
        chek[24-D[key]]=1;
        dfs(key+1,chek);
        chek[24-D[key]]=0;
    }
}

int main(){
    ll chek[50];
    cin >> N;
    rep(i,24){
        chek[i]=0;
    }
    chek[0]=1;
    chek[24]=1;
    rep(i,N){
        cin >> D[i];
    }
    dfs(0,chek);
    cout << (X==1 ? 0 : ma ) << endl;
}

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

char s[50][50];

void Main()
{
  int H, W;
  cin >> H >> W;
  rep (i,H){
    rep(j,W) {
      cin >> s[i][j];
    }
  }
  rep(i,H) {
    rep(j,W) {
      if (s[i][j] == '#') {
        bool canPaint = false;
        if (i > 0) {
          if (s[i-1][j] == '#') canPaint = true;
        }
        if (j > 0) {
          if (s[i][j-1] == '#') canPaint = true;
        }
        if (i < H-1) {
          if (s[i+1][j] == '#') canPaint = true;
        }
        if (j < W-1) {
          if (s[i][j+1] == '#') canPaint = true;
        }
        if (!canPaint) {cout << "No" << endl; return;}
      }
    }
  }
  cout << "Yes" << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    boost::multiprecision::cpp_int A,B,C;
    cin >> A >> B >> C;
    if(A%2 == 0 || B%2 == 0 || C%2 == 0) cout << 0 << endl;

    else cout << A*B*C / max({A,B,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 n = sc.nextInt();
    int[] a = new int[n];
    int[] ans  = new int[n+1];

    for(int i=0; i<n; ++i) a[i] = sc.nextInt();
    for(int i=1; i<ans.length; ++i) {
      ans[a[i-1]] = i;
    }

    for(int i=1; i<ans.length; ++i) {
      System.out.print(ans[i]);
      System.out.print(" ");
    }

  }
}

Measured memory_bytes: 63264
n = int(input())
a = [int(x) for x in input().split()]
ans = pow(10, 15)
key = sum(a)
p = 0
for i in range(n-1):
  p += a[i]
  if ans > abs(key-2*p):
    ans = abs(key-2*p)
    
print(ans)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(string s, int &ans){

    int ans_buf = 1e6;
    string old_s, new_s;

    for(char c = 'a'; c <= 'z'; ++c){
        old_s = s;

        for(int cnt = 0; ; ++cnt){
            if(old_s.empty()) break;

            else if(old_s == string(old_s.size(), c)){
                ans_buf = min(cnt, ans_buf);
                break;
            }

            new_s = "";
            for(int i = 0; i != (int)(old_s.size())-1; ++i){
                if(old_s.at(i) == c || old_s.at(i+1) == c) new_s += c;
                else new_s += old_s.at(i);
            }
            old_s = new_s;
        }
    }
    ans = ans_buf;

    return;
}

int main(){

    string s;
    cin >> s;

    int ans;
    solver(s, ans);

    cout << ans << endl;
    cerr << string(s.size(), 'a');
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll solve(ll A){
	if (A % 2 == 0){
		if ((A / 2) % 2 == 0){
			return A ^ 0;
		}
		else{
			return A ^ 1;
		}
	}	
	else if (((A + 1)/2) % 2 == 0){
			return 0;
	}
	else{
		return 1;
	}
}
int main(){
	ll A,B;
	cin >> A;
	cin >> B;
	cout << (solve(A-1) ^ solve(B)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
ll ans=0;
string s;
int main()
{
	cin>>s;
	rep(i,s.size())
	{
		ans+=s[i]-'0';
		if(ans>9)
		{
			ans%=9;
		}
	}
	ans%=9;
	if(ans==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3736
# solution

nim, mike = map(int, input().split())
array = list(map(int, input().split()))
k = float("INF")
for i in range(nim-mike+1):
	l = array[i]
	r = array[i+mike-1]
	k = min(k, abs(l)+abs(r-l), abs(r)+abs(r-l))
print(k)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 0) {
    vector<char> st_1(s.size() / 2);
    vector<char> st_2(s.size() / 2);
    rep(i, s.size() / 2) {
      st_1.at(i) = s.at(i);
      st_2.at(i) = s.at(i + (s.size() / 2));
    }
    if (st_1 == st_2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main()
{
    long S,W;
    std::cin >> S >> W;
    if(W>=S){
        std::cout << "unsafe" << std::endl;
    }else{
        std::cout << "safe" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;

ll v[110] ;
ll w[110] ;
ll dp[110][110000] ;

int main() {

    ll n,W ;
    cin >> n >> W ;

    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i] ;
    }    

    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            dp[i][j] = dp[i-1][j] ;
            if(j-w[i]>=0){
            dp[i][j] = max(dp[i][j],
                           dp[i-1][j-w[i]] + v[i]) ;
        }
        }
    }

    cout << dp[n][W] << endl ;

    return 0 ;
}

Measured memory_bytes: 82016
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << char(a[0] + 'A' - 'a') << char(b[0] + 'A' - 'a') << char(c[0] + 'A' - 'a') << endl;
 
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = tuple(map(int, tuple(input())))

    ans = 10 ** 5
    for i in range(2):
        v = i
        a = 0
        for s in S:
            if s != v:
                a += 1
            v = 1 if v == 0 else 0
        ans = min(ans, a)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4780
#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
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename 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 T> ostream& operator<<(ostream& s,const multiset<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=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n+1),b(n);
    rep(i,n+1) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(i,n){
        if(b[i]>=a[i]){
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(b[i]>=a[i+1]){
                ans+=a[i+1];
                a[i+1]=0;
            }else{
                ans+=b[i];
                a[i+1]-=b[i];
            }
        }else{
            ans+=b[i];
            a[i]-=b[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
s = input()
x = 7
if s == "SUN":
    pass
elif s == "SAT":
    x = x - 6
elif s == "FRI":
    x = x - 5
elif s == "THU":
    x = x - 4
elif s == "WED":
    x = x - 3
elif s == "TUE":
    x = x - 2
elif s == "MON":
    x = x - 1


print(x)


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

int N;
string s,t;

bool solve(char a,char b){
    for (int i=0;i<N;i++) t[i]='X';
    t[0]=a;t[1]=b;
    //cout<<a<<" "<<b<<endl;
    for (int i=0;i<N;i++){
        //cout<<t<<endl;
        int l,r;
        l = (i==0)?N-1:i-1;
        r = (i==N-1)?0:i+1;
        //cout<<l<<" "<<r<<endl;
        if (t[i]=='S') {
            if (s[i]=='o'){
                if (t[l]=='X') t[l] = t[r];
                else if (t[r]=='X') t[r] = t[l];
                else if (t[r]!=t[l]){
                    //cout<<1<<endl;
                    return false;
                }
            }
            if (s[i]=='x'){
                if (t[l]=='X') t[l] = (t[r]=='S')?'W':'S';
                else if (t[r]=='X') t[r] = (t[l]=='S')?'W':'S';
                else if (t[r]==t[l]){
                    //cout<<2<<endl;
                    return false;
                }
            }
        }
        else if (t[i]=='W') {
            if (s[i]=='x'){
                if (t[l]=='X') t[l] = t[r];
                else if (t[r]=='X') t[r] = t[l];
                else if (t[r]!=t[l]){
                    //cout<<3<<endl;
                    return false;
                }
            }
            if (s[i]=='o'){
                if (t[l]=='X') t[l] = (t[r]=='S')?'W':'S';
                else if (t[r]=='X') t[r] = (t[l]=='S')?'W':'S';
                else if (t[r]==t[l]){
                    //cout<<4<<endl;
                    return false;
                }
            }
        }
    }
    return true;
}

int main(void){

    cin>>N>>s;
    for (int i=0;i<N;i++) t.push_back('X');

    bool ans = false;
    if (solve('S','S')){
        cout<<t<<endl;
        return 0;
    }
    if (solve('S','W')){
        cout<<t<<endl;
        return 0;
    }
    if (solve('W','S')){
        cout<<t<<endl;
        return 0;
    }
    if (solve('W','W')){
        cout<<t<<endl;
        return 0;
    }  
    cout<<-1<<endl;
    return 0;
}

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

int main() {
  ll n, t;
  cin >> n >> t;
  ll limit = t;
  ll ans = t;
  vector<ll> time(n);
  rep(i, n) cin >> time[i];
  rep(i,n){
    if(i > 0){
      if(time[i] >=limit){
        ans += t;
      }else {
        ans += time[i] - time[i-1];
      }
      limit = time[i] + t;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int minus = 0;
  int AT[n];
  long ans = 0;
  bool zero = 1;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] < 0) minus++;
    ans += abs(a[i]);
    AT[i] = abs(a[i]);
    if(a[i] == 0) zero = 0;
  }
  if(zero) {
    if(minus % 2 == 1) {
      sort(AT, AT + n);
      ans -= 2 * AT[0];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <numeric>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> p;
    int in;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        p.emplace_back(in);
    }

    int sum;
    int max = 0;
    int maxi;
    vector<int>::iterator pstart, pend;
    for (int i = 0; i <= N - K; i++)
    {
        pstart = p.begin() + i;
        pend = pstart + K;
        sum = accumulate(pstart, pend, 0);
        if (sum > max)
        {
            max = sum;
            maxi = i;
        }

    }

    double ans = 0.0;
    for (int i = 0; i < K; i++)
    {
        ans += 0.5 * (1 + p[maxi + i]);
    }
    
    cout <<  fixed  <<  setprecision(12)  <<  ans  << endl;
    
    return 0;
}

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

using namespace std;

namespace tt {

template <typename T>
class SegmentTree {
 public:
  using Op = function<T(const T &a, const T &b)>;

 private:
  vector<T> data_;
  int size_;
  Op op_;
  T e_;

  T QuerySub(int left, int right, int k, int k_left, int k_right) {
    if (right <= k_left || k_right <= left) {
      return e_;
    } else if (left <= k_left && k_right <= right) {
      return data_[k];
    } else {
      int mid = (k_left + k_right) / 2;
      return op_(QuerySub(left, right, k * 2 + 1, k_left, mid),
                 QuerySub(left, right, k * 2 + 2, mid, k_right));
    }
  }

 public:
  T operator[](int pos) { return data_[pos + size_ - 1]; }

  SegmentTree(int size, T e, Op op) : op_(op), e_(e) {
    size_ = 1;
    while (size_ < size) {
      size_ *= 2;
    }

    data_.resize(size_ * 2 - 1);
  };

  void Update(int pos, T val) {
    pos += size_ - 1;
    data_[pos] = val;
    while (pos > 0) {
      pos = (pos - 1) / 2;
      data_[pos] = op_(data_[pos * 2 + 1], data_[pos * 2 + 2]);
    }
  }

  T Query(int left, int right) { return QuerySub(left, right, 0, 0, size_); }
  T QueryAll() { return QuerySub(0, size_, 0, 0, size_); }
};

}  // namespace tt

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  int max_el = 5 * pow(10, 5);
  tt::SegmentTree<int> seg_tree(
      max_el, 0, [](const int &a, const int &b) { return max(a, b); });

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

    int max_n = seg_tree.Query(max(0, a - k), min(max_el, a + k + 1));
    seg_tree.Update(a, max_n + 1);
  }

  cout << seg_tree.QueryAll() << '\n';
}

Measured memory_bytes: 7472
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] array = new int[3][3];
		for(int i = 0; i<3; i++){
			for(int j = 0; j<3; j++){
				array[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		int[] rows = new int[3];
		int[] cols = new int[3];
		for(int k = 0; k<n; k++){
			int b = sc.nextInt();
			for(int w = 0; w<3; w++){
				for(int m = 0; m<3; m++){
					if(array[w][m] == b){
						array[w][m] = 0;
						rows[w]++;
						cols[m]++;
					}
				}
			}
		}
		String ans = "No";
		for(int i = 0; i<3; i++){
			if(rows[i] == 3 || cols[i] == 3){
				ans = "Yes";
				break;
			}
		}
		if(array[0][0] == 0 && array[1][1] == 0 && array[2][2] == 0 ||
			array[0][2] == 0 && array[1][1] == 0 && array[2][0] == 0){
			ans = "Yes";
		}
		System.out.println(ans);
		sc.close();
	}
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

const int mod = 1e9 + 7;

int64 A[16][16];
int64 cost[1 << 16];
int64 dp[1 << 16];
bool memo[1 << 16];

int64 rec(int bit) {
  if(exchange(memo[bit], true)) return dp[bit];
  int64 ret = cost[bit];
  for(int i = bit; i > 0; i = (i - 1) & bit) {
    if(i == bit) continue;
    int other = i ^bit;
    ret = max(ret, rec(i) + rec(other));
  }
  return dp[bit] = ret;
}

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < (1 << N); i++) {
    for(int j = 0; j < N; j++) {
      for(int k = j; k < N; k++) {
        if((i >> j) & 1 && (i >> k) & 1) cost[i] += A[j][k];
      }
    }
  }
  cout << rec((1 << N) - 1) << endl;
}


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

long long func(long long p, vector<long long> S, vector<long long> T) {
  long long x, y, w, z;
  
  auto p_s_u = upper_bound(S.begin(), S.end(), p);
  if(p_s_u==S.end()) {
    x = S[S.size()-1];
    y = S[S.size()-1];
  } else {
    x = *p_s_u;
    if(x!=S[0]) {
      y = *(p_s_u-1);
    } else {
      y = x;
    }
  }
  
  auto p_t_u = upper_bound(T.begin(), T.end(), p);
  if(p_t_u==T.end()) {
    w = T[T.size()-1];
    z = T[T.size()-1];
  } else {
    w = *p_t_u;
    if(w!=T[0]) {
      z = *(p_t_u-1);
    } else {
      z = w;
    }
  }
    
  long long a = abs(p-x) + abs(x-w);
  long long b = abs(p-x) + abs(x-z);
  long long c = abs(p-y) + abs(y-w);
  long long d = abs(p-y) + abs(y-z);
  long long e = abs(p-w) + abs(w-x);
  long long f = abs(p-w) + abs(w-y);
  long long g = abs(p-z) + abs(z-x);
  long long h = abs(p-z) + abs(z-y);
  
  return min({a,b,c,d,e,f,g,h});
}

int main() {
  int A, B, Q;
  cin >> A >> B >> Q;
  
  vector<long long> S(A,0);
  vector<long long> T(B,0);
  
  for(int i=0; i<A; i++) {
    cin >> S[i];
  }  
  
  for(int i=0; i<B; i++) {
    cin >> T[i];
  }
  
  for(int i=0; i<Q; i++) {
    long long p;
    cin >> p;
    
    long long x, y, w, z;
  
    auto p_s_u = upper_bound(S.begin(), S.end(), p);
    if(p_s_u==S.end()) {
      x = S[S.size()-1];
      y = S[S.size()-1];
    } else {
      x = *p_s_u;
      if(x!=S[0]) {
        y = *(p_s_u-1);
      } else {
        y = x;
      }
    }
  
    auto p_t_u = upper_bound(T.begin(), T.end(), p);
    if(p_t_u==T.end()) {
      w = T[T.size()-1];
      z = T[T.size()-1];
    } else {
      w = *p_t_u;
      if(w!=T[0]) {
        z = *(p_t_u-1);
      } else {
        z = w;
      }
    }
    long long a = abs(p-x) + abs(x-w);
    long long b = abs(p-x) + abs(x-z);
    long long c = abs(p-y) + abs(y-w);
    long long d = abs(p-y) + abs(y-z);
    long long e = abs(p-w) + abs(w-x);
    long long f = abs(p-w) + abs(w-y);
    long long g = abs(p-z) + abs(z-x);
    long long h = abs(p-z) + abs(z-y);
    
    cout << min({a,b,c,d,e,f,g,h}) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2944
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  int N, M;
  cin >> N >> M;

  int x = M / N;
  for (; M % x != 0; x--) {
  }
  cout << x << endl;
}

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


Measured memory_bytes: 256
#define max(a,b)((a)>(b)?(a):(b))
D[3][301],i,j,c,p;
main(n,m){
	for(;~scanf("%d%d",&n,&m);){
		memset(D,0,sizeof(D));
		for(;n--;){
			scanf("%*c%*[^\n]%d",&c);
			for(i=3;i--;){
				scanf("%d",&p);
				for(j=c;j<=m;j++)
					D[i][j]=max(D[i][j],D[i][j-c]+p);
			}
		}
		printf("%d\n",max(max(D[0][m],D[1][m]),D[2][m]));
	}
	{int n;for(n=1e6;n--;)getchar();}//delay(0.52s)
	exit(0);
}

Measured memory_bytes: 424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int S=N;
  int l,r;
  for(int i=0;i<N;i++){
    cin>>l>>r;
    S+=r-l;
  }
  cout<<S<<endl;
}

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

const int mod=1e9+7;

void U(int &x,int y){
    x=(x+y)%mod;
}

int n, m, a[202000];
char s[202000];

int main(){
    cin>>n>>m>>s+1;
    for (int i=1;i<=m;++i)
        a[i]= s[i]==s[1];
    if (*min_element(a+1,a+m+1)==1){
        static int f[202000][2][2];
        f[1][0][0]=f[1][1][1]=1;
        for (int i=1;i<n;++i){
            for (int s=0;s<=1;++s)
                for (int t=0;t<=1;++t)
                    for (int tt=0;tt<=1;++tt){
                        if (t==0&&tt==0) continue;
                        U(f[i+1][s][tt],f[i][s][t]);
                    }
        }
        int ans=(1ll*f[n][0][1]+f[n][1][0]+f[n][1][1])%mod;
        cout<<ans<<endl;
        return 0;
    }
    int las=0, mx=1e9; vector<int>vec;
    for (int i=1;i<=m;++i)
        if (a[i]){
            ++las;
        }else{
            vec.push_back(las);
            las=0;
        }
    {
        int t=vec.front(); vec.erase(vec.begin());
        mx=min(mx,(t&1? t: t+1));
    }
    for (auto t:vec){
        if (t&1) mx=min(mx,t);
    }


    static int ans=0, f[202000], sum[202000];
    f[1]=sum[1]=1;
    for (int i=1;i<=n;++i){
        if (i!=1){
            f[i]=(sum[i-2]-sum[max(0,i-mx-3)]+mod)%mod;
            sum[i]=(sum[i-2]+f[i])%mod;
        }
        if ((n-i&1)&&n-i<=mx){
            ans=(ans+(ll)f[i]*(n-i+1))%mod;
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v={0};
    int a;
    for(int i=0;i<n;++i){
        cin >> a;
        v.push_back(a);
    }
    int i=1,count=0;
    while(i!=2){
        i = v[i];
        ++count;
        if(count>n){
            count = -1;
            i=2;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int h,w,n;
    cin >> h >> w >> n;
    int R,U;
    cin >> U >> R;
    string s,t;
    cin >> s >> t;

    bool flag = false;


///横方向
    int l,r;
    l = 1;
    r = w;

    REPR(i,n-1){
        if(i !=n -1){
            if(t[i] == 'R'){
                l = max(l - 1, llong(1));
            }
            else if(t[i] == 'L'){
                r = min(r + 1, w);

            }
        }

        if(s[i] == 'R'){
            r-= 1;
        }
        else if(s[i] == 'L') l += 1;

        if(l> r) flag = true;
    }


    int d = 1,u = h;
    REPR(i,n-1){
        if(i !=n -1){
            if(t[i] == 'D'){
                d = max(llong(1), d-1);
            }
            else if(t[i] == 'U'){
                u = min(u + 1, h);

            }
        }

        if(s[i] == 'D'){
            u -= 1;
        }
        else if(s[i] == 'U') d += 1;

        if(d> u) flag = true;
    }



    if( R<l or r < R) flag = true;
    if( U<d or u < U) flag = true;


    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int m,n;
  cin>>m>>n;
  vector<string> vec(m);
  rep(i,m) cin>>vec[i];
  rep(i,m) vec[i] = "-" + vec[i] + "-";
  vec.pb(string(n+2, '-'));

  int ans = 0;
  repl(i,1,m){
    repl(j,1,n+1) if(vec[i][j]=='-'){
      if(vec[i][j-1]!='-' || vec[i][j+1]!='-') continue;
      bool ok = true;
      for(int k=-1; k<=1; k++) for(int l=-1; l<=1; l++) if(vec[i+k][j+l]=='x') ok = false;
      if(ok) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
ll a[114514];
map<int, int>mp;
signed main() {
	ll n, ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)mp[a[i]]++;
	for (auto x : mp) {
		if (x.second % 2 == 1)ans++;
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 5760
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

struct team{
	int ac,penalty,id;
	vi penalties;
//	team(int ac,int penalty,int id):ac(ac),penalty(penalty),id(id){}
	team(int numP):penalties(vi(numP)),ac(0),penalty(0){}
	bool operator<(const team &other)const{
		if(ac==other.ac){
			if(penalty==other.penalty){
				return id>other.id;
			}else{
				return penalty<other.penalty;
			}
		}else{
			return ac>other.ac;
		}
	}
	bool same(const team &other) const{
		return(ac==other.ac&&penalty==other.penalty);
	}
};


int main(){
	int M,T,P,R;
	while(cin>>M>>T>>P>>R,M|T|P|R){
		vector<team> teams(T,team(P));
		REP(i,T){
			teams[i].id=i+1;
		}
		REP(i,R){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			t--;p--;
			if(j==0){
				teams[t].ac++;
				teams[t].penalty+=teams[t].penalties[p]+m;
			}else{
				teams[t].penalties[p]+=20;
			}
		}
		sort(ALL(teams));
		cout<<teams[0].id;
		FOR(i,1,T){
			if(teams[i-1].same(teams[i])){
				cout<<"=";
			}else{
				cout<<",";
			}
			cout<<teams[i].id;
		}
		cout<<endl;
	}
}

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

P f(int x) {
  int a = x % 10;
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(b, a);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<P, int> freq;
  rep(i, 1, n + 1) {
    P p = f(i);
    freq[p]++;
  }

  ll ans = 0;
  rep(i, 1, n + 1) {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int main(void){
	uint32_t a;
	uint64_t b, c;
	scanf("%"SCNu32"%"SCNu64"%"SCNu64, &a, &b, &c);
	uint64_t x=b<=c?b-1:c;
	uint64_t ans = a*x/b - x/b*a;
	printf("%"PRIu64"\n", ans);
}



Measured memory_bytes: 1732
#include<stdio.h>
int main()
{
    float hideo, ruio;
    while (scanf("%f %f", &hideo, &ruio)!=EOF) {
        if (hideo < 35.50 && ruio < 71.00) {
            printf("AAA\n");
        }
        else if (hideo < 37.50 && ruio < 77.00) {
            printf("AA\n");
        }
        else if (hideo < 40.00 && ruio < 83.00) {
            printf("A\n");
        }
        else if (hideo < 43.00 && ruio < 89.00) {
            printf("B\n");
        }
        else if (hideo < 50.00 && ruio < 105.00) {
            printf("C\n");
        }
        else if (hideo < 55.00 && ruio < 116.00) {
            printf("D\n");
        }
        else if (hideo < 70.00 && ruio < 148.00) {
            printf("E\n");
        }
        else {
            printf("NA\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2528
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
using namespace __gnu_pbds;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> s;
    for (int i = 0; i < n; ++i) {
        s.insert(i);
    }
    int cur = 0, sz = n;
    for (int i = 0; i < m; ++i) {
        int a; scanf("%d", &a);
        if(a&1){
            cur = ((cur-a)%sz+sz)%sz;
            s.erase(s.find_by_order(cur));
        }else {
            cur = (cur+a)%sz;
            s.erase(s.find_by_order(cur));
        }
        sz--;
        cur %= sz;
    }
    for (int i = 0; i < q; ++i) {
        int x; scanf("%d", &x);
        if(s.find(x) != s.end()) puts("1");
        else puts("0");
    }
    return 0;
}


Measured memory_bytes: 12508
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
C = [a1, a2, a3]
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]
a2 = C[1][1] - b2
a3 = C[2][2] - b3
A = [a1, a2, a3]
B = [b1, b2, b3]
for i in range(3):
    for j in range(3):
        if C[i][j] == A[i] + B[j]:
            continue
        else:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 38384