akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)
#define forl(n) for (ll i = 0 ; i < n ; i++)

int main() {
    ios::sync_with_stdio(false);
    int n, k;
  	cin >> n >> k;
	int a[n];
    for1(n) cin >> a[i];
	int b = 1;
	n -= k;
	while( n > 0 ) {
		n = n - k + 1;//重疊部分 +1 
	    b++;//全都是 1 
	}
    cout << b;
}

Measured memory_bytes: 4024
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//abc142E
int main(void) {
  int n, m, i, j, k, tmp, big=1000000;
  scanf("%d %d", &n, &m);

  int com=pow(2, n), a[m], b[m], c[m][12], dp[com + 1];
  for(i=0; i < m; i++){
    scanf("%d %d", &a[i], &b[i]);
    for(j=0; j < b[i]; j++)
      scanf("%d", &c[i][j]);
  }
  for(i=0; i <= com; i++)
    dp[i]=big;

  for(i=0; i < m; i++){
    tmp=0;
    for(j=0; j < b[i]; j++)
      tmp+=pow(2, c[i][j] - 1);
    //printf("tmp=%d\n", tmp);

    if(dp[tmp] > a[i]){
      //printf("dp[%d]<=a[%d] = %d<=%d\n", tmp, i, dp[tmp], a[i]);
      dp[tmp]=a[i];

    }
    for(j=0; j < com; j++){
      if(dp[j] != big && dp[j | tmp] > dp[j] + a[i]){
        //printf("dp[%d]<= dp[%d]+a[%d] = %d+%d\n", j | tmp, j, i, dp[j], a[i]);
        dp[j | tmp]=dp[j] + a[i];
      }
    }
  }

  //for(i=0; i < com; i++) printf("dp[%d]=%d\n", i, dp[i]);

  if(dp[com - 1] == big) printf("-1");
  else printf("%d", dp[com - 1]);
  return 0;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int r, c;
    int X[101][101] = {0};

    cin >> r >> c;
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> X[i][j];
            X[i][c] += X[i][j];
            X[r][j] += X[i][j];
            X[r][c] += X[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            if (j > 0) {
                cout << " ";
            }
            cout << X[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		scanner.close();
		int yakusu = 0;

		for (int n = 1; n <= N; n = n + 2) {
			int count = 0;
			for (int m = 1; m <= n; m = m + 2) {
				if (n % m == 0) {
					count++;
				}

				if (count == 8) {
					yakusu++;
				}
			}
		}
		System.out.println(yakusu);
	}
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int C[500], S[500], F[500];

int main(void)
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; ++i) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 0; i < N; ++i) {
		int tim = 0;
		for (int j = i; j < N - 1; ++j) {
			if (tim < S[j]) {
				tim = S[j];
			}
			else {
				if (tim % F[j]) {
					tim /= F[j];
					tim *= F[j];
					tim += F[j];
				}
			}
			tim += C[j];
		}
		cout << tim << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut ans = 0;
    let mut part_sum = a.iter().sum::<u64>();
    let divisor = 10_u64.pow(9) + 7;
    // println!("ps: {}", part_sum);
    // println!("{:?}", a);
    for i in 1..n {
        // println!("ai-1: {}", a[i - 1]);
        part_sum = (part_sum + divisor - a[i - 1]) % divisor;
        // println!("ps: {}", part_sum);
        ans = (ans + (a[i - 1] * part_sum) % divisor) % divisor;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5604
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 5000
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,LL b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}
void upd(int &a,int b){a=add(a,b);}

int n;
vector<int> G[MAXN+5];
int dp[MAXN+5][MAXN+5],tmp[MAXN+5],f[MAXN+5],siz[MAXN+5];

void dfs(int x,int fa){
	siz[x]=1;dp[x][1]=1;
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==fa)continue; 
		dfs(v,x);
		for(int j=1;j<=siz[x]+siz[v];j++)tmp[j]=0;
		for(int j=1;j<=siz[x];j++)
			for(int k=0;k<=siz[v];k++)
			upd(tmp[j+k],mul(dp[x][j],dp[v][k]));
		siz[x]+=siz[v];
		for(int j=1;j<=siz[x];j++)dp[x][j]=tmp[j];
	}
	for(int j=2;j<=siz[x];j+=2)
	dp[x][0]=dec(dp[x][0],mul(dp[x][j],f[j]));
}

