akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
struct item {
  int x, s, t;
};
int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, q;
  cin >> n >> q;
  vector<item> a;
  for (int i = 0; i < n; ++i) {
    int x, s, t;
    cin >> s >> t >> x;
    a.push_back({x, s, t});
  }
  vector<int> b(q);
  for (auto &z: b) cin >> z;
  vector<int> tree(q << 1, MOD);
  for (int i = 0; i < n; ++i) {
    int l = (int) (lower_bound(ALL(b), a[i].s - a[i].x) - b.begin());
    int r = (int) (lower_bound(ALL(b), a[i].t - a[i].x) - b.begin());
    for (l += q, r += q; l < r; l /= 2, r /= 2) {
      if (l & 1) { uin(tree[l++], a[i].x); }
      if (r & 1) { uin(tree[--r], a[i].x); }
    }
  }
  for (int i = 0; i < q; ++i) {
    int ans = MOD;
    int p = i + q;
    for (; p > 0; p /= 2) {
      uin(ans, tree[p]);
    }
    if (ans == MOD) ans = -1;
    cout << ans << '\n';
  }
  
  return 0;
}


Measured memory_bytes: 6640
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
	bool x = false;
	if((a.second*a.first) < b.second*b.first){
		x = true;
	}
    return x;
}
int main(){
	
	ll n,k;
	cin>>n>>k;
	cout<<(k+(n*3))/2<<"\n";
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

satisfy = 0

before = -2
for i in range(n):
    satisfy += B[A[i]-1]
    if A[i]-2 == before:
        satisfy += C[A[i]-2]
    before = A[i]-1
print(satisfy)


Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author I.E
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <iomanip>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define fr(i,start,end) for(int i=start;i<end;++i)
#define rep(i,end) fr(i,0,end)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define sz(a) int((a).size())
#define srt(container, lambda) sort(container.begin(), container.end(), lambda)

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

int int_pow(int x, int p)
{
    if (p == 0) return 1;
    if (p == 1) return x;

    int tmp = int_pow(x, p/2);
    if (p%2 == 0) return tmp * tmp;
    else return x * tmp * tmp;
}

void fill(istream& in, vi& a, int n) {
    int elm;
    rep(i, n) {
        in >> elm;
        a.push_back(elm);
    }
}

void fill(istream& in, vl& a, int n) {
    ll elm;
    rep(i, n) {
        in >> elm;
        a.push_back(elm);
    }
}

void fill(vi& a, int n, int val) {
    rep(i, n) {
        a.push_back(val);
    }
}

void fill(vl& a, int n, ll val) {
    rep(i, n) {
        a.push_back(val);
    }
}

int sum(vi arr) {
    int s = 0;
    for (auto& x: arr)
        s += x;
    return s;
}

int max(vi a) {
    return *max_element(a.begin(), a.end());
}

int min(vi a) {
    return *min_element(a.begin(), a.end());
}

void print(ostream& out, vi a) {
    for (auto& x: a) {
        out << x << " ";
    }
    out << endl;
}

void print(ostream& out, vl a) {
    for (auto& x: a) {
        out << x << " ";
    }
    out << endl;
}

#pragma GCC optimize("Ofast")
static auto speedup = [](){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();



class CVacation {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in >> n;
	    vvi a;
	    int elm;
	    rep(i, n) {
	        vi l;
	        in >> elm;
	        l.push_back(elm);
	        in >> elm;
	        l.push_back(elm);
	        in >> elm;
	        l.push_back(elm);
            a.push_back(l);
	    }
        fr(i, 1, n) {
            rep(j, 3) {
                int mx = -1;
                rep(k, 3) {
                    if (j == k) {
                        continue;
                    }
                    if (a[i-1][k] > mx) {
                        mx = a[i-1][k];
                    }
                }
                a[i][j] += mx;
            }
        }
        int ret = max(a[n-1]);
        out << ret << endl;
	}
};


int main() {
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8420
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #pragma comment(linker, "/STACK:2000000")
  #pragma comment(linker, "/HEAP:2000000")
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  int32_t main()
  {        
    IOS
    int n;
    cin>>n;
    int arr[n+1];
    int ans=0;
    rep(i,1,n)
    {
      cin>>arr[i];
      if(arr[i]!=i)
      {
        ans++;
      }
    }
    if(ans==2 or ans==0)
    {
      cout<<"YES";
    }
    else
    {
      cout<<"NO";
    }
    return 0;
} 

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

int main()
{
    int sum=0,res=0;
    char s[110];
    cin >>s;
    int n=strlen(s);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
        {
            sum++;
            res=max(sum,res);
        }
        else
            sum=0;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll N, M;
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    int res = -1;

    for (int i = 1; i < n; i++) {
        string x = s.substr(0, i);
        string y = s.substr(i, n-i);
        set<char> xs, ys;
        rep(j, x.size()) xs.insert(x[j]);
        rep(j, y.size()) ys.insert(y[j]);

        int c = 0;
        for (auto&& e : xs) {
            if (ys.find(e) != ys.end()) c++;
        }
        res = max(c, res);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 12;

/* typedef */

/* global variables */

int ps[N];

/* subroutines */

int checkdigit(int ps[]) {
  int sum = 0;
  for (int i = 1; i < N; i++)
    sum += ps[i] * ((i <= 6) ? (i + 1) : (i - 5));
  int chd = 11 - sum % 11;
  if (chd >= 10) chd = 0;
  return (chd >= 10) ? 0 : chd;
}

/* main */

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

  int k = -1;
  for (int i = 0; i < N; i++) {
    if (s[N - 1 - i] == '?') k = i, ps[i] = -1;
    else ps[i] = s[N - 1 - i] - '0';
  }
  //for (int i = 0; i < N; i++) printf("%d ", ps[i]); putchar('\n');

  int ans, an = 0;

  if (k == 0) {
    ans = checkdigit(ps);
    an++;
  }
  else {
    for (int i = 0; i <= 9; i++) {
      ps[k] = i;
      int cd = checkdigit(ps);
      if (cd == ps[0]) {
	ans = i;
	an++;
      }
    }
  }

  if (an > 1) cout << "MULTIPLE" << endl;
  else printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<string>

using namespace std;

int N;
string S;
string ans;
const string DICT = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin >> N;
    cin >> S;
    for (int i = 0; i < S.length(); i++)
    {
        int tmp_index = DICT.find_first_of(S[i]);
        // cout << tmp_index << endl;
        int tns_index = (tmp_index + N) % 26;
        // cout << tns_index << endl;
        ans += DICT[tns_index];
        // cout << DICT[tns_index] << endl;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

const int mmod = 1000000007;
	int inv_mod(int a, int b) {
		if (a == 1) return b;
		int div = mmod / a + 1;
		return inv_mod((a * (long long)div) % mmod, (b * (long long)div) % mmod);
	}

int fac[999999];

int calc(int a, int b) {
  int ret = fac[a+b] ;
  ret = (ret * 1LL * inv_mod(fac[a], 1)) % mmod;
  ret = (ret * 1LL * inv_mod(fac[b], 1)) % mmod;
  return ret;
}

int main()
{
  fac[0] = 1;
  for (int i=1; i<222222; i++)
    fac[i] = (fac[i-1] * 1LL * i) % mmod;

  int h, w, a, b;
  cin >> h >> w >> a >> b;

  int res = 0;
  for (int i=1; i<=h-a; i++)
    res = (res + 1LL * calc(b-1, i-1) * calc(w-b-1, h-i)) % mmod;
  printf("%d\n", res);
}


Measured memory_bytes: 1152
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		int part = partition(A, 0, n-1);
		int work=0;
		for(int i=0; i<n; i++){
			if(work == 0){
				work = 1;
			} else{
				System.out.print(" ");
			}
			if(part == i){
				System.out.print("["+A[i]+"]");
			} else{
				System.out.print(A[i]);
			}
		}
		System.out.println();
	}
	static int partition(int A[], int p, int r){
		int work;
		int i = p-1;
		for(int j=p; j<=r-1; j++){
			if(A[j] <= A[r]){
				i++;
				work = A[i];
				A[i] = A[j];
				A[j] = work;
			}
		}
		work   = A[i+1];
		A[i+1] = A[r];
		A[r]   = work;
		return i+1;
	}
}

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

int main(){
  string s; cin >> s;
  ll q; cin >> q;
  ll t1count=0;
  string s1,s2;s1=s;
  reverse(s.begin(), s.end());
  s2=s;
  rep(i,q){
    ll t; cin >> t;
    if(t==1){
      t1count+=1; continue;
    }
    ll f; char c; cin >> f >> c;
    
    if((t1count%2==0&&f==1)||(t1count%2==1&&f==2)){
      s1.insert(s1.begin(),c); s2.insert(s2.end(),c);
    }else{
      s1.insert(s1.end(),c); s2.insert(s2.begin(),c);
    }
  }
  string ret=s1;
  if(t1count%2==1)ret=s2;
  cout << ret;

}


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

int main(){
	int N; cin>>N;
	long double pH[N+1];
	for(int i = 1; i <= N; i++) cin>>pH[i];
	long double dp[2][N+1]; dp[0][0] = 1;
	for(int j = 1; j <= N; j++) dp[0][j] = dp[0][j-1]*pH[j];
	long double res = dp[0][N];
	for(int i = 1; i <= (N/2); i++){
		int currRow = i%2, prevRow = (i+1)%2;
		dp[currRow][0] = 0;
		for(int j = 1; j <= N; j++) dp[currRow][j] = dp[currRow][j-1]*pH[j] + dp[prevRow][j-1]*(1.0-pH[j]);
		res += dp[currRow][N];
	}
	printf("%.15Lf\n", res);
}

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

int tmp(int n){
    int ans=0;
    while(n){ans+=n%10;n/=10;}
    return ans;
}

int main (){
    int n;scanf("%d",&n);
    int ans=0x3f3f3f3f;
    for(int i=1;i<n;i++){
        ans=min(tmp(i)+tmp(n-i),ans);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int canNum = 0;

            for(int i = 0; i < N; i++)
            {
                canNum += (i + 1);
            }

            Console.WriteLine(canNum);
        }
    }

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}


// Fenwick Tree {{{
template <class T>
class Fenwick {
	private:
		std::vector<T> arr;
		int sz;
		T myQuery(int idx) {
			T rt{};
			for(;idx>0;idx-=idx&-idx) rt += arr[idx];
			return rt;
		}
		void myUpdate(int idx, const T &val) {
			for(;idx<=sz;idx+=idx&-idx) arr[idx] += val;
		}
	public:
		Fenwick(int n) : arr(n + 1), sz(n) {}
		T query(int x) { return myQuery(x + 1); }
		T query(int l, int r) { return query(r) - query(l - 1); }
		void update(int x, const T &v) { myUpdate(x + 1, v); }
};
// }}}

// Range Update Fenwick {{{
template <class T>
class RangeFenwick {
	private:
		Fenwick<T> tr1, tr2;
	public:
		RangeFenwick(int n) : tr1(n), tr2(n) {}
		T query(int x) { return (x + 1) * tr1.query(x) - tr2.query(x); }
		T query(int l, int r) { return query(r) - query(l - 1); }
		void update(int l, int r, const T &v) {
			tr1.update(l, v);
			tr1.update(r + 1, -v);
			tr2.update(l, v * l);
			tr2.update(r + 1, -v * (r + 1));
		}
};
// }}}

int solve() {
	int n, q; cin >> n >> q;
	RangeFenwick<ll> lst(n);
	while (q--) {
		int op; cin >> op;
		if (op == 0) {
			int l, v; cin >> l >> v;
			l--; // l--, r--;
			lst.update(l, l, v);
		} else {
			int l, r; cin >> l >> r;
			l--, r--;
			cout << lst.query(l, r) << endl;
		}
	}
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker



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

typedef struct city{
	double x, y;
}city;

int main() {
	city cities[8];
	int n, i, j;
	double dist = 0.0;
	scanf("%d\n", &n);
	for(i = 0; i < n; i++)
		scanf("%lf %lf\n", &cities[i].x, &cities[i].y);
	for(i = 0; i < n; i++)
		for(j = i + 1; j < n; j++)
			dist += sqrt((cities[i].x - cities[j].x) * (cities[i].x - cities[j].x) + (cities[i].y - cities[j].y) * (cities[i].y - cities[j].y));
	dist *= 2;
	dist /= n;
	printf("%lf\n", dist);
}

Measured memory_bytes: 128
#include<cctype>
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    
    char ch;
    
    while(1){
        
        scanf("%c", &ch);
        
        if( isalpha(ch)){
            if(islower(ch)){
                printf( "%c", toupper(ch));
            } else{
                printf("%c", tolower(ch));
            } 
            
        }else{
            printf("%c", ch);
        }
        
        if(ch =='\n') break;
    }
    
    return 0;
    
}


Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

bool check(char* s) {
  char t=s[0];
  for(int i=0;s[i];++i) {
    if(s[i] != t) return false;
  }
  return true;
}

int main() {
  char s[110];
  memset(s, 0, sizeof(s));

  scanf("%s", s);

  int ans=1000;

  for(char i = 'a'; i <= 'z';++i) {
    char t[110];
    memcpy(t, s, sizeof(s));
    for(int j=0;j<110;++j) {

      if(check(t)) {
        ans = min(ans, j);
        break;
      }

      for(int k=0;k<strlen(t)-1;++k) {
        if(t[k] == i || t[k+1] ==i) {
          t[k] = i;
        }
      }

      t[strlen(t)-1]=0;
      
    }
  }

  printf("%d", ans);
  
  return 0;
  }

Measured memory_bytes: 128
(princ ((lambda (x)
          (let ((count 0)
                (ans-list nil))
            (dotimes (n 3)
              (let ((c (aref x n)))
                (if (eql c #\R)
                    (incf count)
                    (progn
                      (push count ans-list)
                      (setq count 0)))))
            (push count ans-list)
            (sort ans-list #'>)
            (car ans-list)))
        (read-line)))


Measured memory_bytes: 24392
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()) {
        s[i] += n;
        if(s[i] > 'Z') s[i] -= 26;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3616
import sys

dic = {}
for i in xrange(97, 123):
  dic.setdefault(chr(i), 0)

line = ""
while True:
  try:
    temp = raw_input()
    # print "temp = " + temp
    if temp != "":
      line += temp
    else:
      break
  except:
    break

# print line

for i in xrange(len(line)):
  try:
    if line[i].lower() in dic:
      dic[line[i].lower()] += 1
  except TypeError:
    continue

  # print dic
for i in xrange(97, 123):
  print chr(i) + " : " + str(dic[chr(i)])

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  if (n%m == 0) cout << "0" << endl;
  else cout << "1" << endl;


  return 0;
}

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

const int MAX = 1000100;
const int MOD = 1000000007;

long long fac[MAX], inv[MAX], finv[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() {
    COMinit();
    int X, Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0){
        cout << "0" << endl;
        return 0;
    }
    int n, m;
    n = (2 * Y - X) / 3;
    m = (Y - 2 * n);
    cout << COM(n + m, n) << endl;
}

Measured memory_bytes: 23680
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	vector<P> r(N);
	set<P> b;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		r[i] = P(a, b);
	}
	sort(r.begin(), r.end(), greater<P>());
	REP(i, N) {
		int c, d;
		cin >> c >> d;
		b.insert(P(d, c));
	}
	int res = 0;
	for (int i = 0;i < N;i++) {
		for (set<P>::iterator itb = b.begin();itb != b.end();itb++) {
			if (r[i].first < itb->second && r[i].second < itb->first) {
				res++;
				b.erase(*itb);
				break;
			}
		}
	}
	cout << res << "\n";

	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var sp = Console.ReadLine().Split(' ');
        int allC = int.Parse(sp[0]);
        int eatC = int.Parse(sp[1]);
        var lists = new List<long>[8];
        for(int i = 0; i < 8; ++i)
        {
            lists[i] = new List<long>(allC);
        }
        for(int i = 0; i < allC; ++i)
        {
            sp = Console.ReadLine().Split(' ');
            long n0 = long.Parse(sp[0]), n1 = long.Parse(sp[1]), n2 = long.Parse(sp[2]);
            lists[0].Add(n0 + n1 + n2);
            lists[1].Add(n0 + n1 - n2);
            lists[2].Add(n0 - n1 + n2);
            lists[3].Add(-n0 + n1 + n2);
            lists[4].Add(n0 - n1 - n2);
            lists[5].Add(-n0 + n1 - n2);
            lists[6].Add(-n0 - n1 + n2);
            lists[7].Add(-n0 - n1 - n2);
        }
        long result = 0;
        for(int k = 0; k < 8; ++k)
        {
            var list = lists[k];
            list.Sort();
            long tmp = 0;
            for (int i = list.Count - 1, j = 0; j < eatC; --i, ++j)
            {
                tmp += list[i];
            }
            if (k == 0 || result < tmp) result = tmp;
        }
        Console.WriteLine(result.ToString());
    }
}


