akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define HASH 1000003

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i;
	long long x = 0;
	for (i = 0; s[i] != 0; i++) x = (x * 10007 + s[i] - 'a') % HASH;
	return (int)x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 10007, HASH);
	for (k = 1, pow[0] = 10007; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				for (p = hash[h[i]]; p != NULL; p = p->next) if (p->l == l[i] - j && p->s[0] == T[j] && lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (T[j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 23548
N = int(input())
words = [input() for _ in range(N)]
w_prev = words[0]
wordlist = [w_prev]
flag = True

for i in range(1, N):
    w = words[i]
    if w_prev[-1] == w[0] and w not in wordlist:
        w_prev = w
        wordlist.append(w)
    else:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(void){
    int n,i,l;
    long a[5000],ans,s;
     
    for(i=0;i<5000;i++)a[i]=NULL;
     
    while(scanf("%d",&n)){
        if(n==0)break;
        ans=-100000;
        for(i=0;i<n;i++){
            scanf("%ld",&a[i]);
        }
         
        for(i=0;i<n;i++){
            s=0;
            for(l=i;l<n;l++){
                s+=a[l];
                if(ans<s)ans=s;
            }
        }
         
        printf("%ld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;
const int N= (int)2e5+10;
int n,a[N];
void input()
{
    cin>>n;
    up(i,1,2*n-1) cin>>a[i];
}
bool ok(int x)//<=x
{
    int dmin= N; bool res;
    down(i,n,2)
     if ( (a[i]> x and a[i-1]> x) or (a[i]<=x and a[i-1]<=x) )
	 {
	 	if (n-i< dmin)
		{
			dmin= n-i; res= (a[i]<=x)?1:0;
		}
		break;
	 }
	up(i,n,2*n-2)
	 if ( (a[i]>x and a[i+1]>x) or (a[i]<=x and a[i+1]<=x) )
	{
		if (i-n< dmin)
		{
			dmin= i-n; res= (a[i]<=x)?1:0;
		}
		break;
	}

	if (dmin== N)
	{
		res= (a[n]<=x)?1:0;
		if (n%2==0) res= res^1;
	}
	return res;
}
void solve()
{
    int low,high,mid;
    low= 1; high= 2*n-1;
    while (low<= high)
	{
		mid= (low+high)/2;
		if (!ok(mid)) low= mid+1;
		else high= mid-1;
	}
	cout<<low;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    
     string s;
     cin>>s;
     int sum;
     for(int i=0;i<3;i++){
         if(s[i]=='1'){
             sum++;
         }
     }

    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


int main() {
  string s;
  cin >> s;

  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i%2 == 0 && s[i] == '0') {
      ans1++;
    }
    if (i%2 == 1 && s[i] == '1') {
      ans1++;
    }
  }
  ans2 = s.size() - ans1;
  int ans = min(ans1, ans2);

  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << st.size() << endl;

    return 0;
}



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

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

  int n;
  while (cin >> n && n) {
    map<char,char> exchange;
    for (int i = 0; i < n; ++i) {
      char a, b;
      cin >> a >> b;

      exchange[a] = b;
    }

    int q;
    cin >> q;

    string ans;

    while (q --> 0) {
      char c;
      cin >> c;
      ans += (exchange[c] ? exchange[c] : c);
    }

    cout << ans << '\n';
  }

  return (0);
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long 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;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int a,b; cin>>a>>b;
  cout<<a*b<<endl;

}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> B(N-1);
  rep (i, N-1) cin >> B[i];
  long ans = 0;
  rep (i, N) {
    if (i == 0) ans += B[i];
    else if (i == N-1) ans += B[i-1];
    else ans += min(B[i], B[i-1]);
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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


int main(void) {
    using namespace std;

    long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    long g = __gcd(n, m);
    long l = n*m / g;

    for(int i=0, j=0; i<n&&j<m; i+=n/g, j+=m/g) {
        if(s[i] != t[j]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << l << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define dec(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define clr(a, v) memset((a), (v), sizeof(a))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

string s;

int main() {
	cin >> s;
	s += "asdk";
	string w = "YAKI";
	rep(i,0,4) if(s[i]!=w[i]) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
class Dice:
    #f[]はUSEWNDの順，添字はU:0,S:1,E:2,W:3,N:4,D:5
    def __init__(self,l):
        self.f=l
        
    def __str__(self):
        l=self.f
        s=f'[U:{l[0]},S:{l[1]},E:{l[2]},W:{l[3]},N:{l[4]},D:{l[5]}]'
        return(s)
       
    def roll(self,c):
        if c=='N':
            ni=[1,5,2,3,0,4]
        elif c=='S':
            ni=[4,0,2,3,5,1]
        elif c=='E':
            ni=[3,1,0,5,4,2]
        elif c=='W':
            ni=[2,1,5,0,4,3]
        self.f=[self.f[j] for j in ni]
    
    def rotate(self,r):
        if r==+1: #Uから見て反時計(西)回り
            ni=[0,3,1,4,2,5]
        elif r==-1: #Uから見て時計(東)周り
            ni=[0,2,4,1,3,5]
        self.f=[self.f[j] for j in ni]

    def patterns(self):
        fs=[]
        for i in range(6):
            if i%2==0:
                self.roll('N')
            else:
                self.roll('E')
            for j in range(4):
                self.rotate(+1)
                fs.append(self.f)
        return fs
        
    def lookEast(self,l):
        for f in self.patterns():
            if f[0]==l[0] and f[1]==l[1]:
                return f[2]

d=Dice(list(map(int,input().split())))
q=int(input())
for i in range(q):
    print(d.lookEast(list(map(int,input().split()))))


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

int d,score,i,j,k,pscore,cscore,id;
int c[26],s[365][26],last[26],t[365];
int day1,day2,v1,v2,csize,f,check[4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> d;
  for(i=0;i<26;i++) {
    cin >> c[i];
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      int tscore=s[i][j];
      for(int k=0;k<26;k++) {
        if(k==j) continue;
        tscore-=c[k]*(i+1-last[k]);
      }
      if(j==0) score=tscore;
      else if(tscore>score) {
        score=tscore;
        t[i]=j;
      }
    }
    last[t[i]]=i+1;
  }
  int cnt=200000;
  while(cnt--) {
    day1=rand()%d;
    v1=rand()%26;
    day2=rand()%d;
    v2=rand()%26;
    if(t[day1]==v1) continue;
    check[0]=t[day1];
    check[1]=v1;
    csize=2;
    f=0;
    if(cnt%4==0&&day1!=day2&&t[day2]!=v2) {
      f=1;
      if(t[day1]!=t[day2]&&v1!=t[day2]) {
        check[csize++]=t[day2];
      }
      if(t[day1]!=v2&&v1!=v2) {
        check[csize++]=v2;
      }
    }
    pscore=0;
    cscore=0;
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      pscore+=s[i][t[i]];
      last[t[i]]=i+1;
      for(j=0;j<csize;j++) {
        int id=check[j];
        pscore-=c[id]*(i+1-last[id]);
      }
    }
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      if(day1==i) {
        cscore+=s[i][v1];
        last[v1]=i+1;
      }
      else if(f&&day2==i) {
        cscore+=s[i][v2];
        last[v2]=i+1;
      }
      else {
        cscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(j=0;j<csize;j++) {
        id=check[j];
        cscore-=c[id]*(i+1-last[id]);
      }
    }
    if(pscore<cscore) {
      t[day1]=v1;
      t[day2]=v2;
    }
  }
  for(i=0;i<d;i++) {
    printf("%d\n",t[i]+1);
  }
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>
#include <cassert>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    for(int i=K; i<N; i++){
        if(A[i-K] < A[i]) cout << "Yes\n";
        else cout << "No\n";
    }
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define ll long long
using namespace std;
double dp[3001][3001];
double calc_prob(int n, vector<double>&pH, ll HC)
{
	if (HC == 0)
	{
		return 1;
	}
	if (n < 0)
	{
		return 0;
	}
	if (dp[n][HC] > -0.9)
	{
		return dp[n][HC];
	}

	double ans = pH[n] * calc_prob(n - 1, pH, HC - 1) + (1 - pH[n]) * calc_prob(n - 1, pH, HC);
	return dp[n][HC] = ans;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vector<double>pH(n);
	for (int i = 0; i < n; i++)
	{
		double f;
		cin >> f;
		pH[i] = f;
	}

	// for (int i = 0; i < n; i++)
	// {
	// 	for (int j = 0; j < (n + 1) / 2; j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	memset(dp, -1, sizeof(dp));
	cout << fixed << setprecision(10) << calc_prob(n - 1, pH, (n + 1) / 2);
	return 0;
}

Measured memory_bytes: 74376
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,C,k;
    fi>>n>>C>>k;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s + 1,s + 1 + n);
    int ans = 0;
    for (int i = 1;i <= n;)
    {
        int time = s[i] + k;
        int nxt = min(n,i + C - 1);
        while (i <= nxt && s[i] <= time)
            ++i;
        ++ans;
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 764
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string S, pre, post;
  char c;
  int opc, pos;
  ll Q;
  bool flipped = false;
  cin >> S >> Q;
  for (ll i = 0; i < Q; i++) {
    cin >> opc;
    if (opc == 1) {
      flipped = !flipped;
    } else {
      cin >> pos >> c;
      if ((pos == 1 && !flipped) || (pos == 2 && flipped)) {
        pre.push_back(c);
      } else {
        post.push_back(c);
      }
    }
  }
  reverse(pre.begin(), pre.end());
  S = pre + S + post;

  if (flipped) reverse(S.begin(), S.end());

  cout << S << endl;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
set<ll> parent[100005];
set<ll> child[100005];
ll true_parent[100005];
ll root,depth[100005];

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    REP(N+M-1){
        parent[B[i]].insert(A[i]);
        child[A[i]].insert(B[i]);
    }
    REP(N){
        if(parent[i+1].empty()){
            root=i+1;
        }
    }
    queue<ll> q;
    q.push(root);
    while(!q.empty()){
        ll cur=q.front();q.pop();
        for(auto c:child[cur]){
            if(parent[c].size()>1){
                parent[c].erase(cur);
                continue;
            }
            depth[c]=depth[cur]+1;
            true_parent[c]=cur;
            q.push(c);
        }
    }
    REP(N){
        cout<<true_parent[i+1]<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N-1+M);
    std::vector<long long> B(N-1+M);
    for(int i = 0 ; i < N-1+M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 25628
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def NWD(A,B): 
    if B > A: 
        A, B = B, A 
    if B == 0: 
        return A
    else: 
        return NWD(A%B,B)

def party(): 
    A, B = wczytaj_liste()
    najwiekszy_dzielnik = NWD(A,B)
    odp = A*B//najwiekszy_dzielnik
    print(odp)

party()

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

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans;
	if((b - a) % 2 == 0){
		ans = (b - a) / 2;
	}else{
		ll t1,t2;
		t1 = (n - b + 1) + (n - (a + (n - b + 1)) ) / 2;
		t2 = (a - 1 + 1) + ( (b - (a - 1 + 1)) - 1) / 2;
		if(t1 > t2) ans = t2;
		else ans = t1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  vector<int> sum(N+1,0);
  cin >> S;
  
  for(int i=0;i<N;i++){
    // if(S.at(i)=='W'){
    //   sum.at(i+1) = sum(i) + 1;
    // }else
    sum.at(i+1) = S.at(i)=='W' ? sum.at(i) + 1 : sum.at(i);
  }
  
  int cost=10000000;
  
  for(int i=0;i<N;i++){
    int tcost = sum.at(i);
    tcost += (N-i-1)-(sum.at(N)-sum.at(i+1));
    cost = min(cost,tcost);
  }
  
  cout << cost;
}

Measured memory_bytes: 2052
#include <iostream>
#include <string>
using namespace std;

int main(){
  long long N;
  long long a[5];
  long long worst = 1000000000000001, ans=5, loss;
  long long times[5];
  long long answ=0;
  cin >> N;
  for(int i=0; i < 5; i++){
    cin >> a[i];
    if(a[i] < worst){
      worst = a[i];
    }
  }



  loss = N / worst;
  if(N % worst == 0) loss--;

  if(N == worst) {
    loss = 0;
  }

  ans += loss;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#define ll long long int
#define f(i,n) for(long long int i=0;i<n;i++)
#define fx(i,x,n) for(long long int i=x;i<n;i++)
#define fxe(i,x,n) for(long long int i=x;i<=n;i++)
#define MAX 1000000
#include<bits/stdc++.h>
using namespace std;
int maxcandies(vector<vector<ll> >a,ll i,ll j){
    if(i>=a.size() || i<0 || j>=a[i].size() || j<0){
        return 0;
    }
    else{
        return a[i][j]+max(maxcandies(a,i+1,j),maxcandies(a,i,j+1));
    }
}
int main(){
    ll n;
// Input
    cin>>n;
    vector<vector<ll> >a;
    vector<ll>temp;
    f(i,n){
        ll x;
        cin>>x;
        temp.push_back(x);
    }
    a.push_back(temp);
    temp.clear();

    f(i,n){
        ll x;
        cin>>x;
        temp.push_back(x);
    }
    a.push_back(temp);
    cout<<maxcandies(a,0,0)<<"\n";
}


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

int main(){
	char s[12]={}, s_[12]={};

	while( cin >> s ){
		for(int i = 0 ; i<12 ; ++i )
			s[i] -= '0';
		for(int i=0 ; i<9 ; ++i ){
			for(int j=0 ; i<9-j ; ++j ){
				s_[j] = (s[j] + s[j+1]) % 10;
			}
			for(int k=0 ; k<12 ; ++k ) s[k] = s_[k];
		}
		cout << (int) s[0] << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;



int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;
  
  string ans = "";
  int current;
  // vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
  vector<vector<int>> dp(s.size()+2, vector<int>(t.size()+2,0));
  for (int i=1; i<=s.size(); ++i) {
    for (int j=1; j<=t.size(); ++j) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
      // cout << dp[i][j] << " ";
    }
    // cout << "" <<endl;
  }
  // max number
  // cout << dp[s.size()-1][t.size()-1] << endl;

  // get the string...
  ans = "";
  int i = s.size();
  int j = t.size();
  while (i>0 && j>0) {
    // cout << dp[i][j] << dp[i-1][j-1] << endl;
    if (dp[i][j] == dp[i-1][j]) i--;
    else if (dp[i][j] == dp[i][j-1]) j--;
    else if (dp[i][j] == dp[i-1][j-1] + 1) {
      // cout << s[i] << endl;
      ans = s[i-1] + ans;
      --i;
      --j;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

ll get(ll x, ll y) {
  return (x / y);
}

bool can(string s, string op) {
  int n = s.length();
  int tot = s[0] - '0';
  for(int i = 0; i < n - 1; i++) {
    char ope = op[i];
    int x = tot, y = s[i + 1] - '0';
    if(ope == '+') tot = x + y;
    else tot = x - y;
  }
  return tot == 7;
}

vector <string> save;

void dfs(int idx, string op) {
  if(idx == 3) {
    save.push_back(op);
    return;
  }
  dfs(idx + 1, op + "+");
  dfs(idx + 1, op + "-");
}

int main() {
  string s; cin >> s;
  dfs(0, "");
  for(auto x : save) {
    if(can(s, x)) {
      for(int i = 0; i < s.length() - 1; i++) {
        cout << s[i] << x[i];
      }
      cout << s.back();
      cout << "=7";
      puts("");
      return 0;
    }
  }
  
}

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

int main() {
  int N, K, x, sum;
  sum = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < K - x) {
      sum += 2 * x;
    }
    else {
      sum += 2 * (K - x);
    }
  }

  cout << sum << endl;
}

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

long long N, M;
long long R;
#define MAX_N 3000
long long I[MAX_N + 1], F[MAX_N + 1], IF[MAX_N + 1];
long long P[MAX_N + 1], PP[MAX_N + 1];
long long PX[MAX_N + 1][MAX_N + 1];
long long D[MAX_N + 1][MAX_N + 1];

int main() {
  cin >> N >> M;
  I[0] = I[1] = F[0] = F[1] = IF[0] = IF[1] = 1;
  for(int i = 2; i <= N; ++i) {
    I[i] = M - (M / i) * I[M % i] % M;
    F[i] = i * F[i - 1] % M;
    IF[i] = I[i] * IF[i - 1] % M;
  }
  P[0] = 1;
  for(int i = 1; i <= N; ++i) {
    P[i] = 2 * P[i - 1] % M;
  }
  for(int i = 0; i <= N; ++i) {
    PP[i] = 2;
    for(int k = 0; k < i; ++k) {
      (PP[i] *= PP[i]) %= M;
    }
  }
  for(int i = 0; i <= N; ++i) PX[i][0] = 1;
  for(int i = 0; i <= N; ++i) for(int k = 1; k <= N; ++k) {
    PX[i][k] = PX[i][k - 1] * P[i] % M;
  }
  D[0][0] = 1;
  for(int i = 1; i <= N; ++i) for(int j = 0; j <= N; ++j) {
    D[i][j] = (D[i - 1][j] * (j + 1) + (j == 0 ? 0 : D[i - 1][j - 1])) % M;
  }
  for(int i = 0; i <= N; ++i) {
    long long tmp = i % 2 == 0 ? 1 : M - 1;
    (tmp *= (F[N] * IF[i]) % M * IF[N - i] % M) %= M;
    (tmp *= PP[N - i]) %= M;
    long long buf = 0;
    for(int j = 0; j <= i; ++j) {
      (buf += D[i][j] * PX[N - i][j] % M) %= M;
    }
    (tmp *= buf) %= M;
    (R += tmp) %= M;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 141056
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
string s, t;
int main() {
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	cout << (s < t ? "Yes" : "No") << endl;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        cin >> n;
        bool f = false;
        while (n){
            if (n % 10 == 7) f = true;
            n/=10;
        }
        cout << (f ? "Yes" : "No") << endl;
    }

}



Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>

using namespace std;

typedef	pair<int,int>	pii;

int main(){
	pii isl[25];
	for(int n;scanf("%d",&n),n;){
		for(int i=0;i<n;i++)	scanf("%d%d",&isl[i].second,&isl[i].first);

		sort(isl,isl+n);

		bool ok=true;
		int wsum=0;
		for(int i=0;i<n;i++){
			wsum+=isl[i].second;
			if(isl[i].first<wsum){ ok=false; break; }
		}

		puts(ok?"Yes":"No");
	}

	return 0;
}

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

const int RLEN=1<<18|1;
inline char nc() {
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
    char ch=nc(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
    return i*f;
}

const int N=2e5+50;
int n,a[N];
#define up(i,j) ((a[i]>=v) && (a[j]>=v))
#define dn(i,j) ((a[i]<v) && (a[j]<v))
inline bool check(int v) {
    for(int i=0;i<n-1;i++) {
        if(up(n+i,n+i+1) || up(n-i,n-i-1)) return 1;
        if(dn(n+i,n+i+1) || dn(n-i,n-i-1)) return 0;
    } return up(1,1);
}
int main() {
    n=rd(); for(int i=1;i<n*2;++i) a[i]=rd();
    int l=1, r=*max_element(a+1,a+2*n), ans=0;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) ans=mid, l=mid+1;
        else r=mid-1;
    } cout<<ans<<'\n';
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x = i;
		if(x % 3 == 0){
			cout << ' ' << i;
			continue;
		}
		while(x){
			if(x % 10 == 3){
				cout << ' ' << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;

int main() {

	FAST;

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

long long power(long long b,long long e){
    long long r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}


long long inverse(long long b){
    long long r=1,e=MOD-2;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

int nCr(int n,int r){
    int R=1;
    int f=1;
    REP(i,r){
        R*=(n-i);
        R%=MOD;
        f*=(i+1);f%=MOD;
    }
    R*=inverse(f);R%=MOD;
    return R;
}

signed main(void){
    int N,A,B;
    cin >> N >> A >> B;
    int Ans=1;
    Ans=power(2,N);
    Ans+=MOD-1;Ans%=MOD;
    Ans-=nCr(N,A);
    Ans-=nCr(N,B);
    Ans+=2*MOD;Ans%=MOD;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
n,*a=map(int,open(0).read().split());c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):s,t,r=c[i:i+3];print(y+abs(r-s)-abs(t-s)-abs(t-r))

Measured memory_bytes: 13804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long
//cout << fixed << setprecision (10);   小数点以下１０桁まで

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

 cout << max(max(2*a-1,2*b-1),a+b) << endl;
  
  
}



Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    cout << (n % 2 == 0 ? n : n * 2) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<int, int>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<P> q;

  rep(i, N){
    int a, b; cin >> a >> b;
    q.push_back(make_pair(b, a));
  }
  sort(q.begin(), q.end());

  bool flag = true;
  int now = 0;
  rep(i, N){
    now += q[i].second;
    if (q[i].first < now) flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.area", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		int n;
		stringstream ss(str);
		ss >> n;
		int res = n*(n+1)/2 + 1;

		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>

typedef unsigned long long int ull;

int N;

ull targetOfRow[505],targetOfCol[505];
int opcatOfRow[505],opcatOfCol[505];
ull matrix[505][505];

int zeroCountOfRow[505],zeroCountOfCol[505];

bool check(){
    //
    for(int r=1;r<=N;r++){
        ull androw=-1,orrow=0ull,andcol=androw,orcol=orrow;
        for(int c=1;c<=N;c++){
            androw&=matrix[r][c];
            orrow|=matrix[r][c];
            andcol&=matrix[c][r];
            orcol|=matrix[c][r];
        }

        if (opcatOfRow[r]&&orrow!=targetOfRow[r]) return false;
        if (!opcatOfRow[r]&&androw!=targetOfRow[r]) return false;
        if (opcatOfCol[r]&&orcol!=targetOfCol[r]) return false;
        if (!opcatOfCol[r]&&andcol!=targetOfCol[r]) return false;
    }

    return true;
}

void simpleInference(int pos){
    for(int r=1;r<=N;r++){
        for(int c=1;c<=N;c++){
            //目標値の対応ビットを取り出す
            auto colBit=(targetOfCol[c]>>pos)&1;
            auto rowBit=(targetOfRow[r]>>pos)&1;

            if (colBit^opcatOfCol[c]) matrix[r][c]|=(colBit<<pos);

            if (rowBit^opcatOfRow[r]) matrix[r][c]|=(rowBit<<pos);

            if (rowBit==colBit) matrix[r][c]|=(rowBit<<pos);
        }
    }
}

void SpecialInference(ull targets[],ull targets2[],int ops1[],int ops2[],int zeros1[],int zeros2[],bool isRow,int pos){
    ull mask=(ull)1<<(ull)pos;
    for(int r=1;r<=N;r++){
        //今の桁を何にするかを表す
        auto bitTarget=(targets[r]>>pos)&ops1[r];
        if (!bitTarget||zeros1[r]<N) continue;
        
        int c=1;
        while(c<=N){
            if (ops2[c]==0&&(targets2[c]&mask)==0&&zeros2[c]>1) break;
            c++;
        }
        if (c>N) continue;
        if (isRow)
            matrix[r][c]|=mask;
        else 
            matrix[c][r]|=mask;
        zeros2[c]--;
        zeros1[r]--;
    }
}

int main(){

    scanf("%d",&N);

    for(int i=1;i<=N;i++) scanf("%d",opcatOfRow+i);
    for(int i=1;i<=N;i++) scanf("%d",opcatOfCol+i);
    for(int i=1;i<=N;i++) scanf("%llu",targetOfRow+i);
    for(int i=1;i<=N;i++) scanf("%llu",targetOfCol+i);

    for(int bit=0;bit<64;bit++){
        ull mask=(ull)1<<(ull)bit;

        simpleInference(bit);

        memset(zeroCountOfCol,0,sizeof(zeroCountOfCol));
        memset(zeroCountOfRow,0,sizeof(zeroCountOfRow));
        for(int r=1;r<=N;r++)
            for(int w=1;w<=N;w++)
                if ((mask&matrix[r][w])==0) zeroCountOfRow[r]++,zeroCountOfCol[w]++;

        SpecialInference(targetOfRow,targetOfCol,opcatOfRow,opcatOfCol,zeroCountOfRow,zeroCountOfCol,true,bit);
        SpecialInference(targetOfCol,targetOfRow,opcatOfCol,opcatOfRow,zeroCountOfCol,zeroCountOfRow,false,bit);
    }

    if (!check()){
        puts("-1");
        return 0;
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++)
            printf("%llu ",matrix[i][j]);
            putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 7440
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int a[3];
int main(void){
	register int i;
	cin>>s;
	for(i=0;i<s.length();++i)
		++a[s[i]-'a'];
	sort(a,a+3);
	if(a[2]==a[1]&&a[1]==a[0]||a[2]==a[1]&&a[1]-1==a[0]||a[2]-1==a[1]&&a[1]==a[0])
		puts("YES");
	else 
		puts("NO");
	return 0;
}

Measured memory_bytes: 512
for _ in range(3):
    time = list(map(int, input().split()))
    if time[2] > time[5]:
        time[5] += 60
        time[4] -= 1
    if time[1] > time[4]:
        time[4] += 60
        time[3] -= 1
    hour = time[3] - time[0]
    minute = time[4] - time[1]
    second = time[5] - time[2]
    print(hour, minute, second)



Measured memory_bytes: 5596
#include<stdio.h>
#include<limits.h>
#include<vector>
#include<algorithm>
using namespace std;


struct P{int x,y;P(int x,int y):x(x),y(y){}P(){}};

vector<int>pressX,pressY;

const int C=5120;
short treasure[C][C]={};

P Compress(int x,int y)
{
	return P( upper_bound(pressX.begin(),pressX.end(),x)-pressX.begin()-1,
		upper_bound(pressY.begin(),pressY.end(),y)-pressY.begin()-1);
}

int CountPoint(int x,int y)
{
	P p=Compress(x,y);
	return treasure[p.y][p.x];
}
int CountArea(int x1,int x2, int y1, int y2)
{
	int lu=CountPoint(x1-1,y1-1);
	int ru=CountPoint(x2,y1-1);
	int ld=CountPoint(x1-1,y2);
	int rd=CountPoint(x2,y2);
	//printf("x1:%d y1:%d x2:%d y2:%d    左上;%d 右上:%d 左下:%d 右下:%d\n",x1,y1,x2,y2,lu,ru,ld,rd);
	return rd+lu-ru-ld;
}
int main()
{
	int n,m,i,j,x[5000],y[5000];
	scanf("%d%d",&n,&m);
	pressX.reserve(n+2);
	pressY.reserve(n+2);
	for(i=0;i<n;++i)
	{
		scanf("%d%d",x+i,y+i);
		pressX.push_back(x[i]);
		pressY.push_back(y[i]);
	}
	pressX.push_back(INT_MAX);
	pressX.push_back(INT_MIN);
	pressY.push_back(INT_MAX);
	pressY.push_back(INT_MIN);
	sort(pressX.begin(),pressX.end());
	sort(pressY.begin(),pressY.end());


	for(i=0; i<n; ++i)
	{
		P p=Compress(x[i],y[i]);
		++treasure[p.y][p.x];
	}
	for(i=1; i<C; ++i)
	{
		treasure[i][0]+=treasure[i-1][0];
		treasure[0][i]+=treasure[0][i-1];
	}
	for(i=1; i<C; ++i)
		for(j=1; j<C; ++j)
			treasure[i][j] += treasure[i][j-1]+treasure[i-1][j]-treasure[i-1][j-1];

	int x1,x2,y1,y2;
	while(m--)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",CountArea(x1,x2,y1,y2));
	}
	return 0;
}

Measured memory_bytes: 52328
def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    steps = [inf] * K

    for i in range(1, N):
        steps = [inf] * K
        for j in range(1, min(i, K) + 1):
            steps[j-1] = abs(H[i-j]-H[i]) + dp[i-j]
        step = min(steps)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 54876
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
    
int main()
{
string s;
cin >> s;
if(s[0] == s[2]) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
from collections import deque

mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    n, m = map(int,raw_input().split())
    
    adj_list = [[] for _ in range(n+5)]
    
    q = deque()
    
    ans = [-1] * (n+5)
    
    failed = False
    
    for _ in range(m):
        a, b = map(int,raw_input().split())    
        adj_list[a].append(b)
        adj_list[b].append(a)
    
    q.append(1)
    
    #print(adj_list)
    
    visited = set()
    
    visited.add(1)
    
    while len(q):
        sz = len(q)
        for _ in range(sz):
            cur = q.popleft()
            for nei in adj_list[cur]:
                if nei not in visited:
                    ans[nei] = cur
                    q.append(nei)
                    visited.add(nei)
    
    
    print('Yes')
    for i in range(2, n+1):
        print(ans[i])
            
            
        
        
    
    

main()

Measured memory_bytes: 112076
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 123456789;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

char s[50][51];
int d[50][50];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	fup(i,0,n-1,1)scanf("%s",s[i]);
	queue<Pi> q;
	q.push(mp(0,0));
	d[0][0]=1;
	while(!q.empty())
	{
		Pi p=q.front();
		q.pop();
		int x,y;
		tie(x,y)=p;
		fup(i,0,3,1)
		{
			int nx=x+dx[i],ny=y+dy[i];
			if(nx>=0&&nx<n&&ny>=0&&ny<m&&s[nx][ny]=='.'&&d[nx][ny]==0)
			{
				d[nx][ny]=d[x][y]+1;
				q.push(mp(nx,ny));
			}
		}
	}
	if(d[n-1][m-1]==0)return !printf("-1");
	int ans=0;
	fup(i,0,n-1,1)fup(j,0,m-1,1)if(s[i][j]=='.')ans++;
	printf("%d",ans-d[n-1][m-1]);
}

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

int main(){

    string s;
    cin>>s;

	if(s[0] != '2'){
	    s[0] = '2';
	}
	if(s[1] != '0'){
	    s[1] = '0';
	}
	if(s[2] != '1'){
	    s[2] = '1';
	}
	if(s[3] != '8'){
	    s[3] = '8';
	}

    cout<<s;
	

}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,A[300000];

int main()
{
	long long a = 0;
	scanf ("%d",&N);
	for (int i=0;i<3*N;i++) scanf ("%d",A+i);
	sort(A,A+3*N);
	for (int i=3*N-2,j=0;j<N;i-=2,j++) a += A[i];
	printf ("%lld\n",a);
	return 0;
}

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

int main(){
  int tail = 0;
  int n;
  cin >> n;
  vector<int> in(n);
  for(int i = 0;i < n;i++){
    cin >> in[i];
  }

  long long ans = 0;
  int now = 0;
  for(int i = 0;i < n;i++){
    while(tail < i && (now & in[i]) != 0){
      now = now ^ in[tail];
      tail++;
    }
    now = now ^ in[i];
    ans += i - tail + 1;
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// 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; }
 
using namespace std;

int main()
{
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  
  //Aの角度を求める
  long double angleA=2*M_PI/12*H+2*M_PI/12*M/60.0;
  //Bの角度を求める
  long double angleB=2*M_PI/60*M;
  
  long double c=sqrt(A*A+B*B-2*A*B*cos(angleA-angleB));
  
  cout << fixed << setprecision(15) << c << endl;
  
  return 0;
}

Measured memory_bytes: 4168
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
int main(){
	int a,b,c,d,ans;
	cin>>a>>b>>c>>d;
	if(b<=c||d<=a)ans=0;
	else{
		ans=min(b,d)-max(a,c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
ac = Array.new(10**5+1, 0)

a.each do |i|
  ac[i] += 1
end

puts a.uniq.map{|o| ac[o-1] + ac[o] + ac[o+1]}.max


Measured memory_bytes: 13956