akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

string _10to2(long long l){
    if (l == 0) return "0";
    string res = "";
    while(l != 1){
        if ( l & 1 ) res = '1' + res;
        else res = '0' + res;
        l >>= 1;
    }
    return '1' + res;
}

LL n;
LL MOD = 1000000007;

void init() {
}

void input() {
	cin >> n;
}

void solve() {
	int bit = SZ(_10to2(n));
	LL dp[100][3]; MSET(dp, 0);
	dp[bit-1][0] = 1;
	dp[bit-1][1] = 1;
	dp[bit-1][2] = 0;
	for(int b = bit-2; b >= 0; b--){
		if((n>>b)&1){
			dp[b][0] = dp[b+1][0];
			dp[b][1] = (dp[b+1][0] + dp[b+1][1]) % MOD;
			dp[b][2] = (dp[b+1][1]*2 + dp[b+1][2]*3) % MOD;
		}
		else{
			dp[b][0] = (dp[b+1][0] + dp[b+1][1]) % MOD;
			dp[b][1] = dp[b+1][1];
			dp[b][2] = (dp[b+1][1] + dp[b+1][2]*3) % MOD;
		}
	}
	cout << (dp[0][0] + dp[0][1] + dp[0][2])%MOD << endl;
}

int main() {
	init();
    input();
    solve();
	return 0;
}








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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<pair<LL, int> > HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int na, nb, nc, k;
LL x[N], y[N], z[N], t[N];

bool cmp(LL a, LL b)
{
	return a > b;
}

void merge(LL a[], int n, LL b[], int m)
{
	HEAP heap;
	for (int i = 0; i < m; i ++ ) heap.push({a[0] + b[i], 0});
	
	n = min(k, n * m);
	for (int i = 0; i < n; i ++ )
	{
		LL v = heap.top().F;
		int j = heap.top().S;
		heap.pop();
		
		t[i] = v;
		
		if (j + 1 < na) heap.push({v - a[j] + a[j + 1], j + 1});
	}
	
	na = n;
	memcpy(a, t, sizeof t);
}

