akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<pair<int,int>> in;
	for(int i = 0; i < n; i++){
		int x, l; cin >> x >> l;
		in.push_back({x - l, x + l});
	}
	sort(in.begin(), in.end(), [](pair<int,int> a, pair<int,int> b){
		return a.second < b.second;
	});
	int last = -(1<<30), ans = 0;
	for(auto e : in){
		int l, r; tie(l, r) = e;
		if(last <= l){
			last = r;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAX_N = (int)1e5 + 777;

ll a[MAX_N], b[MAX_N], diff[MAX_N], c[MAX_N];
ll n;

void solve()
{
	cin >> n;
	ll fsum = 0;

	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		fsum += a[i];
	}

	a[n] = a[0];

	for(int i = 0; i < n; ++i)
	{
		diff[i] = a[i + 1] - a[i];
		b[i] = diff[i];
	}

	ll adder = (n * (n + 1)) / 2;

	if(fsum % adder != 0)
		goodbye("NO");

	ll ops = fsum / adder;

	for(int i = 0; i < n; ++i)
		b[i] -= ops;

	ll cnt = 0;

	for(int i = 0; i < n; ++i)
	{
		if(b[i] > 0 || b[i] % n != 0)
			goodbye("NO");

		ll temp = -b[i];

		cnt += temp / n;
		c[0] += (temp / n) * (n - i);
	}

	if(cnt != ops)
		goodbye("NO");

	for(int i = 1; i < n; ++i)
		c[i] = c[i - 1] + diff[i - 1];

	for(int i = 0; i < n; ++i)
	{
		DBG(c[i]);

		if(a[i] != c[i])
			goodbye("NO");		
	}

	cout << "YES" << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3456
'use strict'

const main = (input) => {
    const num = Number.parseInt(input.split('\n')[0].split(' ').join(''))
    if(num % 4 === 0 ){
        console.log('YES')
    }else{
        console.log('NO')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
#include <stdio.h>

int main(void)
{
	int n;
	int c;
	
	c = 0;
	while (scanf("%d", &n) != EOF){
		if (n == 0){
			break;
		}
		else {
			for (;;){
				if (n == 1){
					printf("%d\n", c);
					c = 0;
					break;
				}
				else {
					if (n % 2 == 0){
						n = n / 2;
						c = c + 1;
					}
					else {
						n = (n * 3) + 1;
						c = c + 1;
					}
				}
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF 100000000

int n,m,k,p,q,r;
int d[2][100][100];

int main(){
	while(scanf("%d%d", &n, &m)){
		if(n == 0 && m == 0) break;
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 100; j++){
				for(int k = 0; k < 100; k++) d[i][j][k] = INF;
			}
		}
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 100; j++) d[i][j][j] = 0;
		}
			
		for(int i = 0; i < n; i++){
			int a,b,c[2];
			scanf("%d%d%d%d", &a, &b, &c[0], &c[1]);
			a--; b--;
			for(int j = 0; j < 2; j++){
				d[j][a][b] = c[j];
				d[j][b][a] = c[j];
			}
		}
		for(int u = 0; u < 2; u++){
			for(int k = 0; k < m; k++){
				for(int i = 0; i < m; i++){
					for(int j = 0; j < m; j++){
						d[u][i][j] = min(d[u][i][j],d[u][i][k]+d[u][k][j]);
					}
				}
			}
		}
		scanf("%d", &k);
		for(int i = 0; i < k; i++){
			scanf("%d%d%d", &p, &q, &r);
			p--; q--;
			printf("%d\n", d[r][p][q]); 
		}
	}
}

Measured memory_bytes: 1104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

pair<ll, ll> XY[100100];
int T[3100][3100];
int TSUM[3100][3100];

int get_sum(int x1, int y1, int x2, int y2){
    ll ret = 0;
    ret = TSUM[x2][y2];
    if(x1-1 >= 0) ret -= TSUM[x1-1][y2];
    if(y1-1 >= 0) ret -= TSUM[x2][y1-1];
    if(x1-1 >= 0 && y1-1 >= 0) ret += TSUM[x1-1][y1-1];
    return ret;
}

int main(){
    int N,K;
    cin >> N >> K;
    ll x, y;
    REP(i,N){
        ll x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2*K;
        y %= 2*K;
        if(c == 'B'){
            x += K;
            x %= 2*K;
        }
        if(x >= K){
            x -= K;
            y = (y+K)%(2*K);
        }
        //printf("x:%d, y:%d\n", x, y);
        XY[i] = make_pair(x,y);
        T[y][x]++;
    }

    TSUM[0][0] = T[0][0];
    for(int i = 1; i < 2*K; i++) TSUM[0][i] = T[0][i] + TSUM[0][i-1];
    for(int i = 1; i < 2*K; i++) TSUM[i][0] = T[i][0] + TSUM[i-1][0];
    for(int i = 1; i < 2*K; i++){
        for(int j = 1; j < 2*K; j++){
            TSUM[i][j] = T[i][j] + TSUM[i-1][j] + TSUM[i][j-1] - TSUM[i-1][j-1];
        }
    }

    //for(int i = 2*K-1; i >= 0; i--){
    //    REP(j,K){
    //        printf("%d ", T[i][j]);
    //    }
    //    printf("\n");
    //}
    //REP(i,2*K){
    //    REP(j,K){
    //        printf("%d ", TSUM[i][j]);
    //    }
    //    printf("\n");
    //}

    ll ans = 0;
    //(0, 0) white
    for(int i = 0; i < 2*K; i++){
        for(int j = 0; j < K; j++){
            ll tmp = 0;
            if(j == 0){
                if(i <= K){
                   tmp = get_sum(i, j, i+K-1, j+K-1);
                }
                else{
                    tmp += get_sum(i, j, 2*K-1, j+K-1);
                    tmp += get_sum(0, 0, (i+K-1)%(2*K), (j+K-1)%(2*K));
                }
            }else{
                if(i == 0){
                    tmp += get_sum(i, j, i+K-1, K-1);
                    tmp += get_sum(K, 0, 2*K-1, j-1);
                }
                else if(i <= K){
                    tmp += get_sum(i, j, i+K-1, K-1);
                    tmp += get_sum(i+K, 0, 2*K-1, j-1);
                    tmp += get_sum(0, 0, i-1, j-1);
                }
                else{
                    tmp += get_sum(i, j, 2*K-1, K-1);
                    tmp += get_sum(0, j, (i+K-1)%(2*K), K-1);
                    tmp += get_sum((i+K-1)%(2*K)+1, 0, i-1, j-1);
                }
            }
            //printf("(%d, %d) : %d\n", i, j, tmp);
            ans = max(ans, tmp);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 54272
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    string s;
    cin>>s;
    if(s=="ARC")
        cout<<"ABC"<<endl;
    else
        cout<<"ARC"<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

#define endl '\n'

typedef long long ll;
ll const MOD = 1000000007;

ll mult(ll a, ll b){return ( (a%MOD) * (b%MOD) )%MOD;}
ll soma(ll a, ll b){return ( (a%MOD) + (b%MOD) )%MOD;}
ll subt(ll a, ll b){return ( (a%MOD) - (b%MOD) + MOD)%MOD;}

ll fpow(ll b, ll e){
    if (e == 0) return 1;
    if (e == 1) return b;
    if (e & 1) return mult(b, fpow(b, e-1));
    ll temp = fpow(b, e/2);
    return mult(temp, temp);
}

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

    ll n,k; cin >> n >> k;
    ll g[k+1], ans=k;
    g[k] = 1;
    for (ll i = k-1; i>=1; i--){
        g[i] = fpow(k/i, n);
        for (ll j = i*2; j<=k; j+=i) g[i] = subt(g[i], g[j]);
        ans = soma(ans, mult(i, g[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<55);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N; cin>>N;
    vi A(N),B(N);
    rep(i,0,N) cin>>A[i];
    rep(i,0,N) cin>>B[i];
    ll ans=0;
    rep(j,0,30){
        ll sum=0;
        vi C(N+1,INF);
        rep(i,0,N){
            if((A[i]&(1ll<<j))>0) sum+=N%2;
            if((B[i]&(1ll<<j))>0) sum+=N%2;
            C[i]=B[i]&((1ll<<j)-1);
            sum%=2;
        }
        sort(ALL(C));
        rep(i,0,N){
            ll X=A[i]&((1ll<<j)-1);
            X=(1ll<<j)-X;
            sum+=N-dislow(C,X);
            sum%=2;
        }
        if(sum) ans+=(1ll<<j);
    }
    cout<<ans<<endl;
}


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

int main()
{
  int k;
  cin >> k;
  ll ans = 0;
  for (int a = 1; a <= k; a++)
  {
    for (int b = 1; b <= k; b++)
    {
      for (int c = 1; c <= k; c++)
      {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){

	int n,m;
	int a;
	priority_queue<int> pq;
	
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){scanf("%d",&a);pq.push(a);}

	for(int i=0;i<m;i++){
		a = pq.top();pq.pop();pq.push(a/2);
	}

	long long ans = 0;
	for(int i=0;i<n;i++){
		ans += pq.top();pq.pop();
	}

	printf("%lld\n",ans);
	return(0);
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char x;
  cin>>x;
  if(x==toupper(x))
  {
    cout<<'A'<<endl;
  }
  else if(x!=toupper(x))
  {
    cout<<'a'<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
  using namespace std;
   
  void __print(int x) {cout << x;}
  void __print(long x) {cout << x;}
  void __print(long long x) {cout << x;}
  void __print(unsigned x) {cout << x;}
  void __print(unsigned long x) {cout << x;}
  void __print(unsigned long long x) {cout << x;}
  void __print(float x) {cout << x;}
  void __print(double x) {cout << x;}
  void __print(long double x) {cout << x;}
  void __print(char x) {cout << '\'' << x << '\'';}
  void __print(const char *x) {cout << '\"' << x << '\"';}
  void __print(const string &x) {cout << '\"' << x << '\"';}
  void __print(bool x) {cout << (x ? "true" : "false");}
   
  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
  void _print() {cout << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define debug(x...) cout << "[" << #x << "] = ["; _print(x)
  #else
  #define debug(x...)
  #endif
  #define int long long int 
  #define fi first
  #define se second
  #define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
  #define pb push_back
  #define all(x) (x).begin(), (x).end()
  #define rall(x) (x).rbegin(), (x).rend()
  #define forn(i, n) for (int i = 0; i < (int)(n); ++i)
  #define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
  #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
  #define all(x) (x).begin(), (x).end()
  #define pow10(n) stoll("1"+string(n,'0'))
  //fill(all(arr),1)
  //if(map.count(key)){}
  //bitset<20>(n);
  //int mini=min({a,b,c,d,e});
   
  typedef pair<int, int> pii;
  typedef vector<int> vi;
  typedef vector<pii> vpi;
  typedef vector<vi> vvi;
  typedef long long ll;
  typedef vector<ll> vll;
  typedef vector<vll> vvll;
  typedef long double ld;
  int32_t main()
  {
    string s,t;
    cin>>s>>t;
    int cnt=0;
    forn(i,s.size())
    {
      if(s[i]!=t[i])cnt++;
    }
    cout<<cnt;
  }

Measured memory_bytes: 3920
#include <iostream>
#include <cstring>
int main()
{
	char str[1<<10];
	std::cin>>str;
	int n = strlen(str);
	for(int i=0; i<n; i++){
		if( str[i]<'D' ){
			str[i] = str[i]+23;
		}else{
			str[i] = str[i]-3;
		}
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n;
struct ll{
	int a,b;
}x[200005];

bool cmp(ll u,ll v){
	return u.b<v.b;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d %d",&x[i].a,&x[i].b);
	sort(x+1,x+n+1,cmp);
	int g=0;
	for(int i=1;i<=n;i++){
		if(g+x[i].a>x[i].b){
			cout<<"No";
			return 0;
		}
		g+=x[i].a;
	}
	cout<<"Yes";
	
	return 0;
}

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

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

    if (n % 1000 == 0)
        cout << 0 << endl;
    else
    {
        cout << 1000 - (n % 1000) << endl;
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef struct REstaurant{
  int number;
  int point;
  char name[10];
}restaurant;

int str_cmp(const restaurant *x,const restaurant *y){
  return strcmp(x->name,y->name);

}

int main(void){



  int n;
  int i,j;
  scanf("%d",&n);
  restaurant rest[n];
  restaurant tmp;
  for(i=0;i<n;i++){
    scanf("%s",rest[i].name);
    scanf("%d",&rest[i].point);
    rest[i].number=i+1;
  }

  qsort(rest,n,sizeof(restaurant),(int (*)(const void *,const void *))str_cmp);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(rest[i].name,rest[j].name)==0){
        if(rest[i].point<rest[j].point){
          tmp=rest[j];
          rest[j]=rest[i];
          rest[i]=tmp;
        }
      }
    }
  }
  for(i=0;i<n;i++)
  printf("%d\n",rest[i].number);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n != 0) {
		n = n / k;
		// cout << "n = " << n << endl;
		ans = ans + 1;
	}
	cout << ans << endl;
	return 0;
}

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

/*20190814 */
int main() {
    int N;
    int A;
    cin >> N;
    cin >> A;

    if(N % 500 <= A)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define forup(i,a,b) for(int i=(a); i<(b); ++i)
#define fordn(i,a,b) for(int i=(a); i>(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)

#define gi(x) scanf("%d",&x)
#define gl(x) cin>>x
#define gd(x) scanf("%lf",&x)
#define gs(x) scanf(" %s",x)

#define D(x) cout << #x << " : " << x << endl

#define fs first
#define sc second

#define pb push_back
#define mp make_pair

const int inf=numeric_limits<int>::max();
const LL linf=numeric_limits<LL>::max();

const int max_n=1010;

LL h, w, dp[max_n][max_n];
char grid[max_n][max_n];

int main() {
    string s;
    gl(h>>w);
    rep(i,h){
        cin >> s;
        rep(j, w){
            grid[i][j] = s[j];
            if(grid[i][j]=='#')
                dp[i][j] = -1;
        }
    }
    dp[h-1][w-1] = 0;
    if(dp[h-2][w-1] != -1) dp[h-2][w-1] = 1;
    if(dp[h-1][w-2] != -1) dp[h-1][w-2] = 1;

    fordn(i,h-1,-1){
        fordn(j,w-1,-1){
            if(dp[i][j]!=-1 && dp[i][j] == 0 )
                dp[i][j] = (((dp[i+1][j]==-1)?0:dp[i+1][j]) + ((dp[i][j+1]==-1)?0:dp[i][j+1]))%1000000007 ;
        }
    }

    cout << dp[0][0] << endl;
    return 0;
}

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

const int maxn = 1013;

int h, w;
bool used[maxn][maxn];
int d[maxn][maxn];

int main() {
  char a;
  cin >> h >> w;
  queue < pair < int, int > > q;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      cin >> a;
      if (a == '#') {
        q.push(make_pair(i, j));
        used[i][j] = 1;
      }
    }
  }
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    if (!used[x - 1][y] && x > 1) {
      d[x - 1][y] = d[x][y] + 1;
      used[x - 1][y] = 1;
      q.push(make_pair(x - 1, y));
    }
    if (!used[x + 1][y] && x < h) {
      d[x + 1][y] = d[x][y] + 1;
      used[x + 1][y] = 1;
      q.push(make_pair(x + 1, y));
    }
    if (!used[x][y - 1] && y > 1) {
      d[x][y - 1] = d[x][y] + 1;
      used[x][y - 1] = 1;
      q.push(make_pair(x, y - 1));
    }
    if (!used[x][y + 1] && y < w) {
      d[x][y + 1] = d[x][y] + 1;
      used[x][y + 1] = 1;
      q.push(make_pair(x, y + 1));
    }
  }
  int ans = 0;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j)
      ans = max(ans, d[i][j]);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 11408
import math

A,B,H,M = map(int,input().split())
x = H*60+M
y = x/2
z = 6*M
a = abs(y-z)
if a > 180:
    a = 360 - a
c_2 = A**2 + B**2 - 2*A*B*(math.cos(math.radians(a)))
print(math.sqrt(c_2))


Measured memory_bytes: 62456
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

//UnionFind木(サイズ有り)
struct UnionFind{
private:
	vector<int> par;
	vector<int> siz;
public:
	void init(int N){ //初期化する O(N)
		par.clear();
		siz.clear();
		for(int i=0; i<N; i++) par.push_back(i);
		for(int i=0; i<N; i++) siz.push_back(1);
	}
	int root(int a){ //親を返す O(α(N))
		if(par[a] == a) return a;
		return par[a] = root(par[a]);
	}
	void unite(int a, int b){ //木を併合する O(α(N))
		int rootA = root(a);
		int rootB = root(b);
		if(rootA == rootB) return;
		if(siz[rootA] < siz[rootB]) swap(rootA, rootB);
		par[rootB] = rootA;
		siz[rootA] += siz[rootB];
	}
	bool same(int a, int b){ //属する木が同じかを返す O(α(N))
		return root(a) == root(b);
	}
	int size(int a){ //その素集合の要素数を返す O(α(N))
		return siz[root(a)];
	}
};

int N;
const int M = 100000;
int x[100000], y[100000];
vector<int> X[100000], Y[100000];
UnionFind uf;
set<int> xx[100000], yy[100000];

signed main() {
	cin >> N;
	rep(i, N){
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		X[x[i]].pb(i);
		Y[y[i]].pb(i);
	}

	uf.init(N);
	rep(i, M){
		rep(j, X[i].size()){
			if(j == 0) continue;
			uf.unite(X[i][j-1], X[i][j]);
		}
		rep(j, Y[i].size()){
			if(j == 0) continue;
			uf.unite(Y[i][j-1], Y[i][j]);
		}
	}

	rep(i, N){
		xx[uf.root(i)].insert(x[i]);
		yy[uf.root(i)].insert(y[i]);
	}
	ll ans = 0;
	rep(i, N){
		if(uf.root(i) != i) continue;
		ans += (ll)xx[i].size() * yy[i].size();
	}
	cout << ans - N << endl;
}

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

void fnInput(int &rnLodSiz, int &rnTrkSiz, vector<int> &rvnLod)
{
  cin >> rnLodSiz >> rnTrkSiz;

  rvnLod.resize(rnLodSiz);
  for (int i = 0; i < rnLodSiz; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int nLod)
{
  int nCurLod;
  int nTrkCnt = 0;

  for (int i = 0; i < cnrvnLod.size();    )
  {
    if (cnrvnLod[i] > nLod)  return 0;

    nTrkCnt++;
    nCurLod = 0;
    while (i < cnrvnLod.size())
    {
      nCurLod += cnrvnLod[i];
      if (nCurLod > nLod)  break;

      i++;
    }
  }
  return (nTrkCnt <= nTrkSiz);
}

void fnAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int &rnMinLod)
{
  const int cnnMinLod = 0;
  const int cnnMaxLod = 1000000000;

  int nLow  = cnnMinLod;
  int nHigh = cnnMaxLod;
  rnMinLod  = cnnMaxLod;

  while (nLow < nHigh)
  {
    int nLod = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkSiz, nLod))
    {
      rnMinLod = min(rnMinLod, nLod);
      nHigh = nLod;
    }
    else
      nLow = nLod + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nLodSiz, nTrkSiz;
  vector<int> vnLod;
  int nMinLod = 0;

  fnInput(nLodSiz, nTrkSiz, vnLod);
  fnAlloc(vnLod, nTrkSiz, nMinLod);
  fnReSult(nMinLod);

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    double ans = 0;
    for (int i = 0; i < N; i++)
    {
        double tmp;
        cin >> tmp;
        ans += 1 / tmp;
    }
    cout << 1 / ans << endl;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = []
    B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N % 2 == 1:
        start = A[((N + 1) // 2) - 1]
        last = B[((N + 1) // 2) - 1]
        print(last - start + 1)
    else:
        start = (A[(N // 2) - 1] + A[(N // 2 + 1) - 1]) / 2
        last = (B[(N // 2) - 1] + B[(N // 2 + 1) - 1]) / 2
        print(int((last - start) * 2 + 1))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25580
import sys
def input(): return sys.stdin.readline().rstrip()
class mod_comb3:
    def __init__(self,mod=10**9+7,n_max=1):
        self.mod,self.n_max=mod,n_max
        self.fact,self.inv,self.factinv=[1,1],[0,1],[1,1]
        if 1<n_max:setup_table(n_max)
    def comb(self,n,r):
        if r<0 or n<r:return 0
        if self.n_max<n:self.setup_table(n)
        return self.fact[n]*(self.factinv[r]*self.factinv[n-r]%self.mod)%self.mod
    def setup_table(self,t):
        for i in range(self.n_max+1,t+1):
            self.fact.append(self.fact[-1]*i%self.mod)
            self.inv.append(-self.inv[self.mod%i]*(self.mod//i)%self.mod)
            self.factinv.append(self.factinv[-1]*self.inv[-1]%self.mod)
        self.n_max=t

def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    com=mod_comb3()
    A.sort()
    mod=10**9+7
    max_a,min_a=0,0
    for i in range(n):
        max_a=(max_a+A[i]*com.comb(i,k-1))%mod
        min_a=(min_a+A[i]*com.comb(n-i-1,k-1))%mod
    print((max_a-min_a)%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 73240
#include <stdio.h>
int main (){
  char n[3];
  scanf("%s",n);
  for (int i=0;i<=2;i++){
    if (n[i]=='1') n[i]='9';
    else if (n[i]=='9') n[i]='1';
  }
  
  printf("%s",n);
  
  return 0;
}


Measured memory_bytes: 128
import math

def resolve():

    n, m = map(int, input().split())

    nc=0
    mc=0
    if n >=2:
        nc=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
    if m>=2:
        mc=math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))

    print(nc+mc)

resolve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,f,r,sum,cal;
    while(scanf("%d%d%d",&m,&f,&r)!=EOF)
    {
        if(m==-1 && f==-1 && r==-1)
        {
            break;
        }
        else if(m==-1 || f==-1)

        {
            cout<<"F"<<endl;
        }
        else if(m+f>=80)
        {
            cout<<"A"<<endl;
        }
        else if(m+f>=65 && m+f<80)
        {
            cout<<"B"<<endl;
        }
        else if(m+f>=50 && m+f<65)
        {
            cout<<"C"<<endl;
        }
        else if(m+f>=30 && m+f<50)
        {
            if(r>=50)
            {
                cout<<"C"<<endl;
            }
            else
            {
                cout<<"D"<<endl;
            }
        }
        else if(m+f<30)
        {
            cout<<"F"<<endl;
        }
    }

}



Measured memory_bytes: 3112
import sys
input = sys.stdin.readline
n = int(input().strip())
dic = {}
ans = 0

for i in range(n):
  s = ''.join(sorted(input().strip()))
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1
for v in dic.values():
  ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 17852
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

int dp[1LL<<18][51];

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

    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int S=0;S<(1LL<<18);S++){
        for(int i=0;i<51;i++){
            dp[S][i]=MAX;
        }
    }
    dp[0][0]=0;
    for(int S=0;S<(1<<N);S++){
        int num=__builtin_popcount(S);
        int bin[18];
        int count=0;
        for(int i=N-1;i>=0;i--){
            if(bit(S,i)) count++;
            else bin[i]=i+count;
        }
        for(int i=0;i<51;i++){
            if(dp[S][i]==MAX) continue;
            for(int j=0;j<N;j++){
                if(bit(S,j)) continue;
                int x;
                if((int)(abs(num-j))%2==0){
                    x=A[j];
                }else x=B[j];
                if(x>=i){
                    chmin(dp[S|(1<<j)][x],dp[S][i]+abs(num-bin[j]));
                }
            }
        }
    }
    int ans=MAX;
    for(int i=0;i<51;i++){
        chmin(ans,dp[(1<<N)-1][i]);
    }
    if(ans==MAX) cout<<-1<<endl;
    else cout<<ans<<endl;

}

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
	if(l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m+1, r);
	post.push_back(root);
}

void solve(){
	pos = 0;
	rec(0, pre.size());
	cout << post[0];
	for(int i = 1; i < n; i++){
		cout << ' ' << post[i];
	}
	cout << endl;
}

int main(){
	int k;
	cin >> n;
	r(i, n){
		cin >> k;
		pre.push_back(k);
	}
	r(i, n){
		cin >> k;
		in.push_back(k);
	}
	solve();
	return 0;
}



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

int n, p[15];
int main() {
	std::cin >> n;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		std::cin >> p[i];
		ans += p[i];
	}
	std::sort(p, p + n, std::greater<int>());

	std::cout << ans - p[0] / 2 << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

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

int main(void) {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a;i <= b;i++) {
		int s = i % 10; /*1桁*/ int t = i / 10000 % 10; /*5桁*/
		int u = i / 10 % 10; /*2桁*/ int v = i / 1000 % 10; /*4桁*/
		if (s == t && u == v)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int N;
    int x;

    cin >> N;

    rep(i,N){
        cin >> x;
        if(x%2==0){
            if(x%3!=0 && x%5!=0){
                cout << "DENIED" <<endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> s(N);
    Rep (i, N) {
        cin >> s[i];
    }

    ll ans = 0;
    set<ll> passed;
    for (ll C = 1; C < N; C++) {
        ll score = 0;
        passed.clear();
        for (ll n = 0; N-1-n*C > 0; n++) {
            ll A = N-1 - n*C;
            ll B = A - C;
            // cout << "C, n, A, B: " << C << " " << n << " " << A << " " << B << "\n";
            score += s[n*C] + s[N-1-n*C];
            if (A <= 0 || B <= 0 || A <= B) continue;
            if (passed.count(n*C) || passed.count(N-1-n*C) || n*C == N-1-n*C) continue;
            passed.insert(n*C);
            passed.insert(N-1-n*C);
            ans = max(ans, score);

            // cout << A << " " << B << " " << score << "\n";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
struct stane{int a,b;LL c;};
int n,m,N,g[20][20],val[40010],dp[40010][20];
vector<pii>vv;
vector<int>vc;
inline void update(int &a,int b){ if(a<b) a=b;}
int solve(){
	memset(g,0,sizeof g);
	memset(val,0,sizeof val);
	int i,j,k,r,rest,u,v,w;
	int sum=0;
	N=(1<<n);
	for(i=1;i<=m;i++){
		u=vv[i-1].F;
		v=vv[i-1].S;
		w=vc[i-1];
		g[u][v]=g[v][u]=w;
		sum+=w;
	}
	memset(dp,-1,sizeof dp);
	for(i=1;i<N;i++){
		for(j=0;j<n;j++)if(i&(1<<j))break;
		val[i]=val[i^(1<<j)];
		for(k=j+1;k<n;k++)if(i&(1<<k))val[i]+=g[j][k];
		if(j==0)dp[i][0]=val[i];
	}
	for(i=1;i<N;i++)
		for(j=0;j<n;j++){
			if((v=dp[i][j])<0)continue;
			for(k=0;k<n;k++){
				if(i&(1<<k))continue;
				if(g[j][k]==0)continue;
				update(dp[i^(1<<k)][k],v+g[j][k]);
				for(rest=r=(N-1)^i^(1<<k);r;r=(r-1)&rest)
					update(dp[i^r^(1<<k)][k],v+val[r^(1<<k)]+g[j][k]);
			}
		}
	return sum-dp[N-1][n-1];
	return 0;
}
vector<stane>road;
LL cost[1<<16];
LL dp2[1<<16][16];
LL lis[16][16];
LL ddp[1<<16];
LL mt[1<<16][16];
int main(){
	cin>>n>>m;
	if(n==1)return 1;
	LL S=0;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		vv.pb(make_pair(a,b));
		vc.pb(c);
		road.pb({a,b,c});
		S+=c;
		if(lis[a][b])return 1;
		lis[a][b]=max(lis[a][b],(LL)c);
		lis[b][a]=max(lis[b][a],(LL)c);
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if((i>>j)&1)continue;
			for(int k=0;k<n;k++)
				if((i>>k)&1)
					mt[i][j]=max(mt[i][j],lis[k][j]);
		}
	}
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<road.size();j++)
			if((i>>road[j].a)&1)
				if ((i>>road[j].b)&1)
					cost[i]+=road[j].c;
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<n;j++)
			dp2[i][j]=LLONG_MIN;
	dp2[1][0]=0;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(!(i>>j)&1)continue;
			if(dp2[i][j]!=LLONG_MIN)for(int k=0;k<n;k++){
				if((i>>k)&1)continue;
				if(lis[j][k])
					dp2[i|(1<<k)][k]=max((LL)dp2[i|(1<<k)][k],dp2[i][j]+lis[j][k]);
			}
		}
	}
	for(int i=0;i<(1<<n);i++)ddp[i]=dp2[i][n-1];
	for(int i=0;i<(1<<n);i++){
		if(ddp[i]!=LLONG_MIN){
			if((!(i>>0)&1)||(!(i>>(n-1)&1)))return 1;
			for(int j=i;j<(1<<n);j++,j|=i){
				if(i==j)continue;
				int xr=(j^i);
				if(xr&i)return 1;
				if(xr==0)return 1;
				LL cosm=max(cost[1|xr],cost[(1<<(n-1))|xr]);
				for(int ii=0;ii<n;ii++)if((i>>ii)&1)
					cosm=max(cosm,cost[1<<(ii)|xr]);
				ddp[j]=max(ddp[j],ddp[i]+cosm);
			}
		}
	}
	cout<<S-ddp[(1<<n)-1]<<endl;
	return 0;
}


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

int main(){
	int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if(A>=D||B<=C)
  	cout<<0<<endl;
  else{
  	if((A-C)*(B-D)<0)
      cout<<min(B-A,D-C)<<endl;
    else
      cout<<min(abs(A-D),abs(B-C))<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace  std;
  int main()
  {
      int n;
       cin>>n;
       int v[n];
        for(int i=0; i<n; i++)
         cin>>v[i];
         
          int dp[n];
          memset(dp,0, sizeof dp);
          
          dp[0]=0;
           dp[1]=dp[0]+abs(v[1]-v[0]);
           for(int i=2; i<n;i++)
           {
               int a= abs(v[i]-v[i-1]);
                int b= abs(v[i]- v[i-2]);
                
                dp[i]= min(a+dp[i-1], b+dp[i-2]);
           }
            cout<<dp[n-1]<<endl;
  }

Measured memory_bytes: 4408
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,t,m=0,k=1;
    cin>>n;
    vector<int>v;
    vector<int>l(n,1);
    for(int i=0;i<n;i++){
        cin>>t;
        v.push_back(t);
    }
    for(int i=1;i<n;i++){
        if(v[i-1]!=v[i]){
            l[i]=l[i-1]+1;
        }
    }
    for(int i=n-2;i>=0;i--){
        m=max(m,k+l[i]+(i-l[i]<0?0:l[i-l[i]]));
        k=v[i]==v[i+1]?1:k+1;
    }
    cout<<m<<endl;
}

Measured memory_bytes: 2064
#include<stdio.h>
int main()
{
    int N,count=0;
    scanf("%d",&N);
    while(N>0)
    {
        int rem=N%10;
        if(rem == 7)
        {
            printf("Yes\n");
            count++;break;
        }
        N=N/10;
    }
    if(count==0)
        printf("No\n");
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int ans = 0, N,M,C,sum;
//入力
    cin >> N>>M>>C;
    int A[N][M],B[N]; 
    for (int j = 0; j < M; j++)
    {
        cin >> B[j];
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }

//判定
    for (int i = 0; i < N; i++)
    {
        sum = 0;
        for (int j = 0; j < M; j++)
        {
            sum += A[i][j] * B[j];
        }
        if(sum+C>0)ans++;
    }


    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int count = 0;

  // 素朴な実装

  for (int a_i = 0; a_i <= a; a_i++) {
    int a_made = a_i * 500;
    if (a_made > x) break;

    for (int b_i = 0; b_i <= b; b_i++) {
      int b_made = a_made + b_i * 100;
      if (b_made > x) break;

      for (int c_i = 0; c_i <= c; c_i++) {
        int c_made = b_made + c_i * 50;
        if (c_made > x) {
          break;
        } else if (c_made == x) {
          count++;
        }
      }
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 256
N = int(input())
t_x_y = [0]*N
for n in range(N):
    t_x_y[n] = [int(x) for x in input().split()]
    
can_flag = 1
for t, x, y in t_x_y: 
    if (t%2 == (x+y)%2) & ((x+y)<=t):
        continue
    else:
        can_flag=0
        break

if can_flag:
    print("Yes")
else:
    print("No")

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

from collections import defaultdict
d = defaultdict(int)

def f(x, y, z):
    return pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x


for x in range(1, 100):
    for y in range(x, 100):
        for z in range(y, 100):
            tmp = f(x, y, z)
            if x == y == z:
                d[tmp] += 1
            elif x == y or y == z or z == x:
                d[tmp] += 3
            else:
                d[tmp] += 6

for i in range(1, n + 1):
    print(d[i])

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

using namespace std;

const int maxn=1e5+10;

long long n,x,b[maxn];
long long a[maxn],s[maxn];
long long ans;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>b[0];
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    sort(b,b+n+1);
    for(int i=1;i<=n;i++)
    {
        s[i-1]=b[i]-b[i-1];
//        cout<<s[i-1]<<endl;
    }
    ans=__gcd(s[0],s[1]);
    for(int i=1;i<n;i++)
    {
        ans=__gcd(s[i],ans);

    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
    using namespace std;
    
    //                                 (POLICY BASED DS)
    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/pb_ds/tree_policy.hpp>
    // using namespace __gnu_pbds;
    // template<typename T>
    // using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
    // template<typename T>
    // using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    //                      ( find_by_order( )  ,  order_of_key( ) )
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz size()
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define ncr(n,r) ( n >= r ? ((((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod) : (ll)0)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return ans; 
    }
    
    // vector<ll> adj[MAX];
    // ll visit[MAX];
    // void dfs(ll node){
    //     visit[node]=1;
    //     for(auto i : adj[node]){
    //         if(!visit[i]) dfs(i);
    //     }
    // }
    
    // ll spf[MAX];
    // void sieve(){
    //     sidha(i,1,MAX)  spf[i]=i;
    //     for(ll i=4;i<MAX;i+=2)  spf[i]=2;
    //     for(ll i=3;i*i<=MAX;i++){
    //         if(spf[i]==i){
    //             for(ll j=i*i;j<MAX;j+=i){
    //                 if(spf[j]==j)   spf[j]=i;
    //             }
    //         }
    //     }
    // }

    int main()
    {
        boost;
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a>=0 && c>=0)    cout<<b*d;
        else if(b<=0 && d<=0)   cout<<a*c;
        else{
            if((a<=0 && b>=0) || (c<=0 && d>=0)){
                ll maxx=0;
                maxx=max(maxx,a*c);
                maxx=max(maxx,a*d);
                maxx=max(maxx,b*c);
                maxx=max(maxx,b*d);
                cout<<maxx;
            }
            else{
                if(b<0 && c>0)  cout<<c*b;
                else    cout<<a*d;
            }
        }
        return 0;
    }
    

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
    char s;
    cin>>s;
    if(s>='A' and s<='Z') cout<<"A";
    else cout<<"a";
}



Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;	cin>>n;
	for(int i=0;i<n;i++){
		int k,p;	cin>>k>>p;
		if(k%p==0)	cout<<p<<endl;
		else 	cout<<k%p<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
#define mp make_pair
int a,b,x;
int main()
{
	cin>>a>>b>>x;
	if(a>x||a+b<x){
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
    return 0;
}


Measured memory_bytes: 256
#nCr(mod prime)をフェルマーの小定理から求める(n~10**5でも可)
import sys
sys.setrecursionlimit(10**9)

def cmb(n,r,mod):
    if (r<0 or r>n):
        return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7
N=10**4
g1=[1,1]
g2=[1,1]
inverse=[0,1]

#n!とその逆元を求めておく
for i in range(2,N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)


s=int(input())
c=s//3
ans=0
mod=10**9+7
for i in range(1,c+1):
    r=s-i*3
    ans=(ans+cmb(r+i-1,i-1,mod))%mod
print(ans)

Measured memory_bytes: 67756
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n,x = map(int,input().split())
l = list(map(int,input().split()))

d = 0
count =0
for i in range(n):
    # print(d)
    if d <= x:
        count += 1
    d = d+l[i]
if d <= x:
    count += 1
print(count)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
    int a, b, ab[9], ba[9], i;

    scanf("%d", &a);
    scanf("%d", &b);

    if (a < b) {
        for (i = 0; i < b; i++) {
            printf("%d", a);
        }
    } else {
        for (i = 0; i < a; i++) {
            printf("%d", b);
        }       
    }
    printf("\n");

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a_index = 0, z_index = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      a_index = i;
      break;
    }
  }
  for(int i = s.size(); i >= 0; i--){
    if(s[i] == 'Z'){
      z_index = i;
      break;
    }
  }
  cout << z_index - a_index + 1 << endl;
  return 0;
}

Measured memory_bytes: 3728