akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll N,W;
ll v[100005];
ll w[100005];
ll dp[105][100005];
ll func(ll i,ll sum)
{
	if(dp[i][sum]!=-1)
		return dp[i][sum];
	ll ans1,ans2;
	if(i>=N)
		return 0;
	if(sum+w[i]<=W)
	{
		ans1=v[i]+func(i+1,sum+w[i]);
		ans2=func(i+1,sum);
		dp[i][sum]=max(ans1,ans2);
	}
	else
		dp[i][sum]=func(i+1,sum);
	return dp[i][sum];
}
int main()
{
	boost
	cin>>N>>W;
	ll i,j;
	for(i=0; i<105; i++)
	{
		for(j=0; j<100005; j++)
			dp[i][j]=-1;
	}
	for(i=0; i<N; i++)
		cin>>w[i]>>v[i];
	ll ans=func(0,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
// #define ll long long
#define endl "\n"
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
const int N = 2e3+1;
int dp[N];

int logic(int s){
    if(s == 0){
        return 1;
    }
    if(s < 3){
        return 0;
    }
    if(dp[s] != 0){
        return dp[s];
    }
    for(int i=3; i<=s; i++){
        dp[s] = (dp[s]+logic(s-i))%mod;
    }
    return dp[s];
}
void solve(){
 
    dp[0] = 1;
    int s;
    cin >> s;
    logic(s);
    cout << dp[s];
}
 
int32_t main(){
 
    fast_cin;
    // int t;
    // cin >> t;
    // while(t-- > 0){
        solve();
        cout << "\n";
    // }
    
    return 0;
}

Measured memory_bytes: 3676
#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)++)

int main(){
  int A, B, ans;
  cin >>A >> B;
  
  REP(i,10){
    REP(j,10){
      REP(k,10){
	if(i*(1e4+1)+j*(1e3+1e1)+k*1e2>=A && i*(1e4+1)+j*(1e3+1e1)+k*1e2<=B)ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,k,ans;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&k);
    if((a*60+b)<(c*60+d)){
        ans=((c*60+d)-(a*60+b));
    }
    else{
        ans=24*60-((a*60+b)-(c*60+d));
    }
    printf("%d\n",ans-k);
}


Measured memory_bytes: 3760
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()
l=0
r=10**9
mid=0

if(K==0):
    print(max(A))
    sys.exit(0)

while(l+1<r):
    mid=(l+r)//2
    tmp=0
    for i in range(len(A)):
        if((A[i])%mid==0):
           tmp+=((A[i])//mid)-1
        else:
           tmp+=((A[i])//mid)
    if(tmp<=K):
        r=mid
    else:
        l=mid

print(r)

Measured memory_bytes: 32196
#include <stdio.h>

int main() {
  long long int i, number_a, number_b, number_x;
  scanf("%lld %lld %lld", &number_a, &number_b, &number_x);
  if(number_a % number_x == 0) {
    number_a = number_a / number_x;
  } else {
    number_a = number_a / number_x + 1;
  }
  number_b = number_b / number_x;
  printf("%lld\n", number_b - number_a + 1);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

template <class RandomIt>
size_t isort(RandomIt first, RandomIt last, ptrdiff_t g) {
    using T=typename RandomIt::value_type;
    size_t count_=0;
    for (RandomIt it=first+g; it<last; ++it) {
        T v=*it;
        RandomIt it2;
        for (it2=it-g; it2>=first&&v<*it2; it2-=g) {
            it2[g] = it2[0];
            ++count_;
        }
        it2[g] = v;
    }
    return count_;
}

template <class RandomIt>
size_t shsort(RandomIt first, RandomIt last) {
    /* Shell sort */
    size_t count_=0, m=last-first;

    vector<ptrdiff_t> g; g.push_back(1);
    for (size_t h=4; h<=m&&g.size()<100; ++(h*=3))
        g.push_back(h);

    reverse(g.begin(), g.end());

    printf("%zu\n", g.size());
    for (size_t i=0; i<g.size(); ++i) {
        printf("%zu%c", g[i], i<g.size()-1? ' ':'\n');
        count_ += isort(first, last, g[i]);
    }

    return count_;
}

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int> A(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &A[i]);

    size_t t=shsort(A.begin(), A.end());

    printf("%zu\n", t);
    for (size_t i=0; i<N; ++i)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 6264
#include<cstdio>
const int N=200050;
char s[N];
int f[N][2];
inline int Min(int a,int b){return a<b?a:b;}
int main(){
	int n,i;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;++i){
		f[i][0]=f[i-1][0]+(s[i]=='#');
		f[i][1]=Min(f[i-1][0],f[i-1][1])+(s[i]=='.');
	}
	printf("%d\n",Min(f[n][0],f[n][1]));
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;

ll dp[1010][1010];

int main() {
  ll n,k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) dp[1][i] = 1;
  ll pre = k;
  ll sum = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = pre - dp[i-1][j];
      sum += dp[i][j];
    }
    pre = sum;
    sum = 0;
  }
  cout << pre << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 6272
import numpy as np

N,K = map(int,raw_input().split())

a_list = []
b_list = []
for i in range(N):
    a,b = map(int,raw_input().split())
    a_list.append(a)
    b_list.append(b)
    
a_list=np.array(a_list)

arg = a_list.argsort()

count=0
for i in range(N):
    count+=b_list[arg[i]]
    if count>=K:
        print a_list[arg[i]]
        break

Measured memory_bytes: 20752
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n;
  cin>>n;

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  if(p[0]) {
    cout << -1 << endl;
    return 0;
  }

  ll ans=0;
  repo(i,n){
    if(p[i]-p[i-1]>1) {
      cout << -1 << endl;
      return 0;
    }
    else if(p[i]==p[i-1]+1) ans++;
    else ans+=p[i];
  }

  cout << ans << endl;
}


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

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

    vector<int> spit(N*2);

    for(int i=0;i<N*2;i++) cin>>spit[i];

    sort(spit.begin(),spit.end());

    int ans = 0;

    for(int i=0;i<N*2;i++){
        if(i % 2 == 0) ans += spit[i];
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(void){
   double a,b,C,c;
   double S,L,H;
   cin >> a >> b >> C;
   S=0.5*a*b*sin(M_PI*C/180);
   c = sqrt(a*a+b*b-2*a*b*cos(M_PI*C/180));
   L=a+b+c;
   H=2*S/a;
   cout << fixed << setprecision(8) << S << endl;
   cout << fixed << setprecision(8) << L << endl;
   cout << fixed << setprecision(8) << H << endl;
  
}



Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
int n,G[1001][1001],dis[1001],vis[1001],inf=10e8;
void dij(int u){
	for(int i=0;i<n;i++){
	 dis[i]=G[u][i];
	}
	int k;
	vis[u]=1;dis[u]=0;
	for(int i=0;i<n-1;i++){
		int min=inf ;
		for(int j=0;j<n;j++){
			if(vis[j]==0&&dis[j]<min){
				min=dis[j];
				k=j;
			}
		}
		vis[k]=1;
		for(int j=0;j<n;j++){
			if(!vis[j]&&dis[j]>dis[k]+G[k][j])
			dis[j]=dis[k]+G[k][j];
		}
	}
}
int main(){
	scanf("%d",&n);
	int c,v1,v2,k;
	for(int i=0;i<n;i++){
		scanf("%d%d",&v1,&k);
		for(int j=0;j<k;j++){
			scanf("%d%d",&v2,&c);
			G[v1][v2]=c;
		}
	}
	
		for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
		  if(G[i][j]==0&&i!=j){
		  	G[i][j]=inf;
		  }
	}
	
	
//	for(int i=0;i<n;i++){
//		for(int j=0;j<n;j++){
//			printf("%d ",G[i][j]);
//		}printf("\n"); 
//	}
	dij(0);
	for(int i=0;i<n;i++)
	printf("%d %d\n",i,dis[i]);
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
  int N,M,sum = 0; cin>>N;
	int T[N];
	vector<vector<int>> VVI(M,vector<int>(2,0));
	rep(i , N){
		cin>>T[i];
		sum += T[i];
	}
  cin>>M;
	rep(j , M){
		cin>>VVI[j][0]>>VVI[j][1];
	}

	for(int t = 0; t < M; t++){
	  cout<<sum + VVI[t][1] - T[VVI[t][0] - 1]<<endl;
	}
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
    int N;ll K; cin >> N >> K;
    vector<ll> A(N);
    ll s=0;
    ll ans = 0LL;
    REP(i,N){
        cin >> A[i];
        s += A[i];
    }
    vector<ll> v = calc_divisor(s);

    for(ll yaku:v){
        vector<ll> diff;
        REP(i,N) {
            ll r = A[i]%yaku;
            diff.push_back(r);
        }
        sort(all(diff));
        ll cnt = K;
        REP(i,N){
            ll t = min(cnt, diff[i]);
            diff[i] -= t;
            cnt -= t;
        }
        cnt = K;
        for (int i=N-1; i>=0; i--){
            ll t = min(cnt, diff[i]%yaku?yaku-diff[i]:0);
            diff[i] += t;
            cnt -= t;
        }
        bool check = true;
        REP(i,N){
            if (diff[i]%yaku!=0) check = false;
        }
        if(check) ans = yaku;
    }
    cout << ans <<endl;
    return 0;
}

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

using  namespace std;


int main(){
    int ans = 1,n,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x == ans) ans++;

    }
    ans--;
    printf("%d",ans == 0 ? -1 : n-ans);



}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+1;
const ll inf = 1e12;

int main(){
	ll n,l,r,d;
	cin >> n;
	ll ans = 0;
	f(i,1,n+1){
		cin>>d;
		if(i%2 == 1 && d%2 ==1) ans++;
	}
	cout << ans << endl;

}



Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<pll>& h,pll n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]>h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

pll popHeap(vector<pll>& h){
  int n=h.size()-1;
  if(n==-1)return pll(0,0);
  ll i;
  pll ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]>h[j+1])j++;
    if(h[i]>h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  char s[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)cin>>s[i][j];
  }
  int p,q;
  for(k=0;k<n;k++){
    bool flg=1;
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        p=j+k;q=i+k;
        if(p>=n)p-=n;
        if(q>=n)q-=n;
        if(s[i][p]!=s[j][q]){
          flg=0;
          break;
        }
      }
    }
    if(flg)cnt++;
  }
  cout<<n*cnt<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	map<ll,int> m;
	rep(i,n){
		cin >> a.at(i);
		m[a.at(i)]++;
	}
	sort(a.rbegin(),a.rend());
	ll t = 2;
	while(t <= a.at(0)){
		t <<= 1;
	}
	int ans = 0;
	rep(i,n){
		if(m[a.at(i)] == 0) continue;
		while(t / 2 > a.at(i)) t >>= 1;
		if(a.at(i) == t - a.at(i)){
			if(m[a.at(i)] > 1){
				ans++;
				m[a.at(i)] -= 2;
			}
		}
		else if(m[t - a.at(i)] > 0){
			ans++;
			m[a.at(i)]--;
			m[t - a.at(i)]--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 26880
A, B, C, K = map(int, input().split())
ans = 0

def k(n, m):
    global ans, K
    if K >= n:
        K -= n
        ans += (n * m)
    else:
        ans += (K * m)
        K = 0
        
k(A, 1)
k(B, 0)
k(C, -1)

print(ans)

Measured memory_bytes: 9004
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int n,m;
char tosenB[100][10];
int tosenK[100];
char myB[1000][10];

bool mystrcmp(char s1[],char s2[]){
  int len1=strlen(s1);
  int len2=strlen(s2);
  if(len1 != len2){
    return false;
  }else{
    for(int i=0;i<len1;i++){
      if(s1[i]!=s2[i] && s1[i]!='*' && s2[i]!='*'){
	return false;
      }
    }
  }
  return true;
}
int main(){
  cin>>n>>m;
  int ans;
  while(n!=0){
    ans=0;
    for(int i=0;i<n;i++)
      cin>>tosenB[i]>>tosenK[i];
    for(int i=0;i<m;i++)
      cin>>myB[i];
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	if(mystrcmp(myB[i],tosenB[j])){
	  ans+=tosenK[j];
	  break;
	}
      }
    }
    cout<<ans<<endl;
    cin>>n>>m;

  }

  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
int dis[410][410],i,j,n,m,k,l,o,ans;
char map[22][22];
int b[4][2]={0,1,1,0,0,-1,-1,0};
int main()
{
	scanf("%d%d\n",&n,&m);
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
		scanf("%c",&map[i][j]);
		scanf("\n");
	}
	for (i=1;i<=n*m;i++)
	 for (j=1;j<=n*m;j++)
	  if (i!=j) dis[i][j]=0x7f7f7f7f/3;
	for (i=1;i<=n;i++)
	 for (j=1;j<=m;j++)
	  if (map[i][j]=='.')
	  {
	  	int x=(i-1)*m+j;
	  	for (k=0;k<4;k++)
	  	{
	  		int xx,yy;
	  		xx=i+b[k][0];yy=j+b[k][1];
	  		if (map[xx][yy]=='.')
	  		{
	  			int y=(xx-1)*m+yy;
	  			dis[x][y]=1;
			}
		}
	  }
	for (k=1;k<=n*m;k++)
	 for (i=1;i<=n*m;i++)
	  for (j=1;j<=n*m;j++)
	   dis[i][j]=std::min(dis[i][j],dis[i][k]+dis[k][j]);
	for (i=1;i<=n*m;i++)
	 for (j=1;j<=n*m;j++)
	  if (dis[i][j]<=n*m) ans=std::max(ans,dis[i][j]);
	printf("%d",ans); 
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT" };
		String temp = sc.next();
		for (int i=0;i<s.length;i++) {
			if (temp.equals(s[i])==true) {
				System.out.println(7-i);
				return ;
			}
		}
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <bitset>
#define R register
#define Abs(_A) (_A > 0 ? _A : -(_A))
#define Min(_A, _B) (_A < _B ? _A : _B)
int n, a[2010], sum, Ans;
std::bitset<4000010> u;
int main()
{
	scanf("%d", &n);
	for(R int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
	u[0] = 1;
	for(R int i = 1; i <= n; i++) u |= u << a[i];
	for(R int i = 0; i <= sum; i++)
	{
		if(u[i] && Abs((sum + 1 >> 1) - i) <= Abs((sum + 1 >> 1) - Ans)) Ans = i;
	}	
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 1664
#coding: utf-8

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

def view():
    print(str(a[0]), end = '')
    for k in range(1, n):
        print(' {}'.format(a[k]), end = '')
    print('')
    
for i in range(1, n):
    view()
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
view()


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

using namespace std;
const int maxn = 1e5+10;

int n;
char s[maxn];

int main() {
    scanf("%d%s", &n, s);

    int sol = 0;
    for (int i = 2; i < n; i++) {
        if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') sol++;
    }
    printf("%d", sol);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s;
	scanf("%c",&s);
	if(s=='A'){
		printf("T\n");	
	}
	else if(s=='C'){
		printf("G\n");	
	}
	else if(s=='G'){
		printf("C\n");	
	}
	else if(s=='T'){
		printf("A\n");
	}
	return 0;
}

Measured memory_bytes: 128
from math import factorial
import itertools
N = int(input())
ML = 0
AL = 0
RL = 0
CL = 0
HL = 0
for i in range(N):
  x = input()[0]
  if x == 'M':
    ML += 1
  elif x == 'A':
    AL += 1
  elif x == 'R':
    RL += 1
  elif x == 'C':
    CL += 1
  elif x == 'H':
    HL += 1

num = 0

for x in itertools.combinations([('M',ML),('A',AL),('R',RL),('C',CL),('H',HL)],3):
  X = x[0][1]
  Y = x[1][1]
  Z = x[2][1]
  num += X*Y*Z
print(num)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, k;
    cin >> n >> k;
    if (n == 0) cout << 0 << '\n';
    else {
        if (n > k) {
            cout << min(n % k, k - n % k) << '\n';
        } else if (n < k) {
            cout << min(n, k - n) << '\n';
        } else cout << 0 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

class T {
  public:
  int city , P , Y;
};
string adjust(int n){
  string s = to_string(n);
  while(sz(s) < 6) {
    s = '0' + s;
  }
  return s;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int N , M;
  cin >> N >> M;
  vector<T> a;
  for(int i = 0;i < M; i++) {
    int p , y;
    cin >> p >> y;
    a.push_back({i , p , y});
  }

  sort(a.begin() , a.end() , [&](const T &x , const T & y) {
     if(x.P != y.P) return x.P < y.P;
     return x.Y < y.Y;
  });

  for(auto i : a){
    dg3(i.city , i.P , i.Y);
  }

  map<int, string> ans;
  int cnt = 1;
  ans[a[0].city] = adjust(a[0].P) + adjust(cnt);
  cnt++;

  for(int i = 1; i < M; i++) {
    if(a[i].P != a[i-1].P) cnt = 1;
    ans[a[i].city] = adjust(a[i].P) + adjust(cnt);
    cnt++;
  }
  for(int i = 0; i < M; i++) {
    cout << ans[i] << '\n';
  }
}

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

int main()
{
  int n, m;
  string s;
  cin >> n >> m >> s;
  string ans;
  int ix = n;
  while (ix > 0) {
    int i;
    for (i = m; i > 0; i--) {
      if (ix - i < 0) continue;
      if (s[ix - i] == '0') {
        ix -= i;
        if (ans.length() > 0) ans.insert(0, " ");
        ans.insert(0, to_string(i));
        break;
      }
    }
    if (i == 0) break;
  }
  cout << (ix == 0 ? ans : "-1") << endl;
}


Measured memory_bytes: 960
n=int(input())
p=list(map(int,input().split()))

l=-1
arr=[]
for i in range(n):
    if p[i]==i+1:
        arr.append(i)
ans=len(arr)
i=0
while i<len(arr)-1:
    if arr[i+1]==arr[i]+1:
        ans-=1
        i+=1
    i+=1
print(ans)

Measured memory_bytes: 20592
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (i = 0; i < n; i++)
#define P pair<int, int>

int times_per_prime(int e)
{
  for (int n = 2; n < 100; n++)
  {
    int m = n * (n + 1) / 2;
    if (e < m)
    {
      return (n - 1);
    }
  }
  return -1;
}

map<ll, int> mp;

void primeFactors(ll n)
{
  while (n % 2 == 0)
  {
    mp[2]++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2)
  {
    while (n % i == 0)
    {
      mp[i]++;
      n = n / i;
    }
  }
  if (n > 2)
    mp[n]++;
}

int main()
{
  ll n;
  cin >> n;
  primeFactors(n);
  int ans = 0;
  for (auto p : mp)
  {
    int e = p.second;
    ans += times_per_prime(e);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3684
n=int(input())
you=[]
al=[]
vot=[]
ans=[]
for i in range(n):
  s=input()
  al.append(s)
al.sort()
bef="zzzzzzzzzzz"
co=0
mx=1
for x in al:
  if bef!=x:
    if mx<co:
      mx=co
      ans=[bef]
    elif mx==co:
      ans.append(bef)
    co=1
    bef=x
  else:
    co+=1
if mx<co:
  mx=co
  ans=[bef]
elif mx==co:
  ans.append(bef)
for x in ans:
  print(x)

Measured memory_bytes: 20680
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


int N;

signed main()
{
	cin >> N;

	int ans = 0;
	int cur = 0;
	REP(i, N)
	{
		int a;
		cin >> a;

		int offset = 0;
		if (cur > a)
		{
			offset = cur - a;
		}

		ans += offset;
		cur = a + offset;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3196
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
void printv(vvi amida){
	for(int i = 0; i < amida.size(); i++){
		cout << i << " " ;
		for (int j = 0; j < amida.front().size(); j++){
			cout << amida[i][j] << " ";
		}
		cout << endl;
	}
	return ;
}

int dfs(vvi &amida,int h,int a){
	vi dx = {-1,1,0};
	vi dy = {0,0,1};
	//cout << "h = " << h << " a+1 = " << amida[h][a+1] << " a-1 = " <<amida[h][a-1] <<  endl;
	if (h == amida.size()-1 and amida[h][a+1] == 0 and amida[h][a-1] == 0) {
		//cout << "a = " <<  a << endl;
		return (a + 1) / 2;
	}
	if (h < amida.size()){
		if (amida[h][a-1] == 1){
			amida[h][a] = 0;
			return dfs(amida,h,a-1);
		}else if (amida[h][a+1] == 1){
			amida[h][a] = 0;
			return dfs(amida,h,a+1);
		}else if(amida[h+1][a] == 1){
			amida[h][a] = 0;
			return dfs(amida,h+1,a);
		}
	}
	return 0;

}


int main() {
	while(1){
		int n,m,a; cin >> n >> m >> a;
		vvi amida(1000,vi(2 * n + 1,0));
		if (n + m + a == 0)  break;
		for (int i = 0; i < 1000; i++){
			for (int j = 1; 2 * j - 1 < amida.front().size(); j++){
				amida[i][2 * j - 1] = 1;
			}
		}

		for (int i = 0; i < m; i++) {
			int h,p,q; cin >> h >> p >> q;
			amida[amida.size() - h][2 * p] = 1;
		}

		cout << dfs(amida,0,2 * a - 1) << endl;;
	}
	
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define ALL(a) (a).begin(), (a).end()
#define ll long long
using namespace std;

ll m[100001][2] = {};
vector<ll> A;
int N;

ll solve(int i, int bef) {
  if(i == N) return 0;
  if(m[i][bef] != -1) return m[i][bef];
  int now = A[i] + bef;
  if(now && A[i]) 
    m[i][bef] = max((now-1)/2 + solve(i+1,1), now/2 + solve(i+1,0));
  else 
    m[i][bef] = solve(i+1,0);
  return m[i][bef];
}

int main() {
  memset(m,-1,sizeof(ll)*100001*2);
  cin >> N;
  A.resize(N+1);
  FOR(x,N) cin >> A[x];
  cout << solve(0,0) << '\n';
}


Measured memory_bytes: 7296
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var isOk = true;

            if (!S.Contains('a')) isOk = false;
            if (!S.Contains('b')) isOk = false;
            if (!S.Contains('c')) isOk = false;

            Console.WriteLine(isOk ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

#gridのindexは入力値のまま扱う(grid=[1,1]~[H,W])
#left<x<rightの間が生存範囲(初めはグリッド全てが生存可能状態)
left=0
right=W+1
up=0
down=H+1

ans="YES"
#手を逆順で見ていく。
for s,t in zip(reversed(S),reversed(T)):
    if t=='R':#生存可能範囲を広げる(0より小さくならないようにする)
        left=max(0,left-1)
    elif t=="L":
        right=min(W+1,right+1)
    elif t=="D":
        up = max(0,up-1)
    else:
        down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    #もし、途中でright-left==1。つまり、生存可能範囲がなくなってしまったら、
    #落とされてしまうため、ans=NOにして終了する
    if right-left==1 or down-up==1:
        ans="NO"
        break

#全ての手を見た後で、スタート地点が生存可能範囲に入っていればOK
if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)


Measured memory_bytes: 3888
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
   int n; cin >> n;
   int m = (n+ 999)/1000;
   cout << m * 1000 - n; 		
}

Measured memory_bytes: 3604
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int w, h, n, i, s1, s2, s3, menseki, xr, xl = 0, yu, yd = 0, p, q;
	vector<int> x, y, a;
	cin >> w >> h >> n;
	xr = w; yu = h;
	rpt(i, n) {
		cin >> s1 >> s2 >> s3;
		x.push_back(s1);
		y.push_back(s2);
		a.push_back(s3);
	}
	rpt(i, n) {
		switch (a[i]) {
			case 1:
				if(xl < x[i])
					xl = x[i];
				break;
			case 2:
				if(xr > x[i])
					xr = x[i];
				break;
			case 3:
				if(yd < y[i])
					yd = y[i];
				break;
			case 4:
				if(yu > y[i])
					yu = y[i];
				break;
			default:
				break;
		}
	}
	p = (xr - xl);
	q = (yu - yd);
	if (p < 0)
		p = 0;
	if (q < 0)
		q = 0;
	menseki = p * q;
	cout << menseki;

	return 0;
}

Measured memory_bytes: 256
l = input()
l = int(l, 2)
MOD = 10**9+7

dp = [[0 for i in range(2)] for i in range(100001)]
dp[100000][0] = 1


for i in range(99999, -1, -1):
  mask = 1<<i
  num = 0

  if dp[i+1][1]!=-1:
    dp[i][1] = (dp[i][1]+dp[i+1][1]*2)%MOD
    dp[i][1] = (dp[i][1]+dp[i+1][1])%MOD
  if dp[i][0]!=-1:
    if l&mask:
      dp[i][0] = (dp[i][0]+dp[i+1][0]*2)%MOD
      dp[i][1] = (dp[i][1]+dp[i+1][0])%MOD
    else:
      dp[i][0] = (dp[i][0]+dp[i+1][0])%MOD

print((dp[0][0]+dp[0][1])%MOD)

Measured memory_bytes: 55916
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    a, b, c, d = LI()

    ans = max(a*c, a*d, b*c, b*d)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10008
#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

int main(){
    int N;
    sd(N);

    int b = N/100;
    int f = N%100;
    if(b > 12 || b == 0){
        if(f == 0) printf("NA\n");
        else if(f > 12) printf("NA\n");
        else if(f <= 12) printf("YYMM\n");
    }
    else if(b < 12 && b != 0){
        if(f == 0) printf("MMYY\n");
        else if(f > 12) printf("MMYY\n");
        else if(f <= 12) printf("AMBIGUOUS\n");

    }
    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		for(int i=1; i < 10; i++){
			for(int j=1; j < 10; j++){
				if(i*j == n){
					cout << "Yes\n";
					return;
				}
			}
		}
		cout << "No\n";
		return;
	};
};

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    ll sum = 1e9;
    for (int i = -100; i <= 100 ; ++i){
        ll tmp = 0;
        for(int j=0;j<n;j++){
            tmp += pow((i - v[j]), 2);
        }
        sum = min(tmp, sum);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
a = [4,6,9,11]
b = [1,3,5,7,8,10,12]
ans = "No"
if x in a and y in a:
  ans = "Yes"
elif x in b and y in b:
  ans = "Yes"
elif x == y == 2:
  ans = "Yes"
print(ans)

Measured memory_bytes: 3060
def columnCheck(a):
  result = False
  for i in a:
    if i == [0, 0, 0]:
      result = True
  return result

def rowCheck(a):
  result = False
  for j in range(3):
    if a[0][j] == 0 and a[1][j] == 0 and a[2][j] == 0:
      result = True
  return result

def crossCheck(a):
  result = False
  if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    result = True
  if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    result = True
  return result

a = []
for i in range(3):
  a.append([int(i) for i in input().split(" ")])
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

for num in b:
  for i in range(3):
    for j in range(3):
      if a[i][j] == num:
        a[i][j] = 0

print("Yes" if columnCheck(a) or rowCheck(a) or crossCheck(a) else "No")

Measured memory_bytes: 3064
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      x = a*500 + b*100 + c*50
      if X == x:
        ans+=1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n, n2, logn = 0;
	cin >> n;
	n2 = n;

	while (n2 > 0)
	{
		n2 /= 10;
		logn++;
	}
	INT ans = 0;
	INT tmp = 1;

	for (size_t i = 0; i < logn - 1; i += 2)
	{
		ans += tmp*9;
		tmp *= 100;
	}

	if (n >= tmp)
	{
		ans += (n - tmp) + 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func calcDay(daily, bonus, req int) int {
	fullWcoin   := 7 * daily + bonus	//"週給"
	sixDaycoin := 6 * daily				//6日目まででもらえるコイン

	week := req / fullWcoin //必要満週数
	day := 0
	rem  := req % fullWcoin
		
		if sixDaycoin < rem && rem < fullWcoin {
			week++
		} else {
			day = rem / daily
				if rem % daily > 0 {
					day++
				}
		}

	return 7 * week + day
}

func main() {
	var daily, bonus, req int
		fmt.Scanf("%d %d %d",&daily ,&bonus ,&req)
		fmt.Printf("%d\n",calcDay(daily, bonus, req))
}


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

LL mod = 1e9+7, N, ans;

LL p(LL a, LL b) {
	if (b==0) return 1;
	LL temp = p(a, b/2);
	temp *= temp;
	temp %= mod;
	if (b%2) {
		temp *= a;
		temp %= mod;
	}
	return temp;
}

int main () {
	cin >> N;
	ans = p(10, N);
	
	ans -= p(9, N);
	ans %= mod;
	ans += mod;
	ans %= mod;
	
	ans -= p(9, N);
	ans %= mod;
	ans += mod;
	ans %= mod;
	
	ans += p(8, N);
	ans %= mod;
	
	cout << ans << endl;	
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(lint i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint A,B,N;
  cin>>A>>B>>N;
  lint X=min(B,N);
  lint ans=-1e18;
  FOR(i,max(0LL,X-B/A-1),X+1){
    ans=max(ans,(A*i)/B-A*(i/B));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3600
n = int(input())

ans = 0
for i in range(1, n+1):
  if i % 3 == 0 and i % 5 == 0:
    continue
  elif i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  else:
    ans += i

print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int k=0;
    int x[100100];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int y[100100]={};
    for(int i=0;i<n;i++){
        y[x[i]]+=1;
    }
    int z[100100]={};
    int w[100100]={};
    for(int i=0;i<100001;i++){
        z[i%m]+=y[i];
        w[i%m]+=(y[i]/2);
    }
    if(m%2==1){
        k+=z[0]/2;
        for(int i=1;i<=m/2;i++){
            if(z[i]>=z[m-i]){
                k+=z[m-i];
                if((z[i]-z[m-i])/2>=w[i]){
                    k+=w[i];
                }else
                {
                    k+=(z[i]-z[m-i])/2;
                }
            }else
            {
                k+=z[i];
                if((z[m-i]-z[i])/2>=w[m-i]){
                    k+=w[m-i];
                }else
                {
                    k+=(z[m-i]-z[i])/2;
                }
            }
        }
        
    }else
    {
        k+=z[0]/2;
        k+=z[m/2]/2;
        for(int i=1;i<m/2;i++){
            if(z[i]>=z[m-i]){
                k+=z[m-i];
                if((z[i]-z[m-i])/2>=w[i]){
                    k+=w[i];
                }else
                {
                    k+=(z[i]-z[m-i])/2;
                }
            }else
            {
                k+=z[i];
                if((z[m-i]-z[i])/2>=w[m-i]){
                    k+=w[m-i];
                }else
                {
                    k+=(z[m-i]-z[i])/2;
                }
            }

        }
    

    }

    cout<<k<<endl;
    

    

    return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
int a[101],n,cnt;
main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i%2==1 && a[i]%2==1){
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

char s[2][100];
int main() {
  int n = 2, m = 3;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  bool found = false;
  for (int i = 0; i < m; ++i) {
    if (s[0][i] != s[1][m - 1 - i]) {
      found = true;
    }
  }
  puts(found ? "NO" : "YES");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long int a,b;
  scanf("%lld",&a);
  if((0<a%11) && (a%11<7)){
    b= (long long int)(a/11) * 2 + 1;}
  else if(a%11==0){
    b = (long long int)(a/11) * 2;}
  else{
    b = (long long int)(a/11) * 2 + 2;}
  printf("%lld",b);
  return 0;
  }


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

using int64 = long long;
struct Task {
  int64 income;
  int64 delay;
};

int main() {
  int64 n, m;
  cin >> n >> m;
  vector<Task> tasks;
  for (int i = 0; i < n; ++i) {
    int64 a, b;
    cin >> a >> b;
    tasks.emplace_back(Task { b, a });
  }
  sort(tasks.begin(), tasks.end(),
       [](const Task& a, const Task&b) {
         if (a.income == b.income)
           return a.delay < b.delay;
         return a.income > b.income;
       });
  set<int64> delays;
  for (int i = 1; i <= m; ++i)
    delays.insert(i);

  int64 sum = 0;
  for (auto& t : tasks) {
    int64 c = t.income;
    int64 d = t.delay;
    auto itr = delays.lower_bound(d);
    if (itr != delays.end()) {
      sum += c;
      delays.erase(itr);
    }
  }
  cout << sum << "\n";

  return 0;
}



Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
 
 
 
int main()
{
	string s;
	cin >> s;
	ll n=(ll)s.size();
	ll kaisu[30]={};
	rep(i, s.size()) kaisu[s[i]-'a']++;
	ll ans=n*(n+1)/2+1;
	rep(i, 26) ans-=kaisu[i]*(kaisu[i]+1)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640