int main()
{
	cin >> na >> nb >> nc >> k;
	for (int i = 0; i < na; i ++ ) cin >> x[i];
	for (int i = 0; i < nb; i ++ ) cin >> y[i];
	for (int i = 0; i < nc; i ++ ) cin >> z[i];
	
	
	sort(x, x + na, cmp);
	merge(x, na, y, nb);
	merge(x, na, z, nc);
	
	for (int i = 0; i < k; i ++ ) cout << x[i] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 2e18

int main(){
    int k, a, b;
    cin >> k >>a >> b;
    repr(i, a, b){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    // printf("%d\n", N);
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int H[200000];
long long tree[1<<19];

void set_tree(int n, long long v, int bit=1, int s=0, int e=200000)
{
	int m=(s+e)>>1;
	if(s==e) {
		tree[bit]=v;
		return;
	}
	if(n<=m) set_tree(n,v,2*bit,s,m);
	else set_tree(n,v,2*bit+1,m+1,e);
	tree[bit]=max(tree[2*bit],tree[2*bit+1]);
}

long long get_max(int n1, int n2, int bit=1, int s=0, int e=200000)
{
	int m=(s+e)>>1;
	if(n2<n1 || n2<s || e<n1) return 0;
	if(n1<=s && e<=n2) return tree[bit];
	return max(get_max(n1,n2,2*bit,s,m),get_max(n1,n2,2*bit+1,m+1,e));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	cin>>N;
	for(int i=0;i<N;i++) cin>>H[i];
	for(int i=0;i<N;i++) {
		int A;
		cin>>A;
		set_tree(H[i],A+get_max(0,H[i]-1));
	}
	cout<<tree[1]<<'\n';
	return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
#include<math.h>
int main(){
  int q;
  double x;
  for(;;){
    scanf("%d",&q);
    if(q==-1)
      break;
    x=q/2.0;
    while(fabs(x*x*x-q)>=0.00001*q)
      x-=(x*x*x-q)/x/x/3;
    printf("%lf\n",x);
  }
  return 0;
}

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

int main(){
    int a[9], n, b[100];
    rep(i,9) cin >> a[i];
    cin >> n;
    rep(i,n) cin >> b[i];

    bool ans = false;

    rep(i,n)
        rep(j,9)
            if (a[j] == b[i]) a[j] = -1;

    rep(i,3)
        if (a[i] == - 1 && a[i+3] == -1 && a[i+6] == -1){
            ans = true;
            cout << "Yes" << endl;
            return 0;
        }
    rep(i,3)
        if (a[i * 3] == -1 && a[i* 3 + 1] == -1 && a[i * 3 + 2] == -1){
            ans = true;
            cout << "Yes" << endl;
            return 0;
        }
    if (a[2] == a[4] && a[4] == a[6]){
        ans = true;
        cout << "Yes" << endl;
        return 0;
    }
    if (a[0] == -1 && a[4] == -1 && a[8] == -1){
        ans = true;
        cout << "Yes" << endl;
        return 0;
        }

    if (ans == false) cout << "No" << endl;

    return 0;
    
}

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

int main()
{
	int n, l;
  	string s;
  	vector<string> v;
  	cin >> n >> l;
  	for(int i=0; i<n; i++) cin >> s, v.push_back(s);
  	sort(v.begin(),v.end());
  	for(int i=0; i<n; i++) cout << v[i];
  	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int powi(int n, int p) {
    int ans = 1;
    rep(i, p) {
        ans *= n;
    }
    return ans;
}

int main(){
    int n, m;
    cin >> n >> m;
    vi k(m), p(m);
    vector<vi> s(m);
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            int si;
            cin >> si;
            s[i].push_back(si);
        }
    }
    rep(i, m) cin >> p[i];
    int ans = 0;
    rep(i, powi(2, n)) {
        bool ok = true;
        rep(j, m) {
            int pa = 0;
            rep(j2, k[j]) {
                if (i&powi(2, s[j][j2]-1)) ++pa;
            }
            if (pa%2!=p[j]) ok = false;
        }
        if (ok) ++ans;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[4];
int change(int num,int f)
{
	if(f==0)
		return -num;
	else
		return num;
}
void print(int num,int f)
{
	if(f==0)
		printf("-%d",num);
	else
		printf("+%d",num);
} 
int main()
{
	for(int i=0;i<4;i++)x[i]=getchar()-'0';
	for(int a=0;a<2;a++)
	{
		for(int b=0;b<2;b++)
		{
			for(int c=0;c<2;c++)
			{
				if(x[0]+change(x[1],a)+change(x[2],b)+change(x[3],c)==7)
				{
					cout<<x[0];
					print(x[1],a);
					print(x[2],b);
					print(x[3],c);
					puts("=7");
					return 0;
				}
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	if(a>0)puts("Positive");
	else if(b>=0)puts("Zero");
	else if((a&1)^(b&1))puts("Positive");
	else puts("Negative");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = ll(1e9 + 7);

ll f(vector<ll> v) {
	int N = v.size();
	ll sum = 0;
	for(int i = 1; i < N; i++) {
		sum += v[i] - v[0];
		sum %= MOD;
	}
	ll ret = sum;
	for(int i = 1; i < N; i++) {
		ll d = abs(v[i] - v[i - 1]);
		sum -= d * (N - i);
		ret += sum;
		ret %= MOD;
	}
	return ret;
}

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

	int N, M;
	cin >> N >> M;
	vector<ll> x(N), y(M);
	for(int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for(int i = 0; i < M; i++) {
		cin >> y[i];
	}
	ll xx = f(x), yy = f(y);
	cout << (xx * yy) % MOD << endl;
}

Measured memory_bytes: 2672
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


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


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


H, W = zz()
board = []
for i in range(H):
    board.append(S())

dx_lis = (-1, 0, 1, 0)
dy_lis = (0, -1, 0, 1)


def check(i, j):
    for dx, dy in zip(dx_lis, dy_lis):
        if (i + dx >= H or i + dx < 0 or j + dy >= W or j + dy < 0):
            continue
        if (board[i + dx][j + dy] == '#'):
            return(True)
    return False


for i in range(H):
    for j in range(W):
        if (board[i][j] == '#'):
            if (check(i, j) is False):
                print('No')
                exit()
print('Yes')


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

int main(){
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for (int i=0; i<N; i++){
    cin >> H[i];
  }
  double temp[N], diff[N];
  double min_diff=1000000;
  int ans=0;
  for (int i=0; i<N; i++){
    temp[i]=T-H[i]*0.006;
    if (temp[i]>A){
      diff[i]=temp[i]-A;
    }
    else {
      diff[i]=A-temp[i];
    }
    if (min_diff>=diff[i]){
      min_diff=diff[i];
      ans=i+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

g_num = 1
p_num = 0

win = 0
lose = 0

if s[0] == 'p':
    lose += 1


for i in range(1, len(s)):
    if s[i] == 'p':
        if p_num < g_num:
            p_num += 1
        else:
            g_num += 1
            lose += 1
    else:
        if p_num < g_num:
            p_num += 1
            win += 1
        else:
            g_num += 1

print(win - lose)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int MN = 2005;
int mod = 1e9 + 7;
int n,sz[MN],p[MN];
vector<int>gph[MN];
int dp[MN][MN][2];
int f[MN];
int a[MN][3], nxt[MN][3];
signed main(){
f[0]=1;
for(int i=1;i<MN;i++)f[i]=f[i-1]*i%mod;
cin >> n;
for(int i=2;i<=n;i++){cin>>p[i];gph[p[i]].push_back(i);} 
for(int i=n;i;i--){
memset(a,0,sizeof(a));
a[0][0]=1;
for(auto &j:gph[i]){
memset(nxt,0,sizeof(nxt)); 
rep(k,sz[j]+1)rep(l,sz[i]+1)rep(m,3){
nxt[k+l][m]+=dp[j][k][0]*a[l][m]%mod;
if(m<2) nxt[k+l+1][m+1]+=dp[j][k][1]*a[l][m] % mod;
}
sz[i]+=sz[j];  
rep(j,sz[i]+1)rep(k,3){a[j][k]=nxt[j][k]%mod;}  
}
rep(j,sz[i]+1){
dp[i][j][0]=a[j][0]+a[j][1]*2+a[j][2]*2;
dp[i][j][1]=a[j][0]+a[j][1];dp[i][j][0]%=mod;dp[i][j][1]%=mod;}
sz[i]++;}
int ret=0;  
for(int i=0; i<=n; i++){
int cur = dp[1][i][0]*f[n-i]%mod;
if(i & 1) cur=mod-cur;
ret+=cur;}
cout<<ret%mod<<endl;
}

Measured memory_bytes: 42476
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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

int main(){
    ll N;
    string S;
    cin>>N>>S;
    ll red=0,gre=0,blu=0;
    for(ll i=0;i<N;i++){
        if(S[i]=='R')red++;
        if(S[i]=='G')gre++;
        if(S[i]=='B')blu++;
    }
    ll res = red*blu*gre;
    for(ll i=0;i<N;i++){
        for(ll j=1;j<N;j++){
            if(i+j>=N||i-j<0)break;
            if(S[i-j]!=S[i+j]&&S[i]!=S[i-j]&&S[i]!=S[i+j])res--;
        }
    }
    cout<<res<<endl;
}


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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  int cnt = 0;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) cnt++;
  }
  std::cout << cnt << std::endl;
}


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

int main(void){
  int a=0, b=0;
  int product = 0;
  cin >> a >> b ;
  product = a*b;
  if((product % 2) ==0){
    cout << "Even";
  }else{
    cout << "Odd";
  }

  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, d;
  cin >> n >> d;

  d = (2 * d + 1);
  cout << ((n + d - 1) / d) << endl;

  return 0;
}


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

int FindLCM(int a, int b) 
{ 
    return (a * b) / __gcd(a, b); 
} 
  
// Function to calculate all divisors in given range 
int rangeDivisor(int m, int n, int a, int b) 
{ 
    // Find LCM of a and b 
    int lcm = FindLCM(a, b); 
  
    int a_divisor = n / a - (m - 1) / a; 
    int b_divisor = n / b - (m - 1) / b; 
  
    // Find common divisor by using LCM 
    int common_divisor = n / lcm - (m - 1) / lcm; 
  
    int ans = a_divisor + b_divisor - common_divisor; 
    return ans; 
} 
  
// Drive code 
int32_t main() 
{ 
    int mm,nn,a,b;
    cin >> mm >> nn >> a >> b;
	int m= min(mm,nn);
	int n = max(mm,nn);
    cout << n-m  + 1 - rangeDivisor(m, n, a, b) << endl; 
    return 0; 
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[3 * n];
		for (int i = 0; i < 3 * n; i++) {
			arr[i] = sc.nextInt();
		}
		PriorityQueue<Integer> front = new PriorityQueue<>();
		long frontValue = 0;
		long[] frontValues = new long[n + 1];
		PriorityQueue<Integer> reer = new PriorityQueue<Integer>(new Comparator<Integer>(){
		public int compare(Integer i1, Integer i2) {
			return i2.intValue() - i1.intValue();
		}
		});
		long reerValue = 0;
		long[] reerValues = new long[n + 1];
		for (int i = 0; i < 2 * n; i++) {
			front.add(arr[i]);
			frontValue += arr[i];
			reer.add(arr[3 * n - i - 1]);
			reerValue += arr[3 * n - i - 1];
			if (i >= n) {
				frontValues[i - n] = frontValue - arr[i];
				frontValue -= front.poll();
				reerValues[i - n] = reerValue - arr[3 * n - i - 1];
				reerValue -= reer.poll();
			}
		}
		frontValues[n] = frontValue;
		reerValues[n] = reerValue;
		long max = Long.MIN_VALUE;
		for (int i = 0; i <= n; i++) {
			max = Math.max(max, frontValues[i] - reerValues[n - i]);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 94924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  long long sum=0;
  int mx = a[0];
  for(int i=1;i<n;i++){
     if(a[i]<mx){
	  sum+=(mx-a[i]);
	  //a[i]=a[i-1];
	 }
	 else{
	  mx = a[i];
	 }
  }
  cout<<sum<<"\n";
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x[3], y[3];
    rep(i,0,3) cin >> x[i] >> y[i];
    x[1] -= x[0]; x[2] -= x[0];
    y[1] -= y[0]; y[2] -= y[0];
    x[0] = 0; y[0] = 0;
    double S = abs(x[1]*y[2] - x[2]*y[1]) / 2;
    double a = sqrt(x[1]*x[1] + y[1]*y[1]);
    double b = sqrt(x[2]*x[2] + y[2]*y[2]);
    double c = sqrt((x[1]-x[2])*(x[1]-x[2]) + (y[1]-y[2]) * (y[1]-y[2]));
    double r = 2 * S / (a+b+c);
    double cc = max(max(a,b), c);
    double ans = cc/(2+cc/r);
    cout << setprecision(10) << ans << endl;
 

}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf = (ll)1e14;
const ll N = (ll)1e3+77;
const ll mod = (ll)1e9+7;

int main() {
    fast;
    string s;
    cin >> s;
    forn(i, sz(s) - 1) {
        if (s[i] == 'A' and s[i+1] == 'C') return cout << "Yes\n", 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int L,R,l,r,i,j,min,temp;
  
  //L,Rを読み込み
  scanf("%d %d",&L,&R);
  
  l=L%2019;
  r=R%2019;
  min=2018;
  
  if(R-L>=2018){min=0;}
  
  
  for(i=l; i<r; i++){
  	for(j=i+1; j<=r; j++){
      temp=(i*j)%2019;
      if(min>=temp){min=temp;}
    }  
  }
  
  printf("%d\n",min);
  
  return(0);
}

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265

typedef long long ll;

int PrimeNum_Count( int a ) {
    int r_a = sqrt( a );
    for( int i = 2; i <= r_a; i++ ) {
        if( a % i == 0 ) return 0;
    }
    return 1;
}

//*******************
//エントリーポイント
//*******************
int main( void ) {
    int num;
    int cnt = 0;
    while( cin >> num ){
        cnt += PrimeNum_Count( num );
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3080
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

M = sum(A)
L = []
i = 1
while i <= M**0.5:
    if M%i == 0:
        L.append(i)
        L.append(M//i)
    i += 1
    
L.sort(reverse=True)

for i in L:
    temp = [0]*N
    for j in range(N):
        temp[j] = A[j]%i
    temp.sort()
    cnt = 0
    l = 0
    r = N-1
    while l < r:
        if temp[l] == 0:
            l += 1
            continue
        if temp[r] == 0:
            r -= 1
            continue
        t = temp[l]
        temp[l] = 0
        cnt += t
        while l < r and temp[r]+t > i:
            t -= i-temp[r]
            temp[r] = 0
            r -= 1
        temp[r] += t
        temp[r] %= i
            
    if cnt <= K:
        ans = i
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n;
    cin >> n;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] -= i+1;
    sort(a.begin(), a.end());
    ll b;
    if(n%2==0) b = (a[n/2] + a[n/2-1])/2;
    else b = a[n/2];
    ll ans = 0;
    rep(i,n) ans += abs(a[i]-b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4808
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int check(int n, string s);

int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;
    int* sum = new int[n];
    int count = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            count++;
        }
        sum[i] = count;
    }
    int min = 1000000;
    int now = 0;
    for(int i = 0; i < n; i++){
        now = sum[i] + n - i - 1 - (sum[n - 1] - sum[i]);
        if(s[i] == 'W'){
            now--;
        }
        if(now < min){
            min = now;
        }
    }
    std::cout << min << std::endl;
}

Measured memory_bytes: 1796
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while (K && A >= B) {
        B *= 2;
        --K;
    }
    while (K && B >= C) {
        C *= 2;
        --K;
    }
    if (A < B && B < C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
typedef long long ll;
int lcs(string x,string y){
    int dp[1001][1001];
    int maxl=0;
    int X=x.size(),Y=y.size();
    x=" "+x;y=" "+y;
    rp(j,X+1)dp[j][0]=0;
    rp(j,Y+1)dp[0][j]=0;
    rep(j,1,X+1){
        rep(k,1,Y+1){
            if(x[j]==y[k])dp[j][k]=dp[j-1][k-1]+1;
            else dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
        }
    }
    return dp[X][Y];
}
int main(){
    int q;cin>>q;
    rp(i,q){
        string s1,s2;
        cin>>s1>>s2;
        cout<<lcs(s1,s2)<<endl;
    }
}



Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
int point = 0;
int out = 0;
bool base[3];

//1... Single Hit  2... Home run  3...Out
void exec(int event) {
    switch(event) {
        case 1:
            if(base[2]){ base[2] = false; point++;}
            if(base[1]){ base[2] = true; base[1] = false;}
            if(base[0]){ base[1] = true; base[0] = false;}
            base[0] = true; break;
        case 2:
            point += base[0] + base[1] + base[2] + 1;
            memset(base, false, sizeof(base)); break;
        case 3:
            out++; break;
    }
}

int main(void) {
    int n; cin >> n;
    for(int r = 0; r < n; r++) {
        point = out = 0; memset(base, false, sizeof(base));
        while(out < 3) {
            string input; cin >> input;
            if(input == "HIT")          exec(1);
            else if(input == "HOMERUN") exec(2);
            else                        exec(3);
        }
        cout << point << endl;
    }
    return(0);
}

Measured memory_bytes: 1212
words = lambda t : list(map(t, input().split()))

n,u,v = words(int)
u -= 1
v -= 1

edges = [[] for i in range(n)]
for i in range(n-1):
    f,t = words(int)
    edges[f-1].append(t-1)
    edges[t-1].append(f-1)

from queue import Queue
def bfs1(edges,stt):
    dist = [-1] * n
    q = Queue()
    q.put(stt)
    dist[stt] = 0
    #print(q)
    while not q.empty():
        v = q.get()
        #print(v)
        for c in edges[v]:
            #print("es", c)
            if dist[c] == -1:
                dist[c] = dist[v]+1
                q.put(c)
    return dist

dist_v = bfs1(edges, v)
dist_u = bfs1(edges, u)
#print(u,v)
#print(edges)
#print(dist_v)
#print(dist_u)

ans = 0
for i in range(n):
    if dist_v[i] > dist_u[i]:
        ans = max(ans,dist_v[i])

print(max(ans-1,0))


Measured memory_bytes: 75548
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int a, b; cin >> a >> b;
	if( 1 <= a && a <= 9 && 1 <= b && b <= 9 ) cout << a*b << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main ()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int x=b-a;
    int y=c-b;
    if(x==y)
    printf("YES\n");

    else
        printf("NO\n");
        return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int N;
    string stringN;
    cin >> stringN;
    // stringN = (string) N;
    if(stringN[0] == '7' || stringN[1] == '7' || stringN[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
int main()
{
    int a,b,c;std::cin >>a >> b>>c;
    std::cout << std::min({a,b,c})<<" "<<(a+b+c)-std::min({a,b,c})-std::max({a,b,c})<<" "<<std::max({a,b,c})<<std::endl;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n;
vector<int> adj[maxn + 5];

int dfs(int x, int f = -1)
{
	int ret = 0;
	for (auto y : adj[x]) if (y != f)
	{
		ret ^= dfs(y, x) + 1;
	}
	return ret;
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n - 1)
	{
		int u, v;
		scanf("%d%d", &u, &v), --u, --v;
		adj[u].pb(v), adj[v].pb(u);
	}
	puts(dfs(0) ? "Alice" : "Bob");
	return 0;
}


Measured memory_bytes: 10368
#include<stdio.h>
int main(void)
{int n,m,x,i,a[100],s,b;
scanf("%d%d%d",&n,&m,&x);

 for(i=0;i<m;i++)
 scanf("%d",&a[i]);
 s=0;
 for(i=0;i<m;i++)
 if(a[i]<x) s=s+1;
 b=m-s;
if(s>b) s=b;
printf("%d",s);
return 0;
}


Measured memory_bytes: 128
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int i, j;
	cin >> i >> j;
	cout << i - j + 1 << endl;
	return 0;
}


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

int main() {
    int A , B , C , D , E , F;
    cin >> A >> B >> C >> D;
    E = A + B;
    F = C + D;
    if (E > F) {
        cout << "Left" << endl;
    }
    else if (E < F) {
        cout << "Right" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
import Data.List

main = do
  n <- readLn :: IO Int
  as <- getLine >>= return . reverse . sort . map read . words :: IO [Int]

  let
    alice = sum [as !! i | i <- [0..n-1], even i]
    bob = sum [as !! i | i <- [0..n-1], odd i]
    
  print $ alice - bob


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

//OUTN
void OUTN() {}
template<class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

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

  VAR(string, s);

  string rear = "";
  i64 res = 0;
  for (int i = 0; i < s.length(); ++i) {

    if (!i) {
      rear.push_back(s[i]);
      ++res;
    }

    else {
      if (s[i] == s[i-1]) {
        string t = "";
        for (int j = i; j < s.length(); ++j) {
          t += s[j];
          if (t != rear) {
            rear.clear();
            rear = t;
            ++res;
            i += t.length() - 1;
            break;
          }
        }
      }

      else if (s[i] != s[i-1]) {
        rear.clear();
        rear.push_back(s[i]);
        ++res;
      }
    }

  }

  OUTL(res);

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main(){
    string S;
    int N;
    static int dp[33][101010];//i(要素2)番目のマスから2^p(要素1)回移動したマス
    static int ans[101010];
    cin >> S;

    N=S.length();
    rep(i, 0, N) {
        if (S[i] == 'R') dp[0][i] = i + 1;
        else dp[0][i] = i - 1;
    }

    rep(p, 0, 32) rep(i, 0, N) dp[p + 1][i] = dp[p][dp[p][i]];

    rep(i, 0, N) ans[dp[32][i]]++;
    rep(i, 0, N) {
        if (i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");

    // int n=0;
    // vector<int> vec;
    // vector<int> vec1;
    // vector<int> vec2;


    // while(S[n] != '\0'){
    //     if(S[n]=='R'){
    //         vec.emplace_back(1);
    //     }else if(S[n]=='L'){
    //         vec.emplace_back(-1);
    //     }

    //     vec1.emplace_back(1);
    //     vec2.emplace_back(0);

    //     n++;
    // }

    // for(int i=0;i<100000;i++){
    //     for(int j=0;j<vec.size();j++){
    //         vec2[j+vec[j]]=vec1[j];
    //         j++;
    //     }
    //     vec1 = vec2;
    // }

    // for(auto it =vec1.begin();it != vec1.end();++it ){
    //     cout << *it << "\t"<< flush;
    // }
    // cout << endl;

    return 0;
}


Measured memory_bytes: 14080
s = input()

w1 = s[0]
w2 = s[1]
w3 = s[2]

if w2 == 'R':
	if w1 != w3:
		print(2)
	elif w1 == 'S':
		print(1)
	else:
		print(3)
else:
	if w1 != w3:
		print(1)
	elif w1 == 'S':
		print(0)
	else:
		print(1)

Measured memory_bytes: 9048
#PyPy遅え
import sys
sys.setrecursionlimit(400000000)
inf=1000000000000000000
n,m=map(int,input().split())
x=[inf]*n
#まだ訪問してなければTrue
check=[True]*n
#どこと関係があるかを記録する(maybe right)
lrd=[[] for i in range(n)]
for i in range(m):
    l,r,d=map(int,input().split())
    l-=1
    r-=1
    lrd[l].append((r,d))
    lrd[r].append((l,-d))
#wrong thought
#どっちも決まってない場合の処理
#決まってるとこからやれば良い
#ソートして順番に決めておく

#記録した関係から辿っていく
#まず初めのやつ決定
#非連結な場合を忘れていた


def bfs(z):
    #globalくらいちゃんとしろ
    global lrd,check,x
    for i in range(len(lrd[z])):
        k=lrd[z][i]
        if check[k[0]]:
            x[k[0]]=x[z]+k[1]
            check[k[0]]=False
            bfs(k[0])
        else:
            if x[k[0]]!=x[z]+k[1]:
                print("No")
                sys.exit()
st=0
while any(check):
    for i in range(st,n):
        if len(lrd[i])!=0 and check[i]:
            st=i
            break
        else:
            check[i]=False
    else:
        break
    x[st]=0
    check[st]=False
    bfs(st)
print("Yes")

Measured memory_bytes: 129008
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A>>B;
    ll ans = 1;
    Rreps(i,1e+5 + 1, 1){
        if(A%i == 0 && B%i == 0){
            ans *= i;
            A /= i;
            B /= i;
        }
    }
    cout<<ans*A*B<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
using namespace std;
int main(){
	char a[6];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
	if(a[0]==a[5] && a[1]==a[4] && a[2]==a[3])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if(b > a+W) {
        cout << b-(a+W) << endl;
    } else if(b+W < a) {
        cout << a-(b+W) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

typedef std::vector<int> vi;

bool isGone(int a, std::vector<int> gone){
  auto itr = std::find(gone.begin(), gone.end(), a);
  if(itr != gone.end()) return true;
  else return false;
}

int count(int depth, int pos, vi gone, std::map<int, vi> neighborNode){
  int root = 0;
  if(gone.size() == depth){
    for(auto x : neighborNode[pos]){
      if(isGone(x, gone)) continue;
      else return 1;
    }//auto x
    return 0;
  }else{
    for(auto x : neighborNode[pos]){
      int temp = pos;
      if(isGone(x, gone)) continue;
      else{
        pos = x;
        gone.push_back(x);
        root += count(depth, pos, gone, neighborNode);
        gone.pop_back();
        pos = temp;
      }
    }
  }//depth
  return root;
}

int main(){
  int N, M;
  std::cin >> N >> M;
  std::map<int, vi> neighborNode;
  for(int i = 0; i < M; i++){
    int tempA, tempB;
    std::cin >> tempA >> tempB;
    neighborNode[tempA].push_back(tempB);
    neighborNode[tempB].push_back(tempA);
  }
  vi gone;
  int pos = 1;
  gone.push_back(1);
  int pattern = count(N - 1, 1, gone, neighborNode);
  std::cout << pattern << std::endl;
}

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

int main(void){

    int A, B;

    scanf("%d%d", &A, &B);

    int max = A + B;

    if(max < A - B){
        max = A - B;
    }

    if(max < A * B){
        max = A * B;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<math.h>
int maxpri(int);
int minpri(int);

int pri[50000];

int main(){
  int n;
  while(scanf("%d",&n)!=EOF){
    printf("%d %d\n",maxpri(n),minpri(n));
  }
  return 0;
}


int maxpri(int n){
  int c=0,i,j,h;
  for(i=2;i<n;i++){
    h=0;
  if(pri[i]==3)continue;
  if(pri[i]==1){c=i;continue;}

    for(j=2;j<=sqrt(i);j++){
      if(i%j==0){pri[i]=3;  h=1;break;
      }
    } if(h==0){pri[i]=1;c=i;}
  }
  return c;
}

int minpri(int n){
  int c=0,i,j,h;
  for(i=n+1;;i++){
    h=0;
    if(pri[i]==3)continue;
    if(pri[i]==1)return i;
    for(j=2;j<=sqrt(i);j++){
      if(i%j==0){pri[i]=3; h=1;break;
      }
     
    } if(h==0)return i;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define INF 99999999
using namespace std;
int main() {
    int mod = 1e9+7;
    long long n, k;
    long long ans = 0;
    cin >> n >> k;
    for (int i = k; i <= n+1; ++i) {
        ans += (n-i+2)*i-(i-1);
        //cout << ans << endl;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
   
    int N;
    cin >> N;
    map<string,int>mp{};
    
    char b;
    string w_i;
    cin >> w_i;
    mp[w_i] = 1;
    b = w_i[w_i.size()-1];
    
    for(int i=1;i<N;i++){
        cin >> w_i;
        if(w_i[0] == b && mp.count(w_i) == 0){
            mp[w_i] = 1;
            b = w_i[w_i.size()-1];
        }
        else{
            cout << "No" <<endl;
            return 0;
        }
    }
    
    cout << "Yes" <<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}


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

    string ans;

    if(a.size()>b.size())ans="GREATER";
    else if(a.size()<b.size())ans="LESS";
    else {
        if(a>b)ans="GREATER";
        else if(a<b)ans="LESS";
        else ans="EQUAL";
    }

    cout<<ans<<endl;
}




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

#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,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
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

ll dsum(ll x, ll y) {
  ll ret = 0;
  if (y == 1) return x;
  while (x > 0) {
	ret += x % y;
	x /= y;
  }
  return ret;
}

int main(void) {
  cin >> n >> m;
  ans = inf;
  if (n < m) {
	cout << "-1" << endl;
	return 0;
  }
  if (n == m) {
	cout << n + 1 << endl;
	return 0;
  }
  FOR(i, 2, sqrt(n)) {
	if (dsum(n, i) == m) ans = min(ans, i);
  }
  FOR(i, 1, sqrt(n) + 1) {
	tmp = (n - m) / i + 1;
	if (dsum(n, tmp) == m) ans = min(ans, tmp);
  }

  if (ans == inf) {
	cout << "-1" << endl;
  }
  else {
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <cstring>

using namespace std;

int main() {

    int n;
    cin >> n;
    int h[n], dp[n];

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

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;


    return 0;
}

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

int main(){
	int n,k,j=0;
  	cin >> n >> k;
  	vector<int> s(n);
  	for (int i=0;i<n;i++){
    	cin >> s.at(i);
    }
  	sort (s.begin(),s.end());
  	reverse (s.begin(),s.end());
  	for (int i=0;i<k;i++){
    	j += s.at(i);
    }
  	cout << j << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	static long [] [] k;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int w = Integer.parseInt(st.nextToken());
		int [] wt = new int [n];
		int [] vl = new int [n];
		for(int i=0;i<n;i++)
		{
			st = new StringTokenizer(br.readLine());
			wt[i]=Integer.parseInt(st.nextToken());
			vl[i]=Integer.parseInt(st.nextToken());
		}
		k=new long[n][w];
		for(int i=0;i<n;i++)
		{
			Arrays.fill(k[i],-1);
		}
		System.out.println(knapsack(w,n,vl,wt));
	}
	public static long knapsack(int w , int n , int [] vl, int [] wt )
	{
		if(w==0||n==0)
			return 0;
		if(wt[n-1]>w)
		{
			if(k[n-1][w-1]==-1)
				k[n-1][w-1]=knapsack(w, n-1, vl, wt);
			return k[n-1][w-1];
			
		}
		else
		{
			if(k[n-1][w-1]==-1)
				k[n-1][w-1]=Math.max(vl[n-1]+knapsack(w-wt[n-1], n-1, vl, wt), knapsack(w, n-1, vl, wt));
			return k[n-1][w-1];			
		}
	}
}


Measured memory_bytes: 126868
import fractions
A,B,C,D = map(int,input().split())
c = B//C - (A-1)//C
d = B//D - (A-1)//D
E = (C*D)//fractions.gcd(C,D)
e = B//E - (A-1)//E
answer = B-A+1-(c+d-e)
print(answer)
            



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

void fnInput(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';
}

int fnBitFullSch(const vector<int>& cnrvnNum)
{
  for (int n = 0; n < (1 << 3); n++)
  {
    int nSum = cnrvnNum[0];
    for (int i = 0; i < 3; i++)
      if (n & (1 << i))  nSum += cnrvnNum[i + 1];
      else               nSum -= cnrvnNum[i + 1];

    if (nSum == 7)  return n;
  }
  return 7;
}
    
void fnResult(const vector<int>& cnrvnNum, int nRslt)
{
  cout << cnrvnNum[0];
  for (int i = 0; i < 3; i++)
  {
    if (nRslt & (1 << i))  cout << "+";
    else                   cout << "-";

    cout << cnrvnNum[i + 1];
  }
  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  
  fnInput(vnNum);
  int nRslt = fnBitFullSch(vnNum);
  fnResult(vnNum, nRslt);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define RI register int
#define CI const int&
using namespace std;
const int N=1000005;
int n,len[N],c[26]; string s[N]; long long ans;
class Trie
{
	private:
		struct Trie_Node
		{
			int ch[26],ct[26];
		}node[N]; int rt,tot=1;
		#define next(x,y) node[x].ch[y]
		#define C(x,y) node[x].ct[y]
	public:
		inline void reroot(void)
		{
			rt=1; for (RI i=0;i<26;++i) if (c[i]) ++C(rt,i);
		}
		inline void insert(const char& ch)
		{
			if (next(rt,ch-'a')) rt=next(rt,ch-'a'); else rt=next(rt,ch-'a')=++tot;
			for (RI i=0;i<26;++i) if (c[i]) ++C(rt,i);
		}
		inline int query(const string& s,CI len)
		{
			rt=1; for (RI i=len-1;i;--i)
			if (next(rt,s[i]-'a')) rt=next(rt,s[i]-'a'); else return 0;
			return C(rt,s[0]-'a');
		}
		#undef next
		#undef C
}T;
int main()
{
	RI i,j; ios::sync_with_stdio(0); for (cin>>n,i=1;i<=n;++i)
	{
		for (cin>>s[i],len[i]=s[i].size(),j=0;j<len[i];++j) ++c[s[i][j]-'a'];
		for (T.reroot(),j=len[i]-1;~j;--j) --c[s[i][j]-'a'],T.insert(s[i][j]);
	}
	for (i=1;i<=n;++i) ans+=T.query(s[i],len[i]); return cout<<ans-n,0;
}

Measured memory_bytes: 238680
//Pollok's conjecture
#include<bits/stdc++.h>
using namespace std;

#define INF 1000000
typedef long long ll;
vector<ll> v1;
vector<ll> v2;
ll num1[1000001], num2[1000001];

int main(){
  ll tmp;
  for(ll i=1; (tmp=(i*(i+1)*(i+2)/6))<1000000; i++){
      v1.push_back(tmp);
      if(tmp%2==1)
	v2.push_back(tmp);
    }

  for(ll i=0; i<=1000000; i++){num1[i]=i; num2[i]=i;}
  for(ll i=1; i<v1.size(); i++){
    for(ll j=0; j<=1000000; j++){
      if(v1[i]<=j)num1[j]=min(num1[j], num1[j-v1[i]]+1);
    }
  }
  for(ll i=1; i<v2.size(); i++){
    for(ll j=0; j<=1000000; j++){
      if(v2[i]<=j)num2[j]=min(num2[j], num2[j-v2[i]]+1);
    }
  }
  ll n;
  while(cin>>n, !(n==0)){
    cout<<num1[n]<<" "<<num2[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 16840
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N,a=0;
	string A,B,C;
	vector<ll>ANS;
	cin>>N>>A>>B>>C;
	rep(i,N){
		if(A[i]==B[i]&&A[i]!=C[i])a++;
		if(A[i]==C[i]&&A[i]!=B[i])a++;
		if(B[i]==C[i]&&B[i]!=A[i])a++;
		if(A[i]!=B[i]&&B[i]!=C[i]&&A[i]!=C[i])a+=2;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256