akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() >k) {
        cout << s.substr(0,k) << "..." << endl;
    } else {
        cout << s << endl;
    }
}

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

int main(){
	int a[4];
	int b[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	cin>>b[0]>>b[1]>>b[2]>>b[3];
	int S;
	int T;
	S = a[0]+a[1]+a[2]+a[3];
	T = b[0]+b[1]+b[2]+b[3];
	if(S>=T){
		cout<<S<<endl;
	}
	else{
		cout<<T<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>

int main(void){
	int n, i, j, k, len=0, count=0, flag;
	char seek[12], ring[12];
	
	scanf(" %s", seek);
	scanf(" %d", &n);
	
	while(seek[len] != '\0') ++len;
	
	for(i=0; i<n; i++){
		scanf(" %s", ring);
		flag=0;
		
		for(j=0; j<10 && flag==0; j++) {
			flag=1;
			for(k=0; k<len; k++){
				if(ring[(j+k)%10] != seek[k]){
					flag=0;
					break;
				}
			}	
		}
		
		count += flag;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 596
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]
uu = inputs[0][2]
vv = inputs[0][3]

if aa < bb
  ww = bb
  hh = aa
  uu, vv = vv, uu
else
  ww = aa
  hh = bb
end
xx = [uu, ww-uu].max
yy = [vv, hh-vv].max

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p "aa=#{aa}"
  p "bb=#{bb}"
  p "uu=#{uu}"
  p "vv=#{vv}"
  p "ww=#{ww}"
  p "hh=#{hh}"    
  p "xx=#{xx}"
  p "yy=#{yy}"  
end

area = 0
flag = 0

if ((ww % 2 == 0) and (ww/2 == xx)) and ((hh % 2 == 0) and (hh/2 == yy))
  flag = 1
else
  flag = 0
end

puts (ww*hh).to_f/2
puts flag


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> c(h);
  for (int i = 0; i < h; ++i) {
    cin >> c[i];
  }

  for (int i = 0; i < h; ++i) {
    cout << c[i] << endl;
    cout << c[i] << endl;
  }
  return 0;
}


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

#define fo(i, n) for(ll i = 0; i < n; i++)
#define endl "\n"
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rep(i,j,n) for (int i = j; i <= n; ++i)
ll mod= 1e9+7;


/*int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int vis[600][600];
int cnt=0,k;
ll n,m;
//int a[600][600];

vector<pair<int,int> > str;
int cnt2=0;
bool check(int x,int y){
    if(x<n && x>=0 && y<m && y>=0)return 1;
    return 0;
}

void dfs(int x,int y)
{
    vis[x][y]=1;
    cnt++;
    //cout<<cnt<<" "<<x<<" "<<y<<endl;
    if(v[x][y]=='.' && cnt>cnt2-k)
    {
        //cout<<cnt<<" "<<x<<" "<<y<<endl;
        str.push_back(make_pair(x,y));
    }
    rep(i,0,3)
    {
        int xx = x+dx[i];
        int yy = y+dy[i];
        if(check(xx,yy) && vis[xx][yy]==0)
        {
            if(v[xx][yy]=='.') dfs(xx,yy);
        }
    }



}*/
vector<vector<int> > v;
int main()
{
    int n,m;
    cin>>n>>m;
    v.resize(n+1);
    rep(i,0,m-1)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    queue<int> q;

    q.push(1);
    int par[n+1],vis[n+1];
    memset(vis,0,sizeof(vis));
    int cnt;
    while(q.size())
    {
        int s = q.front();
        //cout<<s<<endl;
        q.pop();
        vis[s]=1;
        rep(i,0,v[s].size()-1)
        {
            if(!vis[v[s][i]])
            {
                q.push(v[s][i]);
                vis[v[s][i]]=1;
                par[v[s][i]]=s;
            }
        }
        cnt++;

    }
    rep(i,1,n) if(vis[i]==0) {cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;
    rep(i,2,n) cout<<par[i]<<endl;


}


Measured memory_bytes: 10648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      if(S.contains("Sunny")){
        System.out.println("Cloudy");
      }else if(S.contains("Cloudy")){
        System.out.println("Rainy");
      }else if(S.contains("Rainy")){
        System.out.println("Sunny");
      }
    }
}

Measured memory_bytes: 35700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

long d[10][10];

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

  int h, w;
  cin >> h >> w;

  rep(i, 10) rep(j, 10) {
    cin >> d[i][j];
  }

  rep(k, 10) rep(i, 10) rep(j, 10) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }

  int res = 0;
  rep(i, h) rep(j, w) {
    int a;
    cin >> a;
    if (a != -1) {
      res += d[a][1];
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
from math import sqrt 
Q = int(input())
table=[]
for i in range(Q):
    A,B=map(int,input().split())
    if A>B:
        table.append([B,A])
    else:
        table.append([A,B])
def f(a,b):
    if a==b:
        return 2*a-2
    if a+1==b:
        return 2*a-2
    m = int(sqrt(a*b))
    if m**2 ==a*b:
        m-=1
    if m*(m+1) >= a*b:
        return 2*m -2
    return 2*m-1

ans = []
for a,b in table:
    ans.append(f(a,b))
print('\n'.join(map(str,ans)))

Measured memory_bytes: 3064
from fractions import gcd

from functools import reduce


n = int(input())
a_list = [int(x) for x in input().split()]

temp = 1
for a in a_list:
    temp *= a // gcd(a, temp)

ans = 0
for a in a_list:
    ans += temp // a
mod = 10 ** 9 + 7
ans %= mod

print(ans)

Measured memory_bytes: 6108
def read():
    S = input().strip()
    return S,


def solve(S):
    n_lose = 0
    for s in S:
        if s == 'x':
            n_lose += 1
    if n_lose >= 8:
        return 'NO'
    else:
        return 'YES'


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=200005;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define set multiset
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//int dp[N];
int dp1[N];
vi adj[N];
vi adj2[N];
int vis[N];
vi printDivisors(int n) 
{ 
    vi temp;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                temp.pb(i);
  
            else // Otherwise print both 
                {
                    temp.pb(i);
                    temp.pb(n/i);

                }
        } 
    } 
    return temp;
}
int dp[3001][3001];
int arr[N];
int rec(int first, int last)
{
    if(dp[first][last]!=-1) return dp[first][last];
    if(last<first) return 0;
   // if((last-first)==1) return dp[first][last]=max(arr[first],arr[last]);
    if(first==last) return dp[first][last] = arr[first];
    return dp[first][last]=max(arr[first]+min(rec(first+2,last),rec(first+1,last-1)),arr[last]+min(rec(first,last-2),rec(first+1,last-1)));

}
signed main()
{
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=-1;
        }
    }
    for(int i=1;i<=n;i++)
    { 
        cin>>arr[i];
        sum+=arr[i];
    }

    //cout<<rec(1,n);
    cout<<rec(1,n)-(sum-rec(1,n));
    return 0;

}
 
    