int main(){
	n=read();
	f[0]=1;
	for(int i=2;i<=n;i+=2)f[i]=mul(f[i-2],i-1);
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	printf("%d",dec(0,dp[1][0]));
}

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

int main(){
    int N; cin >> N;
    vector<double> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double res = v[0];
    for(int i = 1 ; i < N; i++){
        res = (res + v[i]) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, k;
  cin >> n >> k;
  V x(n);
  REP(i, n) {
    cin >> x[i];
  }
  int sum = 0;
  REP(i, n) {
    if (x[i] < k-x[i]) sum += x[i];
    else sum += k-x[i];
  }
  dump(sum*2);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll a, p;
    cin >> a >> p;

    p += (a * 3);

    const ll ans = p >> 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;
/*
	  br = new BufferedReader(new FileReader("input.txt"));
	  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
	  br = new BufferedReader(new InputStreamReader(System.in));
	  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			int n = readInt();
			int a = readInt();
			int b = readInt();
			if(a%2 == b%2) {
				pw.println("Alice");
			}
			else {
				pw.println("Borys");
			}
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private static String nextLine() throws IOException  {
		if(!br.ready()) {
			exitImmediately();
		}
		st = null;
		return br.readLine();
	}

	private static String nextToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			if(!br.ready()) {
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

Measured memory_bytes: 21460
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<functional>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int v[100000], e[100001] = {}, o[100001] = {};
	for(int i = 0; i < n; i++){
		scanf("%d", &v[i]);
		if(i & 1) o[v[i]]++;
		else e[v[i]]++;
	}
	vector<pair<int, int>> v1, v2;
	for(int i = 1; i <= 100000; i++){
		if(e[i] > 0) v1.push_back(make_pair(e[i], i));
		if(o[i] > 0) v2.push_back(make_pair(o[i], i));
	}
	v1.push_back(make_pair(0, 0)); v2.push_back(make_pair(0, 0));
	sort(begin(v1), end(v1), greater<pair<int, int>>());
	sort(begin(v2), end(v2), greater<pair<int, int>>());
	int res;
	if(v1[0].second != v2[0].second) res = v1[0].first + v2[0].first;
	else res = max(v1[0].first + v2[1].first, v1[1].first + v2[0].first);
	printf("%d\n", n - res);
	return 0;
}

Measured memory_bytes: 2428
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,x,ret;
vi a;
vpi operation;



struct SegmentTree {
private:
    int n;
    vi node;

public:
    SegmentTree(vi v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 1e+14);
        REP(i,sz) node[i+n-1] = v[i];
        REPN(i,n-2) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(int k, int x){
        k += n-1;
        node[k] = x;
        while(k){
            k = (k-1)/2;
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }
    int getmin(int a, int b, int k=0, int l=0, int r=-1){
        if(r<0) r=n;
        if(r<=a || b<=l) return 1e+14;
        if(a<=l && r<=b) return node[k];
        return min( getmin(a,b,2*k+1,l,(l+r)/2),getmin(a,b,2*k+2,(l+r)/2,r) );
    }
};

signed main(){

    I(n); I(x);
    a.resize(n);
    REP(i,n) I(a[i]);
    REP(i,n) a.pb(a[i]);
    REP(i,n) a.pb(a[i]);

    SegmentTree st = SegmentTree(a);
    
    ret = 1e+17;
    REP(cast,n){
        int casttime = cast * x;
        REP(i,n) casttime += st.getmin(i+n-cast-1, i+n);
        cerr << casttime << endl;
        ret = min(ret, casttime);
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
# ABC057B - Checkpoints
n, m = list(map(int, input().rstrip().split()))
st = [list(map(int, input().rstrip().split())) for _ in range(n)]
ch = [list(map(int, input().rstrip().split())) for _ in range(m)]
dis_lst = []
for i in st:
    temp_lst = []
    for j in ch:
        temp_lst.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
    dis_lst.append(temp_lst.index(min(temp_lst)) + 1)

for i in dis_lst:
    print(i)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int num,count=1;
  scanf("%d",&num);
  while(num!=4 && num!=2 && num!=1){
    if(num%2==0)
      num/=2;
    else
      num=num*3+1;
    count++;
  }
  printf("%d\n",count+3);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll p=min(k,x/d);
		
	k-=p;
	x-=p*d;
	if(k%2==0)
		cout<<x;
	else
		cout<<d-x;
	return 0;
	
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        cout<<(1000-n%1000)%1000<<endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int t = abs(a-b);
	if(t%2 == 1) cout<<"Borys"<<endl;
	else if(t%2 == 0) cout<<"Alice"<<endl;
	else cout<<"Draw"<<endl;
	return 0;
}


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

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

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    vector<ll> b(m);
    rep (i, m)
        cin >> b[i];

    ll time = 0;
    rep (i, m)
        time += b[i];

    int ans = 0;
    for (int i = 0, j = m - 1; i <= n; i++)
    {
        while (time > k && j >= 0)
            time -= b[j--];

        if (time > k)
            break;

        ans = max(i + j + 1, ans);

        if (i == n)
            break;

        time += a[i];
    }

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

Measured memory_bytes: 6380
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

   cin>>n;


     ll ara[n+2];

     input(ara,n+1);

     ll bra[n+2];

     input(bra,n);


     i=0;
     j=0;

    while(i<n && j<n)
    {
        ll mi=min(ara[i],bra[j]);

        ans+=mi;

        ara[i]-=mi;

        bra[j]-=mi;


        if(bra[j] && i+1<n+1)
        {
             mi=min(ara[i+1],bra[j]);

             ara[i+1]-=mi;

             ans+=mi;

        }
        i++;
        j++;
    }

    cout<<ans<<endl;












}



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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int r=0,b=0;
  for(int i=0;i<S.size();i++)
    if(S[i]=='R')
      r++;
    else
      b++;
  if(b<r)
    cout<<"Yes";
  else
    cout<<"No";
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 10**18
for ab in range(max(X, Y) * 2 + 10):
    a = max(0, X - ab // 2)
    b = max(0, Y - ab // 2)
    ans = min(ans, A * a + B * b + C * ab)
print(ans)


Measured memory_bytes: 3060
def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    m = A[0]
    S = 0

    for a in A:
        if m - a > 0:
            S += m - a
        if m < a:
            m = a
    
    print(S)


if __name__ == "__main__":
    main()

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

using namespace std;


string s;

int main(){
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size() - 1; i++){
    	ans+=(s[i] != s[i+1]);
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,coin,day;
   coin=0;
   day=0;
   cin>>a>>b>>c;
   while(1){
       if(coin>=c){
           break;
       }
       coin=coin+a;
       day=day+1;
       if(day%7==0){
           coin=coin+b;
       }
   }
   cout<<day<<endl;
}


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

using namespace std;

int main()
{
  int n,l;
  cin >> n >> l;

  string ss[n];
  for (int i = 0; i < n; ++i) {
    cin >> ss[i];
  }
  sort(ss, ss+n);

  for (string s : ss) {
    cout << s;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 5010
#define M 1000000007
int he[N],ne[N<<1],e[N<<1],cnt,n,sz[N],dp[N][N],g[N];
void add(int u,int v){ne[++cnt]=he[u];he[u]=cnt;e[cnt]=v;}
void dfs(int x,int f){
    sz[x]=1; dp[x][1]=1;
    for (int i=he[x];i;i=ne[i]){
        int y=e[i];
        if (y==f) continue;
        dfs(y,x);
        int pre=sz[x]; sz[x]+=sz[y];
        int sum=0;
        for (int j=1;j<=sz[y];j++) (sum+=dp[y][j]*g[j]%M)%=M;
        for (int i=sz[x];i;i--){
            int tmp=-dp[x][i]*sum%M; (tmp+=M)%=M;
            for (int j=max(1LL,i-pre);j<=min(i,sz[y]);j++) (tmp+=dp[x][i-j]*dp[y][j]%M)%=M;
            dp[x][i]=tmp;
        }
    }
}
signed main(){
    scanf("%lld",&n);
    for (int i=1;i<n;i++){
        int u,v; scanf("%lld%lld",&u,&v);
        add(u,v); add(v,u);
    }
    g[0]=1;
    for (int i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%M;
    dfs(1,0);
    int ans=0;
    for (int i=1;i<=n;i++) (ans+=dp[1][i]*g[i]%M)%=M;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 195072
def solve(n):
    l = [1 for i in range(n+1)]
    for k in range(2,n+1):
        tmp = k
        i = 2
        while tmp > 1:
            if tmp % i == 0:
                tmp = tmp // i
                l[i] += 1
            else:
                i += 1
    res = 1
    for i in l:
        res = res * i % (10**9+7)
    return res

if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Measured memory_bytes: 65096
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}


int main() {

    get3(n,k,s);
    if(s==1000000000) {
        rep(i,k)
            printf("%lld ", s);
        rep2(i,k,n)
            printf("%lld ", s-1);
    }

    else {
        rep(i,k)
            printf("%lld ", s);
        rep2(i,k,n)
            printf("%lld ", s+1);
    }
    
    return 0;  
}

Measured memory_bytes: 1280
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
p = map(int, raw_input().split())
ans = 0
for i in range(1, N - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        ans += 1
print ans

Measured memory_bytes: 2936
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

LL N,K;
LL A[200000];

mint ans = 1;

void solve(){
	sort(A,A+N,[](int x,int y){return abs(x)>abs(y);});
	vector<LL> pos,neg;
	int Np = 0;
	for(int i=0;i<N;i++){
		if(A[i]>=0){
			pos.push_back(A[i]);
			if(A[i]>0) Np++;
		}
		if(A[i]<0){
			neg.push_back(A[i]);
		}
	}

	if(Np==0){
		if(K%2==0){
			for(int i=0;i<K;i++) ans *= mint(A[i]);
		}else{
			for(int i=N-1;i>=N-K;i--) ans *= mint(A[i]);
		}
		return;
	}

	vector<LL> cand;
	if(K%2==0){
		for(int i=0;i+1<pos.size();i+=2) cand.push_back(pos[i]*pos[i+1]);
		for(int i=0;i+1<neg.size();i+=2) cand.push_back(neg[i]*neg[i+1]);
	}else{
		ans *= mint(pos[0]);
		for(int i=1;i+1<pos.size();i+=2) cand.push_back(pos[i]*pos[i+1]);
		for(int i=0;i+1<neg.size();i+=2) cand.push_back(neg[i]*neg[i+1]);
	}
	if(neg.size()>0)cand.push_back((*(--pos.end()))*(*(--neg.end())));
	sort(cand.begin(),cand.end(),greater<LL>());

	for(int i=0;i<K/2;i++){
		ans *= mint(cand[i]);
		//cout << cand[i] << endl;
	}
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 7688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A = sc.nextInt();
		long B = sc.nextInt();

		long[] X = new long[N];
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0L;

		for (int i = 0; i < N - 1; i++) {
			ans += Math.min((X[i + 1] - X[i]) * A, B);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 33876
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from bisect import bisect_left as bl, bisect_right as br
n,q = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def sub(x, i):
    # i番目を取れるかどうか
    v = a[i]
    target = x - (v-x)
    num = i - bl(a, target-0.1)
    return num+1 >= n - i

anss = [None] * q
cumsum1 = [0] * n
cumsum0 = [0] * n
cumsum = [0] * n
for i in range(n):
    if i%2:
        cumsum1[i] = cumsum1[i-1] + a[i]
        cumsum0[i] = cumsum0[i-1]
    else:
        cumsum0[i] = cumsum0[i-1] + a[i]
        cumsum1[i] = cumsum1[i-1]
    cumsum[i] = cumsum[i-1] + a[i]

for j in range(q):
    x = int(input())
    l = 0
    r = n-1
    while l<r-1:
        m = (r+l)//2
        if sub(x, m):
            r = m
        else:
            l = m
    # rまではxより大きくて取れる
#     ans = sum(a[r:])
    ans = cumsum[-1] - cumsum[r-1]
    ii = r-2 - (n-r-1)
    if ii>=0:
        if ii%2:
            ans += cumsum1[ii]
        else:
            ans += cumsum0[ii]
    anss[j] = ans
write("\n".join(map(str, anss)))

Measured memory_bytes: 108712
#include <iostream>
#include <math.h>
using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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


int main(){
    ll int N, K, ans;
    cin >> N >> K;
    ans = min(N % K, abs(N % K - K));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

bool sosuu[50001];

void init(){
	for (int i = 0; i < 50001; i++)sosuu[i] = true;

	sosuu[0] = sosuu[1] = false;

	for (int i = 2; i*i < 50001; i++){
		if (sosuu[i]){
			for (int j = i * 2; j < 50001; j += i)sosuu[j] = false;
		}
	}
}

int main(){

	init();

	int n;
	while (std::cin >> n, n){

		int cnt = 0;

		for (int i = 2; i <= n / 2; i++){
			if (sosuu[i] && sosuu[n - i])cnt++;
		}

		std::cout << cnt << std::endl;

	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
int main()
{
    cin>>n;
    for(int i=1;i<n;++i)
    {
        int x;cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;++i)
        cout<<a[i]<<endl;
}


Measured memory_bytes: 4360
fn main() {
    let n = read();
    let mut ans: usize = 1;
    let mut a = vec![];
    for _ in 0..n {
        let v: usize = read();
        if v == 0 {
            ans = 0;
        }
        a.push(v);
    }
    for i in 0..n {
        match ans.checked_mul(a[i]) {
            Some(v) => ans = v,
            None => {
                println!("-1");
                exit(0)
            }
        }
    }
    if ans <= 10usize.pow(18) {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2912
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		sc.close();
		for (int i = 0; i < 10; i++) {
			x = r * x - D;
			System.out.println(x);
		}

	}
}

Measured memory_bytes: 21844
carda, cardb, cardc = list(map(int,input().split()))
nokori = int(input())
while carda >= cardb:
  cardb *= 2
  nokori -= 1
while cardb >= cardc:
  cardc *= 2
  nokori -= 1
if nokori >= 0:
  print('Yes')
else:
  print('No')

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

int main(){
  int a,b;
  int con = 1;
  int cnt = 0;
  cin >> a >> b;
  while(true){
    if(con >= b){
      break;
    }
    con = con - 1 + a;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int debt = 100000, n, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		debt *= 1.05;
		debt += 999;
		debt *= 0.001;
		debt *= 1000;
	}
	printf("%d\n", debt);
	return 0;
}

Measured memory_bytes: 592
//Created by Aigerim.
//© 2019 Aigerim.
                                                                               
/***************************************************************                                       ****       ****
**                                                                                                  *       *   *      *
**  *********   **          *********    **           **  ********     **        **                 *        * *       *
**      **      **          **     **     **         **   **           **        **                 *         *        *
**      **      **          **     **      **       **    **           **        **                  *                *    
**      **      **          **     **       **     **     ********     **        **                   *              *
**      **      **          **     **        **   **      **           **        **                    *            *        
**      **      *********   **     **         ** **       **            *        *                       *         *
**  *********   *********   *********          ***        ********       ********                          *      *
**                                                                                                           *  *
**                                                                                                             *
***************************************************************/  
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout<<max(a*b,c*d);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
int main()
{long int n;
 std::cin>>n;
 int a[n],b[n],c[n];
 for(long int i=0;i<n;i++)
  std:: cin>>a[i]>>b[i]>>c[i];
 long int dp[n][3];
 dp[0][0]=a[0];
 dp[0][1]=b[0];
 dp[0][2]=c[0];
 for(long int i=1;i<n;i++)
 {  for(int j=0;j<=2;j++)
 {long int emp;
  if(j==0)
    emp=a[i];
  else if(j==1)
    emp=b[i];
  else
    emp=c[i];
 dp[i][j]=std::max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+emp;
 }}
 std::cout<<std::max(dp[n-1][0],std::max(dp[n-1][1],dp[n-1][2]));
}

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

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

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<functional>
#include<ctime>
#include<cassert>
#include<cstring>
#include<unordered_map>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define fo(a,b) for(int o=a;o<=b;++o)
#define fdi(a,b) for(int i=a;i>=b;--i)
#define fdj(a,b) for(int j=a;j>=b;--j)
#define fdo(a,b) for(int o=a;o>=b;--o)
#define pb push_back
#define mp make_pair
#ifdef LOCAL
#define err(format, ...) fprintf(stderr, format, __VA_ARGS__);
#else
#define err(format, ...) while(false) {}
#endif
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef vector<int> vi;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

/////////////////////////////////

int n, a, b;

void solve0() {
	vi ans;
	int rb = b - 1;
	fi(n - a + 1, n) {
		ans.pb(i);
	}		
	for(int i = n - a; i >= 1; i -= a) {
		if (1 + max(0, i - a) >= rb) {
			fo(max(1, i - a + 1), i) {
				ans.pb(o);
			}
			rb--;
		}	else {
			int t = rb - max(0, i - a);
			if (t > a || t < 0) return;
			int q = min(i, a);
			fj(0, q - t - 1) {
				ans.pb(max(1, i - a + 1) + j);
			}
			fj(0, t - 1) {
				ans.pb(i - j);
			}
			rb -= t;
		}
	}
	if (rb != 0) return;
	for(int z : ans) {
		printf("%d ", z);
	}
	exit(0);
}

void solve() {
  if (a + b <= n + 1) {
		solve0();  	
  }
	printf("-1\n");	
}

int main() {
#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d %d", &n, &a, &b);	
	solve();		

	
#ifdef LOCAL
	fprintf(stderr, "ELAPSED TIME: %.3lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 4080
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	vector<int> n(4);
	bool f[4] = { 0,0,0,0 };
	for (int i = 0; i < 4; i++) {
		cin >> n[i];
		if (n[i] == 1) f[0] = true;
		if (n[i] == 9) f[1] = true;
		if (n[i] == 7) f[2] = true;
		if (n[i] == 4) f[3] = true;
	}

	bool ans=true;
	for (int i = 0; i < 4; i++) {
		if(!f[i]) ans=false;
	}

	cout << (ans?"YES":"NO") << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String C[] = new String[N];
		String C1[] = new String[N];
		String C2[] = new String[N];
		for (int i = 0; i < N; i++) {
			C[i] = sc.next();
			C1[i] = C[i];
			C2[i] = C[i];
		}

		BubbleSort(C1);

		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				System.out.println(C1[i]);
			} else {
				System.out.print(C1[i] + " ");
			}
		}

		if (isStable(C, C1)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}

		SelectionSort(C2);

		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				System.out.println(C2[i]);
			} else {
				System.out.print(C2[i] + " ");
			}
		}

		if (isStable(C, C2)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}

	public static void BubbleSort(String[] a) {
		int n = a.length;
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; j > i; j--) {
				if (a[j - 1].charAt(1) > a[j].charAt(1)) {
					String temp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = temp;
				}
			}
		}
	}

	public static void SelectionSort(String[] a) {
		int n = a.length;
		for (int i = 0; i < n - 1; i++) {
			int min = i;
			for (int j = i + 1; j < n; j++) {
				if (a[min].charAt(1) > a[j].charAt(1)) {
					min = j;
				}
			}
			String temp = a[i];
			a[i] = a[min];
			a[min] = temp;
		}
	}

	public static boolean isStable(String in[], String out[]) {
		int n = in.length;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int a = 0; a < n; a++) {
					for (int b = a + 1; b < n; b++) {
						if (in[i].charAt(1) == in[j].charAt(1) && in[i].equals(out[b]) && in[j].equals(out[a])) {
							return false;
						}
					}
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin>>S;
  int a=S.size();
  int b=0;
  int c=0;
rep(i,a){
    if(i%2==0)
    {
        if(S[i]=='0'){
            b++;
        }
    }
    else{
        if(S[i]=='1'){
            b++;
        }
    }
}
rep(i,a){
    if(i%2==1)
    {
        if(S[i]=='0'){
            c++;
        }
    }
    else{
        if(S[i]=='1'){
            c++;
        }
    }
}
  cout<<min(b,c)<<endl;
}

