akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto &it : v)
		cin >> it;
	int ans = oo;
	for (int x = 0; x <= 100; x++) {
		int sum = 0;
		for (auto &it : v)
			sum += (it - x) * (it - x);
		ans = min(ans, sum);
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int A = x/1000;
        x %= 1000;
        int B = x/100;
        x %= 100;
        int C = x/10;
        x %= 10;
        int D = x;
        if(A + B + C + D == 7){
            System.out.printf("%d+%d+%d+%d=7\n",A,B,C,D);
            return;
        }
        if(A + B + C - D == 7){
            System.out.printf("%d+%d+%d-%d=7\n",A,B,C,D);
            return;
        }
        if(A + B - C + D == 7){
            System.out.printf("%d+%d-%d+%d=7\n",A,B,C,D);
            return;
        }
        if(A + B - C - D == 7){
            System.out.printf("%d+%d-%d-%d=7\n",A,B,C,D);
            return;
        }
        if(A - B + C + D == 7){
            System.out.printf("%d-%d+%d+%d=7\n",A,B,C,D);
            return;
        }
        if(A - B + C - D == 7){
            System.out.printf("%d-%d+%d-%d=7\n",A,B,C,D);
            return;
        }
        if(A - B - C + D == 7){
            System.out.printf("%d-%d-%d+%d=7\n",A,B,C,D);
            return;
        }
        if(A - B - C - D == 7){
            System.out.printf("%d-%d-%d-%d=7\n",A,B,C,D);
            return;
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//#include<set>
#include<algorithm>
//#include<math.h>
//#include<iostream>
//#include<time.h>
using namespace std;

#define LL long long
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (t=-1);
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}

//Pay attention to read!

int n;
#define maxn 200011
int a[maxn];

int main()
{
	n=qread(); for (int i=1;i<=n;i++) a[i]=qread();
	if (a[1]!=0) {puts("-1"); return 0;}
	for (int i=2;i<=n;i++) if (a[i]>a[i-1]+1) {puts("-1"); return 0;}
	LL ans=0; for (int i=n,j=0;i;i--)
	{
		ans+=((a[i]-j)>0)*a[i];
		j=a[i]-1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vec s(M), c(M);
    REP(i,0,M) {
        cin >> s[i] >> c[i];
        --s[i];
    }

    vec D(N, -1);
    bool f = true;
    REP(i,0,M) {
        if(s[i] < N && (D[s[i]] == -1 || D[s[i]] == c[i])) D[s[i]] = c[i];
        else {
            f = false;
            break;
        } 
    }

    if(N > 1 && D[0] == 0) f = false;
    if(N == 1 && D[0] == -1) D[0] = 0;
    if(N > 1) {
        if(D[0] == -1) D[0] = 1;
        REP(i,1,N) if(D[i] == -1) D[i] = 0;
    }

    if(f) REP(i,0,N) cout << D[i];
    else cout << -1;
    cout << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 3604
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	char S[3][101];
	scanf("%s%s%s", S[0], S[1], S[2]);
	int lena = (strlen(S[0]));
	int lenb = (strlen(S[1]));
	int lenc = (strlen(S[2]));
	int i[3] = { 0 };//イテレータ i[0],i[1],i[2]]
	int turn = 0;//ターン 0,1,2

	while (S[turn][i[turn]] != '\0') {
		if (S[turn][i[turn]] == 'a') {
			i[turn]++;
			turn = 0;
		}
		if (S[turn][i[turn]] == 'b') {
			i[turn]++;
			turn = 1;
		}
		if (S[turn][i[turn]] == 'c') {
			i[turn]++;
			turn = 2;
		}
	}

	if (turn == 0) { puts("A"); }
	if (turn == 1) { puts("B"); }
	if (turn == 2) { puts("C"); }

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

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

string board[2020];
int up[2020][2020], down[2020][2020], le[2020][2020], ri[2020][2020];

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

    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> board[i];
    
    for (int i = 0; i < h; i++) {
        int cnt = 0;
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '.') {
                cnt++;
            } else {
                cnt = 0;
            }
            le[i][j] = cnt;
        }
        cnt = 0;
        for (int j = w - 1; j >= 0; j--) {
            if (board[i][j] == '.') {
                cnt++;
            } else {
                cnt = 0;
            }
            ri[i][j] = cnt;
        }
    }
    for (int i = 0; i < w; i++) {
        int cnt = 0;
        for (int j = 0; j < h; j++) {
            if (board[j][i] == '.') {
                cnt++;
            } else {
                cnt = 0;
            }
            up[j][i] = cnt;
        }
        cnt = 0;
        for (int j = h - 1; j >= 0; j--) {
            if (board[j][i] == '.') {
                cnt++;
            } else {
                cnt = 0;
            }
            down[j][i] = cnt;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '.') {
                ans = max(ans, up[i][j] + down[i][j] + le[i][j] + ri[i][j] - 3);
            }
        }
    }
    cout << ans << endl;
}

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

