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

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 365 + 7;
const int K = 26 + 7;
const int C = 100;
int n;
int c[K], s[N][K];
/// int t[N], last[K], sol[N];
int best = -(int) 1e9;

struct Data {
  int sol;
  int last[K];
  vector<int> ans;
  Data() {
    sol = 0;
    for (int k = 1; k <= 26; k++) {
      last[k] = 0;
    }
    ans.clear();
  }
};

bool operator < (Data x, Data y) {
  return x.sol > y.sol;
}

vector<Data> posi;

void nextgen(int i) {
  vector<Data> posi2;
  for (auto &it : posi) {
    for (int j = 1; j <= 26; j++) {
      Data it2;
      it2.sol = it.sol + s[i][j];
      for (int k = 1; k <= 26; k++) {
        it2.last[k] = it.last[k];
      }
      it.last[j] = i;
      for (int k = 1; k <= 26; k++) {
        it2.sol += c[j] * it2.last[j];
      }
      it2.ans = it.ans;
      it2.ans.push_back(j);
      posi2.push_back(it2);
    }
  }
  posi = posi2;
  sort(posi.begin(), posi.end());
  while ((int) posi.size() > C) {
    posi.pop_back();
  }
}

/**int get() {
  for (int j = 1; j <= 26; j++) {
    last[j] = 0;
  }
  int sol = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      sol -= c[j] * i;
    }
  }
  for (int i = 1; i <= n; i++) {
    sol += s[i][t[i]];
    last[t[i]] = i;
    for (int j = 1; j <= 26; j++) {
      sol += c[j] * last[j];
    }
  }
  return sol;
}

void upd() {
  int now = get();
  if (now > best) {
    best = now;
    for (int i = 1; i <= n; i++) {
      sol[i] = t[i];
    }
  }
}**/

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //freopen ("input", "r", stdin);
  cin >> n;
  for (int i = 1; i <= 26; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
    }
  }
  Data first;
  first.sol = 0;
  for (int j = 0; j < K; j++) {
    first.last[j] = 0;
  }
  first.ans.clear();
  posi.push_back(first);
  for (int i = 1; i <= n; i++) {
    nextgen(i);
  }
  for (auto &it : posi[0].ans) {
    cout << it << "\n";
  }
  return 0;
}