Measured memory_bytes: 3756
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[]
y=[]
c=[]
prices=[]
for i in range(M):
    x1,y1,c1=map(int,input().split())
    x.append(x1)
    y.append(y1)
    c.append(c1)
for i in range(M):
    prices.append(a[x[i]-1]+b[y[i]-1]-c[i])
prices.append(min(a)+min(b))
print(min(prices))

Measured memory_bytes: 27820
#include <stdio.h>
#include <math.h>
#define MAX_N 100001

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void quick_sort(int *begin, int *end) {
  int n = end - begin;
  int p, i;
  if(n < 1) return;
  swap(begin, begin+rand()%n);
  p = 0;
  for(i = 1; i < n; ++i) {
    if(begin[i] < begin[0]) {
      ++p;
      swap(begin+p,begin+i);
    }
  }
  swap(begin+p, begin);
  quick_sort(begin,begin+p);
  quick_sort(begin+p+1,end);
}

int binarry_search(int *begin, int *end, int value) {
  int l, r, m;
  l = 0;
  r = end-begin;
  while(l < r) {
    m = (l+r)/2;
    if(begin[m] == value)
      return 1;
    else if(begin[m] < value) 
      l = m+1;
    else
      r = m;
  }
  return 0;
}

int main() {
  int n, q, S[MAX_N], t, num;
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", S+i);
  }
  quick_sort(S,S+n);
  num = 0;
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &t);
    if(binarry_search(S,S+n,t)) ++num;
  }
  printf("%d\n", num);
  return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 20100;