ll gcd(ll a, ll b) {
    if (a%b==0) return b;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
    ll N, M;
    cin >> N >> M;

    ll a[N];
    rep(i, N) {
        cin >> a[i];
        a[i] = a[i] / 2;
    }

    ll minX = 1;
    rep(i, N) {
        if (minX > M) break;
        minX = lcm(minX, a[i]);
    }

    rep(i, N) {
        ll minX2 = minX;
        while ((a[i] > 0 && minX2 > 0) && (minX2 % 2 == 0 || a[i] % 2 == 0)) {
            if (minX2 % 2 == 1 || a[i] % 2 == 1) M = 0;
            minX2 /= 2;
            a[i] /= 2;
        }
    }

    // cout << minX << endl;
    cout << M / minX - M / (2 * minX) << endl;

    return 0;
}



Measured memory_bytes: 1024
from time import time
start=time()
from copy import deepcopy
from random import randint

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    a=list(map(int,input().split()))
    s.append(a)

def score_calculator(l):
    score=0
    las=[0]*26
    for i in range(d):
        for j in range(26):
            las[j]+=1
        las[l[i]]=0
        for j in range(26):
            score-=las[j]*c[j]
        score+=s[i][l[i]]
    return score
    
highest_sum_score=-1000000000000

for i in range(1,13):
    last=[0]*26
    temp_ans_lst=[]
    for j in range(d):
        daily_highest_score=-10000000000000
        for k in range(26):
            temp_score=s[j][k]
            temp_last=deepcopy(last)
            for p in range(26):
                temp_last[p]+=1
            temp_last[k]=0
            for p in range(26):
                down=temp_last[p]
                for q in range(i):
                    qdown=down+i+1
                    down+=qdown
                temp_score-=down*c[p]
            if temp_score>daily_highest_score:
                daily_highest_score=temp_score
                daily_choice=k
        for k in range(26):
            last[k]+=1
        last[daily_choice]=0
        temp_ans_lst.append(daily_choice)
    if score_calculator(temp_ans_lst)>highest_sum_score:
        ans_lst=deepcopy(temp_ans_lst)
        highest_sum_score=score_calculator(temp_ans_lst)
        
while time()-start<1.9:
    a=randint(0,d-1)
    b=randint(0,25)
    temp_ans_lst=deepcopy(ans_lst)
    temp_ans_lst[a]=b
    if score_calculator(temp_ans_lst)>highest_sum_score:
        ans_lst=deepcopy(temp_ans_lst)
        highest_sum_score=score_calculator(temp_ans_lst)

for i in ans_lst:
    print(i+1)

Measured memory_bytes: 98028
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string A;
	cin >> N >> A;
	vector<int> aa(N);
	bool exist1 = false;
	for (int i = 0; i < N; ++ i) {
		aa[i] = A[i]-'1';
		if (aa[i] == 1) exist1 = true;
	}

	vector<int> a;
	for (int i = 0; i < N; ++ i) {
		if ((i | (N-1-i)) == N-1) a.push_back(i);
	}

	if (exist1) {
		int r = 0;
		for (auto i : a) {
			r ^= aa[i]&1;
		}
		cout << r << endl;
	} else {
		int r = 0;
		for (auto i : a) {
			r ^= aa[i];
		}
		cout << r << endl;
	}
}