Measured memory_bytes: 11476
#include<stdio.h>
int main(){
int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}
}



Measured memory_bytes: 128
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

def f(rate):
    global zero
    color = [400,800,1200,1600,2000,2400,2800,3200]
    for i in range(8):
        if rate < color[i]:
            return i
if __name__ == "__main__":
    cnt = [0,0,0,0,0,0,0,0]
    n = I()
    a = Intl()
    zero = 0
    ans = 0
    for i in a:
        if i < 3200:cnt[f(i)] = 1
        else:zero += 1
    #print(cnt)
    print(max(1,sum(cnt)),sum(cnt)+zero)

Measured memory_bytes: 9144
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto X = RD;
	auto x = RDA(-X);
	x.sort();
	long ans = abs(x[0]);
	long y = x[0];
	foreach (e; x)
		ans = gcd(ans, e-y);

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 4092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

int main(int argc, char** argv)
{
   int N;
   std::cin >> N;
   std::pair<std::pair<std::string, int>, int> restaurant[N];
   for(int i=0;i<N;++i){
      int t;
      std::string temp;
      std::cin>> temp >> t;
      restaurant[i] = std::make_pair(std::make_pair(temp, -t), i);
   }

   std::sort(restaurant, restaurant+N);

   for(int i=0;i<N;++i) std::cout << restaurant[i].second+1 << std::endl;

   return 0;
}


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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	double r1, r2;
	cin >> r1 >> r2;
	printf("%lf\n", r1 * r2 / (r1 + r2));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	string str;
	while(cin>>str){
		vector<int> Vec;
		for(int i=0; i < str.size();i++){
			if(str[i] == 'I'){
				Vec.push_back(1);
			}else if(str[i] == 'V'){
				Vec.push_back(5);
			}else if(str[i] == 'X'){
				Vec.push_back(10);
			}else if(str[i] == 'L'){
				Vec.push_back(50);
			}else if(str[i] == 'C'){
				Vec.push_back(100);
			}else if(str[i] == 'D'){
				Vec.push_back(500);
			}else if(str[i] == 'M'){
				Vec.push_back(1000);
			}
		}
		
		int sum=0;
		bool flag = false;
		for(int i=0;i<Vec.size()-1;i++){
			// 右側に大きな数が続くとき
			if( Vec[i] < Vec[i+1] ){
				sum += Vec[i+1] - Vec[i];
				// iを一つ進める
				i++;
				flag = true;
			}else{  // 右側に同じ又は小さな数
				sum += Vec[i];
				flag = false;
			}
		}
		// 最後まで足せていない場合は、最後だけ足す
		if( !flag ){
			sum += Vec[ Vec.size()-1 ];
		}
		
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b)
    printf("%d\n",c);
  else if(b==c)
    printf("%d\n",a);
    else if(a==c)
    printf("%d\n",b);

