akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout高速化のおまじない＋桁数指定
	Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }



void solve()
{
	ll n;  cin >> n;
	vector<ll> x(n);  rep(i,0,n-1){ ll x_; cin>>x_; x[i]=x_; }

	ll ans=INF;
	rep(p,1,100){
		ll sum=0;
		rep(i,0,n-1){
			sum+=POW((x[i]-p),2);
		}
		chmin(ans,sum);
	}
	cout << ans << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<set>
#include<math.h>
#include<list>
#include<vector>
#include<map>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    int i, num;
    i = 0;num=0;
    int n;
    cin >> n;
    while(i < n){
        num++;
        i += num;
    }
    cout << num << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MOD = 1000000007;

int main() {
    int N, K;
    std::cin >> N >> K;

    long long ans = 0;
    for (int i = K; i <= N + 1; i++) {
        long long a = 1LL * (i - 1) * i / 2;
        long long b = 1LL * ((N - i + 1) + N) * i / 2;
        ans += b - a + 1;
        ans %= MOD;
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 3596
R,G,B,N= map(int,input().split())

cnt = 0

a = 3000//R


for i in range(0,a+1):
    b = (3000-R*i)//G
    for j in range(0,b + 1):
        if(R*i+G*j)<=N and (N-R*i - G*j )%B==0:

            cnt += 1
            # print(cnt)
        # if(R*i + G*j) < == N:
        #     cnt += (N-R*i + G*j )//B
        # # for k in range(0,c + 1):
        #     # if (R*i + G*j + B * k) == N:
        #     #     cnt += 1


print(cnt)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
int j = 1;
int k = vec.at(0);
int count = 1;
while(N > j){
  if(k <= vec.at(j)){
  count++;
  k = vec.at(j);
  }
j++;
}
cout << count << endl;
}


Measured memory_bytes: 256
n=int(input())
A=input()
B=input()
C=input()

As=list(map(int,A.split(' ')))
Bs=list(map(int,B.split(' ')))
Cs=list(map(int,C.split(' ')))
total=0
for i in range(0,n):
    if As[i]-As[i-1]==1 and i!=0:
        total=total+Cs[As[i]-2]
    total=total+Bs[As[i]-1]
print(total)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,v,p,a[100005],i,j,x,y,ans;
long long k,sum[100005];
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(i=1;i<=n;++i)
		scanf("%d",a+i);
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i)
		sum[i]=sum[i-1]+a[i];
	for(i=1;i<=n;++i)
	{
		j=a[i]+m;
		if(a[n-p+1]>j)
			continue;
		k=1ll*p*m;
		if(i<n-(p-1)+1)
			x=n-(p-1);
		else
			x=n-(p-1)-1;
		k+=1ll*m*min(i-1,x);
		if(i<=x)
			k+=1ll*(x-i)*j-(sum[x]-sum[i]);
		/*for(;x>=1;--x)
			if(x!=i)
				k+=min(j-a[x],m);*/
		if(k>=1ll*m*v)
			++ans;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		
		int sum = a+b;
		int mul = a-b;
		int kake = a*b;
		int[] array = {sum,mul,kake};
		int max = Integer.MIN_VALUE;
		for(int i:array) {
			if(max<i) {
				max = i;
			}
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 25044
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c = readInts()
    # 二つの構成で、合計結局偶数個増えることが分かる
    d = max(a,b,c)*3 - a - b - c
    if d % 2 == 0:
        # 偶数なら、
        print(d//2)
        # 1回で2個
    else:#奇数なら、
        print(d//2 + 2)
        # 条件1, 条件2を結局1回ずつ増やす
if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    vector<vector<int>> g(N);
    rep(i,N){
        rep(j,N){
            char x;
            cin>>x;
            if(x=='1') g[i].push_back(j);            
        }
    }
    int ans = -1;
    bool can = true;
    rep(i,N){
        queue<int> bfs;
        vector<int> d(N,-1);
        bfs.push(i);
        d[i]=1;
        while(!bfs.empty()){
            int t = bfs.front();
            bfs.pop();
            for(auto nx:g[t]){
                if(d[nx]!=-1){
                    if(d[nx]==d[t]) {
                        can = false;
                        break;
                    }
                }
                else {
                    d[nx] = d[t]+1;
                    bfs.push(nx);
                }
            }
        }
        if(can){
            for(auto x:d) chmax(ans,x);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <string > S;
int num['z' - 'a'+1] = {};




int main()
{

	cin >> N;

	S.resize(N);

	REP(i,N){
		cin >> S[i];
	}

	REP(i,S[0].size()){
		num[S[0][i] - 'a']++;
	}

	FOR(i,1,N){
		int num1['z' - 'a'+1] = {};
		REP(j,S[i].size()){
			num1[S[i][j]-'a']++;
		}
		REP(i,'z'-'a'+1){
			if(num[i]==0)
				continue;
			if(num[i] > num1[i])
				num[i] = num1[i];
		}
	}

	int ans =0;
	REP(i,'z'-'a'+1){
		REP(j,num[i]){
			printf("%c",'a'+i);
		}
	}


}


Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
ans = 0
while True:
    ok = True
    for i in range(N):
        if A[i] % 2 != 0:
            ok = False
            break
        A[i] //= 2
    if not ok:
        break
    ans += 1
print(ans)


Measured memory_bytes: 63428
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int N;
string s[2];

bool flag;	// true ; 1line
ll ans = 1;

void solve() {
	cin >> N >> s[0] >> s[1];
	int i = 0;
	if (s[0][i] == s[1][i]) {
		ans *= 3 % MOD;
		flag = true;
	}
	else {
		ans *= 6 % MOD;
		flag = false;
		i++;
	}
	i++;
	
	for (; i < N; i++) {
		if (flag) {
			if (s[0][i] == s[1][i]) {
				ans = ans * 2 % MOD;
				flag = true;
			}
			else {
				ans = ans * 2 % MOD;
				flag = false;
				i++;
			}
		}
		else {
			if (s[0][i] == s[1][i]) {
				ans = ans * 1 % MOD;
				flag = true;
			}
			else {
				ans = ans * 3 % MOD;
				flag = false;
				i++;
			}
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
def irekae(array2):
    return [array2[1],array2[0],array2[2]]
n=int(input())
l=[input().split() for i in range(n)]
for i in range(len(l)):
    l[i].append(i+1)
    l[i][1]=int(l[i][1])
for i in range(len(l)):
    l[i]=irekae(l[i])
l.sort(reverse=True)
for i in range(len(l)):
    l[i]=irekae(l[i])
lx=sorted(l,key=lambda x: x[0])
for i in range(len(lx)):
    print(lx[i][2])

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

int a[200005], b[200005];
int n, ans;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%d", a+i);
	for (int i = 0;i < n;i++) scanf("%d", b+i);
	for (int v = (1<<28);v;v>>=1)
	{
		for (int i = 0;i < n;i++) a[i] &= (v*2-1);
		for (int i = 0;i < n;i++) b[i] &= (v*2-1);
		sort(a, a+n); sort(b, b+n);
		int t = 0;
		for (int i = n-1, j = 0, k = 0, l = 0;i >= 0;i--)
		{
			while (j < n && a[i]+b[j] < v) j++;
			while (k < n && a[i]+b[k] < 2*v) k++;
			while (l < n && a[i]+b[l] < 3*v) l++;
			t += k-j+n-l;
			t &= 1;
		}
		if (t) ans |= v;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k = ril()
ls = ril()
acc = [0]
for x in ls:
    acc.append((acc[-1] + x - 1) % k)
counter = collections.Counter(acc[:k])
res = 0
for i in range(n + 1):
    res += counter[acc[i]] - 1
    counter[acc[i]] -= 1
    if i + k < n + 1:
        counter[acc[i + k]] += 1
print(res)

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

ll gcd(ll p, ll q){ 
    while(q != 0){
        ll r=p%q;
        p=q;
        q=r;
    }
    return p;
}

ll lcm(ll a, ll b)
{
    /*if((ll)a * b / gcd(a, b)>inf){
        cout<<0<<endl;
        return 0;
    }*/
   return (ll)a * b / gcd(a, b);
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n),ca(n),ba(n);
    rep(i,0,n){
        cin>>a.at(i);
        ca.at(i)=a.at(i);
    }
    int cz=0;
    while(ca.at(0)%2==0){
        ca.at(0)/=2;
        cz++;
    }
    rep(i,1,n){
        int c=0;
        while(ca.at(i)%2==0){
            ca.at(i)/=2;
            c++;
        }
        if(cz!=c){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,0,n){
        ba.at(i)=a.at(i)/2;
    }
    ll la=ba.at(0);
    rep(i,0,n){
        la=lcm(ba.at(i),la);
    }
    //cout<<la;
    if(m/la%2==0)cout<<m/la/2<<endl;
    else cout<<m/la/2+1<<endl;
return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

/* a^b */
int opow(int a, int b)
{
  int i;
  int ret = 1;
  for(i = 0; i < b; i++)
    ret *= a;
  return ret;
}

int hash(char *str)
{
  int i, ret = 0;
  for (i = 0; str[i] != '\0'; i++)
    ;
  
  for (i = 0; str[i] != '\0'; i++) {
    switch(str[i]) {
    case 'A':
      break;
    case 'C':
      ret += 1 * opow(4, i);
      break;
    case 'G':
      ret += 2 * opow(4, i);
      break;
    case 'T':
      ret += 3 * opow(4, i);
      break;
    }
  }
  return ret;
}


int main()
{
  short int dict[1700000];
  int n, i, j, nstr;
  char command[7];
  char str[13];
  char ans[1000000];
  int nans = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", command, str);
    j = hash(str);
    for(nstr = 0; str[nstr] != '\0'; nstr++)
      ;
    if( command[0] == 'i' ) {
      dict[j] |= (1<<(nstr-1));
    } else {
      if( (dict[j] & (1<<(nstr-1))) != 0 ) ans[nans++] = 'y';
      else ans[nans++] = 'n';
    }
  }
  for (i = 0; i < nans; i++) {
    if(ans[i] == 'y')
      printf("yes\n");
    else
      printf("no\n");
  }
  /*  for (i = 0; i < nans; i++) {
    printf("%c\n", ans[i]);
    } */
  return 0;
}

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

int N,M=0,u[66],v[66],w[66];

void addedge(int s, int t, int l){
	u[M] = s; v[M] = t; w[M] = l;
	++M;
}

int l2(int x){
	int l = 0,r = 25,m;
	while(r - l > 1){
		m = (l+r)/2;
		if(x < (1<<m)){
			r = m;
		}else{
			l = m;
		}
	}
	return l;
}



int main(void){
	int L,p,t,i,l;
	cin >> L;
	p = l2(L); N = p+1;
	for(i=0; i<p; ++i){
		addedge(i+1,i+2,0);
		addedge(i+1,i+2,(1<<i));
	}
	l = (1<<p);
	while(l < L){
		t = l2(L-l);
		addedge(t+1,N,l);
		l += (1<<t);
	}
	cout << N << " " << M << endl;
	for(i=0; i<M; ++i){
		cout << u[i] << " " << v[i] << " " << w[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

char cake[500][500];
int id_cake[500][500];

int cut_cake(int top, int bottom, int left, int right, int k, int id) {
    // cout << "top:" << top << " bottom:" << bottom << " left:" << left<< "
    // right:" << right << " k:" << k << " id:" << id << endl;
    if (k == 1) {
        FOR(i, top, bottom) {
            FOR(j, left, right) { id_cake[i][j] = id; }
        }
        id++;
        return id;
    } else {
        int count = 0;
        int i = top;
        while (count == 0) {
            FOR(j, left, right) {
                if (cake[i][j] == '#') {
                    count++;
                }
            }
            i++;
        }
        if ((k - count) != 0 && i < bottom) {
            int new_id = cut_cake(top, i, left, right, count, id);
            return cut_cake(i, bottom, left, right, k - count, new_id);
        } else {
            int count = 0;
            int j = left;
            while (count == 0) {
                FOR(i, top, bottom) {
                    if (cake[i][j] == '#') {
                        count++;
                    }
                }
                j++;
            }
            if ((k - count) != 0 && j < right) {
                int new_id = cut_cake(top, bottom, left, j, count, id);
                return cut_cake(top, bottom, j, right, k - count, new_id);
            }
        }
    }
    return -1;
}

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

    int H, W, K;
    cin >> H >> W >> K;

    REP(i, H) {
        REP(j, W) {
            char tmp;
            cin >> tmp;
            cake[i][j] = tmp;
        }
    }

    cut_cake(0, H, 0, W, K, 1);

    REP(i, H) {
        REP(j, W) { cout << id_cake[i][j] << " "; }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1536
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*
    vector<ll> X(N);
    string s,t;
    in >> s >> t;
    vector<string> s,t;
    s.resize(N);
    ll N;
    in >> N;
    */

    string s;
    in >> s ;
    
    out<<s[0]<<s[1]<<s[2]<<endl;
    

    
    
}

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

struct SegTree{
    SegTree *l = nullptr, *r = nullptr;
    int value = 0;
    int left, right;
    SegTree(int size):SegTree(0, size - 1){ }
    SegTree(int st, int lt): left(st), right(lt){
        if(left != right){
            int piv = left + (right - left) / 2;
            l = new SegTree(left, piv);
            r = new SegTree(piv + 1, right);
        }
    }
    double getSum(int st, int lt){
        if(right < st || lt < left){ return 0; }
        if(st <= left && right <= lt){ return value; }
        return l->getSum(st, lt) + r->getSum(st, lt);
    }
    void add(int idx, int val){
        if(right < idx || idx < left){ return; }
        value += val;
        if(l){
            l->add(idx, val);
            r->add(idx, val);
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int, int>> lrs(m), pqs(q);
    cin >> lrs >> pqs;
    sort(lrs.begin(), lrs.end());
    vector<int> anss(q), qis(q);
    iota(qis.begin(), qis.end(), 0);
    sort(qis.begin(), qis.end(), [&](int i, int j){ return pqs[i] > pqs[j]; });
    SegTree st(n + 1);
    int idx = m - 1;
    for(auto qi : qis){
        while(idx >= 0 && pqs[qi].first <= lrs[idx].first){
            st.add(lrs[idx].second, 1);
            idx--;
        }
        anss[qi] = st.getSum(pqs[qi].first, pqs[qi].second);
    }
    for(int i = 0; i < q; i++){
        cout << anss[i] << '\n';
    }
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()

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

  sort(all(w));

  string ans = "Yes";
  int head = 0, cnt = 1;
  REP(i, 1, w.size()) {
    if (w[i-1] == w[i]) ++cnt;
    // 文字が変わるタイミング
    else {
      // 偶数であればカウントを戻す
      if (cnt%2 == 0) cnt = 1;
      // 偶数でないならばNoにしてループを抜ける
      else {
        ans = "No";
        break;
      }
    }
  }
  // すべて同じ文字で奇数の場合
if (w.size()==cnt && cnt%2!=0) ans = "No";

  cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  
  rep(i,n){
    if(s[i]=='R' && i%2==1){
      puts("No");
      return 0;
    }
    if(s[i]=='L' && i%2==0){
      puts("No");
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		while(true) {
			int a=sc.nextInt();
			String op=sc.next();
			int b=sc.nextInt();
			if(op.equals("?")) {
				break;
			}
			switch(op) {
			case "+":
				System.out.println(a+b);
				break;
			case "-":
				System.out.println(a-b);
				break;
			case "*":
				System.out.println(a*b);
				break;
			case "/":
				System.out.println(a/b);
				break;

			}
		}
	}

}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int n;
  	cin >> n;
  	string s;
  	int a=0,w=0,t=0,r=0;
  	for(int i=0;i<n;i++){
    	cin >> s;
      if(s=="AC")
        a++;
      else if(s=="WA")
        w++;
      else if(s=="TLE")
        t++;
      else
        r++;
    }
  	cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r;
    return 0;
}

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

using namespace std;

int main() {
    int A, B;
    int i = 0;

    cin >> A >> B;

    if (B != 1) {
        for (i = 1; i <= 100; i++) {
            if (1 + (A - 1) * i >= B) {
                break;
            }
        }
    }

    cout << i << endl;

    return 0;
}



Measured memory_bytes: 256
from fractions import gcd


MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)
lcm %= MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD - 2, MOD) % MOD
    ans %= MOD

print(ans)


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

int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if (abs(A - B) >= pow(10, 18)) {
        cout << "Unfair" << endl;
    } else {
        if (K % 2 == 1) {
            printf("%lld\n", -(A - B));
        } else {
            printf("%lld\n", A - B);
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))

count = 10**4

for i in range(N+1):
  k1 = sum(W[:i])
  k2 = sum(W[i:])
  diff = abs(k1 - k2)
  if diff < count:
    count = diff

print(count)

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

int main() {
  int d;
  cin >> d;
  if (d == 25)
    cout << "Christmas" << endl;
  if (d == 24)
    cout << "Christmas Eve" << endl;
  if (d == 23)
    cout << "Christmas Eve Eve" << endl;
  if (d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
int main()
{
    ll a,b,c;
    sl(a);
    sl(b);
    sl(c);
    ll k;
    sl(k);
    while(k>0&&b<=a)
    {
        b*=2;
        k--;
    }
    while(k>0&&c<=b)
    {
        c*=2;
        k--;
    }
    if(a>=b||b>=c)
    {
       cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    for(int i = 1;i <= N;i++){
        int count = 0;
        for(int x = 1;x <= 100;x++){
            if(x*x >= i)break;
            for(int y = x;y <= 100;y++){
                for(int z = y;z <= 100;z++){
                    int p = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);
                    if(p == i){
                        if(x==y && y==z)count++;
                        else if(x!=y && y!=z && z!=x)count += 6;
                        else count += 3;
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

const int MAX_V = 100010;
vector<int> G[MAX_V];
int odd, even;
vector<P> d;
// 2部グラフ判定
struct BipartiteGraph{
    int n;    
    vector<int> color;
    BipartiteGraph(int _n){
        n = _n;
        color.resize(n, 0);
    }
    bool dfs(int v, int c){
        color[v] = c;
        if(c == 1) odd++;
        else even++;
        bool res = true;
        for(int i = 0; i < G[v].size(); i++){
            if(color[G[v][i]] == c) res &= false;
            if(color[G[v][i]] == 0) res &= dfs(G[v][i], -c);
        }
        return res;
    }
    bool isBipartiteGraph(){
        bool res = true;
        for(int i = 0; i < n; i++){
            if(color[i] == 0){
                odd = 0; even = 0;
                res &= dfs(i, 1);
                d.push_back({odd, even});
            }
        }
        return res;
    }
};

bitset<MAX_V> dp, nxt;

signed main(){
    long long n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    BipartiteGraph bg(n);
    bool f = bg.isBipartiteGraph();
    if(!f){
        cout << -1 << endl;
        return 0;
    }
    dp[0] = true;
    rep(i, 0, d.size()){
        nxt.reset();
        nxt = dp << d[i].first;
        nxt |= dp << d[i].second;
        dp = nxt;
    }
    int ans = 0;
    rep(i, 0, n + 1){
        if(dp[i]){
            int tmp = i * (n - i);
            ans = max(ans, tmp - m);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    string a, b;
    cin >> a >> b;
    n = a.size();

    for (int i = 0; i < n; i++)
        if (a[i] != b[i])
            ans++;
    cout << ans << "\n";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}




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

#define Max 100001
int dp[Max][3];

int main(){
	int n,a,b,c;
	memset(dp,0,sizeof(dp));
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c;
	}
	int ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(b - a) <= d && abs(c - b) <= d) || (abs(c - a) <= d)) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
#define eps 1e-6
using namespace std;
int main(){
    ll a, b, c;
    double d;
    scanf("%lld %lf", &a, &d);
    d += eps;
    b = d * 100;
    c = a * b / 100;
    printf("%lld\n", c);
    return 0;
}

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

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

    long long ans=0;

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

        long long j=N/i;
        ans += ( (long long) i ) * j * ( j+1ll ) / 2ll;

    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll x, y;
  cin>>x>>y;
  priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll> >, greater<tuple<ll, ll, ll> > >que;
  que.push(make_tuple(0, x, y));
  tuple<ll, ll, ll> state;
  ll path, xx, yy;
  ll ans;
  map<pair<ll, ll>, int> amap;
  while(!que.empty()){
    state = que.top();que.pop();
    path = get<0>(state);
    xx = get<1>(state);
    yy = get<2>(state);
    if(xx==yy){
      ans = path;
      break;
    }
    if(amap[mp(xx, yy)]>0) continue;
    amap[mp(xx, yy)]++;
    if(amap[mp(-xx, yy)]==0){
      que.push(make_tuple(path+1, -xx, yy));
    }
    if(xx<yy){
      if(amap[mp(yy, yy)]==0){
        que.push(make_tuple(path+yy-xx, yy, yy));
      }
    }
    if(xx<-yy){
      if(amap[mp(-yy, yy)]==0){
        que.push(make_tuple(path-yy-xx, -yy, yy));
      }
    }
  }
  cout<<ans<<endl;
}



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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c) cout << "Yes" << endl;
    else if(c == b && a != c) cout << "Yes" << endl;
    else if(a == c && b != c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

using Point = complex<double>;
struct Line {
    Point s, t;
    Line(Point s, Point t) : s(s), t(t){}
};
double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }
double slope(Line l) { return tan(arg(l.t - l.s)); }

Point project(Line l, Point p) { // project p onto line (s,t)
    return l.s + (l.t - l.s) * dot(p - l.s, l.t - l.s) / norm(l.t - l.s);
}

Point reflect(Line l, Point p) {
    return l.s + conj((p - l.s) / (l.t - l.s)) * (l.t - l.s);
}

int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if(cross(b, c) >  EPS) return +1; // counter-clockwise
    if(cross(b, c) < -EPS) return -1; // clockwise
    if(  dot(b, c) < -EPS) return +2; // c--a--b
    if(abs(b)+EPS < abs(c))return -2; // a--b--c
    return 0; // a--c--b
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int q;
    cin >> q;
    for(int i=0; i < q; ++i) {
        double a,b,c,d,e,f,g,h;
        cin >> a >> b >> c >> d >> e >> f >> g >> h;
        Point p1 = Point(c, d) - Point(a, b);
        Point p2 = Point(g, h) - Point(e, f);

        if(abs(dot(p1, p2)) < EPS) cout << 1;
        else if(abs(cross(p1, p2)) < EPS) cout << 2;
        else cout << 0;
        cout << '\n';
    }
    return 0;
}


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

using namespace std;
char grid[1010][1010];

const char *cube[8][7] = {
        {},
        {},
        {},
        { // 3, 1
                "aa.",
                "..a",
                "..a"

        },
        { // 4, 3
                "aabc",
                "ddbc",
                "bcaa",
                "bcdd"
        },
        { // 5, 3
                "aabba",
                "bcc.a",
                "b..cb",
                "a..cb",
                "abbaa"
        },
        { // 6, 3
                "aabc..",
                "ddbc..",
                "..aabc",
                "..ddbc",
                "bc..aa",
                "bc..dd"
        },
        { // 7, 3
                "aabbcc.",
                "dd.dd.a",
                "..d..da",
                "..d..db",
                "dd.dd.b",
                "..d..dc",
                "..d..dc"
        }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if (N < 3) {
        puts("-1");
        return 0;
    }
    int tmp = 0;
    auto f = [&](const int c) {
        for (int i = 0; i < c; ++i) {
            for (int j = 0; j < c; ++j) {
                if (cube[c][i][j] != '*') {
                    grid[tmp+i][tmp+j] = cube[c][i][j];
                }
            }
        }
        tmp += c;
    };
    if (N % 3 == 0) {
        while (tmp < N) {
            f(3);
        }
    } else {
        const int surplus = N % 4;
        if (surplus == 1) {
            f(5);
        } else if (surplus == 2) {
            f(6);
        } else if (surplus == 3) {
            f(7);
        }
        while (tmp < N) {
            f(4);
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (grid[i][j] == 0) {
                putchar('.');
            } else {
                putchar(grid[i][j]);
            }
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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 n,a,b;

int main() {
    cin >> n >> a >> b;
    put(min(a,b));
    put(max(a+b-n,0));
    return 0;
}




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

using namespace std;
#define PROBLEM "E"
#define MAX 100010

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	int N;

	cin >> N;
	long long int a[MAX];
	memset(a, 0, sizeof(a));
	int count = 0;

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

		cin >> a[i];
		if(a[i] < 0)
			count++;
	}

	transform(a, a+N, a, [](long long i){

		return abs(i);
	});

	int tmp = *std::min_element(a, a+N);

	if(count % 2 == 0)
		cout << accumulate(a, a+N, (long long)0) << endl;
	else
		cout << accumulate(a, a + N, (long long)0) - 2*tmp << endl;

	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

ll a[10001],b[10001],N;
ll ans = 0;
int main(void)
{
	cin >> N;
	ll asum = 0, bsum =0, sam=0;
	FOR(i, 0, N) {
		cin >> a[i];
	}
	FOR(i, 0, N) {
		cin >> b[i];
		ll sama = b[i] - a[i];
		sam += sama;
		if (sama > 0)if (sama % 2 == 0)asum += (sama / 2);
		else asum += sama / 2 + 1;
		else if(sama < 0)bsum -= sama;
	}
	if (asum<=sam&&bsum<=sam)ct("Yes");
	else ct("No");
	
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
int main()
{
    int sx,sy,tx,ty,lenX,lenY;
    std::cin>>sx>>sy>>tx>>ty;
    lenX=tx-sx;lenY=ty-sy;
    for(int i=0;i<2;i++){
    if(i==1)std::cout<<"D";
    for(int i=0;i<lenX;i++) std::cout<<"R";
    if(i==1) std::cout<<"R";
    for(int i=0;i<lenY;i++) std::cout<<"U";
    if(i==1) std::cout<<"ULU";
    for(int i=0;i<lenX;i++) std::cout<<"L";
    if(i==1) std::cout<<"L";
    for(int i=0;i<lenY;i++) std::cout<<"D";
    if(i==1) std::cout<<"DR";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int A[510];
int sum[10000];
vector<int> V;
vector<int> a[10000];
int main()
{
	int N, K;
	cin >> N >> K;
	int S = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		S += A[i];
	}
	for (int i = 1; i * i <= S; i++) {
		if (S % i == 0) {
			if (i * i != S) V.push_back(S / i);
			V.push_back(i);
		}
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < V.size();i++) {
		for (int j = 0; j < N; j++) {
			a[i].push_back(A[j] % V[i]);
			sum[i] += (A[j] % V[i]);
		}
		sort(a[i].rbegin(), a[i].rend());
	}
	int ans = 1;
	for (int i = 0; i < V.size(); i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			sum[i] -= a[i][j];
			cnt += V[i] - a[i][j];
			if (cnt == sum[i] && cnt <= K) {
				ans = V[i];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
  int m, n;
  while (cin >> m >> n) {
    if ((m|n) == 0)
      break;

    vector<int> p;
    for (int i = 1; i <= m; ++i)
      p.push_back(i);

    int index = 0, mm = m;
    for (int i = 1; i <= n; ++i) {
      string s;
      cin >> s;

      if (mm == 1)
	continue;

      if (s == "FizzBuzz" && i % 15 == 0 ||
	  s == "Fizz" && i % 3 == 0 ||
	  s == "Buzz" && i % 5 == 0 ||
	  (i % 3 != 0 && i % 5 != 0 && atoi(s.c_str()) == i)) {


      } else {
	if (mm > 0) {
	  p[index] = -1;
	  --mm;
	}
      }

      if (mm > 0) {
	++index;
	if (index >= m)
	  index -= m;
	while (p[index] == -1) {
	  ++index;
	  if (index >= m)
	    index -= m;
	}
      }
    }

    vector<int> ans;
    for (unsigned int i = 0; i < p.size(); ++i) {
      if (p[i] != -1)
	ans.push_back(p[i]);
    }

    if (!ans.empty()) {
      for (int i = 0; i < ans.size()-1; ++i)
	cout << ans[i] << " ";
      cout << ans.back();
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 948
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
map<ll, bool> mp,cmp; int n;
ll calc(vector<int> v) {
	ll res = 0;
	rep(i, n) {
		res *= 10; res += v[i];
	}
	return res;
}
ll rev(ll x, int l, int r) {
	vector<int> v;
	rep(i, n) {
		v.push_back((int)(x % 10)); x /= 10;
	}
	reverse(v.begin(), v.end());
	reverse(v.begin() + l, v.begin() + r + 1);
	ll res = 0;
	rep(i, n) {
		res *= 10; res += v[i];
	}
	return res;
}
int main() {
	cin >> n;
	ll sta = 0; ll g = 0;
	rep(i, n) {
		int a; cin >> a; a--; g *= 10; g += a;
		sta *= 10; sta += i;
	}
	if (sta == g) {
		cout << 0 << endl; return 0;
	}
	queue<ll> q; q.push(sta); mp[sta] = true;
	queue<ll> p; p.push(g); cmp[g] = true;
	int c = 0; int sc = 0;
	bool fin = false;
	while (!fin) {
		int len = q.size();
		rep(j, len) {
			ll x = q.front(); q.pop();
			rep(i, n) {
				Rep(k, i + 1, n) {
					ll val = rev(x, i, k);
					if (cmp[val]) {
						cout << c + sc + 1 << endl; return 0;
					}
					if (!mp[val]) {
						mp[val] = true; q.push(val);
					}
				}
			}
		}
		c++;
		len = p.size();
		rep(j, len) {
			ll x = p.front(); p.pop();
			rep(i, n) {
				Rep(k, i + 1, n) {
					ll val = rev(x, i, k);
					if (mp[val]) {
						cout << c + sc + 1 << endl; return 0;
					}
					if (!cmp[val]) {
						cmp[val] = true; p.push(val);
					}
				}
			}
		}
		sc++;
	}
	//stop
	return 0;
}


Measured memory_bytes: 79192
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
const ll MOD = 1000000007LL;
ll dp[2010][2010] = {};

int main() {
    int n, m; cin >> n >> m;
    V<int> S(n), T(m);
    loop (n, i) cin >> S[i];
    loop (m, i) cin >> T[i];

    loop (n + 1, i) dp[i][0] = 1;
    loop (m + 1, i) dp[0][i] = 1;

    loop1 (n, i) {
        ll gt = 0;
        loop1 (m, j) {
            if (T[j - 1] == S[i - 1]) {
                gt = (gt + dp[i - 1][j - 1]) % MOD;
            }
            dp[i][j] = (dp[i - 1][j] + gt) % MOD;
        }
    }

    cout << dp[n][m] << endl;
    return 0;
}



Measured memory_bytes: 31744
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i,N){
        cin >> h[i];
    }
    sort(h.begin(),h.end());

    ll ans = LLONG_MAX;
    rep(i,N-K+1){
        ll result = h[i+K-1] - h[i];
        // cout << result << endl;
        ans = min(ans,result);
    }

    cout << ans << endl;
}




Measured memory_bytes: 3984
import math
import sys

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

s = int(input())
a = False
while a == False:
  bb = is_prime(s)
  if bb == True:
    print(s)
    sys.exit()
  else:
    s += 1

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

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

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


ll n;

int main(){
	while(cin>>n,n!=0){
		ll id[4005]={0};
		int a[8000]={0};
		
		int cou;
		rep(i,n){
			ll t1,t2,t3;
			cin>>t1>>t2>>t3;
			a[i]=t1;
			//if(id[t1]>0){
				id[t1]+=t2*t3;
			//}
			/*
			else{
				id[t1]=t2*t3;
			}
			*/
			cou=i;
		}
		bool f=true;
		rep(i,cou+100){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228