Measured memory_bytes: 83444
import sys
sys.setrecursionlimit(10**5)

def expsq(n,k):
    global mod

    if k==0:
        return 1
    elif k%2==0:
        return pow(expsq(n,k/2),2,mod)
    else:
        return expsq(n,k-1)*n%mod

m,n=map(int,raw_input().split())
mod=10**9+7
print(expsq(m,n)%mod)  

Measured memory_bytes: 6424
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[2 * N];
		for(int i = 0; i < 2 * N; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		for(int i = 0; i < 2 * N; i += 2)
			ans += a[i];
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

const int N_MAX = 101000;

vector<ll> sl(N_MAX);
vector<ll> tl(N_MAX);

ll solve(ll x, vector<ll> &da){
	ll ok = -1, ng = INT_MAX;
	while(ng -ok > 1){
		ll now = (ok+ng)/2;
		auto le = lower_bound(da.begin(), da.end(), x-now);
		auto ri = lower_bound(da.begin(), da.end(), x+now);
		if(ri-le > da.end()-ri){
			ng = now;
		}
		else{
			ok= now;
		}
	}
	ll ret = 0;
	auto le = lower_bound(da.begin(), da.end(), x-ok);
	auto ri = lower_bound(da.begin(), da.end(), x+ok);
	ret += sl.back()-sl[ri - da.begin()];
	// cout << ok  MM ret << ' ';
	if(ri-le == da.end() - ri) ret += tl[le-da.begin()];
	else if(le != da.begin()) ret += tl[le-da.begin()-1];
	// cout << ret/2 << endl;
	return ret/2;
}

int main(){
	int n, q; cin >> n >> q;
	vector<ll> da(n);
	rip(i,n,0) cin >> da[i];
	tl.resize(n+1);
	sl.resize(n+1);
	// vdeb(tl);
	rip(i,n,0) da[i] *= 2;
	vector<ll> x(q);
	rip(i,q,0) cin >> x[i];
	rip(i,n,0){
		sl[i+1] = sl[i] + da[i];
		if(i == 0) tl[i+1] = da[i];
		else tl[i+1] = tl[i-1] + da[i];
	}
	vector<ll> ans(q);
	rip(i,q,0){
		ans[i] = solve(x[i]*2, da);
	}
	rip(i,q,0) cout << ans[i] << endl;
}

Measured memory_bytes: 5632
#include<stdio.h>

int main(void){
  double x,sum;
  int i;
  while(scanf("%lf",&x)!=EOF){
    sum=x;
    for(i=0;i<9;i++){
      if(i%2==0)x*=2;
      else if(i%2==1)x/=3;
      sum+=x;
    }
    printf("%.8f\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int H, W, K; 
vector<string> s;
vector<bool> v1, v2;
int ans = 0;

void h(){
  int cnt = 0;
  REP(i, H) REP(j, W){
    if(v1[i] && v2[j] && s[i][j] == '#') cnt++;
  }
  if(cnt == K) ans++;
}
void g(int n){
  if(n == W){
    h();
    return;
  }

  v2[n] = false;
  g(n+1);
  v2[n] = true;
  g(n+1);
}
void f(int n){
  if(n == H){
    g(0);
    return;
  }

  v1[n] = false;
  f(n+1);
  v1[n] = true;
  f(n+1);
}

signed main() {
  cin >> H >> W >> K;

  s.resize(H);
  REP(i, H) cin >> s[i];

  v1.resize(H, false);
  v2.resize(W, false);
  f(0);

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d\n",&a);
	scanf("%d\n",&b);
	scanf("%d",&c);
	if(a<b&&b<c&&a<c)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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

using namespace std;
using ll = long long;

class Osa_k {
private:
	int n;
	vector<int> factor;

	void dfs(int val, int idx ,vector<int>& ans, map<int,int>& mp,const vector<int> &facts) {
		if(idx == (int)facts.size()) {
			ans.push_back(val);
			return;
		}
		int v = facts[idx];
		for(int i = 0; i <= mp[v]; i++) {
			dfs(val, idx+1, ans, mp, facts);
			val *= v;
		}
	}

public:

	//O(NloglogN)
	Osa_k(int _n):n(_n) {
		factor.assign(n, 0);
		iota(factor.begin(), factor.end(), 0);
		for(int i = 2; i*i < n; i++) {
			if(factor[i] < i)continue;
			for(int j = i * i; j < n; j += i) {
				if(factor[j] == j)factor[j] = i;
			}
		}
	}

	//O(logV)
	map<int, int> sieve(int v) {
		map<int, int> ret;
		while(v != factor[v]) {
			ret[factor[v]]++;
			v /= factor[v];
		}
		if(v != 1)ret[v]++;
		return ret;
	}


	vector<int> divisor(int v) {
		map<int,int> mp = sieve(v);
		vector<int> factors;
		for(auto i : mp)factors.emplace_back(i.first);
		vector<int> ans;
		dfs(1, 0, ans, mp, factors);
		sort(ans.begin(), ans.end());
		return ans;
	}


	//O(N)
	vector<int> get_list() {
		vector<int> prime;
		for(int i = 2; i < n; i++)if(factor[i] == i)prime.emplace_back(i);
		return prime;
	}

	//O(1)
	bool is_prime(int v) {
		if(v <= 1)return false;
		return (factor[v] == v);
	}

}fact(1000001);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> in(1000001);
    for(int i = 0; i < n; i++)cin >> a[i], in[a[i]]++;
    int sum = 0;
 
    for(int i = 0; i < n; i++) {
        vector<int> num = fact.divisor(a[i]);
        int res = 0;
        for(int j = 0; j < num.size(); j++) {
            res += in[num[j]];
        }
        if(res == 1)sum++;
    }
    cout << sum << '\n';
}

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

int main(void)
{
    long long D;
    cin >> D;
    vector<long long> c(26);
    vector<vector<long long>> used(26);
    for (long long i = 0; i < 26; i++)
    {
        cin >> c[i];
        used[i].push_back(-1);
    }
    vector<vector<long long>> s(D,vector<long long>(26));
    for (long long i = 0; i < D; i++)
    {
        for (long long j = 0; j < 26; j++)
        {
            cin >> s.at(i).at(j);
        }
    }

    long long lastnum = 0;
    vector<long long> ans(D);
    for (long long i = 0; i < D; i++)
    {
        long long pena = 0;
        for (long long j = 0; j < 26; j++)
        {
            pena += c[j] * (i - used.at(j).at(used[j].size() - 1));
        }
        ans[i] = -1;
        long long cnt = -100000000;
        for (long long j = 0; j < 26; j++)
        {
            pena -= c[j] * (i - used.at(j).at(used[j].size() - 1));
            if (s.at(i).at(j) - pena > cnt)
            {
                ans[i] = j;
                cnt = s.at(i).at(j) - pena;
            }
            pena += c[j] * (i - used.at(j).at(used[j].size() - 1));
        }
        used[ans[i]].push_back(i);
        lastnum += cnt;
    }

    while(clock() <  1.9 * CLOCKS_PER_SEC)
    {
        long long cnt = 100000000;
        long long ranD = rand() % D;
        long long ranq = rand() % 26;
        // for (long long i = 0; i < 26; i++)
        // {
        //     if (i != ans[ranD])
        //     {
        //         if (abs(s.at(ranD).at(ans[ranD]) - s.at(ranD).at(i)) < cnt)
        //         {
        //             ranq = i;
        //             cnt = abs(s.at(ranD).at(ans[ranD]) - s.at(ranD).at(i));
        //         }
        //     }
        // }

        used[ans[ranD]].erase(remove(used[ans[ranD]].begin(), used[ans[ranD]].end(), ranD), used[ans[ranD]].end());
        used[ranq].push_back(ranD);
        sort(used[ranq].begin(), used[ranq].end());
        long long oldans = ans[ranD];
        ans[ranD] = ranq;

        long long newnum = 0;
        for (long long i = 0; i< D; i++)
        {   
            newnum += s.at(i).at(ans[i]);
        }
        for (long long j = 0; j < 26; j++)
        {
            long long pena = 0;
            for (long long i = 0; i < used[j].size(); i++)
            {
                if ( i == used[j].size() - 1)
                {
                    pena += c[j] * (D - used[j][i] - 1);
                }
                else
                {
                    pena += c[j] * (used[j][i+1] - used[j][i]) * (used[j][i+1] - used[j][i] + 1) / 2;
                }
            }
            newnum -= pena;
        }
        
        if(newnum <= lastnum)
        {
            used[ranq].erase(remove(used[ranq].begin(), used[ranq].end(), ranD), used[ranq].end());
            used[ans[ranD]].push_back(ranD);
            sort(used[ans[ranD]].begin(), used[ans[ranD]].end());
            ans[ranD] = oldans;
        }
        else
        {
            lastnum = newnum;
        }
    }

    for (long long i = 0; i < D; i++)
    {
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s=0;
    for(int i=0;i<4;i++){
        char k;
        cin>>k;
        if(k=='+'){
            s++;
        }
        else {
            s--;
        }
    }
    cout<<s<<endl;
}


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

int main() {
	int a;
	scanf("%d", &a);
	vector<int>b(3);
	for (int c = 0; c < a; c++) {
		scanf("%d%d%d", &b[0], &b[1], &b[2]);
		sort(b.begin(), b.end());
		if (b[0] * b[0] + b[1] * b[1] == b[2] * b[2])printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 3176
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int n; cin>>n;
    int a[n+1];
    repa(i,1,n)
        cin>>a[i];
    a[0] = a[1];
    int ans = 0;
    repa(i,1,n)
        if (a[i-1]>a[i])
            ans+=a[i-1]-a[i],a[i]=a[i-1];
    cout<<ans<<endl;

        
}

Measured memory_bytes: 5212
import numpy as np

n = int(input())
a = list(map(int, input().split()))
ret = [0]*(n+1)
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Measured memory_bytes: 30036
MOD = 10**9+7         # 問題に合わせて適宜書き換え
list_size = 1000000   # 問題に合わせて適宜書き換え

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = ((f_list[i] * (i+2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
	f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)

def comb(n,r):
    if n < r:
        return 0
    if n == 0 or r == 0 or n == r:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD

N, K = map(int,input().split())
ans = 0
for i in range(min(K,N-1)+1):
    #print(i,comb(N-1,N-1-i),comb(N,1+i))
    ans += comb(N-1,i)*comb(N,N-i)
    ans %= MOD
    #print(ans)
print(ans)


Measured memory_bytes: 56412
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
const int N = 1e4 + 5;
const ll MOD = 1e9 + 7;
 
ll dp[N][105][2];
// dp[i][j][k] means the count of numbers which at pos i, 
// with sum of each digit modulo D equals to j
// if k == 1, then it hasn't chosen any digit that is smaller than k
// how to ensure all numbers in result is smaller than K?
char K[N];
int d;
 
void add(ll& a, ll b) {
    a += b;
    if (a >= MOD) a -= MOD;
}
 
ll sub(ll a, ll b) {
    int res = a - b;
    if (res < 0) res += MOD;
    return res;
}
 
void solve() {
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < K[0] - '0'; ++i) dp[0][i][0] = 1;
    dp[0][K[0] - '0'][1] = 1;
    int len = strlen(K);
    for (int i = 1; i < len; ++i) {
        for (int j = 0; j < max(d, 10); ++j) {
            for (int k = 0; k < 10; ++k) {
                ll new_sum = (j + k) % d;
                add(dp[i][new_sum][0], dp[i - 1][j][0]);
                if (k < K[i] - '0') add(dp[i][new_sum][0], dp[i - 1][j][1]);
                if (k == K[i] - '0') add(dp[i][new_sum][1], dp[i - 1][j][1]);
            }
        }
    }
    if (len==1&&K[0]=='1'&&d==1){
    	printf("1\n");
    	return;
	}
    printf("%lld\n", sub((dp[len - 1][0][0] + dp[len - 1][0][1]) % MOD, 1));
}
 
void debug() {
    for (int i = 0; K[i]; ++i, putchar('\n')) {
        for (int j = 0; j <= d; ++j) {
            printf("%10d %10d ", dp[i][j][0], dp[i][j][1]);
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    while (~scanf("%s%d", K, &d)) {
        solve();
        // debug();
    }
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
 ll n,k;
 cin>>n>>k;
 vector<ll>a(n+5);
 for(ll i=1;i<=n;i++)cin>>a[i];
 for(ll i=k+1;i<=n;i++)
 	if(a[i-k]<a[i])cout<<"Yes"<<endl;
 else cout<<"No"<<endl;

}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 55;
bool pos[N][N];

void pre(){
	memset(pos, false, sizeof(pos));
	for(int i = 0; i < N; i++){
		pos[i][i] = true;
		for(int j = i + 1; j < N; j++){
			for(int k = 1; k <= j; k++){
				if(pos[j%k][i]){
					pos[j][i] = true;
					break;
				}
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(32);

	pre();
	int n; cin>>n;
	vector<int> a(n), b(n);
	set<int> st[n];
	for(int i = 0; i < n; i++){
		cin>>a[i];
		st[i].insert(a[i]);
	}
	for(int i = 0; i < n; i++){
		cin>>b[i];
		if(!pos[a[i]][b[i]]){
			cout<<-1<<'\n';
			exit(0);
		}
	}
	ll ans = 0;
	int prev = 51;
	while(true){
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(st[i].count(b[i]))cnt++;
		}
		if(cnt == n)break;
		int r = 1;
		for(int i = 0; i < n; i++){
			if(st[i].count(b[i]))continue;
			int nr = N;
			for(int z : st[i]){
				for(int k = 1; k <= z; k++){
					if(pos[z%k][b[i]]){
						nr = min(nr, k);
						break;
					}
				}
			}
			r = max(r, nr);
		}
		ans ^= (1LL<<r);
		for(int i = 0; i < n; i++){
			if(st[i].count(b[i]))continue;
			vector<int> nv;
			for(int z : st[i]){
				if(pos[z%r][b[i]])nv.push_back(z%r);
			}
			for(int z : nv){
				st[i].insert(z);
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3644
import collections
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
sum_list = []
ans = 0
for i in range(N):
        for x in X[i][1:]:
                sum_list.append(x)
c = collections.Counter(sum_list)
for i in c.values():
        if i == N:
                ans += 1
print(ans)

Measured memory_bytes: 3316
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
d,x = iim()
count = 0
for i in range(n):
    a = ii()
    if d%a == 0:
        count += d//a
    else:
        count += d//a + 1
print(count+x)

Measured memory_bytes: 3064
n = int(input())
a = []
a1 = a2 = 0
for i in range(n):
    ai = int(input())
    a.append(ai)
    if ai > a1:
        a1, a2 = ai, a1
    elif ai > a2:
        a2 = ai

for i in range(n):
    if a[i] == a1:
        print(a2)
    else:
        print(a1)


Measured memory_bytes: 12532
#include<bits/stdc++.h>
using namespace std;
#define Pi 3.14159265358979323846 
signed main(void){
	double x,y,a=0,b=0,f=Pi/2;
	char c;
	while(cin>>x>>c>>y){
		if(x==0&&y==0)
			break;
		a+=x*cos(f);
		b+=x*sin(f);
		f-=Pi*((double)y/180.0);
	}
	cout<<(int)a<<endl
		<<(int)b<<endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
#define sp(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=1LL<<22;

int n;
int a[25][25];
ll dp[25][maxn];

ll solve(ll row, ll mask){
	if(row==n){
		if(mask==0)
			return 1;
		return 0;
	}
	if(dp[row][mask]!=-1)
		return dp[row][mask];

	ll ans=0;
	fo(i,n){
		if(a[row][i]==0)
			continue;
		if((mask&(1LL<<i))!=0)
			ans=(ans+solve(row+1,mask&(~(1LL<<i))))%MOD;
	}
	return dp[row][mask]=ans;
}

int main(){
	fastio();
	cin>>n;
	fo(i,n){
		fo(j,n){
			cin>>a[i][j];
		}
	}
	fill(dp,-1);

	ll mask=(1LL<<n)-1;

	cout<<solve(0,mask)<<endl;

}

Measured memory_bytes: 822816
gets
num = gets.chomp.split(' ').map(&:to_i)
count = 0
loop do
  flg = false
  num.each_with_index do |n, i|
    flg = true if n % 2 != 0
    num[i] = n / 2
  end
  break if flg
  count += 1
end
p count


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    ll n;
    cin >> n;
    string s = "";
    rep1(i,99) {
        if (n <= pow(26,i)) {
            n--; // 入力は1から
            for (int j = 0; j < i; j++)
            {
                s = (char)('a'+n%26) + s;
                n /= 26;
            }
            break;
        } else {
            n -= pow(26,i);
        }
    }
    cout << s << endl;
    return 0;
}

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

int main() {
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n == 100) {
            cout << 101 << endl;
        } else {
            cout << n << endl;
        }
    } else if (d == 1) {
        if (n == 100) {
            cout << 101 * 100 << endl;
        } else {
            cout << n * 100 << endl;
        }
    } else {
        if (n == 100) {
            cout << 101 * 100 * 100 << endl;
        } else {
            cout << n * 100 * 100 << endl;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		int n,i;
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();
		int a[]=new int[n];
		for(i=0;i<n;i++)
			a[i]=sc.nextInt();
		for(i=n-1;i>0;i--)
			System.out.print(a[i]+" ");
		System.out.println(a[0]);
	}
}


Measured memory_bytes: 26220
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, M; cin >> N >> M;
		vector<vector<UL>> E(N);
		rep(i, M) {
			UL a, b; cin >> a >> b; a--; b--;
			E[a].push_back(b);
			E[b].push_back(a);
		}
		vector<int> F(N);
		ULL z, b, u; z = b = u = 0;
		rep(s, N) {
			if (F[s]) continue;
			F[s] = s + 1;
			if (E[s].size() == 0) {
				z++; F[s] = s + 1; continue;
			}
			queue<UL> Q; Q.push(s);
			bool bok = true;
			while (Q.size()) {
				UL p = Q.front(); Q.pop();
				for (UL e : E[p]) {
					if (F[p] == F[e]) bok = false;
					if (F[e] == 0) {
						F[e] = -F[p];
						Q.push(e);
					}
				}
			}
			if (bok) b++; else u++;
		}
		ULL ans = 0;
		ans += (z * N * 2 - z * z);
		ans += ((b + u) * (b + u) + b * b);
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}

void solve()
{
    ll x;
    cin>>x;

    ll arr[2005];

    For(i,0,2000)
    {
        arr[i]=pow(i-1000,5);
    }

    For(i,1,1001)
    {
        For(j,-1000,i)
        {
            if(arr[i+1000]-arr[j+1000]==x)
            {
                cout<<i<<" "<<j<<endl;
                return;
            }
        }
    }
}

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 4096
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    string s;
    cin>>s;
    ll c=0;
    f(i,3)
    {
        if(s[i]=='R')
            c++;
    }
   if(c==3)
        cout<<'3';
   else if(c==1)
        cout<<'1';
   else if(c==2)
   {
        if(s=="RSR")
            cout<<'1';
        else
            cout<<'2';
    }
    else
    {
        cout<<'0';
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
char m[110][110];
int main(){
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)cin>>m[i][j];
	}
	for(int i=0;i<w+2;i++)cout<<"#";cout<<endl;
	for(int i=0;i<h;i++){
		cout<<"#";
		for(int j=0;j<w;j++){
			cout<<m[i][j];
		}
		cout<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++)cout<<"#";cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LEN 205
#define swap(type, v1, v2) {type tmp = (v1); (v1) = (v2); (v2) = tmp;}
//swap(void *, void *, size_t s)とかすれば関数化も可能
 
char pre_dic[50010][MAX_LEN];
char rev_dic[50010][MAX_LEN];
 
void reverse(char s[]);
int  patern_match(char s[], int n);
int  low_idx(char key[], char s[][MAX_LEN], int n);
 
int main()
{
    int n, m;
    int i, j;
    char word[MAX_LEN], slate[MAX_LEN];
 
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; ++i) {
        scanf("%s", word);
 
        char rev[MAX_LEN];
        strcpy(rev, word);
        reverse(rev);
        
        strcpy(pre_dic[i], word);
        strcpy(rev_dic[i], rev);
    }
    
    qsort(*pre_dic, n, MAX_LEN, (int (*)(const void *, const void *))strcmp);
    qsort(*rev_dic, n, MAX_LEN, (int (*)(const void *, const void *))strcmp);

    for (i = 0; i < m; ++i) {
        scanf("%s", slate);
        char *p = strchr(slate, '?');

        int ans = 0;
        if (p == NULL) {
            ans += patern_match(slate, n);
        } else {
            char ch;
            for (ch = 'a'; ch <= 'z'; ++ch) {
                *p = ch;
                ans += patern_match(slate, n);
            }
        }

        printf("%d\n", ans);
    }

    return 0;
}

void reverse(char s[])
{
    int i, j;
    i = 0; j = strlen(s) - 1;
    while (i < j) {
        swap(char, s[i], s[j]);

        ++i; --j;
    }

    return;
}

int  patern_match(char s[], int n)
{
    //bsearch(s, dic, n, sizeof(char), (int (*)(const void *, const void *))strcmp)
    int ret = 0;
    char left[MAX_LEN];
    char right[MAX_LEN];

    if (s[strlen(s) - 1] == '*') {
        strcpy(left, s);
        left[strlen(left) - 1] = '\0';
        strcpy(right, left);
        ++right[strlen(right) - 1];


        ret = low_idx(right, pre_dic, n) -
            low_idx(left, pre_dic, n);

    } else if (s[0] == '*') {
        strcpy(left, s + 1);
        reverse(left);
        strcpy(right, left);
        ++right[strlen(right) - 1];

        ret = low_idx(right, rev_dic, n) -
            low_idx(left, rev_dic, n);

    } else {
        if ( bsearch(s, *pre_dic, n, MAX_LEN, (int (*)(const void *, const void *))strcmp) == NULL) {
            ret = 0;
        } else {
            ret = 1;
        }
    }

    return ret;
}

int  low_idx(char key[], char s[][MAX_LEN], int n)
{
    int len = n;
    int forward = 0;
    int half;

    while (len > 0) {
        half = len / 2;

        if (strcmp(s[forward + half], key) < 0) {
            len -= half + 1;
            forward = forward + half + 1;
        } else {
            len = half;
        }
    }

    return forward;
}



Measured memory_bytes: 22576
def A_validation(A, N):
    '''
    input
    A, N: abs_list, population
    output
    True/False: can you line up?
    '''
    A = sorted(A)
    num = N - 1
    
    if N % 2 == 0:
        while A:
            tmp1 = A.pop()
            tmp2 = A.pop()
            if tmp1 != tmp2 or tmp1 != num:
                return False
            num = num - 2
        return True
    
    else:
        if A.pop(0) != 0:
            return False
        while A:
            tmp1 = A.pop()
            tmp2 = A.pop()
            if tmp1 != tmp2 or tmp1 != num:
                return False
            num = num - 2
        return True

N = int(input())
A = list(map(int, input().split()))

mod = 1000000007
if A_validation(A, N):
    ans = 2 ** (N // 2) % mod
else:
    ans = 0
print(ans)

Measured memory_bytes: 14024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
// DSU
/*
const int maxn=100009;
int arr[maxn];
int sz[maxn];
void init(){rep(i,maxn){arr[i]=i;sz[i]=1;}}
int root(int a){while(a!=arr[a]){arr[a]=arr[arr[a]];a=arr[a];}return a;}
int check(int a,int b){if(root(a)==root(b))return 1;return 0;}
int un(int a,int b)
{
  int roota=root(a);int rootb=root(b);
  if(sz[roota]>=sz[rootb]){sz[roota]+=sz[rootb];arr[rootb]=roota;}
  else {sz[rootb]+=sz[roota];arr[roota]=rootb;}
}
*/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
   fastio
   string s;
   cin>>s;
   int n=s.size();
   unordered_map<int,int>ans;
   for(int i=0;i<n-1;i++)
   {
     if(s[i]=='R' && s[i+1]=='L')
     {
       int odd=0;
       int even=0;
       int prev=i;
       int next=i+1;
       while(prev>=0 && s[prev]=='R')
       {
         if(prev%2)odd++;
         else even++;
         prev--;
       }
       while(next<n && s[next]=='L')
       {
         if(next%2)odd++;
         else even++;
         next++;
       }
       if(i%2)
       {
         ans[i]=odd;
         ans[i+1]=even;
       }
       else
       {
         ans[i]=even;
         ans[i+1]=odd;
       }
     }
   }
   rep(i,n)
   {
     if(ans[i])cout<<ans[i]<<" ";
     else cout<<0<<" ";
   }

   return 0;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3010;
ll n, a[N], f[N][N]; //f[i][j]

int main()
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lld", a + i);
    for (int i = 1; i <= n; i++)
        f[i][i] = a[i];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j + i <= n; j++)
            f[j][i + j] = max(a[j] - f[j + 1][i + j], a[i + j] - f[j][i + j - 1]);
    }
    printf("%lld\n", f[1][n]);
    return 0;
}

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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if(k >= a) {
    k -= a;
    a = 0;
    b -= min(b, k);
  } else {
    a -= k;
  }
  cout << a << ' ' << b << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, x;cin>>n>>x;
  int min_m=INF;
  for(int i=0;i<n;i++){
    int m;cin>>m;
    min_m=min(min_m, m);
    x-=m;
  }
  cout << n+x/min_m << endl;
}


Measured memory_bytes: 256