Measured memory_bytes: 5504
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int x;
cin>>x;
if(x%1000==0)
cout<<0;
else{
int n=(x/1000+1)*1000;
cout<<n-x;
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 2345;
int a[MAXN];

int solve(int N, int cur, int Q, int k) {
    int l = 1;
    vector<int> ans;
    while (l <= N) {
          vector<int> tmp;
          while (a[l] >= cur && l <= N) {
                tmp.push_back(a[l]);
                l++;
          }
          sort(tmp.begin(), tmp.end());
          for (int i = 0; i < int(tmp.size()) - k + 1; i++) {
              ans.push_back(tmp[i]);
          }
          l++;
    }
    sort(ans.begin(), ans.end());
    if (int(ans.size()) < Q) return int(1e9);
    else return ans[Q - 1] - cur;
}

int main() {
    int N, K, Q;
    // freopen("in.txt", "r", stdin);
    while (~scanf("%d %d %d", &N, &K, &Q)) {
          for (int i = 1; i <= N; i++) {
              scanf("%d", &a[i]);
          }
          int ans = int(1e9);
          for (int i = 1; i <= N; i++) {
              ans = min(ans, solve(N, a[i], Q, K));
          }
          printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 2e5 + 111;
        
using namespace std;          

int n, p[maxn], ans;             	
pair <pii, int> a[maxn];
vector < pair<int, pii> > v;
map <pii, bool> ma;

int get(int v){
	if (p[v] == v)
		return v;
	return p[v] = get(p[v]);
}

void dsu(int x, int y){
	x = get(x);
	y = get(y);
	p[x] = y;
}

void solve(){
	cin >> n;

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

	sort(a + 1, a + n + 1);

	for (int i = 1; i < n; i++){
		int xx = a[i].s;
		int yy = a[i + 1].s;
		if (xx > yy)
			swap(xx, yy);
		v.pb(mp(abs(a[i].f.f - a[i + 1].f.f), mp(xx, yy)));
		swap(a[i].f.f, a[i].f.s);
	}
	swap(a[n].f.f, a[n].f.s);

	sort(a + 1, a + n + 1);
    
    for (int i = 1; i < n; i++){
    	int xx = a[i].s;
		int yy = a[i + 1].s;
		if (xx > yy)
			swap(xx, yy);
    	v.pb(mp(abs(a[i].f.f - a[i + 1].f.f), mp(xx, yy)));
    }
    
    sort(all(v));

    for (int i = 0; i < sz(v); i++){
    	int xx = v[i].s.f;
    	int yy = v[i].s.s;
    	//cout << xx << " " << yy << " " << v[i].f << endl;
    	if (get(xx) != get(yy)){
    		dsu(xx, yy);
    		ans += v[i].f;
    	}
    }

    cout << ans;
}   
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;

    //cin >> q;

    while (q--){
        solve();
    }
}

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

int main() {
  vector<vector<ll>> A(3,vector<ll>(3));
  for(ll i=0;i<3;i++){
    for(ll j=0;j<3;j++){
      cin >> A.at(i).at(j);
    }
  }
  vector<vector<bool>> T(3,vector<bool>(3,false));
  ll N;
  cin >> N;
  for(ll k=0;k<N;k++){
    ll b;
    cin >> b;
    for(ll i=0;i<3;i++){
      for(ll j=0;j<3;j++){
        if(A.at(i).at(j)==b){
          T.at(i).at(j)=true;
        }
      }
    }
  }
  if((T.at(0).at(0)&&T.at(0).at(1)&&T.at(0).at(2)) || (T.at(1).at(0)&&T.at(1).at(1)&&T.at(1).at(2)) || (T.at(2).at(0)&&T.at(2).at(1)&&T.at(2).at(2)) ||
    (T.at(0).at(0)&&T.at(1).at(0)&&T.at(2).at(0)) || (T.at(0).at(1)&&T.at(1).at(1)&&T.at(2).at(1)) || (T.at(0).at(2)&&T.at(1).at(2)&&T.at(2).at(2)) ||
     (T.at(0).at(0)&&T.at(1).at(1)&&T.at(2).at(2)) || (T.at(0).at(2)&&T.at(1).at(1)&&T.at(2).at(0))){
    cout << "Yes" <<endl;
    return 0;
  }
  else{
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 3624
def mod10(i):
    if i%10 ==0:
        return 0
    else:
        return 1
    


N = int(raw_input())
_sum = 0
data = []
for _ in xrange(N):
    s = int(raw_input())
    _sum += s
    data.append(s)
data = sorted(data)
mods = map(mod10,data)
if _sum%10 == 0:
    if mods.count(1)>0:
        print _sum - data[mods.index(1)]
    else:
        print 0
else:
    print _sum

    

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

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    if(y % 2 != 0) {
        printf("No\n");
        return 0;
    }
    if(2 * x == y) {
        printf("Yes\n");
    }
    else if(4 * x == y) {
        printf("Yes\n");
    }
    else if(((y - 2 * x) % 2) == 0) {
        int a = (y - 2 * x) / 2;
        if(a >= 0 && a <= x) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>

long long int f(long long int n,long long int x){
    if(n < 0) return 0;
    else return n / x + 1;
}

int main(void){
    long long int a,b,x;
    long long int ans = 0;
    scanf("%lld %lld %lld",&a,&b,&x);
    ans = f(b,x) - f(a - 1,x);
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
N,M = map(int,input().split())
list_a = []
ans = 0
for i in range(N):
    list_a.append(list(map(int,input().split())))

for i in range(1,M+1):
    count = 0
    for f_food in list_a:
        f_food[0] = -1
        if(i in f_food):
            count += 1
    if(count == len(list_a)):
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R') {
        cout << 3;
    } else if (s[0] == s[1] and s[0] == 'R') {
        cout << 2;
    } else if (s[1] == s[2] and s[1] == 'R') {
        cout << 2;
    } else if (s[1] == 'R' or s[2] == 'R' or s[0] == 'R') {
        cout << 1;
    } else {
        cout << 0;
    }


    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>

int main(void){
	int n , i , j , table[11][11];
	while(1){
		scanf("%d" , &n);
		if(n==0) break;
		for(i=0;i<11;i++){
			for(j=0;j<11;j++){
				table[i][j] = 0;
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%d" , &table[i][j]);
				table[i][n] += table[i][j];
				table[n][j] += table[i][j];
				table[n][n] += table[i][j];
			}
		}
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				printf("%5d" , table[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

int main() {
  int x, y; cin >> x >> y; int ans = 0; 
  if (x == 1 && y == 1) ans = 1000000;
  else {
    if (x == 1) ans += 300000;
    if (x == 2) ans += 200000;
    if (x == 3) ans += 100000;
    if (y == 1) ans += 300000;
    if (y == 2) ans += 200000;
    if (y == 3) ans += 100000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define use(x) using std::x
#define cmax(a, b) (a < b ? a = b : a)
#define lop(i, s, t) for (int i = s;i < (t);++i)
#define dec(i, s, t) for (int i = s;i >= (t);--i)
#define rep(i, s, t) for (int i = s;i <= (t);++i)
#define mem(x, k) memset(x, k, sizeof(x))
use(fill); use(sort); use(max); use(swap);

const int N = 3e5 + 50, oo = 1e9;

#define Pr(f, ...) printf(f, ##__VA_ARGS__), fflush(stdout)

namespace SegTr {
	const int S = N << 2;
	int tr[S], tag[S];
	void clear() { 
		mem(tr, 0); 
		mem(tag, 0); 
	}
	void down(int v) {
		if (tag[v] == 0) return;
		tag[v << 1] += tag[v], tag[v << 1 ^ 1] += tag[v];
		tr[v << 1] += tag[v], tr[v << 1 ^ 1] += tag[v]; 
		tag[v] = 0;
	}
	void update(int v, int l, int r, int s, int t, int k) {
		if (r < s || l > t) ;
		else if (s <= l && r <= t) {
			tr[v] += k;
			tag[v] += k;
		} else {
			down(v); 
			int mid = (l + r) >> 1;
			update(v << 1, l, mid, s, t, k); 
			update(v << 1 ^ 1, mid + 1, r, s, t, k); 
			tr[v] = max(tr[v << 1], tr[v << 1 ^ 1]);	
		}
	}
	int query() { return tr[1]; }
}

int n, xmax, ymax, ans;
struct P { int x, y; } p[N];
bool operator<(const P &a, const P &b) {
	if (a.x == b.x) return a.y < b.y; 
	return a.x < b.x;
}

P up[N], dn[N];
int tu, td;
void solve() {
	SegTr::clear(); 
	sort(p + 1, p + n + 1); 
	tu = 0, td = 0;
	int mid = ymax >> 1;
	rep(i, 1, n - 1) {
		int y = p[i].y, lst = i - 1;
		if (y > mid) {
			while (tu && y < up[tu].y) {
				SegTr::update(1, 1, n, up[tu].x, lst, -up[tu].y + y);
				lst = up[tu--].x - 1;
			}
			if (lst != i - 1) up[++tu] = (P) { lst + 1, y };
		} else {
			while (td && y > dn[td].y) {
				SegTr::update(1, 1, n, dn[td].x, lst, -y + dn[td].y);
				lst = dn[td--].x - 1;
			}
			if (lst != i - 1) dn[++td] = (P) { lst + 1, y };
		}
		up[++tu] = (P) { i, ymax };
		dn[++td] = (P) { i, 0 };
		SegTr::update(1, 1, n, i, i, ymax - p[i].x); 
		cmax(ans, SegTr::query() + p[i + 1].x); 
	}
}

int main(int argc, char *argv[]) {
	scanf("%d%d%d", &xmax, &ymax, &n); 
	rep(i, 1, n) {
		scanf("%d%d", &p[i].x, &p[i].y); 
	}
	p[++n] = (P) { 0, 0 };
	p[++n] = (P) { xmax, ymax };
	solve(); 
	rep(i, 1, n) swap(p[i].x, p[i].y); 
	swap(xmax, ymax); 
	solve(); 
	printf("%d\n", ans << 1);
	return 0; 
}


Measured memory_bytes: 15616
from bisect import bisect
N = int(input())
X = list(map(int,input().split()))
NX = sorted(X)
a = NX[int(N/2)]
b = NX[int((N-2)/2)]
for i in range(N):
    if bisect(NX,X[i]) <= N/2:
        print(a)
    else:
        print(b)

Measured memory_bytes: 25228
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 
    
    int a[400]={0};
    a[1]=300000;
    a[2]=200000;
    a[3]=100000;
    
    int x,y;
    cin>>x>>y;
    int s=0;
    s+=a[x]+a[y];
    if(x==y && x==1)
    {
        s+=400000;
    }
    cout<<s;

// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct process { string name; int time; };

int main()
{
	int n, q, ntime = 0;
	process tmp;
	queue<process> que;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> tmp.name >> tmp.time;
		que.push(tmp);
	}
	while (!que.empty()) {
		tmp = que.front(); que.pop();
		if (tmp.time <= q) {
			ntime += tmp.time;
			cout << tmp.name << ' ' << ntime << endl;
		}
		else {
			ntime += q;
			tmp.time -= q;
			que.push(tmp);
		}
	}
	return 0;
}

Measured memory_bytes: 6316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define MOD 1000000007
#define W_MAX 8

void calc_moves(ll (*arr)[W_MAX], int w){
  ll dp[w+1] = {};
  dp[0] = 1;
  dp[1] = 1;
  repi(i, 2, w+1) dp[i] = dp[i-2] + dp[i-1];
  rep(i, w){
    if(i == 0){
      arr[i][i] = dp[w-1];
      arr[i][i+1] = dp[w-2];
    }
    else if(i == (w-1)){
      arr[i][i] = arr[0][0];
      arr[i][i-1] = arr[0][1];
    }
    else{
      arr[i][i] = dp[i] * dp[w-i-1];
      arr[i][i+1] = dp[i] * dp[w-i-2];
      arr[i][i-1] = arr[i-1][i];
    }
  }
}

int main(){
  int H, W, K;
  scanf("%d %d %d", &H, &W, &K);
  K--;

  if(W == 1) cout << 1 << endl;
  else{
    ll n_moves[W_MAX][W_MAX] = {};
    calc_moves(n_moves, W);
    ll dp[H][W] = {};
    rep(i, H){
      rep(j, W){
        if(i == 0) dp[i][j] = n_moves[0][j];
        else rep(k, W) dp[i][j] = (dp[i][j] + dp[i-1][k] * n_moves[k][j]) % MOD;
      }
    }
    cout << dp[H-1][K] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 1;
	REP(i, n-1) {
		if (s[i] != s[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL Q;
    cin >> Q;
    vector<bool> prime(100001);
    for(LL i = 2;i < 100001;i++)    prime[i] = true;
    for(LL i = 2;i < 100001;i++){
        if(prime[i]){
            for(LL j = 2*i;j < 100001;j+=i) prime[j] = false;
        }
    }
    vector<LL> like(100001);
    for(LL i = 3;i < 100001;i++){
        if(prime[i] && prime[(i+1)/2])  like[i] = 1;
    }
    vector<LL> sum(100001);
    for(LL i = 3;i < 100001;i++)    sum[i] = sum[i-1]+like[i];
    for(LL i = 0;i < Q;i++){
        LL li, ri;
        cin >> li >> ri;
        LL ans = sum[ri]-sum[li-1];
        cout << ans << endl;
    }
}

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

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        if(p[i] != i + 1) ans++;
    }
    cout << (ans <= 2 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val a = scala.io.StdIn.readLine.toList
	val b = scala.io.StdIn.readLine.toList

	if(a.size > b.size) println("GREATER")
	else if(a.size < b.size) println("LESS")
	else{

		val ita = a.iterator
		val itb = b.iterator

		def rec(ta: Char, tb: Char): String = {
			if(ta > tb) "GREATER"
			else if(ta < tb) "LESS"
			else if(! ita.hasNext) "EQUAL"
			else rec(ita.next, itb.next)
		}

		println(rec(ita.next, itb.next))

	}



}

Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define ll long long
vector<int> v[nn];
int ans;int n,diam;
int del[nn];
int dist[nn];
int bfs(int x,int lb)
{
	memset(dist,0x3f,sizeof(dist));
	queue<int> q;q.push(x);dist[x]=0;
	while(q.size())
	{
		int x=q.front();q.pop();
		for(int i=0;i<v[x].size();i++)
		{
			if(dist[v[x][i]]>dist[x]+1)
				dist[v[x][i]]=dist[x]+1,q.push(v[x][i]);
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++) if(dist[i]<=lb) cnt++;
	return cnt;
}
int bfs(int x,int y,int lb)
{
	memset(dist,0x3f,sizeof(dist));
	queue<int> q;q.push(x);q.push(y);dist[x]=dist[y]=0;
	while(q.size())
	{
		int x=q.front();q.pop();
		for(int i=0;i<v[x].size();i++)
		{
			if(dist[v[x][i]]>dist[x]+1)
				dist[v[x][i]]=dist[x]+1,q.push(v[x][i]);
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++) if(dist[i]<=lb) cnt++;
	return cnt;
}
int main()
{
	cin>>n>>diam;
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,bfs(i,diam/2));
		for(int j=0;j<v[i].size();j++)
			ans=max(ans,bfs(i,v[i][j],(diam-1)/2));
	}
	cout<<n-ans;
	return 0;  
}

Measured memory_bytes: 7552
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll W;
ll w[100], v[100];

ll dp[105][105][305];
ll solve(int n, int m, int k){
    if(w[0]*m+k > W) return LLONG_MIN;
    if(n == N) return 0;
    if(dp[n][m][k] != -1) return dp[n][m][k];
    return dp[n][m][k] = max(solve(n+1, m, k), solve(n+1, m+1, k+w[n]-w[0])+v[n]);
}

signed main(){
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0) << endl;
}

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

using namespace std;

#define pb push_back
#define mod 1000000007
#define endl '\n'

long long int i,j,k,n,m,p=1,x,y,z;
vector<long long int> v1,v2;

int main(){
	p=1;
	while(p--){
		scanf("%lld %lld",&n,&k);
		assert(n>=k);
		v1.clear();
		v2.clear();
		
		long long int ans=1;
		
		for(i=1 ; i<=n ; i++){
			scanf("%lld",&x);
			assert(abs(x)<=1000000000);
			if(x>0)
				v1.pb(x);
			if(x<0)
				v2.pb(-x);
		}
					sort(v1.begin(),v1.end());
		sort(v2.begin(),v2.end());	
		if(v1.size()+v2.size()<k){
			puts("0");
			continue;
		}
		if(v2.size()%2 and k!=n and v1.size()+v2.size()==k){
			puts("0");
			continue;
		}

		if(v1.size()+v2.size()==k and k==n){
			
			for(i=0 ; i<v1.size(); i++)
				ans = ans*v1[i]%mod;
			for(i=0 ; i<v2.size() ; i++)
				ans = (ans*(-v2[i]))%mod;
				
			cout << (ans+mod)%mod << endl;
			
			continue;
		}
		if(!v1.size()){
			if(k%2){
				if(v2.size() != n){
					puts("0");
					continue;
				}
				
				for(i=0 ; i<k ; i++)
					ans = ans*(-v2[i])%mod;
			}
			else
				for(i=v2.size()-1 ; i>=v2.size()-k ; i--)
					ans = ans*(v2[i])%mod;
			
			cout << (ans%mod+mod)%mod << endl;
			continue;
		}

		
		int t2 = (int)v2.size()-1;
		int t1 = (int)v1.size()-1;

		
		if(k%2){
			ans = v1[t1];
			t1--;
			k--;
		}
		
		while(k){
			if(t1<1){
				ans = ans*v2[t2]%mod*v2[t2-1]%mod;
				t2-=2;
			}
			else if(t2<1){
				ans = ans*v1[t1]%mod*v1[t1-1]%mod;
				t1-=2;

			}
			else if(v2[t2]*v2[t2-1]>v1[t1]*v1[t1-1]){
				ans = ans*v2[t2]%mod*v2[t2-1]%mod;
				t2-=2;
			}
			else{
				ans = ans*v1[t1]%mod*v1[t1-1]%mod;
				t1-=2;
			}
			k-=2;
		}
		
		cout << (ans+mod)%mod << endl;
	}
}

Measured memory_bytes: 5560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 標準入力を受け取る
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        // Nが111の倍数となるまで1を足し続ける
        while (N % 111 != 0){
            N++;
        }

        // 全ての桁の数が等しくなったNを標準出力
        System.out.println(N);

    }

}

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

using namespace std;

typedef long long ll;

#define pb push_back


const int N = 2000;

int a[1 + N];
const int MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int n;
    ll k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll fst = 0;
        for (int j = 1; j < i; j++)
            if (a[j] > a[i])
                fst++;
        ll scd = 0;
        for (int j = 1; j <= n; j++)
            if (a[j] > a[i])
                scd++;
        ans += (scd  * (((k - 1) * k) / 2 % MOD) + k * fst) % MOD;
        ans %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MaxN = 1e5 + 5;
long long n, a, b, v[MaxN], k;

int main()
{
    cin >> k;
    long long a = 2, b = 2;
    bool ok = 1;
    for (int i = 1; i <= k; ++i) cin >> v[i];
    for (int i = k; i >= 1 && ok; --i) {
        long long da = a / v[i], db = b / v[i];
        if (a % v[i] == 0) --da;
        if (da >= db) ok = 0;
        else {
            a = (da + 1) * v[i];
            b = (db + 1) * v[i] - 1;
        }
    }
    if (!ok) cout << -1 << '\n';
    else cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {
	
	int x, y;
	cin >> x >> y;

	cout << x + y / 2 << endl;

	return 0;
}

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

int main(void) {
	int a, b, c;
	int n = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) {
			n++;
		}
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 3108
//Touitsu.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
        String a=sc.next();
        String b=sc.next();
        String c=sc.next();

        int ans=0;
        for(int i=0; i<n; i++){
            if(a.charAt(i)==b.charAt(i)&&b.charAt(i)==c.charAt(i)){
                ans+=0;
            }
            else if(a.charAt(i)==b.charAt(i)||b.charAt(i)==c.charAt(i)||c.charAt(i)==a.charAt(i)){
                ans+=1;
            }
            else{
                ans+=2;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,N,total,A;
    cin >> H >> N;
    total = 0;
    for(int i = 0;i < N;i++){
        cin >> A;
        total += A;
    }
    if(total < H){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


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

int main() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;

    int64_t ans_1 = a * c;
    int64_t ans_2 = a * d;
    int64_t ans_3 = b * c;
    int64_t ans_4 = b * d;

    cout << max(ans_1, max(ans_2, max(ans_3, ans_4))) << endl;
}


Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
for i in range(n):
    b[i]=[i,a[i]]
b.sort(key=lambda x:x[1])
c=[]
for i in range(n):
    c.append(b[i][0]+1)
print(*c, sep=' ')

Measured memory_bytes: 27104
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var H = line[0];
        var W = line[1];
        
        var S = new string[H];
        for(var i = 0;i < H;i++){
            S[i] = Console.ReadLine();
        }
        
        for(var i = 1;i < H - 1;i++){
            for(var j = 1;j < W - 1;j++){
                if(S[i][j] == '#' && 
                    S[i - 1][j] == '.' &&
                    S[i][j + 1] == '.' &&
                    S[i + 1][j] == '.' &&
                    S[i][j - 1] == '.')
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	int cnt = 0;
	k *= 2;
	int x = k;
	rep(i,n-1){
		if(s[i] == s[i+1]) ++cnt;
		else{
			if(k > 0){
				--k;
				++cnt;
			}
		}
	}
	int sum = cnt;
	cnt = 0;
	k = x;
	for(int i = n-1;i > 0;--i){
		if(s[i] == s[i-1]) ++cnt;
		else{
			if(k > 0){
				--k;
				++cnt;
			}
		}
	}
	cout << max(cnt,sum) << '\n';
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
    int k,x; cin >> k >> x;
    int ans = x-k;
    for(int i=1; i<k*2; i++){
       cout <<  x - k+i <<endl;
    }
    return 0;
}




Measured memory_bytes: 384
#include <algorithm>
#include <utility>
#include <cstdio>
#include <vector>
#define pb push_back
#define MOD 1000000007
typedef long long ll;
std::vector<std::pair<ll, ll> > seq[105];
ll F[105];
int main()
{
	// freopen("AGC015-F.in", "r", stdin);
	F[0] = F[1] = 1;
	int len = 1;
	while (true)
	{
		F[len + 1] = F[len] + F[len - 1];
		if (F[len + 1] > 1e18)
			break;
		len++;
	}
	seq[1].pb({1, 2});
	seq[1].pb({1, 3});
	seq[1].pb({1, 4});
	for (int i = 1; i <= len - 3; i++)
	{
		for (auto it : seq[i])
		{
			ll x = it.first, y = it.second;
			while (x + y <= F[i + 3] + F[i])
			{
				x += y;
				seq[i + 1].pb({y, x});
			}
		}
	}
	int t; 
	scanf("%d", &t);
	while (t--)
	{
		ll n, m;
		scanf("%lld%lld", &n, &m);
		if (n > m)
			std::swap(n, m);
		int ans = 1;
		while (F[ans + 1] <= n && F[ans + 2] <= m)
			ans++;
		printf("%d ", ans);
		if (ans == 1)
			printf("%lld\n", n * m % MOD);
		else
		{
			ll cnt = 0;
			for (auto it : seq[ans - 1])
			{
				ll x = it.first, y = it.second;
				if (y <= n)
					(cnt += (m - x) / y) %= MOD;
				if (y <= m)
					(cnt += (n - x) / y) %= MOD;
			}
			printf("%lld\n", cnt);
		}
	}
	return 0;
}


Measured memory_bytes: 4096
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=3e3+4;

ll a[N];

//dp[i][j] tells the maximum value first player can take,
//if we the range is i to j and first player starts the game

ll dp[N][N];

ll rec(int i,int j)
{
    if(i==j)
    return a[i];
    
    if(i>j)
    return 0;
    
    ll &here=dp[i][j];
    
    if(here!=-1)
    return here;
    
    here=0;
    
    ll v1=min(rec(i+2,j),rec(i+1,j-1))+a[i];
    
    ll v2=min(rec(i+1,j-1),rec(i,j-2))+a[j];
    
    here=max(v1,v2);
    
    return here;
}

int main()                  
{
    int n;
    
    scn(n);
    
    ll sum=0;
    
    rep(i,0,n)
    lscn(a[i]),sum+=a[i];
    
    memset(dp,-1,sizeof(dp));
    
    ll x=rec(0,n-1);
    
    ll ans=x-(sum-x);
    
    lpri(ans);
} 


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;k--;
  string s;cin>>s;s[k]=tolower(s[k]);
  print(s);
  return 0;
}

Measured memory_bytes: 3624
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b) = readIntegerList()
    val vList = readLongList().sortedDescending()

    println(vList.take(a).average())
    
    val c =pascalTriangle(n)
    if (vList.first() == vList[a - 1]) {
        val maxCount = vList.count { it == vList.first() }
        var ans = 0L
        for (i in a..b) {
            ans += c[maxCount][i]
        }
        println(ans)
    } else {
        val count = vList.count { it == vList[a - 1] }
        val i = vList.lastIndexOf(vList[a - 1]) + 1
        println(c[count][count - (i - a)])
    }
}

fun pascalTriangle(size: Int): Array<LongArray> {
    val table = Array(size + 1) { LongArray(size + 1) }
    table[0][0] = 1L
    for (i in 0 until size) {
        for (j in 0..i) {
            table[i + 1][j] += table[i][j]
            table[i + 1][j + 1] += table[i][j]
        }
    }
    return table
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36132
#include<iostream>

using namespace std;

int main()
{
 int x1,y1;
 int x2,y2;

 cin >> x1 >> y1 >> x2 >> y2;
 
 cout << x2-(y2-y1) /*x3の値*/<< " " << y2+(x2-x1) /*y3*/ << " " << x1-(y2-y1)/*x4*/ << " " << y1+(x2-x1) << endl;  /*y4*/

 return 0;
}


Measured memory_bytes: 256
from itertools import permutations


def submit():
    n, m, _ = map(int, input().split())
    rlist = list(map(int, input().split()))
    rlist = [r - 1 for r in rlist]

    # warshall floyd
    dp = [[float('inf') for _ in range(n)] for _ in range(n)]
    for i in range(n):
        dp[i][i] = 0
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = dp[b][a] = c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

    
    min_cost = float('inf')
    for pt in permutations(rlist):
        cost = 0
        for i in range(len(pt) - 1):
            cost += dp[pt[i]][pt[i + 1]]
        
        if min_cost > cost:
            min_cost = cost

    print(min_cost)


submit()

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

int main() {
  int N;
  cin >> N;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  string S;
  for (int i = 0; i<N ; i++){
    cin >> S;
    if ( S == "AC"){
      AC++;
    }
    else if ( S == "WA"){
      WA++;
    }
    else if ( S == "TLE"){
      TLE++;
    }
    else {
      RE++;
    }
  }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}


Measured memory_bytes: 3624
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()

result = 0
for i in range(N) :
  for j in range(i+1,N) :
    result += bisect_left(L,L[i]+L[j]) - (j+1)

print(result)

Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)  # 大きい順にソート
B = []  # 既に到着した人. 大きい順に追加される.
cnt = 0
for a in A:
    if len(B) != 0:
        j = len(B) // 2  # 中央値の位置を求める
        cnt += B[j]
    B.append(a)
print(cnt)

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

int n,m;
int a[100048];

namespace DSU
{
    int pre[100048];
    inline void init() {for (register int i=1;i<=n;i++) pre[i]=i;}
    inline int find_anc(int x) {if (pre[x]!=x) pre[x]=find_anc(pre[x]); return pre[x];}
    inline void update(int x,int y) {x=find_anc(x);y=find_anc(y);pre[x]=y;}
}

int main ()
{
    int i,x,y;
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++) scanf("%d",&a[i]);
    DSU::init();
    for (i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        DSU::update(x,y);
    }
    int ans=0;
    for (i=1;i<=n;i++) if (DSU::find_anc(i)==DSU::find_anc(a[i])) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

int cnt[3][101];
int card[200][3];
int point[200];

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

	for( int i = 0; i != N; ++i )
	{
		for( int j = 0; j != 3; ++j )
		{
			std::cin >> card[i][j];

			++cnt[j][card[i][j]];
		}
	}

	for( int i = 0; i != N; ++i )
	{
		for( int j = 0; j != 3; ++j )
			if( cnt[j][card[i][j]] < 2 )
				point[i] += card[i][j];

		std::cout << point[i] << std::endl;
	}	

	return 0;
}

Measured memory_bytes: 1168
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
    char x[1001];
    
    while(1){
        scanf("%s", x);       
        if(x[0] == '0') break;
        int sum = 0;
        for(int i = 0; i < strlen(x); i++){
            sum += (x[i] - '0');
        }
        printf("%d\n", sum);

    }
    return 0;
}


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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1<<62LL)

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;

  string no_x("");
  for (char c : S) {
    if (c == 'x') continue;
    no_x += c;
  }

  string rev_no_x = no_x;
  reverse(rev_no_x.begin(), rev_no_x.end());

  if (rev_no_x != no_x) {
    cout << -1 << endl;
    return 0;
  }

  int i = 0, j = S.size() - 1;
  int ans = 0;

  while (i < j) {
    if (S[i] == S[j]) {
      i++;
      j--;
      continue;
    }

    if (S[i] == 'x') {
      i++;
      ans++;
      continue;
    }

    if (S[j] == 'x') {
      j--;
      ans++;
      continue;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 592