akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		double min = Double.MAX_VALUE;
		double H[] = new double[N+1];
		int num = 1;
		for(int i = 1;i <= N;i++) {
			H[i] = Math.abs(A - (T - (sc.nextDouble() * 0.006)));
			if(min > H[i]) {
				min = H[i];
				num = i;
			}
		}
		System.out.println(num);
		sc.close();
	}
}

Measured memory_bytes: 25940
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, x = nm()
    m = [ni() for _ in range(n)]
    
    print(n + (x - sum(m)) // min(m))


if __name__ == '__main__':
    main()

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

int main(){
  long double N = 0,ans = 0;
  ll x = 0;
  cin >> N >> ans;
  x = N * ans;
  cout << x ;
}
  

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

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if(a == b && b == c && c == a){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{	
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int &i:a)cin>>i;
	sort(a.begin(),a.end());
	int lo=-1e18,hi=1e18;
	while((hi-lo)>1)
	{
		int mid=(lo+hi)/2;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]>0)
				sum+=lower_bound(a.begin(),a.end(),(long double)mid/a[i])-a.begin();
			if(a[i]<0)sum+=n-(upper_bound(a.begin(),a.end(),(long double)mid/a[i])-a.begin());
			if(a[i]==0)
			{
				if(mid>0)
				sum+=n;
			}
			if(a[i]*a[i]<mid)sum--;
		}
		if(sum/2<k){lo=mid;}
		else hi=mid;

	}
	cout<<lo<<"\n";
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI v(n);
  rep(i, n) cin >> v[i];
  sort(all(v));
  double ans = 0;
  ans = (v[0] + v[1]) / 2.0;
  rep(i, n-2) {
    ans = (ans + v[i+2]) / 2.0;
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int A[10],B[10],D[10],E[10];
int Search(int num,int ans);
int Answer(void);
int main(void){
	int tmp,i,n,cnt;
	char str[100],*line;

	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); A[1]=n; B[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); A[i]=n; B[i]=n;
	}
	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); D[1]=n; E[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); D[i]=n; E[i]=n;
	}
	for(i=1;i<=5;i++){
		if(A[i]>A[i+1]){
			tmp = A[i+1];
			A[i+1] = A[i];
			A[i] = tmp;
		}
		if(D[i]>D[i+1]){
			tmp = D[i+1];
			D[i+1] = D[i];
			D[i] = tmp;
		}
	}
	cnt=0;
	for(i=1;i<=6;i++){
		if(A[i] == D[i])
			cnt++;
	}
	if((cnt==6) && (A[1]==A[2]) && (A[2]==A[3]) && (A[3]==A[4]) && (A[4]==A[5])){
		printf("Yes\n");
		return 0;
	}
	Search(1,2);
	Search(1,3);
	Search(2,3);
	Answer();	
	return 0;
}			
	