const int mod = 998244353;


int fac[maxn];
map <int,int> mp;


int expo(int x, int exp) {
	int res = 1, base = x;
	while (exp) {
		if (exp & 1) res = (res * base) % mod;
		base = (base*base) % mod;
		exp >>= 1;
	}
	return res;
}

int inv(int x) {
	if (mp.find(x) != mp.end()) return mp[x];
	else return mp[x] = expo(x,mod-2);
}


int choose(int N, int k) {
	return fac[N] * inv(fac[k]*fac[N - k] % mod) % mod;
}

int K,n;

int32_t main() {
	//FAST
	cin >> K >> n;
	fac[0] = 1;
	for (int i =1; i<maxn;i++) fac[i] = fac[i-1] * i % mod;
	
	for (int i = 2;i <= 2 * K; i++) {
		int ans = 0;
		int pairs = i/2 - max(1ll, i - K) + 1;
		
		for (int x = 0; x <= pairs; x++) {
			if (n < x * 2) break;
			int v = choose(n - x*2 + K -1, n - x * 2) * choose(pairs,x) % mod;
			if (x % 2 == 0) ans = (ans + v) % mod; 
			else ans = (ans - v + mod) % mod;
			//cout << i << " " << x << " " << v << " " << ans << "\n";
		}
		cout << ans << "\n";
	}
}









Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
int main(){
    // int t;
    // scanf("%d", &t);
    // while(t--){
        string s;
        cin>>s;
        if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
            cout<<3<<endl;
        else if(s[0] == 'R' && s[1] == 'R' && s[2] == 'S')
            cout<<2<<endl;
        else if(s[0] == 'S' && s[1] == 'R' && s[2] == 'S')
            cout<<1<<endl;
            
        else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S')
            cout<<0<<endl;
        else if(s[0] == 'R' && s[1] == 'S' && s[2] == 'S')
            cout<<1<<endl;
            
        else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'R')
            cout<<1<<endl;
            
        else if(s[0] == 'R' && s[1] == 'S' && s[2] == 'R')
            cout<<1<<endl;
        else if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R')
            cout<<2<<endl;
    // }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<int, int> P;