Measured memory_bytes: 12888
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int A, B, M; cin >> A >> B >> M;
	vector<int> a(A), b(B), aa(A), bb(B);
	rep(i, A)
	{
		int tmp; cin >> tmp;
		a[i] = tmp;
		aa[i] = tmp;
	}
	rep(i, B)
	{
		int tmp; cin >> tmp;
		b[i] = tmp;
		bb[i] = tmp;
	}
	sort(all(aa));
	sort(all(bb));
	int res = aa[0] + bb[0];
	while (M--)
	{
		int x, y, c; cin >> x >> y >> c;
		--x, --y;
		res = min(res, a[x] + b[y] - c);
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

    # Kの上界として、全ての頂点対の数がある。
    # グラフが連結なので頂点数-1個の頂点対は最短距離1になる。
    # よってKの最大値はNC2-(N-1)
    max_K = N * (N - 1) // 2 - (N - 1)
    if K <= max_K:
        # Kが最大値を取るのはスター型
        # そこから葉同士をくっつけて減らしていく
        print((N - 1) + max_K - K)
        for i in range(1, N):
            print(i, N)
        cnt = max_K
        for i, j in itertools.combinations(range(1, N), 2):
            if cnt == K:
                break
            print(i, j)
            cnt -= 1
    else:
        print(-1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10232
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;
vector<int> vp;
void refrain(vector<int>& v1)
{
	if (v1.empty()) return;
	sort(v1.begin(), v1.end());
	int x = v1.front();
	int y = v1.back();
	v1.clear();
	v1.push_back(x);
	v1.push_back(y);
}
void solve(vector<int>& v1, vector<int>& v2, vector<int>& v3)
{
	refrain(v1);
	refrain(v2);
	refrain(v3);
	for (auto& x : v1)
	{
		for (auto& y : v2)
		{
			if (x > y) continue;
			vp.push_back((y - x) / 2 - 1);
			vp.push_back((y - x) / 2);
			vp.push_back((y - x) / 2 + 1);
		}
	}
	for (auto& x : v1)
	{
		for (auto& y : v3)
		{
			if (x > y) continue;
			vp.push_back(y - x - 1);
			vp.push_back(y - x);
			vp.push_back(y - x + 1);
		}
	}
	for (auto& x : v2)
	{
		for (auto& y : v3)
		{
			if (x < y) continue;
			vp.push_back(x - y - 1);
			vp.push_back(x - y + 1);
			vp.push_back(x - y);
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<tuple<int, int, char>> v;
	vector<int> v1, v2, v3, v4, v5, v6;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x, y;
		char c;
		cin >> x >> y >> c;
		x *= 2, y *= 2;
		if (c == 'R') v1.push_back(x);
		else if (c == 'L') v2.push_back(x);
		else v3.push_back(x);
		if (c == 'U') v4.push_back(y);
		else if (c == 'D') v5.push_back(y);
		else v6.push_back(y);
		v.emplace_back(x, y, c);
	}
	vp.push_back(0);
	LL ans = 4 * INF * INF;
	solve(v1, v2, v3);
	solve(v4, v5, v6);
	for (auto& o : vp)
	{
		if (o < 0) continue;
		LL minx = INF * INF, miny = INF * INF;
		LL maxx = -INF * INF, maxy = -INF * INF;
		for (auto& p : v)
		{
			int x, y;
			char c;
			tie(x, y, c) = p;
			if (c == 'R') x += o;
			if (c == 'L') x -= o;
			if (c == 'U') y += o;
			if (c == 'D') y -= o;
			maxx = max(maxx, 1LL * x);
			minx = min(minx, 1LL * x);
			maxy = max(maxy, 1LL * y);
			miny = min(miny, 1LL * y);
		}
		ans = min(ans, (maxx - minx) * (maxy - miny));
	}
	printf("%.15f\n", ans / 4.0);
	return 0;
}

Measured memory_bytes: 2744
var reader = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
 
var lines = [];
reader.on('line', (line)=> {
lines.push(line);
});
 
reader.on('close', () =>{
var line = lines[0];
var elems =line.split(' ');
var A = elems[0];
var B = elems[1];
var C = A * B;
var D = C % 2;
if (D == 0){
console.log('Even');
}
else {
console.log('Odd');
}
});

Measured memory_bytes: 11596
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(long k, long n, const std::vector<long>& points)
{
  long max = points[0] + k - points[n - 1];
  for (long i = 1; i < n; ++i) {
    max = std::max(max, points[i] - points[i - 1]);
  }
  return k - max;
}

int main()
{
  long k, n;
  std::cin >> k >> n;
  std::vector<long> points(n);
  for (auto& p : points) {
    std::cin >> p;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(k, n, points) << std::endl;
}


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

int main() {
  	string s;
  	cin >> s;
  	int count = 0, ans = 0;
  	for(int i = 0; i < s.length(); i++) {
    	if(s[i] == 'R') {
        	count++;
        }
      	else {
        	ans = max(ans, count);
          	count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long long ll;

void solve() {
    ll n;
    cin >> n;
    n--;
    ll res = 0;
    for(ll i = 1; i <= n; i++)  res += n/i;
    cout  << res << endl;
}

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

    ll T = 1;

    while(T--) {
        solve();
    }
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll n,x,y,val=0;
	cin>>n>>x>>y;
	n-=2;
	FOR(i,1,n){ll a;cin>>a;val^=a;}
	ll sum=x+y;
	sum -= val;
	if(sum < 0 || sum % 2) { cout<<"-1\n"; return 0; }
	// can for now
	ll res=0;
	FOR(i,1,40){
		if(1ll<<i&sum) {
			if(1ll<<(i-1)&val) { cout<<"-1\n"; return 0; }
			else res += 1ll<<(i-1);
		}
	}
	if(res>x){cout<<"-1\n";return 0;}
	DEC(i,39,0){
		if((1ll<<i&val) && res + (1ll<<i) <= x) res += 1ll<<i;
	}
	if(res==0){cout<<"-1\n";return 0;}
	cerr<<res<<' '<<x<<'\n';
	cout<<x-res<<'\n';
}


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

using namespace std;

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

  int x;
  cin >> x;

  int res = 0;
  if (x == 1) res = 1;
  else {
    for (int b = 2; b < 32; ++b) {
      for (int p = 2; p < 11; ++p) {
        int cand = pow(b, p);
        if (cand <= x && cand > res) 
          res = cand;
      }
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int sum = 0;
        for (int i=1; i<=N; i++) {
            int n = i;
            int digSum = 0;
            while (n > 0) {
                digSum += n % 10;
                n /= 10;
            }
            if (digSum >= A && digSum <= B)
                sum += i;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	char a[100];
	int b;
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;

	scanf("%d %d %d",&n,&m,&k);
	z = 0;

	for (int i = 0; (2*i)<n; i++){
		x = k;
		x = x - (m*i);
		if (x >= 0){
			if (x % (n - (2 * i)) == 0 && x /(n - (2 * i)) <=m)z = 1;
		}
	}
	if (n*m == 2 * k)z = 1;

	if(z==1)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#define mp make_pair
using namespace std;

typedef pair<int,string> P;
typedef pair<int,P> PP;

int main(){
	int n;
	bool flag = false;
	while(cin >> n,n){
		if(flag) cout << endl;
		else flag = true;
		vector<PP> vec;
		for(int i = 0;i < n;i++){
			string s;
			int a,b,c;
			cin >> s >> a >> b >> c;
			vec.push_back(mp(a * 3 + c,mp(-i,s)));
		}
		sort(vec.begin(),vec.end(),greater<PP>());
		for(int i = 0;i < n;i++){
			cout << vec[i].second.second;
			printf(",%d\n",vec[i].first);
		}
	}
	return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int64 gcd(int64 a, int64 b) { return b? gcd(b,a%b):a; };
int64 lcm(int64 a, int64 b) { return a/gcd(a,b)*b; };

int main() {
    int s;
    cin >> s;
    map<int,bool> mp;
    int a = s;
    int ans = 1;
    while(!mp[a]) {
        mp[a] = true;
        a = (a%2? 3*a+1 : a/2);
        ans++;
    }

    cout << ans << endl;
}


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

int main() {
	// your code goes here
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
	   cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(ll i=0;i<k;i++)
	    sum=sum+a[i];
	cout<<sum<<endl;    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  int b=n;
  int a=0;
  rep(i,10){
    a += n%10;
    n /= 10;
  }
  if(b%a==0){ cout << "Yes" << endl; } else { cout << "No" << endl; }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    a = A[i]
    b = B[i]
    if a < b:
        ans += a
        b -= a
        a = A[i+1]
        if a < b:
            ans += a
            A[i+1] = 0
        else:
            ans += b
            A[i+1] -= b
    else:
        ans += b
print(ans)

Measured memory_bytes: 18624
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

struct edge{
    int to,cost;
};

void warshall_floyd(int n, vector<vector<ll>> &d){
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    ll N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> d(N, vector<ll>(N,INF));
    vector<vector<ll>> new_d(N, vector<ll>(N, INF));
    rep(i,N){
        d[i][i] = 0;
        new_d[i][i] = 0;
    }
    rep(i,M){
        ll A, B, C;
        cin >> A >> B >> C;
        A--;B--;
        d[A][B] = C;
        d[B][A] = C;
    }
    warshall_floyd(N, d);
    rep(i,N)rep(j,N){
        if(i == j) continue;
        if(d[i][j] <= L) new_d[i][j] = 1;
    }
    warshall_floyd(N, new_d);

    int Q;
    cin >> Q;
    vector<int> ans(Q);
    rep(i,Q){
        int s,t;
        cin >> s >> t;
        s--;t--;
        if(new_d[s][t] == INF) ans[i] = -1;
        else ans[i] = new_d[s][t] - 1;
    }
    for(auto a:ans) cout << a << endl;
}

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

Point Proj(Point P, Point P1, Point P2) { // Projection
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

int Direct1(Point P, Point P1, Point P2) { return sgn((P1-P)%(P2-P)); }
int Direct2(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

bool IsSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	if (min(P1.x, P2.x) <= max(Q1.x, Q2.x) && max(P1.x, P2.x) >= min(Q1.x, Q2.x) && min(P1.y, P2.y) <= max(Q1.y, Q2.y) && max(P1.y, P2.y) >= min(Q1.y, Q2.y))
		if (Direct2(P1, P2, Q1) * Direct2(P1, P2, Q2) <= 0 && Direct2(Q1, Q2, P1) * Direct2(Q1, Q2, P2) <= 0) return 1;
	return 0;
}

Point GetSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

DB PointLineDist(Point P, Point P1, Point P2) {
	return DB(Proj(P, P1, P2)-P);
}

DB PointSegDist(Point P, Point P1, Point P2) {
	if (Direct1(P1, P2, P) * Direct1(P2, P1, P) >= 0) return PointLineDist(P, P1, P2);
	return min(DB(P-P1), DB(P-P2));
}

DB SegDist(Point P1, Point P2, Point Q1, Point Q2) {
	if (IsSegInter(P1, P2, Q1, Q2)) return 0;
	return min(min(PointSegDist(P1, Q1, Q2), PointSegDist(P2, Q1, Q2)), min(PointSegDist(Q1, P1, P2), PointSegDist(Q2, P1, P2)));
}

int q;

int main() {
	scanf("%d", &q);
	while (q--) {
		Point P1 = gp(), P2 = gp(), Q1 = gp(), Q2 = gp();
		printf("%.10lf\n", SegDist(P1, P2, Q1, Q2));
		//wp(GetSegInter(P1, P2, Q1, Q2)); enter;
		//printf("%d\n", IsInter(P1, P2, Q1, Q2));
		//wp(Proj(P, P1, P2)); enter;
	}
	return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> ch(26);
  rep(i, n) {
    ch[s[i] - 'a']++;
  }
  ll ans = 1;
  rep(i, 26) {
   (ans *= ch[i] + 1) %= mod;
  }
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
int n;
cin>>n;
llong t,a;
cin>>t>>a;
int j=1000;
t=t*j;
a=a*j;
vector<llong> h(n,0);
int p=INF;
int ans=0;
for(int i=0; i<n; i++) {
cin>>h[i];
if(p>abs(a-t+6*h[i]))
{
    p=abs(a-t+6*h[i]);
    ans=i+1;
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

result = true
last_index = arr.length - 1

arr.each_with_index do |n, i|
  break if i == last_index
  n -= 1 if i == 0
  margin = arr[i+1] - n

  if margin >=  1
    arr[i+1] -= 1
  elsif margin == 0
  else
    result = false
  end

end

if result
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 9604
#include <stdio.h>
int main(void)
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i%10==3||i%3==0||i%100/10==3||i%1000/100==3||i%10000/1000==3){
			printf(" %d",i);
	    }
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(void){
    int a,b;string s;
    while(1){
        cin >> a >> s >> b;
        if(s=="?"){break;}
        else if(s=="+"){cout << a+b << endl;}
        else if(s=="-"){cout << a-b << endl;}
        else if(s=="*"){cout << a*b << endl;}
        else{cout << a/b << endl;}
    }
    
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

//aとbの最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

//aとbの最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}

int main(){
    int N;
    ll K;
    cin >> N >> K;
    ll A[N];
    rep(i, N){
        cin >> A[i];
    }
    ll g = A[0], M = A[0];
    rep2(i, 1, N-1){
        g = gcd(g, A[i]);
        M = max(M, A[i]);
    }
    if(K%g == 0 && K <= M){
        cout << "POSSIBLE" << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
#include<map>
#include<list>
#include<queue>
#include<iostream>
#include<unordered_set>
#include<set>
#include<vector>
#include<cmath>

#define ull unsigned long long
#define ll long long
#define mp make_pair
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

int main(int argc, char *argv[])
{
    int a, idx = 1;
    while(idx <= 5) {
        cin >> a;
        if (!a)
            break;
        idx++;
    }

    cout << idx << endl;

    return 0;
}


Measured memory_bytes: 3632
import numpy as np
MOD = 10 ** 9 + 7
N = int(input())
A = np.array(input().split(), dtype=np.int64)
total = 0
for shamt in range(65):
    bits = np.count_nonzero(A & 1)
    total += (bits * (N - bits)) << shamt
    A >>= 1
    if not A.any():
        break
print(total % MOD)

Measured memory_bytes: 62776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class220
    {
        static void Main()
        {
            var xyz = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = xyz[2], y = xyz[0], z = xyz[1];
            Console.WriteLine($"{x} {y} {z}");
        }
    }
}


Measured memory_bytes: 13396
def bubbleSort(list_, n):
    list_ = list_[:]
    count = 0
    for i in xrange(n):
        for j in xrange(n-1, i, -1):
            if list_[j] < list_[j - 1]:
                list_[j], list_[j - 1] = list_[j - 1], list_[j]
                count += 1

    return list_, count

n = input()
nums = map(int, raw_input().split())
sorted_, count = bubbleSort(nums, n)
print ' '.join(map(str, sorted_))
print count

Measured memory_bytes: 4232
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))

typedef vector<int> Ivec;
typedef pair<int, int> Pos;

vector<pair<int, vector<int>>> graph;


int main() {
	int n;
	scanf("%d", &n);
	Ivec kusi;
	for (int i = 0; 2*n > i; i++) {
		int a;
		scanf("%d", &a);
		kusi.push_back(a);
	}
	sort(kusi.begin(), kusi.end());
	int ans = 0;

	for (int i = 0; n*2 > i; i += 2) {
		ans += min(kusi[i], kusi[i+1]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<numeric>
using namespace std;


int mypow(int x, int y);
    //////////////////////////////////////////
    //    整数用のpow
    //    in   : 整数, 整数
    //    out  : 整数 
    //    ver  : 1.0
    //    概要 : 正の整数での使用のみを想定
    //    include: NA
    //////////////////////////////////////////


vector<int> my_incli(vector<int> v, int n, int m);

int main(){
    int N, M, Q, num_max;
    int judge = 0;
    int a, b, c, d;
    int A_b, A_a;
    long long score = 0;
    long long champ = 0;
    std::cin >> N >> M >> Q;
    
    num_max = mypow(M, N);
    vector<vector<int>> mylist;
    vector<vector<int>> A_list;
    vector<int> temp(N, 1);//最初は1×N
    vector<int> temp_A(4);
    
    for(int i = 0; i < Q; i++){
        std::cin >> a >> b >> c >> d;
        temp_A = {a, b, c, d};
        A_list.push_back(temp_A);
    }

    while(judge < M * N){
        mylist.push_back(temp);
        //次のやつをいじる
        //基本は一番下の桁をインクリしてく
        temp = my_incli(temp, N-1, M);
        judge = std::accumulate(temp.begin(), temp.end(), 0);
        // for(int i = 0; i < N; i++){
        //     std::cout << temp[i] << " ";
        // }
        // std::cout << "\n";
    }
    mylist.push_back(temp);

    // for(int i = 0; i < mylist.size(); i++){
    //     for(int j = 0; j < N; j++){
    //         std::cout << mylist[i][j];
    //     }
    //     std::cout << "\n";
    // }

    for(int i = 0; i < mylist.size(); i++){
    //あとは問題文通りに処理
        score = 0;
        for(int j = 0; j < Q; j++){
            A_b = mylist[i][A_list[j][1]-1];
            A_a = mylist[i][A_list[j][0]-1];
            if(A_b - A_a == A_list[j][2]){
                score = score + A_list[j][3];
            }
        }
        if(champ < score){
            champ = score;
        }

    }
    
    std::cout << champ;

}

vector<int> my_incli(vector<int> v, int n, int m){
    int max = v.size();
    if(n >= max||n < 0){
        return v;
    }
    if(v[n] < m){
        v[n]++;
    }else{
        v = my_incli(v, n-1, m);
        v[n] = v[n-1];
    }
    return v;
}



int mypow(int x, int y){
    int ans = 1;
    for(int i = 0; i < y; i++){
        ans = ans * x;
    }
    return ans;
}



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

using namespace std;

#define FOR(a, b, c) for(int a = b, _c = c; a <= _c; ++a)
#define int long long

const int N = 3e3 + 5;
int n, l, r;
pair<int, int> a[N];
int f[N][N];
int F(int i, int j) {
  if(i > j) return 0;
  if(f[i][j] != -1) return f[i][j];
  int now = j - i + 1;
  int ans = 0;
  ans = max(F(i, j - 1) + abs(a[now].second - j) * a[now].first, F(i + 1, j) + abs(a[now].second - i) * (a[now].first));
  return f[i][j] = ans;
}
main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  FOR(i, 1, n) cin >> a[i].first, a[i].second = i;
  sort(a + 1, a + n + 1, [](pair<int,int> x, pair<int,int> y){
    if(x.first != y.first) return x.first < y.first;
    else x.second < y.second;
  });
  memset(f, -1, sizeof(f));
  int ans = 0;
  cout << F(1, n);
}


Measured memory_bytes: 74348
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int N = 3e5 + 7;

const int md = 998244353;

int mul(int a, int b) {
  return ((ll)a * b) % md;
}

void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

int power(int a, ll b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int f[N], rf[N];

int C(int n, int k) {
  return mul(f[n], mul(rf[n - k], rf[k]));
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif

  f[0] = 1;
  for (int i = 1; i < N; ++i) f[i] = mul(f[i - 1], i);
  rf[N - 1] = power(f[N - 1], md - 2);
  for (int i = N - 2; i >= 0; --i) {
    rf[i] = mul(rf[i + 1], i + 1);
  }


  int n, a, b; ll k;
  cin >> n >> a >> b >> k;
  int ans = 0;
  for (int ca = 0; ca <= n; ++ca) {
    ll have = (ll)ca * a;
    if (have > k) continue;
    ll need = k - have;
    if (need % b) continue;
    ll cb = need / b;
    if (cb > n) continue;
    add(ans, mul(C(n, ca), C(n, cb)));
  }
  cout << ans << '\n';
}



Measured memory_bytes: 2560
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

N = iin()
AB = sorted([iln() for _ in range(N)], key=lambda x:x[1])

time = 0
for i in range(N):
    time += AB[i][0]
    if AB[i][1] < time:
        print('No')
        break
else:
    print('Yes')



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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int f=1;
    int tmaxi = 0;
    rep(i, N) {
        if(H[tmaxi] < H[i]) tmaxi = i;
        if(H[tmaxi] > H[i]) {
            if(H[tmaxi] - H[i] >= 2) {
                f=0;
                break;
            }
        }
        
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int i;
  int x[10];
  int k;
  int a=0;
  int max=0;
  scanf("%d",&i);
  for(k=0;k<i;k++){
    scanf("%d",&x[k]);
    
    if(max<x[k]){
      max=x[k];
    }
    a+=x[k];
  }
  printf("%d",a-(max/2));
  
  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,q;
  string s;
  cin >> n >> q >> s;
  vector<int> ac(111111);
  int t=0;
  for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C') t++;
    ac[i]=t;
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << ac[r-1] - ac[l-1] << endl;
  }
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);
int a[3];
int main() {
	cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a+3);
	int ans = 0;
	ans += a[2] - a[0];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans;
    int ans_min = INFINITY;

    _rep(i, -100, 101){
        ans = 0;
        rep(j, n){
            ans += pow((a[j] - i), 2);
        }
        ans_min = min(ans, ans_min);
    }
    cout << ans_min << endl;
}

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



int main(){
	int a;
	int b;
	int c;
	int x;
	int kotei;
	int p;
	int q;

	cin>>a>>b>>c>>x;

	kotei = x;

	int count =0;
	
	//50円ループ
	for(int i=0;i<c+1;i++){
		x = x-50*i; 
		if(x==0){
			count = count +1;
			x = kotei;
			break;
		}else if(x<50){
			//x = kotei;
			break;
		}
		p = x;
		x = kotei;
		//100円ループ
		for(int j=0;j<b+1;j++){
			int temp = p;
			p = p-100*j; 
			if(p==0){
				count = count +1;				
				break;
			}else if(x<100){				
				break;
			}
			q = p;
			p = temp;
			//500円ループ
			for(int k=0;k<a+1;k++){
				int temp = q;
				q = q-500*k;
				if(q==0){
					count = count +1;
					break;
				}else if(q<500){					
					break;
				}
				q = temp;
			}
		}
		
	}


	
	cout << count;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=3e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],sb=0,sw=0;
int check(int mid) {
    int val=a[1];
    for(int i=3;i<=n;i+=2) {
        if(val>=mid) val=max(val+a[i]-a[i-1],a[i]);
        else val+=a[i]-a[i-1];
    }
    return val>=mid;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi(),(i&1)?sb+=a[i]:sw+=a[i];
    if(!(n&1)) return printf("%d %d\n",max(sb,sw),min(sb,sw)),0;
    int l=0,r=sb,ret=0;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) ret=mid,l=mid+1;
        else r=mid-1;
    }
    printf("%d %d\n",sw+ret,sb-ret);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

int main() {
  int n,k;
  cin >> n >> k;
  cout << n+1-k << endl;
  return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/arc092/submissions/2242272
#include <iostream>
#pragma GCC target ("tune=native,arch=ivybridge")
#pragma GCC optimize ("Ofast,unroll-loops")

int as[202020];
int bs[202020];
constexpr int block = 6000;
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &as[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &bs[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i += block) {
        int end = min(n, i + block);
        int j = 0;
        for (; j + 3 < n; j += 4) {
            for (int ii = i; ii < end; ++ii) {
                ans ^= as[j] + bs[ii];
                ans ^= as[j + 1] + bs[ii];
                ans ^= as[j + 2] + bs[ii];
                ans ^= as[j + 3] + bs[ii];
            }
        }
        for (; j < n; ++j) {
            for (int ii = i; ii < end; ++ii) {
                ans ^= as[j] + bs[ii];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
int main(int argc, const char *argv[]) {
  ll a, b, c;
  char dot;
  cin >> a >> b >> dot >> c;

  ll ans = a * b;
  string s_c = to_string(c * a);
  if (s_c.size() <= 2) {
    cout << ans << '\n';
    return 0;
  }

  ans += stoll(s_c.substr(0, s_c.size() - 2));
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3684
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> ae(5); cin >> ae;
    int k; cin >> k;
    cout << (ae[4] - ae[0] <= k ? "Yay!" : ":(") << '\n';
}


Measured memory_bytes: 256
import sys

n = int(input())
deme = [input().split() for i in range(n)]

#print(deme)

toki = 0

for i in range(n):
  if deme[i][0] == deme[i][1]:
    toki += 1
    if toki >= 3:
      print("Yes")
      sys.exit(0)
    
  else:toki = 0

print("No")

Measured memory_bytes: 9172
#include <stdio.h>
#define INFTY 2000000000
#define MAX 500000
struct card{
	char mark;
	int number;
};

struct card L[MAX/2+2];
struct card R[MAX/2+2];

int partition(struct card *B,int p,int r){
	int i,j;
	struct card tmp;
	struct card parti;
	parti=B[r];// partition
	i=p-1;
	for(j=p;j<r;j++){
		if(B[j].number<=parti.number){
			i++;
			tmp=B[i];
			B[i]=B[j];
			B[j]=tmp;
		}
	}
	
	tmp=B[i+1];
	B[i+1]=B[r];
	B[r]=tmp;
	
	return i+1;
	
}

void quicksort(struct card *B,int p, int r){
	int q;
	if(p<r){
		q=partition(B,p,r);
		quicksort(B,p,q-1);
		quicksort(B,q+1,r);
	}
}

void merge(struct card *A,int n, int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
	
		R[i]=A[mid+i];
	}
	
	L[n1].number=R[n2].number=INFTY;
	int i=0,j=0;
	
	for(int k=left;k<right;k++){
		if(L[i].number<=R[j].number){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
		}
	}
}

void mergesort(struct card  *A,int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergesort(A,n,left,mid);
		mergesort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}




void check(struct card *A,struct card *B,int n){
	int count=0;
	int i;
	for(i=0;i<n;i++){
		if(A[i].mark !=B[i].mark){
			count++;
			}
	}
	
	if(count==0){
			printf("Stable\n");
			}
		else{
			printf("Not stable\n");
			}
}



int main(void){
	int i,n;
	scanf("%d",&n);
	char S[2];
	struct card A[n];
	struct card B[n];
	
	for(i=0;i<n;i++){
		scanf("%s %d",&S,&(A[i].number));
		A[i].mark=S[0];//入力の時に空白も入力するのでCharを作って一番目だけをmarkに代入させる
		B[i]=A[i];
		
		}
	mergesort(A,n,0,n);
	quicksort(B,0,n-1);
	check(A,B,n);
	
	for(i=0;i<n;i++){
		printf("%c %d\n",B[i].mark,B[i].number);
	}
	return 0;
}


Measured memory_bytes: 4144
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> s;
	for(int i = 1; i <= c; ++i) {
		if(c % i == 0) {
			s.insert(i);
			s.insert(c / i);
		}
	}
	auto it = s.lower_bound(a);
	int ret = 0;
	while(it != s.end() && *it <= b) {
		++it, ++ret;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  map<int,int>M;
  M[0]=0;
  for(int i=0;i<N-1;i++){
  if(S.at(i)=='A' && S.at(i+1)=='C')
    M[i+1]=M.at(i)+1;
    else
      M[i+1]=M.at(i);
  }M[N]=M[N-1];
  for(int i=0;i<Q;i++){
  int l,r;
    cin>>l>>r;
    int ans=M.at(r-1)-M.at(l-1);
    cout<<ans<<endl;
  
  }
    
   return 0;
}

Measured memory_bytes: 5632
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by sonekenichiro on 2017/07/09.
 */
public class Main {
    static final int  MIN_START_TIME=540;
    static final int MAX_TIME=720;

    static ArrayList<int[]> pcData;

    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);

        while (true){
            String[] firstNums=scanner.nextLine().split(" ");


            int pcCount=Integer.parseInt(firstNums[0]);
            int studentCount=Integer.parseInt(firstNums[1]);
            if(pcCount==0&&studentCount==0){
                break;
            }

            pcData =new ArrayList<>();

            for(int i =0;i<pcCount;i++){
                pcData.add(new int[720]);
                Arrays.fill(pcData.get(i),0);
            }


            int dataCount=Integer.parseInt(scanner.nextLine());
            for(int i =0;i<dataCount;i++){
                String[] loginData=scanner.nextLine().split(" ");

                setLoginData(Integer.parseInt(loginData[0]),Integer.parseInt(loginData[1]),Integer.parseInt(loginData[2]),Integer.parseInt(loginData[3]));
            }



            int questionCount=Integer.parseInt(scanner.nextLine());

            for(int i =0;i<questionCount;i++){
                String[] question =scanner.nextLine().split(" ");
                int startTime=Integer.parseInt(question[0]);
                int endTime=Integer.parseInt(question[1]);
                int studentNum=Integer.parseInt(question[2]);
                int usingTime=0;

                for (int j=startTime;j<endTime;j++){
                    boolean using=false;
                    for (int k = 0;k<pcData.size();k++) {
                        if (studentNum == pcData.get(k)[j-MIN_START_TIME]) {
                            using=true;
                            break;
                        }
                    }
                    if(using){
                        usingTime++;
                    }

                }


                System.out.println(usingTime);
            }
        }



    }



    public static void setLoginData(int time,int pcNum,int studentNum,int login){
        if(login==1){
            for(int i =time-MIN_START_TIME;i<MAX_TIME;i++){
                pcData.get(pcNum-1)[i]=studentNum;
            }
        }else{
            for(int i =time-MIN_START_TIME;i<MAX_TIME;i++){
                pcData.get(pcNum-1)[i]=0;
            }
        }



    }








}

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

using namespace std;

int main(){

  string s; cin >> s;
  
  for(int i = 1; i < s.size(); ++i) {
  	if(s[i] == s[i-1]){
    	cout << i << " " << i+1 << "\n";
      	return 0;
    }
  }
  
  if(s.size() >= 3){
  	for(int i = 2; i < s.size(); ++i){
    	if(s[i] == s[i-2]){
        	cout << i-1 << " " << i+1 << "\n";
      		return 0;
        }
    }
  }
  
  cout << "-1 -1\n";

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int x;
cin>>x;
if(x<1200)
    cout<<"ABC";
else
    cout<<"ARC";


    return 0;
}


Measured memory_bytes: 3496
#include <iostream>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint N;
vector<edge> G[100005];
llint size[100005];

llint sizedfs(llint v, llint prev)
{
	llint ret = 1;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == prev) continue;
		ret += sizedfs(G[v][i].to, v);
	}
	return size[v] = ret;
}

llint centdfs(llint v, llint prev)
{
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == prev) continue;
		if(size[G[v][i].to] > N/2) return centdfs(G[v][i].to, v);
	}
	return v;
}

llint sumdfs(llint v, llint prev)
{
	llint ret = 0;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i].to == prev) continue;
		ret += size[G[v][i].to] * G[v][i].cost;
		ret += sumdfs(G[v][i].to, v);
	}
	return ret;
}

int main(void)
{
	cin >> N;
	llint a, b, c;
	for(int i = 0; i < N-1; i++){
		cin >> a >> b >> c;
		G[a].push_back(edge(b, c));
		G[b].push_back(edge(a, c));
	}
	
	sizedfs(1, -1);
	llint cent = centdfs(1, -1);
	sizedfs(cent, -1);
	
	llint ans = sumdfs(cent, -1) * 2;
	llint mn = inf; bool flag = false;
	for(int i = 0; i < G[cent].size(); i++){
		if(N % 2 == 0 && size[G[cent][i].to] == N/2){
			flag = true;
			ans -= G[cent][i].cost;
		}
		mn = min(mn, G[cent][i].cost);
	}
	if(!flag) ans -= mn;
	cout << ans << endl;
	
	return 0;
}

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

int n;
int main()
{
	scanf("%d", &n);
	if (n / 100 == 7 || n / 10 % 10 == 7 || n % 10 == 7)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 3640