akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

vint v;
vvll e;

void dfs(ll now, int b){
    if((v[now]&b)>0){
        return;
    }
    v[now] += b;
    rep(i, e[now].size()){
        dfs(e[now][i], (b<4?b*2:1));
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    ll n,m;cin>>n>>m;
    e = vector<vll>(n);
    v = vector<int>(n, 0);
    rep(i, m){
        ll vv,u;cin>>u>>vv;
        e[u-1].push_back(vv-1);
    }
    ll s,t;
    cin>>s>>t;
    /*
    dfs(s-1, 1);
    rep(i, n)debug("ddd%d %d\n", i, v[i]);
    if(v[t-1]%2==1){
        cout << 1 << endl;
    }else{
        cout << -1 << endl;
    }*/
    v = vector<int>(n, 0);
    queue<tuple<int, int, int>> q;
    q.push(tuple<int, int, int>(s-1, 1, 0));
    while(!q.empty()){
        tuple<int, int, int> p = q.front();q.pop();
        int now = get<0>(p), b = get<1>(p), cost = get<2>(p);
        if(now == t-1&&b==1){
            cout << cost/3 << endl;
            return 0;
        }
        if((v[now]&b)>0){
            continue;
        }
        v[now] += b;
        rep(i, e[now].size()){
            q.push(tuple<int, int, int>(e[now][i], (b<4?b*2:1), cost+1));
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;
long long min(long long a,long long b){
    if(a>b)return b;
    else return a;

}
map< long long, long long > prime_factor(long long n) {
  map< long long, long long > ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main(){
    long long N;
    cin>>N;
    long long now=1;
    long long ans=0;
    map<long long,long long>ret;
    ret=prime_factor(N);
    //cout<<"hi"<<endl;
    long long flag=ret.size();
    for(auto p:ret){
      auto k=p.second;
      auto m=p.first;
    //  cout<<m<<" "<<k<<endl;
    }

    //cout<<flag<<endl;
    while(flag>0){


    for(auto p:ret){
        //cout<<now<<endl;
        auto k=p.second;
        auto m=p.first;
        if(k>=0)
        {//cout<<k<<"ima"<<endl;

        k-=now;
        ret[m]=k;

        if(k>=0)ans+=1;
        else flag-=1;
      }
       //if(k>=0)cout<<m<< "個数"<<k<<endl;

    }
   //cout<<flag<<" "<<now<<ans<<endl;
    now+=1;


    }
    cout<<ans<<endl;



}


Measured memory_bytes: 3620
import math

A, B, C, D = map(int, input().split())

cd = (C * D) // math.gcd(C, D)

pac, qac = divmod(A, C)
pad, qad = divmod(A, D)
pacd, qacd = divmod(A, cd)

pbc, qbc = divmod(B, C)
pbd, qbd = divmod(B, D)
pbcd, qbcd = divmod(B, cd)

pac = pac - 1 if qac == 0 else pac
pad = pad - 1 if qad != 0 else pad
pacd = pacd - 1 if qacd != 0 else pacd

ans = (pbc + pbd - pbcd) - (pac + pad - pacd)
print(B - A - ans + 1)



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

#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() pushback()
#define elif else if
#define all(x) x.begin(),x.end()

int shizuku(int,int);

int main(){
    int N,X,m,p,r,H=0,W=0,count=0,count2=0;
    double d,D;
    int C='A'-'a';
    char op;
    str S,T;
    while(true){
        cin>>m>>p>>r;
        if(m>0){
            if(p>=0){//どちらも出席
                if(m+p>=80)cout<<'A'<<endl;
                elif(m+p>=65)cout<<'B'<<endl;
                elif(m+p>=50)cout<<'C'<<endl;
                elif(m+p>=30){
                    if(r>=50)cout<<'C'<<endl;
                    else cout<<'D'<<endl;
                }
                elif(m+p<30)cout<<'F'<<endl;
            }
            elif(p==-1){//期末欠席
                cout<<'F'<<endl;
            }
        }
        elif(m==0){//中間0点
            if(p==50)cout<<'C'<<endl;
            elif(p>=30){//中間からの再試
                if(r>=50)cout<<'C'<<endl;
                else cout<<'D'<<endl;
            }
            elif(p<30)cout<<'F'<<endl;//死
        }
        elif(m==-1){//中間欠席
            if(p!=-1)cout<<'F'<<endl;
            elif(p==-1)break;
        }
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
  fast;
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  
  int ans = 0;
  for(int i=0; i<n; i++){
    if(a[i] == b[i]){
      if(a[i] == c[i]){
        ans += 0;
      } else {
        ans += 1;
      }
    } else {
      if(a[i] == c[i]){
        ans += 1;
      } else {
        if(b[i] == c[i]){
          ans += 1;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 2019;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    map<ll,ll> mp;
    mp[0] = 1;
    ll now = 0, ten = 1;
    rep(i, 0, s.size()){
        now += (s[i] - '0') * ten;
        now %= mod;
        ten *= 10;
        ten %= mod;
        mp[now]++;
    }
    ll ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3808
n = int(input())
s = input()

cnt = s[1:].count('E')
low = cnt
for i in range(n-1):
  if s[i] == 'W':
    cnt += 1
  if s[i+1] == 'E':
    cnt -= 1
  if cnt < low:
    low = cnt
print(low)

Measured memory_bytes: 3700
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in=new Scanner(System.in);
        List<Integer> F=new ArrayList<>();
        int n=in.nextInt();
        double av=0;
        for(int i=0;i<n;i++){
            int f=Integer.parseInt(in.next());
            F.add(f);
            av+=f;
        }

        av/=n;
        
        double d=Math.abs(F.get(0)-av);
        int res=0;
        for(int i=1;i<n;i++){
            double td=Math.abs(F.get(i)-av);
            if(td<d){
                d=td;
                res=i;
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
long long int fact[200005];
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)
		return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	if (n < 0 || r < 0 || n < r)
		return 0;
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	n++;
	long long int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int b[100005];
	for (i = 0; i < n; i++)
		b[i] = 0;
	for (i = 0; i < n; i++)
		b[a[i]]++;
	for (i = 0; i < n; i++)
		if (b[i] > 1)
			break;
	long long int l, r;
	l = 0;
	while (a[l] != i)
		l++;
	r = n - 1;
	while (a[r] != i)
		r--;
	long long int p = 1000000007;
	fact[0] = 1;
	for (i = 1; i < 200005; i++)
		fact[i] = fact[i - 1] * i % p;
	long long int ans;
	long long int k;
	for (k = 1; k <= n; k++)
	{
		ans = comb(n - 2, k, p);
		ans = (ans + comb(n - 2, k - 2, p)) % p;
		ans = (ans + 2 * comb(n - 2, k - 1, p) % p) % p;
		ans = (ans - comb(l + n - r - 1, k - 1, p) + p) % p;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
const int N = 55;
 
int n, par[N], e[N][N], te[N][N], deg[N], tdeg[N];
vector <int> gb[N];
 
void dfs(int u) {
	for (int v : gb[u]) if (v != par[u]) {
		par[v] = u;
		dfs(v);
	}
}
 
void change(vector <int> &available, int u) {
	available.erase(find(available.begin(), available.end(), u));
	for (auto v : gb[u]) if (v != par[u]) {
		available.push_back(v);
	}
}
 
int calc(int root) {
	par[root] = 0;
	dfs(root);
 
	for (int i = 1; i <= n; ++i) {
		tdeg[i] = deg[i];
		for (int j = 1; j <= n; ++j) {
			te[i][j] = e[i][j];
		}
	}
 
	vector <int> available(1, root);
	change(available, root);
 
	int ret = 0;
	while(!available.empty()) {
		bool found = false;
		for (auto u : available) {
			if (te[u][par[u]]) {
				found = true;
				change(available, u);
				break;
			}
			if (tdeg[u] == 1) { // leaf
				found = true;
				// cut
				for (int i = 1; i <= n; ++i) if (te[i][u]) {
					te[i][u] = te[u][i] = false;
					--tdeg[i]; --tdeg[u];
				}
				// concatenate
				te[u][par[u]] = te[par[u]][u] = true;
				++tdeg[u]; ++tdeg[par[u]];
				++ret;
 
				change(available, u);
				break;
			}
		}
		if (!found) return 1e9;
	}
 
	return ret;
}
 
void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		deg[i] = 0;
		gb[i].clear();
		for (int j = 1; j <= n; ++j) {
			e[i][j] = 0;
		}
	}
 
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		e[u][v] = e[v][u] = true;
		++deg[u];
		++deg[v];
	}
 
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		gb[u].push_back(v);
		gb[v].push_back(u);
	}
 
	int res = 1e9;
	for (int i = 1; i <= n; ++i) {
		int cur = calc(i);
		res = min(res, cur);
	}
 
	for (int i = 1; i <= n; ++i) if (deg[i] == 1) {
		int adj_i = 0;
		for (int j = 1; j <= n; ++j) if (e[i][j]) {
			adj_i = j;
			e[i][j] = e[j][i] = false;
			--deg[i]; --deg[j];
		}
		for (int j = 1; j <= n; ++j) if (i != j) {
			e[i][j] = e[j][i] = true;
			++deg[i]; ++deg[j];
			res = min(res, calc(i) + 1);
			e[i][j] = e[j][i] = false;
			--deg[i]; --deg[j];
		}
		e[i][adj_i] = e[adj_i][i] = true;
		++deg[i]; ++deg[adj_i];
	}
 
	cout << (res == 1e9 ? -1 : res) << endl;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 
	int tt; cin >> tt;
	while(tt--) {
		solve();
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 7368792

int isPrime[MAX];

int main(void) {
  int m, n, i, j, count;
  while (1) {
    scanf("%d %d", &m, &n);
    if (m == 0 && n == 0) return 0;
    for (i = 0; i < MAX; i++)
      isPrime[i] = 1;

    count = 0;
    for (i = m; ; i++) {
      if (isPrime[i]) {
	if (count == n) break;
	count++;
	for (j = 1; i * j < MAX; j++) {
	  isPrime[i * j] = 0;
	}
      }
    }
    printf("%d\n", i);
  }
}

Measured memory_bytes: 29384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int X[N];
    int y[N];

    rep(i,N) {
        cin >> X[i];
        y[i]=X[i];
    }
    sort(y,y+N);
    int l=y[N/2-1];
    int r=y[N/2];

    rep(i,N){
        if(l>=X[i]) cout << r << endl;
        else cout << l << endl;
    }



}


Measured memory_bytes: 3712
#include<cstdio>
#include<algorithm>
const int inf = 1e8+7;
int a[300005];
int map[300005];
struct SegmentT{
    int l,r;
    int d;
    SegmentT(){
        d = -inf;
    }
};
SegmentT t[1200005];

int getLower(int u,int n){
    int L = 1, R = n;
    int res = -1;
    while(L<=R){
        int M = (L+R)/2;
        if(map[M]>=u){
            res = M;
            R = M-1;
        }
        else L = M+1;
    }
    return res;
}

int getUpper(int u,int n){
    int L = 1, R = n;
    int res = -1;
    while(L<=R){
        int M = (L+R)/2;
        if(map[M]<=u){
            res = M;
            L = M+1;
        }
        else R = M-1;
    }
    return res;
}

int preWork(int n){
    std::sort(map+1,map+1+n);
    int p = 1, size = 0;
    while(p<=n){
        int np = p;
        while(np+1<=n && map[np+1]==map[p]) np++;
        map[++size] = map[p];
        p = np+1;
    }
    return size;
}

int max(int a,int b){ return a>b?a:b; }

SegmentT merge(SegmentT& u,SegmentT& v){
    SegmentT res;
    res.l = u.l, res.r = v.r;
    res.d = max(u.d,v.d);
    return res;
}

void build(int p,int l,int r){
    t[p].l = l, t[p].r = r;
    if(l==r) t[p].d = -inf;
    else{
        int m = (l+r)/2;
        build(2*p,l,m);
        build(2*p+1,m+1,r);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

void segChange(int p,int x,int v){
    if(t[p].l==t[p].r){
        if(t[p].d<v) t[p].d = v;
    }
    else{
        int m = (t[p].l+t[p].r)/2;
        if(x<=m) segChange(2*p,x,v);
        else segChange(2*p+1,x,v);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

SegmentT segAsk(int p,int l,int r){
    if(l<=t[p].l && r>=t[p].r) return t[p];
    else{
        int m = (t[p].l+t[p].r)/2;
        SegmentT u,v;
        if(l<=m) u = segAsk(2*p,l,r);
        if(r>=m+1) v = segAsk(2*p+1,l,r);
        return merge(u,v);
    }
}

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        map[i] = a[i];
    }
    int size = preWork(n);
    build(1,1,size);
    int ans = 1;
    for(int i = 1; i <= n; i++){
        int l = getLower(a[i]-k,size), r = getUpper(a[i]+k,size);
        int offer = 1;
        if(l!=-1 && r!=-1){
            SegmentT res = segAsk(1,l,r);
            if(offer<res.d+1) offer = res.d+1;
        }
        int u = getLower(a[i],size);
        segChange(1,u,offer);
        if(ans<offer) ans = offer;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 18100
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def kirisute(n):
    p=(-1+math.sqrt(1+8*n))/2
    q=math.floor(p)
    return q

N = int(input())

div_arr = factorization(N)
if div_arr[0][0] == 1:
    div_arr.pop(0)

cnt = 0

for a in div_arr:
    cnt += kirisute(a[1])

print(cnt)




Measured memory_bytes: 63512
num = gets.chomp.to_i
str = gets.chomp
 
data = {
  "R" => 0,
  "B" => 0,
}
str.each_char do |c|
  if c == "R"
    data["R"] += 1
  else
    data["B"] += 1
  end
end
puts data["R"] > data["B"] ? 'Yes' : 'No'


Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	vector<ll> v(n);
	fore(i, 0, n)
	{
		cin >> v[i];
		mp[v[i]]++;
	}

	ll res = 0;
	for (auto x : mp)
		res += x.second * (x.second - 1) / 2;

	for (int x : v)
	{
		ll res2 = res - mp[x] * (mp[x] - 1) / 2;
		res2 += (mp[x] - 1) * (mp[x] - 2) / 2;
		cout << res2 << '\n';
	}
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}
}

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


int main (){   
    int N;
  	ll M;
 	cin >> N >> M;
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    sort(A.begin(), A.end());
    ll pass = 0, fail = 2 * 1e5 + 10;
    while (fail - pass > 1) {
      ll X = (pass + fail) / 2;
      ll cnt = 0;
      int j = N - 1;
      for (int i = 0; i < N; i++) {
        while (j >= 0 && A[i] + A[j] >= X) --j;
        cnt += N - j - 1;
      }
      if (cnt >= M) {
        pass = X;
      } else {
        fail = X;
      }
    }
    ll res = 0;
    ll sum = 0, rem = M;
  int j = N - 1;
    for (int i = 0; i < N; i++) {
      
      while (j >= 0 && A[i] + A[j] > pass) {
        sum += A[j];
        --j;
      }
      ll c = N - j - 1;
      rem -= c;
      res += sum + c * A[i];
    }
    res += pass * rem;
    cout << res << endl;
  
 
}





Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

string s;
int ind=0;

//0:m, 1:e, 2:w, 3:cat;
int dfs(){
  //cout<<s[ind]<<endl;
  if(ind==s.size()) return -1;
  if(s[ind]=='e') return 1;
  if(s[ind]=='w') return 2;
  if(s[ind]=='m'){
    //cout<<"create C"<<endl;
    char c[5];
    c[0]=0;
    REP(i,1,5){
      ind++;
      c[i] = dfs();
      if(i==2 && (c[0]==0&&c[1]==1&&c[2]==2)){
        return 3;
      }
      if(i==3 && ((c[0]==0&&c[1]==1&&c[2]==3&&c[3]==2) || (c[0]==0&&c[1]==3&&c[2]==1&&c[3]==2))){
        return 3;
      }
      if(i==4 && (c[0]==0&&c[1]==3&&c[2]==1&&c[3]==3&&c[4]==2)){
        return 3;
      }
    }
  }

  return -1;
}

int main() {
  cin>>s;
  if(dfs() == 3 && ind==s.size()-1) cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;
  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 505



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

    string s;cin>>s;
    cout<<s.substr(0,3)<<endl;

    return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int w = tx - sx;
    int h = ty - sy;

    rep(i,w) cout << 'R';
    rep(i,h) cout << 'U';
    rep(i,w) cout << 'L';
    rep(i,h) cout << 'D';

    w++; h++;
    cout << 'D';
    rep(i,w) cout << 'R';
    rep(i,h) cout << 'U';
    cout << 'L';
    
    cout << 'U';
    rep(i,w) cout << 'L';
    rep(i,h) cout << 'D';
    cout << 'R' << endl;

}


Measured memory_bytes: 256
def eratos():
    primes = []
    for i in range(2, 10**4):
        flag = True
        for p in primes:
            if i%p == 0:
                flag = False
        if flag:
            primes.append(i)
    return primes

def check(n, primes):
    for p in primes:
        if n <= p:
            return True
        if n%p == 0:
            return False
    return True

N = int(input())
primes = eratos()
ans = 0
for _ in range(N):
    n = int(input())
    if check(n, primes):
        ans += 1
print(ans)


Measured memory_bytes: 5624
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
X,K,D=map(int,input().split())
num=abs(X)//D
subX=0
if X<0:
    X=X+min(K,num)*D
    subX=X+D
else:
    X=X-min(K,num)*D
    subX=X-D
K=max(K-num,0)
#print(X,subX,K)
if K%2==0:
    print(abs(X))
else:
    print(abs(subX))




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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

struct edge {
    ll to;
    ll cost;
};

typedef pair<ll, ll> P;  // first: 最短距離, second: 頂点番号

ll V, d[MAX_V];
vector<edge> G[MAX_V]; // 隣接リスト表現

void dijkstra(ll s) {
    fill(d, d + V, INF_LL);
    d[s] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  // 頂点vから出る辺eを走査
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    REP(i, V-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    ll q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);

    REP(i, q) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        cout << d[x] + d[y] << endl;
    }


}
 

Measured memory_bytes: 12656
#include <bits/stdc++.h>
#define dmin(i, j) ((i) < (j) ? (i) : (j))
#define dmax(i, j) ((i) > (j) ? (i) : (j))
#define cmin(i, j) ((i) > (j) ? (i) = (j) : (i))
#define dabs(i) ((i) < 0 ? -(i) : (i))
using namespace std;
int n, ST[10000010 << 1], *st = ST + 10000010;
long long ans, sum;
char s[10000010], t[10000010];
int main() {
	cin >> n; scanf("%s%s", s, t); ans = 1e18; int _p = 0, _c = (s[0] != t[0]);
	for(register int i = 0; i < n; ++i) {
    	++st[_p - _c]; sum += _p - _c + n + 2;
    	if(s[i] != s[i + 1]) ++_p;
    	if(t[i] != t[i + 1]) ++_c;
    }
    _p = -n;
	for(register int i = -n - 2; i <= n + 2; ++i) {
		if(~i & 1) cmin(ans, sum);
//        cout << sum << endl;
    	_p += st[i] << 1, sum += _p;
    }
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

struct NonrecursiveSegmentTree
{
    int N;
    std::vector<int> data;
    inline int& at(int i) { return data[i]; }

    inline void _merge(int i) { at(i) = at(i << 1) | at((i << 1) + 1); }
    void initialize(const std::vector<int> &seq) {
        N = seq.size();
        data = seq;
        data.insert(data.end(), seq.begin(), seq.end());
        for (int i = N - 1; i; i--) _merge(i);
    }
    NonrecursiveSegmentTree() = default;
    void update(int pos, const int &x) {
        at(pos + N) = x;
        for (int i = pos + N; i > 1;) i >>= 1, _merge(i);
    }

    // [l, r), 0-indexed
    int get(int l, int r) {
        int retl = 0, retr = 0;
        l += N, r += N;
        while (l < r) {
            if (l & 1) retl = retl | data[l++];
            if (r & 1) retr = data[--r] | retr;
            l >>= 1, r >>= 1;
        }
        return retl | retr;
    }
};


int main()
{
    int N;
    string S;
    cin >> N >> S;
    vector<int> v(N);
    REP(i, N) v[i] = 1 << (S[i] - 'a');
    NonrecursiveSegmentTree segtree;
    segtree.initialize(v);

    int Q;
    cin >> Q;
    while (Q--)
    {
        int q;
        cin >> q;
        if (q == 1) {
            int i;
            char c;
            cin >> i >> c;
            segtree.update(i - 1, 1 << (c - 'a'));
        }
        else {
            int l, r;
            cin >> l >> r;
            int ret = segtree.get(l - 1, r);
            printf("%d\n", __builtin_popcount(ret));
        }
    }
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    ll N,M;
    cin >> N >> M;
    ll sum = 0;
    vector<ll> v;
    REP(i,N) {
        int A;
        cin >> A;
        sum += A;
        v.push_back(A);
    }

    sort(ALL(v));
    reverse(ALL(v));

    REP(i,M) {
        if (((sum+(M*4)-1)/(4*M)) <= v[i]) continue;
        else {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
struct Node{
    ll sum, num, nxt;
};
Node preComp[100005];
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll N,X,M;
    cin>>N>>X>>M;
    vector<ll> v;
    map<ll,ll> ma;
    ll cnt=0,cur=X;
    while(cnt!=N){
        v.pb(cur);
        ma[cur]++;
        cur*=cur;cur%=M;
        cnt++;
        if(ma.count(cur))
            break;
    }
    ll idx=0;
    for(ll i=1;i<cnt;i++){
        if(v[i]==cur)
            idx=i;
        v[i]+=v[i-1];
    }
    ll ans=v[cnt-1];
    ll chg=v[cnt-1];
    if(idx)
        chg-=v[idx-1];
    ll num=cnt-idx;
    ans+=((N-cnt)/num)*chg;
    if((N-cnt)%num){
        ans+=v[((N-cnt)%num)+idx-1];
        if(idx)
            ans-=v[idx-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6736
#include<stdio.h>

int main(void){
        int N,i,j;

        scanf("%d",&N);

        if(N<=10){
           printf("Yes");
           return 0;
        }

        for(i=2; i<10; i++){
           for(j=2; j<10; j++){
                if(i*j == N) {  
                   printf("Yes\n");
                   return 0;
                }
           }
        }
        
        printf("No\n");
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
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); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int mod=1000000007;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vlong a(n);
  vlong memo(n);
  rep(i,n){
    cin>>a[i];
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      memo[0]=0;
    }
    else{
      memo[n-i-1]=(a[i+1]+memo[n-i-2])%mod;
    }
  }
  ll ans=0;
  rep(i,n){
    ans+=(memo[n-i-1]*a[i])%mod;
    ans=ans%mod;
  }
  cout<<ans<<'\n';
  return(0);
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {


            //テンプレート
            //// 整数の入力
            //int a = int.Parse(Console.ReadLine());
            //// スペース区切りの整数の入力
            //string[] input = Console.ReadLine().Split(' ');
            //int b = int.Parse(input[0]);
            //int c = int.Parse(input[1]);
            //// 文字列の入力
            //string s = Console.ReadLine();
            ////出力
            //Console.WriteLine(a + b + c + " " + s);

            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            char[] s_char = s.ToCharArray();

            //k番目の文字
            char target = s.ToCharArray(k-1,1)[0];

            var goal = new List<char>();

            foreach (char c in s_char) {



                //if (c == target)
                //    goal.Add(c);
                //else
                //    goal.Add(target);

                if (c == target)
                    Console.Write(c);
                else
                    Console.Write("*");
            }

            Console.ReadLine();


        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

string s;
int K;
vector<string> d;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> s >> K;
  for(int i = 0 ; i < s.length() ; i++){
    for(int j = 1 ; j <= K ; j++){
      d.push_back(s.substr(i,j));
    }
  }
  sort(all(d));
  d.erase(unique(d.begin(),d.end()),d.end());
  cout << d[K-1] << endl;
  return 0;
}


Measured memory_bytes: 1160
N=int(input())
*A,=map(int,input().split())

if N<=2:
    ans=1
else:
    ans=1
    count=(A[0]<A[1])-(A[0]>A[1])
    i=2
    while i<N:
        if count*((A[i-1]<A[i])-(A[i-1]>A[i]))<0:
            ans+=1
            count=0
        else:
            if count==0:
                count=(A[i-1]<A[i])-(A[i-1]>A[i])
        i+=1

print(ans)

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

int main(void) {
    int  n;
    cin>>n;
    int g[101][101];
    for (int i = 0; i < n;i++) {
        for (int j = 0; j<n;j++) {
            g[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            if(j) cout<<" ";
            cout<<g[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3108
N, A, B = map(int, input().split())
if abs(A - B) % 2 == 0:
  print (abs(A - B) // 2)
else:
  hajiniyoru = min(min(A - 1, B - 1), min(N - A, N - B))
  print(hajiniyoru  + 1 + (abs(A - B) - 1) // 2)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>

using namespace std;

int N;

vector<int> color;

using Graph=vector<vector<int>>;

Graph E,O;

int dfs(int n,int m)
{

  for(auto u:E[n])
  {
    if(u==m) continue;
    
    color[u]=color[n];
    dfs(u,n);
  }
  
  for(auto u:O[n])
  {
    if(u==m) continue;
    
    color[u]=(color[n]+1)%2;
    dfs(u,n);
  }
}
int main()
{
  cin >> N;
  int i,j,k,m;

  E.assign(N,vector<int>());
  O.assign(N,vector<int>());
  for(i=0;i<N-1;i++)
  {
    
    cin >> j >> k >> m;  
    j--;
    k--;

    if(m%2==0)
    {
      E[k].push_back(j);
      E[j].push_back(k);
    }
    else
    {
      O[k].push_back(j);
      O[j].push_back(k);
    }
    
  }
  
  color.assign(N,0);
  color[0]=0;
  dfs(0,-1);
  

  for(i=0;i<N;i++)
  {
    cout << color[i] << endl ;
  }
  
  
  
}

Measured memory_bytes: 13440
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, size = 0;
    vector<int> a;
    vector<P> p;
    vector<long long> ans;
    cin >> n;
    a.assign(n, 0);
    ans.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        p.push_back(P(a[i], i));
    }
    sort(p.begin(), p.end(), greater<P>());
    int tg = n;
    for(int i=0;i<n;i++){
        size++;
        while(i+1 < n && p[i+1].first == p[i].first){
            i++;
            size++;
        }
        tg = min(tg, p[i].second);
        if(i == n-1){
            ans[tg] += (long long)p[i].first * size;
            break;
        }
        ans[tg] += (long long)(p[i].first - p[i+1].first) * size;
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

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

    long long result = 0;
    for (int i = 1; i < N; i++) {
        int r = N - i;
        if (r > 1 && i < r) {
            result ++;
        }
    }
    cout << result << endl;
    

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeApplications #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

-- solve :: [Int] -> _
-- solve [x] = fst $ until ((x'<=).snd) (\(n,v) -> (n+1, fromIntegral @Int @Double . floor . (*rate) $ v)) (0, 100.0)
--   where
--     x' = fromIntegral @Int @Double x
--     rate = 1.01 :: Double

solve :: [Int] -> Int
solve [x] = fst $ until ((toDouble x <=) . snd) (fork (+1) (toDouble . floor . (*1.01))) (0, 100.0)
  where
    fork f g (v,w) = (f v, g w)
    toDouble = fromIntegral @Int @Double

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 3772
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

        #print("->", g)

    queue = deque([1])
    d = [None] * (N + 1)
    d[0] = 0
    d[1] = 0

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)

    if None in d:
        print("No")
    else:
        print("Yes")
        print("\n".join(map(str, d[2:])))


if __name__ == '__main__':
	main()

exit()


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n; cin >> n;
  int x = 1,y = 1;
  for(int i = 0; i < n; i++){
    int t,a; cin >> t >> a;
    int p = max((x+t-1)/t,(y+a-1)/a);
    x = p*t;
    y = p*a;
  }
  cout << x + y << endl;

  return 0;
}


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

using namespace std;

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()

const int N = 3e5 + 5;
int n, m, it[N], ans[N];
ii e[N];
vector<int> seg[N];
vector<ii> line[N];

void upd(int i, int val){
	for(; i <= 3e5; i += i & -i) it[i] += val;
}

int get(int i){
	int ans = 0;
	for(; i; i -= i & -i) ans += it[i];
	return ans;
}

main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) cin >> e[i].fi >> e[i].se;
	for(int i = 1; i <= n; ++i) seg[e[i].fi].pb(e[i].se);
	for(int i = 1; i <= m; ++i){
		ans[i] = n;
	}
	for(int i = 1; i <= m; ++i){
		for(int j = 0; j <= m; j += i){
			line[j+1].pb({min(m, i+j-1), i});
		}
	}
	for(int i=m; i; --i){
		for(auto &v : seg[i]) upd(v, 1);
		for(auto &v : line[i]) ans[v.se] -= get(v.fi);
	}
	for(int i=1; i<=m; ++i) cout<<ans[i]<<'\n';
}

Measured memory_bytes: 36340
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val abcd = sc.next().toCharArray().map { it.toString().toInt() }
    println(problem079c(abcd))
}

fun problem079c(n: List<Int>): String {
    val a = n[0]
    val b = n[1]
    val c = n[2]
    val d = n[3]
    return when {
        a + b + c + d == 7 -> "$a+$b+$c+$d=7"
        a - b + c + d == 7 -> "$a-$b+$c+$d=7"
        a + b - c + d == 7 -> "$a+$b-$c+$d=7"
        a + b + c - d == 7 -> "$a+$b+$c-$d=7"
        a + b - c + d == 7 -> "$a+$b-$c+$d=7"
        a + b - c - d == 7 -> "$a+$b-$c-$d=7"
        a - b - c + d == 7 -> "$a-$b-$c+$d=7"
        a - b + c - d == 7 -> "$a-$b+$c-$d=7"
        a - b - c - d == 7 -> "$a-$b-$c-$d=7"
        else -> ""
    }
}

Measured memory_bytes: 31136
#include<bits/stdc++.h>
 
#define mx 100005
using namespace std;
 
int n, k, t, d, j, l;
long long num1[mx], num2[mx], ans, tmp;
pair<int, int> s[mx];
bool al[mx];
 
int main(){
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) scanf("%d%d", &s[i].second, &s[i].first);
	
	sort(s, s+n, greater<pair<int, int> >());
 
	for(int i = 0; i < n; i++){
		if(!al[s[i].second]){
			al[s[i].second] = true;
			num1[j++] = s[i].first + j*2 - 1;
        	if(j <= k) tmp += num1[j-1];
		}else num2[l++] = s[i].first;
	}
	ans = tmp;
	for(int i = 0; i < k; i++){
		tmp += num2[i] - num1[k-1-i];
		ans = max(ans, tmp);
	}
 
	printf("%lld\n", ans);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
int main() {
  for (ll i=2;i<11111111;i++){ll x=2,p=2*i;
    while(p<11111111){
    if(aaa[p]){x++;p=x*i;continue;}
    else {aaa[p]=true;}x++;p=x*i;
    }
  }
  ll b;
  cin>>b;
  for (ll i=b;i<11111111;i++){if(!aaa[i]){cout<<i<<endl;break;}}
 
 
 
  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, n, m; cin >> N; n = N / 100; m = 100 * n + 10 * n + n;
  cout << (m >= N ? m : 100 * (n + 1) + 10 * (n + 1) + n + 1);}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,now,ans;
char ch;
int main()
{
    cin>>n;
    for(int s=0;s<n;s++)
    {
        cin>>ch;
        if(ch=='I')now++;
        else
        	now--;
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

ll l_max(ll a, ll b){
    return a < b ? b : a;
}

bool is_prime(int x){
    for(int i = 2; i*i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    
    ll ans = 0;
    int score = 0;
    rep(i, n){
        switch (t[i]) {
            case 'r':
                score = p;
                break;
            case 's':
                score = r;
                break;
            case 'p':
                score = s;
                break;
            default:
                break;
        }
        if(i >= k){
            if(t[i-k] == t[i]) {
                score = 0;
                t[i] = 'a';
            }
        }
        ans += score;
    }
    cout << ans << el;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] l = new long[n + 1];
		l[0] = 2;
		l[1] = 1;
		for(int i = 2 ; i <= n ; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}
		System.out.println(l[n]);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, K;
	cin >> N >> K;

	if (K == 1) {
		cout << N * N * N << endl;
	} else if (K % 2) {
		int num = N / K;
		cout << num * num * num << endl;
	} else {
		int num1 = N / K;
		int num2 = (N + K / 2) / K;
		int ret = num1 * num1 * num1;
		ret += num2 * num2 * num2;
		cout << ret << endl;
	}

    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(100001);
    vector<int> dis(n, INF);
    vector<int> mark(n, -1);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue <int> q;
    q.emplace(0);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int v : to[x]){
            if(dis[v]!=INF) continue;
            dis[v]++;
            mark[v]=x;
            q.push(v);
        }
    }  
    cout << "Yes" << endl;
    for(int i = 1; i < n; ++i) {
        int ans = mark[i];
        ans++;
        cout << ans << endl; 
    }  
    return 0;
}

Measured memory_bytes: 10740
#include <stdio.h>

int main()
{
    long long int N, K;
    scanf("%lld%lld", &N, &K);
    long long int A[N];
    for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
    long long int ans = 0;
    long long int ct = 0;
    for (int i = 0; i < N-1; ++i)
    {
        for (int j = i+1; j < N; ++j) if (A[i] > A[j]) ans++;
        for (int j = 0; j < N; ++j) if (A[j] > A[i]) ct++;
    }
    for (int j = 0; j < N; ++j) if (A[j] > A[N-1]) ct++;
    long long int mod = 1000000007;
    ans *= K;
    ans %= mod;
    K *= K-1;
    K /= 2;
    K %= mod;
    ct %= mod;
    ct *= K;
    ct %= mod;
    ans += ct;
    ans %= mod;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
const int maxn=1e5+5;
#define ll long long
int main() {
    int n;
    ll ans=0;
    cin>>n;
    ans+=1000*(n/500);
    n=n%500;
    ans+=5*(n/5);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ull, ull> P; //ペア　タイプでふ
constexpr ll bigNum = 1000000007;

int main(void)
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    //ここから本体
    int n,k = 0;
    cin >>n>>k;
    for (int i = k - n + 1; i < k + n ;i++)
    {
        cout << i << " ";
    }
}

Measured memory_bytes: 256