int main() {
  int n,m; cin >> n >> m;
  set<int> LEN, IDX;

  int r = n-1;
  loop(l,1,n) {
    if (m==0) break;
    if (IDX.count(l)) continue; // この左は使用済み
    while (r-l==n-(r-l) or IDX.count(r) or LEN.count(r-l)) r--;
    LEN.insert(r-l);
    LEN.insert(n-(r-l));
    IDX.insert(r);
    m--;
    cout << l << " " << r << endl;
  }
  return 0;
}


Measured memory_bytes: 16120
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


double a;

int main() {
    while (cin >> a) {
        double res = a;
        for (int i = 2; i <= 10; ++i) {
            if (i & 1) a /= 3;
            else a *= 2;
            res += a;
        }
        cout << fixed << setprecision(9) << res << endl;
    }
    
    return 0;
}


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

int main(){
	ll N, ans = 1e18; cin >> N;
	for(ll i=1; i*i<=N; i++){
		if(N % i == 0){
			if(ans > i+(N/i)-2) ans = i+(N/i)-2;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local edge = {}
for i = 1, n do edge[i] = {} end
local edgeinfo = {}
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  edge[a][b], edge[b][a] = c, c
  table.insert(edgeinfo, {a, b, c})
end

local function getlength(start_idx)
  local taskstate = {}
  for i = 1, n do taskstate[i] = false end
  local tasks = {}
  local tasknum = 0
  local done = 0

  local len = {}
  for i = 1, n do len[i] = 100000 end
  len[start_idx] = 0

  local function addtask(idx)
    if not taskstate[idx] then
      taskstate[idx] = true
      tasknum = tasknum + 1
      tasks[tasknum] = idx
    end
  end
  addtask(start_idx)

  while done < tasknum do
    done = done + 1
    local src = tasks[done]
    taskstate[src] = false
    local tmp = {}
    for dst, cost in pairs(edge[src]) do
      if len[src] + cost < len[dst] then
        len[dst] = len[src] + cost
        table.insert(tmp, dst)
      end
    end
    table.sort(tmp, function(a, b) return len[a] < len[b] end)
    for i = 1, #tmp do addtask(tmp[i]) end
  end
  return len
end
local lenall = {}
for i = 1, n do
  lenall[i] = getlength(i)
end
local ret = 0
for i = 1, m do
  local contains = false
  local edge_l, edge_r, c = edgeinfo[i][1], edgeinfo[i][2], edgeinfo[i][3]
  for src = 1, n do
    for dst = 1, n do
      if lenall[src][dst] == lenall[src][edge_l] + c + lenall[edge_r][dst] then
        contains = true
        break
      end
    end
    if contains then break end
  end
  if not contains then ret = ret + 1 end
end
print(ret)


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

int main()
{
	int year, month, day;
	char c[10];

	for (int i = 0; i < 10; i++)
	{
		cin >> c[i];
	}
	
	year = 1000 * (c[0]-'0') + 100 * (c[1] -'0') + 10 * (c[2] -'0') + (c[3]-'0');
	month = 10 * (c[5] -'0') + (c[6] -'0');
	day = 10 * (c[8] -'0') + (c[9] -'0');

	if (year >= 2019)
	{
		if (month > 4)
		{
			cout << "TBD" << endl;
			return 0;
		}
		else if(month == 4)
		{
			if (day > 30)
			{
				cout << "TBD" << endl;
				return 0;
			}
			else
			{
				cout << "Heisei" << endl;
				return 0;
			}
		}
		else
		{
			cout << "Heisei" << endl;
			return 0;
		}
	}
	else
	{
		cout << "Heisei" << endl;
		return 0;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932;
int main(){
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    h = 60*h + m;
    long double hT = 2*PI*(h/720.0000);
    long double hx = a*sin(hT), hy = a*cos(hT);
    long double mT = 2*PI*(m/60.0000);
    long double mx = b*sin(mT), my = b*cos(mT);
    long double dx = hx-mx, dy = hy-my;
    long double ans = pow((dx*dx)+(dy*dy),0.500000000);
    printf("%.9Lf",ans);
}


Measured memory_bytes: 4216
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[][] = new int[2][N];
		for (int i=0;i<2;i++) {
			for (int j=0;j<N;j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int sum2 =0;
		for (int i=0;i<N;i++) {
			sum2+=A[1][i];
		}
		int max=0;
		int sum =0;
		for (int i=0;i<N;i++) {
			sum +=A[0][i];
			int temp=sum+sum2;
			sum2-=A[1][i];
			if (max<temp) {
				max = temp;
			}
		}
		System.out.println(max);
	}

}

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

int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max({(N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E}) + 5 << endl;
    return 0;
}

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

int A[MAX][MAX];

void Counting(int num, int data){
  A[num-1][data-1] = 1;
}

int main(){
  int n, i, j, k, num, data;

  scanf("%d",&n);
  //配列の初期化
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  
  //頂点の番号・出次数（接している頂点の数）を入力
  for(i = 0; i < n; i++){
    scanf("%d %d",&num, &k);
    if(k == 0) continue;
    else{
      //隣接する頂点を入力
      for(j = 0; j < k; j++){
	scanf("%d",&data);
	Counting(num, data);
      }
    } 
  }
  
  //データ出力
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      printf("%d",A[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2148
#include <iostream>

using namespace std;

int main(void) {
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if (a == b) {
		cout << "== ";
	}
	else if (a < b) {
		cout << "< ";
	}
	else {
		cout << "> ";
	}
	cout << "b" << endl;
	return 0;
}



Measured memory_bytes: 3116
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
struct pp
{
	ll x,y,id,idd;
}a[200005];
ll n,i,x,y,ans=0,ok=0,tot,t[2],bst1,bst2,buc[100005];
const ll inf=1e18;
bool cmp(pp a,pp b){return a.x<b.x;}
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		a[i]=(pp){x,y,i,0};
		a[i+n]=(pp){y,x,i,1};
	}
	sort(a+1,a+2*n+1,cmp);
	for(i=1;i<=n;i++)
	{
		ans+=a[i].x;
		t[a[i].idd]++;
		buc[a[i].id]++;
		if(buc[a[i].id]==2)ok=1;
	}
	if(ok||t[0]*t[1]==0)printf("%lld\n",ans);
	else
	{
		bst1=-inf;tot=ans;
		bst2=ans=inf;
		for(i=1;i<=n;i++)
		{
			ans=min(ans,min(tot+a[i].y-bst1,tot-a[i].x+bst2));
			bst1=max(bst1,a[i].x);
			bst2=min(bst2,a[i].y);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7168