return 0;

}

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

using namespace std;

//#define int long long
#define PB push_back
#define MK make_pair
#define MKT make_tuple
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

//constexpr int INF = 1LL<<60;
constexpr int INF = 1 << 28;
//constexpr int MOD = 100000;
constexpr int MAX_N = 52;
constexpr int dx[] = { 1, 0, -1, 0 };
constexpr int dy[] = { 0, 1, 0, -1 };

int mem[MAX_N][MAX_N][4][1 << 6][1 << 6], h, w, k, fld[MAX_N][MAX_N];

inline bool Chk(int x, int y, int mask1, int mask2) {
    constexpr int len = 6;
    int cx = x, cy = y;
    for (int i = 0; i < len; ++i) {
        int b1 = (mask1 & (1 << (len - 1 - i))) ? 1 : 0, b2 = (mask2 & (1 << (len - 1 - i))) ? 1 : 0;
        int idx = b1 + 2 * b2;
        cx -= dx[idx];
        cy -= dy[idx];
        if (x == cx && y == cy) {
            return true;
        }
    }
    return false;
}

int Solve(int x, int y, int c, int mask1, int mask2) {
    if (x == w + 1 && y == h) return 0;
    if (mem[x][y][c][mask1][mask2] != -1) return mem[x][y][c][mask1][mask2];

    int cur = Chk(x, y, mask1, mask2) ? 0 : fld[x][y];
    int res = 0;
    bool flg = false;
    for (int i = 0; i < 4; ++i) {
        if (1 < i && k <= c) break;
        int tx = x + dx[i], ty = y + dy[i];
        int nc = (1 < i) ? c + 1 : c;
        if (fld[tx][ty] == -1) continue;

        int nm1 = (mask1 >> 1) + ((i % 2) << 5), nm2 = (mask2 >> 1) + ((1 < i) << 5);
        int tmp = Solve(tx, ty, nc, nm1, nm2);
        if (tmp <= -INF) {
            continue;
        }
        flg = true;
        res = max(res, tmp);
    }

    if (!flg) {
        res = -INF;
        cur = 0;
    }

    return mem[x][y][c][mask1][mask2] = res + cur;
}

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

    memset(fld, -1, sizeof(fld));
    cin >> h >> w >> k;
    for (int y = 1; y <= h; ++y) {
        string s;
        cin >> s;
        for (int x = 1; x <= w; ++x) {
            char c = s[x - 1];
            if (c == '#') {
                fld[x][y] = -1;
                continue;
            } else if (c == '.') {
                fld[x][y] = 0;
                continue;
            }
            fld[x][y] = c - '0';
        }
    }
    fld[w + 1][h] = 0;
    memset(mem, -1, sizeof(mem));
    cout << max(0, Solve(1, 1, 0, 0, 0)) << endl;
}