int Search(int num,int ans){
	int tmp,i;
	for(i=0;i<10;i++){
		if(B[num]==E[num])
			return 0;
		tmp = B[num];
		B[num] = B[ans];
		B[ans] = B[7-num];
		B[7-num] = B[7-ans];
		B[7-ans] = tmp;
	}
	return 0;
}
int Answer(void){
	int i;
	for(i=2;i<=6;i++){
		if(B[i] != E[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
//upper_bound is maximum index of an array element not greater than the given one
//lower bound is minimum index of an array element not less than the given one

#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define endl "\n";
using namespace std;

/*vector<int>adj[200001];
int vis[200001];


int dfs(int node)
{
	vis[node]=1;
	
	int count=1;
	
	for(auto it:adj[node])
	{
		if(!vis[it])
		{
			count+=dfs(it);
		}
	}
	return count;
}*/

void solve()
{	
	string s,t;
	cin>>s>>t;
	
	int ans=1e9;;
	
	int m=t.size();
	int n=s.size();
	
	for(int i=0;i<n-m+1;i++)
	{
		int q=0;
		for(int j=0;j<m;j++)
		{
			if(t[j]!=s[i+j])
			q++;
		}
		ans=min(ans,q);
	}
	cout<<ans<<endl;
}


signed main()
{
    
	nuenxfiu
	int t;
	//cin>>t;
	t=1;
	for(int i=1;i<=t;i++)
	{
	//cout<<"Case #"<<i<<": ";
	solve();
	}
     return 0;
}

Measured memory_bytes: 3548
import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
abe = [list(map(int, input().split(' '))) for i in range(n-1)]
graph = [[] for i in range(n+1)]
parent = [0 for i in range(n+1)]
edge = [0 for i in range(n+1)]
root = 1
order = []
deq = deque([root])
for a,b,e in abe:
    graph[a].append(b)
    graph[b].append(a)
while deq:
    x = deq.popleft()
    order.append(x)
    for y in graph[x]:
        if parent[x] == y:
            continue
        parent[y] = x
        deq.append(y)
for a,b,e in abe:
    if parent[a] == b:
        edge[a] = e
    else:
        edge[b] = e
ans = [0 for i in range(n+1)]
for x in order:
    if x == 1:
        continue
    if edge[x]%2 == 0:
        ans[x] = ans[parent[x]]
    else:
        ans[x] = 1-ans[parent[x]]
del ans[0]
print(*ans,sep="\n")

Measured memory_bytes: 82396
#include <stdio.h>
typedef long long LL;

int main() {
	LL F[21]; 
	F[0] = 1;
	for(int i = 1; i <= 20; ++i) F[i] = F[i - 1] * i;
	int n;
	while(~scanf("%d", &n)) {
		printf("%lld\n", F[n]);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    while( n>0){
        int t;
        cin >> t;
        v.at(n-1) = t;
        n--;
    }
    std::sort(v.begin(),v.end());
    double m=0;
    for( auto e = v.begin(); e!= v.end(); ++e){
        if( e==v.begin())
            m = *e;
        else
            m = (m + *e)/2.0;
    }
    cout << fixed << setprecision(10) << m << endl;

    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];
    int ans = 0;

    sort(ALL(a));

    map<int, int> mp1;
    map<int, int> mp2;
    REP(i, n) {
        mp1[a[i]]++;
    }
    REP(i, n) {
        int num = a[i];
        if (mp2[num]) continue;
        while(num <= 1000000) {
            mp2[num]++;
            num += a[i];
        }
        if (mp1[a[i]] == 1 && mp2[a[i]] == 1) {
            ans++;
        }
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 60000
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

string m, dp[10004];
int b[12];

string mx(string s, string t) {
	if(s.size() > t.size()) return s;
	if(t.size() > s.size()) return t;
	return max(s, t);
}

int main()
{
	IO_OP;
	
	int a[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int n, m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
		cin >> b[i];
	dp[0] = "";
	for(int i=1;i<=n;i++) {
		for(int j=0;j<m;j++) {
			if(i-a[b[j]] >= 0 && dp[i-a[b[j]]] != "cheissmart")
				dp[i] = mx(dp[i], char('0' + b[j]) + dp[i-a[b[j]]]);
		}
		if (dp[i] == "")
			dp[i] = "cheissmart";
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 32512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    string n;
    cin >> n;
    long int k;
    cin >> k;
    long int dp[n.size()][k+1][2];
    dp[0][0][0] = 0;
    dp[0][0][1] = 1;
    dp[0][1][0] = 1;
    dp[0][1][1] = n[0] - '1';
    for (int i = 2; i <= k; i++){
        dp[0][i][0] = 0;
        dp[0][i][1] = 0;
    }
    for (int i = 1; i < n.size(); i++){
        for (int j = 0; j <= k; j++){
            if (n[i] == '0'){
                dp[i][j][0] = dp[i-1][j][0];
                if (j == 0){
                    dp[i][j][1] = dp[i-1][j][1];
                }else{
                    dp[i][j][1] = dp[i-1][j-1][1] * 9 + dp[i-1][j][1];
                }
            }else{
                if (j == 0){
                    dp[i][j][0] = 0;
                    dp[i][j][1] = dp[i-1][j][1] + dp[i-1][j][0];
                }else{
                    dp[i][j][0] = dp[i-1][j-1][0];
                    dp[i][j][1] = dp[i-1][j-1][1] * 9 + dp[i-1][j][1] + dp[i-1][j-1][0] * (n[i] - '0' - 1) + dp[i-1][j][0];
                }
            }
        }
    }
    // rep(i, n.size()){
    //     rep(j, k + 1){
    //         cout << dp[i][j][0] << " ";
    //     }cout << endl;
    // }

    // rep(i, n.size()){
    //     rep(j, k + 1){
    //         cout << dp[i][j][1] << " ";
    //     }cout << endl;
    // }
    cout << dp[n.size()-1][k][1] + dp[n.size()-1][k][0] << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
cnt=[0]*(10**5+1)
for i in range(N):
    cnt[A[i]]+=1
s=sum(A)
for i in range(Q):
    B,C=map(int,input().split())
    m=cnt[B]
    s-=B*cnt[B]
    cnt[B]=0
    s+=C*m
    cnt[C]+=m
    print(s)

Measured memory_bytes: 83968
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int n, k;
vector<double> dat;

//inputします
void input() {
	cin >> n >> k;
	dat.resize(n);
	ff(i, 0, n) {
		double g;
		cin >> g;
		dat[i] = (g + 1.0) / 2.0;
	}
}

//ライブラリ置き場

//main
int main() {
	input();
	long double pre = 0;
	ff(i, 0, k) {
		pre += dat[i];
	}
	long double ans = pre;
	ff(i, k , n) {
		pre += dat[i];
		pre -= dat[i - k];
		if (pre > ans)ans = pre;
	}
	cout <<setprecision(10)<< ans << endl;
	return 0;
}

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

public class Main {
	
	public static final int[][] move_dir = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	
	public static boolean is_ok(int x, int y, final int n){
		if(x < 0 || x >= n || y < 0 || y >= n){
			return false;
		}else{
			return true;
		}
	}
	
	public static boolean dfs(int deep, final int size, final int n, boolean using[][], int[][] map, int x, int y, int cur, 
			ArrayList<Integer> x_pos, ArrayList<Integer> y_pos, ArrayList<Integer> values, int painted, final int all){
		final int value = values.get(deep);
		
		/*
		System.out.println(deep + " " + n + " " + cur + "/" + value);
		
		System.out.println("---------------------------------------");
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(using[i][j]){
					System.out.print("x ");
				}else{
					System.out.print(map[i][j] + " ");
				}
			}
			System.out.println();
		}
		System.out.println("---------------------------------------");
//		*/
		if(cur > value){
			return false;
		}else if(cur == value){
			if(deep == size - 1 && painted == all){
				return true;
			}else if(deep == size - 1){
				return false;
			}
			
			final int nx = x_pos.get(deep + 1);
			final int ny = y_pos.get(deep + 1);
			
			return dfs(deep + 1, size, n, using, map, nx, ny, 0, x_pos, y_pos, values, painted, all);
		}else{
			for(int[] move : move_dir){
				final int nx = x + move[0];
				final int ny = y + move[1];
				
				if(!is_ok(nx, ny, n)){
					continue;
				}else if(using[ny][nx]){
					continue;
				}
				
				using[ny][nx] = true;
				if(dfs(deep, size, n, using, map, nx, ny, cur + map[ny][nx], x_pos, y_pos, values, painted + 1, all)){
					return true;
				}
				using[ny][nx] = false;
			}
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			boolean[][] using = new boolean[n][n];
			int[][] map = new int[n][n];
			ArrayList<Integer> x_pos = new ArrayList<Integer>();
			ArrayList<Integer> y_pos = new ArrayList<Integer>();
			ArrayList<Integer> values = new ArrayList<Integer>();
			
			int count = 0;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					final int input = sc.nextInt();
					
					if(input < 0){
						using[i][j] = true;
						y_pos.add(i);
						x_pos.add(j);
						values.add(-input);
					}else{
						count++;
						map[i][j] = input;
					}
				}
			}
			
			final int size = x_pos.size();
			
			final boolean ret = dfs(0, size, n, using, map, x_pos.get(0), y_pos.get(0), 0, x_pos, y_pos, values, 0, count);
			
			System.out.println(ret ? "YES" : "NO");
		}

		sc.close();
	}
}

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

int main() {
  int n, i;
  vector<int> p;
  cin >> n;
  p.push_back(0);
  while (cin >> i) p.push_back(i);
  int ans = 1;
  int m = p[1];
  for (i = 2; i <= n; i++) {
    if (p[i] <= m) ans++;
    m = min(m, p[i]);
  } 
  printf("%d\n", ans);
  return 0;}


Measured memory_bytes: 1400
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    if(n==3){
        cout<<"2 1 3 2 3"<<endl;
    }
    else if(n%2==0){
        int memo=n+1;
        int cnt=0;
        rep(i,n-1){
            rep(j,n){
                if(i+1+j+1==memo||i>=j) continue;
                cnt++;
            }
        }
        cout<<cnt<<endl;
        rep(i,n-1){
            rep(j,n){
                if(i+1+j+1==memo||i>=j) continue;
                cout<<i+1<<" "<<j+1<<endl;
            }
        }
    }
    else{
        // exit(1);
        pvec a(n/2+1);
        for(int i=0;i<n/2;i++){
            a[i]=P(i+1,n-(i+1));
            // cout<<i+1<<n-i-1<<endl;
        }
        a[n/2]=P(n,-1);
        int x=a.size();
        int cnt=0;
        for(int i=0;i<x-1;i++){
            for(int j=i+1;j<x;j++){
                //cout<<a[i].fs<<" "<<a[j].fs<<endl;
                //cout<<a[i].sc<<" "<<a[j].fs<<endl;
                cnt+=2;
                if(j==x-1) continue;
                //cout<<a[i].fs<<" "<<a[j].sc<<endl;
                //cout<<a[i].sc<<" "<<a[j].sc<<endl;
                cnt+=2;
            }
        }
        cout<<cnt<<endl;
        for(int i=0;i<x-1;i++){
            for(int j=i+1;j<x;j++){
                cout<<a[i].fs<<" "<<a[j].fs<<endl;
                cout<<a[i].sc<<" "<<a[j].fs<<endl;
                //cnt+=2;
                if(j==x-1) continue;
                cout<<a[i].fs<<" "<<a[j].sc<<endl;
                cout<<a[i].sc<<" "<<a[j].sc<<endl;
                //cnt+=2;
            }
        }
    }

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int q1, b, c1, c2, q2;

bool C(int x)
{
	if (x > q2) return false;

	if (b - (c1 * x) < 0) return false;
	//if (c2 * (q1 - x) < 0) return false;

	if (b - (c1 * x) >= c2 * (q1 - x)) return true;
	else return false;
}

int main()
{
	while (cin >> q1, q1)
	{
		cin >> b >> c1 >> c2 >> q2;

		if (c1 > b)
		{
			cout << "NA" << endl;
			continue;
		}

		int lb = 1, ub = 1000000;
		bool flag = false;

		for (int i = 0; i < 100; i++)
		{
			int mid = (lb + ub) / 2;
			if (C(mid))
			{
				lb = mid;
				flag = true;
			}
			else
			{
				ub = mid;
			}
		}

		if (flag)
		{
			int x = lb;
			int y = (b - (c1 * x)) / c2;
			cout << x << " " << y << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vi> p(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        p[a].pb(b);
    }
    int ans=0;
    int mi=101010;
    rep(i,n){
        if (i==mi){
            ans++;
            mi=101010;
        }
        for(auto e:p[i]) chmin(mi,e);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
const int N = 200005;
int n, kkk;
int M[N][30], Mn[N][30];

int get_max(int u, int v) {
    int x = log2(v - u + 1);
    return max(M[u][x], M[v - (1 << x) + 1][x]);
}

int get_min(int u, int v) {
    int x = log2(v - u + 1);
    return min(Mn[u][x], Mn[v - (1 << x) + 1][x]);
}

bool inc[N];

int main() {
    cin >> n >> kkk;
    vector <int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    inc[0] = false;
    for (int i = 1; i + kkk - 1 <= n; i++) {
        if (inc[i - 1] && a[i + kkk - 1] > a[i + kkk - 2]) {
            inc[i] = true;
            continue;
        }
        bool ok = true;
        for (int j = i + 1; j - i + 1 <= kkk; j++) {
            if (a[j] < a[j - 1]) {
                ok = false;
                i = j - 1;
                break;
            }
        }
        inc[i] = ok;
    }
    for (int i = 1; i <= n; i++) {
        M[i][0] = a[i];
        Mn[i][0] = a[i];
    }
    for (int k = 1; (1 << k) <= n; k++) {
        for (int i = 1; i + (1 << k) - 1 <= n; i++) {
            M[i][k] = max(M[i][k - 1], M[i + (1 << (k - 1))][k - 1]);
        }
    }
    for (int k = 1; (1 << k) <= n; k++) {
        for (int i = 1; i + (1 << k) - 1 <= n; i++) {
            Mn[i][k] = min(Mn[i][k - 1], Mn[i + (1 << (k - 1))][k - 1]);
        }
    }
    int i = 1, j = kkk;
    a[0] = n + 1;
    int ans = 0;
    bool ok = false;
    while (j <= n) {
        if (inc[i]) {
                //cout << i << " das\n";
            ok = true;
            j++;
            i++;
            continue;
        }
        int mn = get_min(i, j - 1);
        int mx = get_max(i, j - 1);
        if (a[i - 1] < mn && mx < a[j]) {
            //cout << a[i - 1] << " " << mn << " " << mx << " " << a[j] << "\n";
        } else {
            //cout << i << "\n";
            ans++;
        }
        j++;
        i++;
    }
    if (ok) ++ ans;
    cout << ans;
	return 0;
}


Measured memory_bytes: 48128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	int ct=0;
	for(int j=1;j<=n;j++)
	{
		if(arr[arr[j]]==j)
		ct++;
	}
	cout<<ct/2<<"\n";
}

Measured memory_bytes: 640
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
a = intl()

ans = 0
for i in range(1,n):
	if a[i-1] > a[i]:
		ans += (a[i-1] - a[i])
		a[i] += (a[i-1] - a[i])
print(ans)

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

int main()
{
    int n;
    cin>>n;
    int a[n];

    for(int i=0; i<n; i++)cin>>a[i];
    sort(a,a+n);
    int diff = a[n/2]-a[n/2 -1];
    cout<<diff<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int a[3]; cin >> a[0] >> a[1] >> a[2];
  int sum=a[0]+a[1]+a[2];
  sort(a,a+3);
  int ans=0;
  if((a[2]*3-sum)%2==1) {a[2]++; sum+=2; ans=1;}
  ans+=(a[2]*3-sum)/2;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int n;
	vector<int> u, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (i % 2) {
			v.push_back(a);
		} else {
			u.push_back(a);
		}
	}
	if (n % 2) {
		for (int i = u.size() - 1; i >= 0; i--) {
			cout << u[i] << ' ';
		}
		for (int i = 0; i < v.size(); i++) {
			cout << v[i] << ' ';
		}
	} else {
		for (int i = v.size() - 1; i >= 0; i--) {
			cout << v[i] << ' ';
		}
		for (int i = 0; i < u.size(); i++) {
			cout << u[i] << ' ';
		}
	}
	return 0;
}


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

int main() {
  ll n,c=0;
  
  string s;
  cin>>s;
  n=s.length();
  for(ll i=0;i<n;i++)
  {
    if(i  & 1)
    {
      if(s[i]!='L' && s[i]!='U' && s[i]!='D')
      {
        c=1;
        break;
      }
    }
      else
      {
        if(s[i]!= 'R' && s[i]!= 'U' && s[i]!='D')
      {
        c=1;
       // cout<<"hello "<<i<<endl;
        break;
      }
      }
    
  }
  
  
  if(c)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  //cout<<c<<endl;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[100000];

        for (int x=1; x<=100; x++) {
            for (int y=1; y<=100; y++) {
                for (int z=1; z<=100; z++) {
                    int ans = x * x + y * y + z * z + x * y + y * z + z * x;
                    arr[ans-1]++;
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++) {
            sb.append(arr[i] + "\n");
        }

        System.out.print(sb.toString());
    }


}



Measured memory_bytes: 39900
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define R cin>>
#define C cout<<
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  string s;
  R s;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] != s[s.size() - i - 1])ans++;
  }
  C ans / 2;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N){
  for (int i = 0; i < N ; i++){
    for(int j = N - 1; j >= i; j--){
       if(A[j].value < A[j - 1].value){
         Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
       }
    }
  }
}

void selection(struct Card A[], int N){
 for(int i = 0; i < N; i++){
  int minj = i;
  for(int j = i; j < N; j++){
      if(A[j].value < A[minj].value) minj = j;
  }
  Card t = A[i]; A[i] = A[minj]; A[minj] = t;
 }
}

void print(struct Card A[], int N){
  for(int i = 0; i < N; i++){
    if(i > 0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
} 

bool isStable(struct Card C1[], struct Card C2[], int N){
  for(int i = 0; i < N; i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N;
  char ch;
  
  cin >> N;
  for(int i = 0;i < N; i++){
    cin >> C1[i].suit >> C1[i].value;
  }

  for(int i = 0; i < N; i++) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);
  
  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if(isStable(C1, C2, N)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
H, W, A, B = map(int, input().split())

ret = [['0'] * W for _ in range(H)]

A, B = B, A
for y in range(A) :
    for x in range(B, W) :
        ret[y][x] = '1'

for y in range(A, H) :
    for x in range(B) :
        ret[y][x] = '1'
        
for y in range(H) :
    print(''.join(ret[y]))

Measured memory_bytes: 48752
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H, W; cin >> H >> W;
  int A, B; cin >> A >> B;

  char res{'0'};
  constexpr char ICHI = 0x0001;
  for (int row = 0; row < H; ++row){
    res ^= ICHI;
    if(row == B) res ^= ICHI;
    for (int column = 0; column < W; ++column){
      if(column == A) res ^= ICHI;
      cout << res;
    }
    cout << CRLF;
  }

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

//a^b(mod p)をO(log b)で求める
ll calc(ll a,ll b){
  if(!b) return 1;
  if(b%2) return (a*calc(a,b-1))%MOD;
  ll d=calc(a,b/2);
  return (d*d)%MOD;
}

//aCb(mod MOD)
ll modcom(ll a,ll b){
  if(a<b) return 0; //a<bの場合は0
  if(a/2<b) b=a-b; //計算量削減

  ll rtn=1;
  for(ll i=a;i>a-b;i--){
    rtn*=i;
    rtn%=MOD;
  }
  for(ll i=b;i>0;i--){
    rtn*=calc(i,MOD-2);
    rtn%=MOD;
  }
  return rtn;
}

int main(){
  ll n,k;cin>>n>>k;

  for(ll i=1;i<=k;i++){
    ll ans=modcom(n-k+1,i);
    ans*=modcom(k-1,i-1);
    ans%=MOD;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<usize>()[0];

    println!("{}", n*n-a);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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; }

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

int main(){
    ios::sync_with_stdio(false);
    int n,x;
    int a[105];
    cin >> n >> x;
    rep(i,n){
        cin >> a[i];
    }
    int ind=0;
    sort(a,a+n);
    while((x>=0)&&(ind<n)){
        x-=a[ind];
        ind++;
    }
    if(x!=0) cout << ind-1 << endl;
    else cout << ind << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    for(int i=1;i<=5;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=5;i++)
        if(!a[i])
            cout<<i;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[114514];
void f_init(int n) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int ans;
signed main() {
	int m, d;
	cin >> m >> d;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			if (i == j / 10 * (j % 10) && 2 <= j / 10 && 2 <= j % 10) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

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

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<ll> sum(n+1,0);
    rep(i,n)sum[i+1]=sum[i]+a[i];
    ll ans=INF;
    for(int i=1;i<n;i++){
       chmin(ans,abs(sum[n]-2*sum[i]));
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 2560
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

ll power(ll a, ll b){
  ll ans = 1;
  if(b%2==0){
    REP(i, b/2){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans;
  }else{
    b = b/2;
    REP(i, b){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans* a;
  }
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(void){

string s;
cin>>s;
int ans = 0;

if(s[0]=='R'){
  if(s[1]=='R' && s[2]=='R') ans = 3;
  else if(s[1]=='R') ans+=2;
  else ans = 1;
}else if(s[1]=='R'){
  if(s[2]=='R')ans = 2;
  else ans = 1;
}else if(s[2]=='R') ans = 1;
cout<<ans<<endl;
 return 0;

}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int N;
    cin >> N;
    vector<int> cols(3,0);
    long ans=1L;
    long MOD = 1e9+7;
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        int mul = 0;
        for(auto c:cols){
            if(c == A){
                mul++;
            }
        }
        ans *= mul;
        ans %= MOD;
        for(auto& c:cols){
            if(c == A){
                c++;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::ops::Range;

#[derive(Clone, Debug)]
pub struct Scan2<I, St, F> {
    iter: I,
    f: F,
    state: St,
}

impl<I, St, F> Scan2<I, St, F> {
    fn new(iter: I, state: St, f: F) -> Scan2<I, St, F> {
        Scan2 { iter: iter, state: state, f: f }
    }
}

impl<I, St, F> Iterator for Scan2<I, St, F>
where
    I: Iterator,
    F: Fn(&St, I::Item) -> St,
    St: Clone,
{
    type Item = St;

    #[inline]
    fn next(&mut self) -> Option<St> {
        let o = self.iter.next();
        if let Some(a) = o {
            self.state = (self.f)(&self.state, a);
            Some(self.state.clone())
        } else {
            None
        }
    }
}

trait Iterator2 {
    type Item;

    fn scan2<St, F>(self, initial_state: St, f: F) -> Scan2<Self, St, F>
    where
        F: Fn(&St, Self::Item) -> St,
        Self: std::marker::Sized,
    {
        Scan2::new(self, initial_state, f)
    }
}

impl<T> Iterator2 for Range<T> {
    type Item = T;
}

fn solve(n: i32, a: Vec<i32>) -> i32 {
    (0..n)
        .scan2(0, |&i, _| a[i as usize] - 1)
        .position(|i| i == 1)
        .map(|i| i as i32 + 1)
        .unwrap_or(-1)
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n = s.trim().parse().ok().unwrap();
    let a = (0..n)
        .map(|_| {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            s.trim().parse().ok().unwrap()
        })
        .collect();
    let ans = solve(n, a);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int F[100][5][2];
int P[100][11];
int main(){
    int N;
    int pro;
    int max = -1e9;
    int c;
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<2;k++){
                cin  >> F[i][j][k];
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin >> P[i][j];
        }
    }
    for(int i=1;i<1<<10;i++){
        pro = 0;
        for(int j=0;j<N;j++){
            c = 0;
            for(int k=0;k<10;k++){
                if(((1 << k)&i) && F[j][k/2][k%2]) c++;
            }
            pro += P[j][c];
        }
        if(pro > max) max = pro;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{   int a,b;
    cin>>a>>b;
    if((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12 ) &&
       (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12 ))
        cout<<"Yes";
    else if ((a==4 || a==6 || a==9 || a==11) &&
       (b==4 || b==6 || b==9 || b==11) )
       cout<<"Yes";
    else
        cout<<"No";
return 0;
}






Measured memory_bytes: 3616
#include<iostream>
//#include<stdio.h>
#include<string>
//#include<typeinfo>
//#include<sstream>
//#include<algorithm>
using namespace std;

int main(void) {
	int N;
	string str;
	string strResult = "";
	cin >> N;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		int x = str[i] - 'A';
		x = (x + N) % 26;
		printf("%c", x + 'A');
	}

	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
  /******input******/
  int N;
  cin >> N;
  //  vector<int> a;
  //  for( int i = 0; i < N; i++ ){
  //    int tmp;
  //    cin >> tmp;
  //    a.push_back(tmp);
  //  }
  int a[N];
  for( int i = 0; i < N; i++){
    cin >> a[i];
  }
  //  for( int j = 0; j < N; j++){
  //    cout << "a[" << j << "]: " << a[j] << "\n";
  //  }

  /******input******/


  /******sort******/
  //  std::sort(a,&a[N-1], greater<int>()); // This is wrong.
  //  sort(a, a + N, greater<int>());
  sort(a, &a[N],greater<int>());

  //  for( int j = 0; j < N; j++){
  //    cout << "a[" << j << "]: " << a[j] << "\n";
  //  }
  /******sort******/


  /******get score******/
  int Alice = 0;
  int Bob = 0;
  for( int k = 0; k < N; k++){
    //    cout << "a[" << k << "]:" << a[k] << "\n";
    if( k%2 == 0 ) Alice += a[k];
    if( k%2 == 1 ) Bob += a[k];
  }
  //  cout << Alice << "\n";
  //  cout << Bob << "\n";

  /******get score******/


  cout << Alice-Bob << "\n";

  return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())


def keta(n):
    result = 0
    for s in str(n):
        result += int(s)
    return result

ans = 0
for i in range(1, N+1):
    k = keta(i)
    if A <= k <= B:
        ans += i
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a,b;
	cin >> a >> b;
	bool flag = false;
	for(int i = 0; i < a.size(); i++) {
		bool flag2 = true;
		for(int j = 0; j < a.size(); j++) {
			int k = (i+j)%a.size();
			flag2 = flag2 && (a.at(k)==b.at(j));
		}
		flag = flag || flag2;
	}
	cout << ((flag)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
/*

0565: lunch

*/

#include <stdio.h>

#define KINDOFPASTA 3
#define KINDOFJUICE 2


int getMin(int array[], int n);

int main(void){
	
	int pasta[KINDOFPASTA];
	int juice[KINDOFJUICE];
	int i, k;
	int minPasta, minJuice;
	int price;
	
	for(i=0; i<KINDOFPASTA; i++){
		
		scanf("%d", &pasta[i]);
		
	}
	
	for(i=0; i<KINDOFJUICE; i++){
		
		scanf("%d", &juice[i]);
		
	}
	
	
	minPasta = getMin(pasta, KINDOFPASTA);
	minJuice = getMin(juice, KINDOFJUICE);
	
	price = minPasta + minJuice - 50;
	
	
	
	printf("%d\n", price);
	
	return 0;
	
}

int getMin(int array[], int n){
	
	int i;
	int min = array[0];
	
	for(i=1; i<n; i++){
		
		if(min > array[i]){
			
			min = array[i];
			
		}
		
	}
	
	return min;
	
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  long int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 3616
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var m = int.Parse(Console.ReadLine().Trim());
        var cards = Enumerable.Range(1, 2 * n).ToList();
        for (int i = 0; i < m; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            if (k == 0) GetShuffle(cards);
            else GetCut(cards, k);
        }
        foreach (var x in cards)
            Console.WriteLine(x);
    }
    public static void GetCut (List<int> c,int k)
    {
        var templist = new List<int>();
        for (int i = 0; i < k; i++) templist.Add(c[i]);
        foreach (var x in templist)
        {
            c.Remove(x);
            c.Add(x);
        }
    }
    public static void GetShuffle (List<int>  c)
    {
        var templist = new List<int>();
        var a = c.Count() / 2;
        for (int i = 0; i < a; i++)
        {
            templist.Add(c[i]);
            templist.Add(c[a + i]);
        }
        c.RemoveAll(x => x > 0);
        foreach (var x in templist) c.Add(x);
    }
}

Measured memory_bytes: 10052