Measured memory_bytes: 176228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

var tree [][]int
var visited []bool
var cnt []int64

func dfs(now int, parentCnt int64) {
	cnt[now] += parentCnt
	visited[now] = true
	for _, v := range tree[now] {
		if !visited[v] {
			dfs(v, cnt[now])
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	q := nextInt()
	tree = make([][]int, n)
	for i := 0; i < n-1; i++ {
		a := nextInt() - 1
		b := nextInt() - 1
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}
	cnt = make([]int64, n)
	for i := 0; i < q; i++ {
		p := nextInt()
		x := nextInt()
		cnt[p-1] += int64(x)
	}

	visited = make([]bool, n)
	dfs(0, 0)
	for _, v := range cnt {
		fmt.Println(v)
	}
}


Measured memory_bytes: 48000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	int N, M; cin >> N >> M;
	int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    int sl = s.length();
    int tl = t.length();
    int ans = sl;
    for(int i=0;i<=sl-tl;i++){
        int tmp = 0;
        for(int j=0;j<tl;j++){
            if(t[j] != s[i+j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

struct edge {
    int s;
    int e;
    int w;
    edge(int s, int e, int w) {
        this->s = s;
        this->e = e;
        this->w = w;
    }
};

int main() {
    int L;
    cin >> L;
    if (L < 2) return 0;
    stack<int> sign;
    int tmp = L;
    for (int i = 0; i < 31; ++i) {
        if (tmp & 1) sign.push(i);
        tmp >>= 1;
    }
    int r = log2(L);
    int n = r + 1;
    vector<edge> graph;
    int x = 1;
    for (int i = 1; i < n; ++i) {
        graph.push_back(edge(i, i + 1, 0));
        graph.push_back(edge(i, i + 1, x));
        x <<= 1;
    }
    r = sign.top();
    int w = 1 << r;
    sign.pop();
    while (!sign.empty()) {
        r = sign.top();
        sign.pop();
        graph.push_back(edge(r + 1, n, w));
        w += 1 << r;
    }
    cout << n << " " << graph.size() << endl;
    for (auto& e : graph) {
        cout << e.s << " " << e.e << " " << e.w << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const int M=1001024;
string H[M];
int getnum(char s)
{
    if(s=='A')return 1;
    else if(s=='C')return 2;
    else if(s=='G')return 3;
    else return 4;
}
ll getKey(string s)
{
    ll sum=0;int p=1;
    for(int i=0;i<s.size();i++)
    {
        sum+=p*getnum(s[i]);
        p*=5;
    }
    return sum;
}

int h1(int key){return (key%M);}
int h2(int key){return 1+key%(M-1);}
ll Insert(string s)
{
    ll key,h,i;
    key=getKey(s);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(H[h]==s)return 1;
        else if(H[h].size()==0)
        {
            H[h]=s;
            return 0;
        }
    }
}

ll Find(string s)
{
    ll key,h,i;
    key=getKey(s);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(H[h]==s)
            return 1;
        else if(H[h].size()==0)return 0;
    }
}
int main()
{
    int n;
    cin>>n;
    string s,str;
    for(int i=0;i<n;i++)
    {
        cin>>s>>str;
        if(s=="find")
            if(Find(str))
                cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        else if(s=="insert")
            Insert(str);
    }
    return 0;
}



Measured memory_bytes: 27468
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    int min=inf;
    for(int i=0;i<=s.size()-3;i++){
        int n=0;
        n+=(s[i]-'0')*100;
        n+=(s[i+1]-'0')*10;
        n+=(s[i+2]-'0');
        //cout<<n<<endl;
        if(min>abs(753-n)) min=abs(753-n);
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int w = sc.nextInt();
				int h = sc.nextInt();
				if(w+h == 0) break;
				boolean[][] r = new boolean[h][w];
				int n = sc.nextInt();
				while(n-- != 0) {
					int a = sc.nextInt() - 1;
					int b = sc.nextInt() - 1;
					r[b][a] = true;
				}
				int[][] dp = new int[h][w];
				dp[0][0] = 1;
				for(int i=0; i<h; i++) {
					for(int j=0; j<w; j++) {
						if(r[i][j]) continue;
						if(i > 0) dp[i][j] += dp[i-1][j];
						if(j > 0) dp[i][j] += dp[i][j-1];
					}
				}
				System.out.println(dp[h-1][w-1]);
			}
		}
	}
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

const int nmax = 1e5 + 10;
int s[nmax];

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

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

    s[max(0, a-1)]++;
    s[a+2]--;
  }

  int ans = s[0]; 
  for(int i = 1; i < nmax; i++){
    s[i] += s[i-1];
    ans = max(ans, s[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
let ans, s = ref max_int, read_line ()
let _ = String.(iter (fun d -> let c, l, cs = ref 0, ref @@ length s, Array.init (length s) (get s) in
  while List.exists ((<>) d) @@ Array.(to_list @@ sub cs 0 !l) do for i = 1 to !l - 1 do if cs.(i) = d then cs.(i - 1) <- cs.(i) done; decr l; incr c done; ans := min !ans !c) s); Printf.printf "%d\n" !ans

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
 
typedef long long ll;
 
int gcd(int a, int b){
  return (b==0)?a:gcd(b,a%b);
}
 
char c[100001];
ll N,M;
string S,T;
 
int main(){
  cin>>N>>M;
  cin>>S>>T;
  ll L=(N*M)/gcd(N,M);
  for (ll i=0;i<N;i++){
    ll pos=i*L/N+1;
    //cout<<pos<<endl;
    //if ((pos-1)%(L/M)==0)
      // cout<<i<<' '<<(pos-1)/(L/M)<<endl;
    if ((pos-1)%(L/M)==0 && (pos-1)/(L/M)<M && T[(pos-1)/(L/M)]!=S[i]){
      //cout<<pos<<' '<<(pos-1)/(L/M)<<endl;
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<L<<endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define Ans(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> inv;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

ll num(ll n, ll c, ll d)
{
	ll f = GCD(c, d);
	f = c * d / f;
	return n - n / c - n / d + n / f;
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << num(b, c, d) - num(a - 1, c, d) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools


def count_zeros(n):
    result = 0
    for x in itertools.count(1):
        divisor = 5 ** x
        if divisor > n:
            break
        else:
            result += (n // divisor)
    return result


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        else:
            print(count_zeros(n))

Measured memory_bytes: 7696
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int N;
  cin >> N;
  string ans = "";
  
  while(N != 0){
    if (N % 2 != 0){
      N--;
      ans = "1"+ans;
    }
    else ans = "0"+ ans;
    N /= -2;
  }
  
  if (ans == "") ans = "0";
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int Syutoku(int N, char *S);

int main(){

	int N;
	char  S[100] = {0};
	scanf("%d",&N);

	Syutoku(N, &S[0]);
	
	return 0;
}


int Syutoku(int N, char *S){
	char buf;
	for(int i = 0; i < N; i++){
		scanf("%c",&buf);
		S[i] = buf;
		if(S[i] == 'Y'){
			printf("Four");
			return 0;
		}
	}
	printf("Three");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 MOD = 1e9 + 7;

i64 A[101010],B[101010],C[101010];

i64 X[101010];

int OROR(bool b){
  if(b) return 3;
  return 1;
}

int main(){
  string s;
  cin >> s;
  int N = s.size();
  s = " " + s;
  X[0] = 1;
  rep(i,1,N){
    X[i] = X[i - 1] * OROR(s[i] == '?');
    X[i] %= MOD;
    A[i] = A[i - 1] * OROR(s[i] == '?') + X[i - 1] * (s[i] == 'A' || s[i] == '?');
    A[i] %= MOD;
  }
  rep(i,1,N){
    B[i] = B[i - 1] * OROR(s[i] == '?') + A[i - 1] * (s[i] == 'B' || s[i] == '?');
    B[i] %= MOD;
  }
  rep(i,1,N){
    C[i] = C[i - 1] * OROR(s[i] == '?') + B[i - 1] * (s[i] == 'C' || s[i] == '?');
    C[i] %= MOD;
  }
  cout << C[N] << endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define int long
set<int> divisor(int k){
  set<int> div;
  for(int p=1;p*p<=k;++p){
    if(k%p==0){
      div.insert(p);
      if(k%(k/p)==0)div.insert(k/p);
    }
  }
  return div;
}
signed main(){
  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b;
  map<int,int> m;
  for(int i=1;i<=n;++i)cin>>a[i];
  for(int i=n;i>n/2;--i)if(a[i]){
    b.push_back(i);
    for(auto p:divisor(i))m[p]++;
  }
  for(int i=n/2;i>0;--i){
    if(m[i]%2!=a[i]){
      b.push_back(i);
      for(auto p:divisor(i))m[p]++;
    }
  }
  cout<<b.size()<<"\n";
  for(int i=0;i<b.size();++i)cout<<(i?" ":"")<<b[i];
}

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

int main()
{

    ll H, N;
    ll ans = 0;
    cin >> H >> N;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        ans += temp;
        if (ans >= H)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll par[N],sz[N],ans[N];
ll findroot(ll i){
	while(par[i]!=i){
		par[i]=par[par[i]];
		i=par[i];
	}
	return i;
}
void dunion(ll a,ll b){
	ll pa=findroot(a);
	ll pb=findroot(b);
	if(pa!=pb){
		par[pb]=pa;
		sz[pa]+=sz[pb];
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m>>k;
	for(i=0;i<=n;i++){
		par[i]=i;
		sz[i]=1;
	}	

	ll a,b;
	for(i=1;i<=m;i++){
		cin>>a>>b;
		ans[a]++; ans[b]++;
		dunion(a,b);
	}
	for(i=1;i<=k;i++){
		cin>>a>>b;
		if(findroot(a)==findroot(b)) ans[a]++,ans[b]++;
	}

	for(i=1;i<=n;i++){
		cout<<sz[findroot(i)]-1-ans[i]<<" ";
	}
	return 0;
}

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

typedef struct S{
    string s;
    int p;
    int num;
} * S_p;

bool func(const S &a, const S &b){
    if(a.s < b.s) return true;
    else if(a.s > b.s) return false;
    else {
        if(a.p > b.p) return true;
        else return false;
    }
}
int main(void) {
    int n;
    cin >> n;
    vector<S> r(n);

    for (int i = 0; i < n; i++){
        cin >> r[i].s >> r[i].p;
        r[i].num = i + 1;
    }

    sort(r.begin(),r.end(),func);

    for(int i = 0; i < n; i++){
        cout << r[i].num << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int dp[50];
int main(){
	int n;
	cin>>n;
	dp[0]=1,dp[1]=1;
	for(int i=2;i<=n;i++)dp[i]=dp[i-1]+dp[i-2];
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1160