akhauriyash/Code-Regression huggingface dataset:
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

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

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e5+5;

int pw(int x,int n)
{
    int res=1;

    x%=M;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res*x)%M;

        x=(x*x)%M;
    }

    return res;
}

void solve()
{
    int n,k;
    cin>>n>>k;

    int ans=0;
    vi v(k+1,0);

    for(int i=k;i>=1;--i)
    {
        v[i]=pw(k/i,n);

        for(int j=2*i;j<=k;j+=i)
            v[i]=(v[i]-v[j]+M)%M;

        ans=(ans+i*v[i]%M)%M;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<int> h(N, 0);
    rep(i, N) cin >> h[i];

    // 状態 i : 足場 i にいる
    // mi(i) : 足場 i にいる時の最小コスト
    vector<int> mi(N, INF);
    mi[0] = 0;

    for (int i = 1; i < N; i++) {
        if (0 <= i - 1) mi[i] = min(mi[i], mi[i - 1] + abs(h[i - 1] - h[i]));
        if (0 <= i - 2) mi[i] = min(mi[i], mi[i - 2] + abs(h[i - 2] - h[i]));
    }

    // dump(mi);

    cout << mi[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 4052
n, m = map(int, input().split())
l = []
r = []

for _ in range(m):
  a, b = map(int, input().split())
  l.append(a)
  r.append(b)
  
l_max = max(l)
r_min = min(r)

if l_max <= r_min:
  print(r_min - l_max + 1)
else:
  print(0)

Measured memory_bytes: 11016
#include <stdio.h>
  
int main(void){
  
  char ch;
  int alpha[26] = {0};
  int count = 0;
  register int i;
  
  while (scanf("%c", &ch) != EOF ){
    if(isupper(ch)){
      ch = tolower(ch);
    }
    count = ch - 'a';
    alpha[count]++;
  }
  for(i = 0;i < 26;i++){
    printf("%c : %d\n",i + 'a',alpha[i]);
  }
  return 0;
}

Measured memory_bytes: 548
a=int(input())
A=0
W=0
T=0
R=0
for i in range(a):
  tex=input()
  if tex=="AC":
    A+=1
  elif tex=="WA":
    W+=1
  elif tex=="TLE":
    T+=1
  elif tex=="RE":
    R+=1
print("AC x "+str(A))
print("WA x "+str(W))
print("TLE x "+str(T))
print("RE x "+str(R))

Measured memory_bytes: 9208
while True:
    (H, W) = [int(i) for i in input().split()]
    if H == 0 == W:
        break

    for hc in range(H):
        for wc in range(W):
            if hc == 0 or wc == 0 or hc == H - 1 or wc == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
R = []
for i in range(N):
    R.append(int(input()))

maxv = R[1] - R[0]
minv = R[0]
for i in range(1, len(R)):
        maxv = max(maxv, (R[i] - minv))
        minv = min(minv, R[i])

print(maxv)

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

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

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

    if (x == 0) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int box[]={0,1,2,3};
void oct(int x){
	int a=x%4;
	if(x/4!=0)
	oct(x/4);
	cout<<box[a];
}
int main(){
	int x;
	while(cin>>x,x!=-1){
		oct(x);
		cout<<endl;
	}
	return 0;
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int ans = 2000000000;
  for (int a = 0; a < X + 1; ++a) {
    int c = (X - a) * 2;
    int b = max(0, Y - c / 2);
    ans = min(ans, A * a + B * b + C * c);
  }
  for (int b = 0; b < Y + 1; ++b) {
    int c = (Y - b) * 2;
    int a = max(0, X - c / 2);
    ans = min(ans, A * a + B * b + C * c);
  }
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s,t;
    cin >> s >>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
set<ll> s;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
void primeFactors(ll n)  
{  
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
            {
              
                if(i>=2)
                s.insert(i);
			}
  
            else 
            {
            
            if(i>=2)
               s.insert(i);
               if(n/i>=2)
               s.insert(n/i);
			}
        } 
    }   
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n;
	cin>>n;
	ll ans= countDivisors(n-1);
	ans--;
    ans++;
    //cout<<ans;
    primeFactors(n);
   // cout<<n;
    for(auto x: s)
    {
		//cout<<x<<" ";
		ll y=n/x;
		if(x!=n)
		{
		while(y%x==0)
		y/=x;
		if(y%x==1)
		ans++;
	   }
	}
	cout<<ans;
 cout<<"\n"; 
 } 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        ans += S[i] != T[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3816
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
suki = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1

ans = len(list(filter(lambda x: x == N, suki)))
print(ans)


Measured memory_bytes: 9012
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
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;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
vector<int> k[200010];
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N = 200000;
	for (int i = 1; i <= N; i++) {
		for (int j = i + i; j <= N; j += i) {
			k[j].push_back(i);
		}
	}
	cin >> N;
	vi a(N + 10);
	rrep(i, N)cin >> a[i];
	vi x(N + 10, 0);
	dequeue<int> ans;
	for (int i = N; i >= 1; i--) {
		if (x[i] % 2 != a[i]) {
			ans.push_front(i);
			for (auto g : k[i]) {
				x[g]++;
			}
		}
	}
	cout << ans.size() << endl;
	for (auto g : ans) {
		cout << g << endl;
	}
}

Measured memory_bytes: 24448
#include<iostream>
int main()
{
	char s[200], p[100];
	std::cin >> s >> p;
	int length1;
	for(int i = 0;; i++)
	{
		if(s[i] == '\0')
		{
			length1 = i;
			break;
		}
	}
	for(int i = 0; i < length1; i++)
	{
		s[i + length1] = s[i];
	}
	int length2;
	for(int i = 0;; i++)
	{
		if(p[i] == '\0')
		{
			length2 = i;
			break;
		}
	}
	bool is_OK;
	for(int i = 0; i < 2 * length1 - length2 + 1; i++)
	{
		is_OK = true;
		for(int j = 0; j < length2; j++)
		{
			is_OK &= p[j] == s[i + j];
		}
		if(is_OK)
		{
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 300000 + 5;
int a[N];

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll t = a+b;
	ll sum = n / t * a;
	ll k = n % t;
	if(k <= a)
		sum += k;
	else
		sum += a;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
include Math

a,b,x = gets.split.map(&:to_f)

s = x / a

if s >= a*b/2
    h = (a*b - s)*2/a
    rad = atan2(h, a)
else
    w = s*2/b
    rad = atan2(b, w)
end

deg = rad * 180 / PI

puts deg


Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys
from itertools import chain

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    if H <= sum(A):
        return YES
    else:
        return NO


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(H, N, A)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19980
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,m; cin >> n >> m;
	if(m>=n) puts("Yes");
	else puts("No");
}

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

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

template <typename T>
static constexpr auto inf = static_cast <T> (sizeof (T) < 8 ? 1e9 : 1e18);

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  int64_t w;
  cin >> n >> w;

  size_t value_candicate = 100000;

  vector <int64_t> weight (value_candicate + 1, inf <int64_t>);
  weight [0] = 0;

  rep (i, n)
  {
    int64_t wi;
    size_t vi;
    cin >> wi >> vi;

    for (size_t j = value_candicate + 1; j --;)
    {
      weight [j + vi] = min (weight [j + vi], weight [j] + wi);
      weight [j] = min (weight [j], weight [j]);
    }
  }

  size_t ans = 0;
  rep (j, value_candicate + 1)
  {
    if (weight [j] <= w)
    {
      ans = j;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int N, sum, a[101];

void solve() {
    sort(a, a+N);
    int tmp = sum;
    for(int i = 0; i < N; i++){
        if(a[i] % 10 != 0) {
            tmp = a[i];
            break;
        }
    }
    if(sum % 10 == 0) sum -= tmp;
    cout << sum << endl;
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    solve();
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	in := make([]int, 3)
	for i := range in {
		fmt.Scan(&in[i])
	}
	fmt.Println(rgb(in))
}

func rgb(in []int) string {
	s := 100*in[0] + 10*in[1] + in[2]
	if s%4 == 0 {
		return "YES"
	}
	return "NO"
}


Measured memory_bytes: 512
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int n, m; 
	cin >> n >> m; 
	vector<int> ans(n); 
	for (int i = 0; i < m; i++)
	{
		int a, b;  
		cin >> a >> b;
		ans.at(a - 1)++; 
		ans.at(b - 1)++;
	}
	for (int i = 0; i < n; i++)
	{
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max];
ll n;
void solve(){
	cin>>n;
	rep(i,0,n)cin>>a[i];
	int ans=1,cnt=1;
	rep(i,1,n){
		if(a[i]<=a[i-1]){
			cnt++;
		}else{
			ans = max(ans,cnt);
			cnt = 1;
		}
	}
	ans = max(ans,cnt);
	cout<<ans-1;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1024
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

LL nC2(LL n){
    return n*(n-1)/2;
}

int main() {
    LL n;
    vector<LL> a;
    LL tmp_a;
    vector<LL> multi_bin_n;
    vector<LL> multi_bin_v;
    LL tmp_ans;
    LL ans;
 
    cin >> n;
    vector<LL> bin(n, 0);
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        tmp_a--;
        a.push_back(tmp_a);
        bin[tmp_a]++;
    }
 
    tmp_ans=0;
    for(int i=0; i<n; i++){
        tmp_ans+=bin[i]*(bin[i]-1)/2;
        //tmp_ans+=nC2(bin[i]);
    }
    //cout << tmp_ans << endl;
 
    for(int i=0; i<n; i++){
        ans=tmp_ans;
        ans-=bin[a[i]]*(bin[a[i]]-1)/2;
        bin[a[i]]--;
        //cout << bin[a[i]] << " " << ans << endl;
        ans+=bin[a[i]]*(bin[a[i]]-1)/2;
        bin[a[i]]++;
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 5872
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int cnt = sc.nextInt();
			boolean[][] arr = new boolean[4][13];
			java.util.stream.IntStream.range(0, cnt).forEachOrdered(i -> {
				int pIdx = 0;
				String pattern = sc.next();
				if (pattern.equals("H")) {pIdx = 1;}
				if (pattern.equals("C")) {pIdx = 2;}
				if (pattern.equals("D")) {pIdx = 3;}
				arr[pIdx][sc.nextInt() - 1] = true;
			});

			for (int i = 0; i < arr.length; i++) {
				for (int j = 0; j <arr[i].length; j++ ) {
					if (!arr[i][j]) {
						String pattern = "S";
						if (i == 1) {pattern = "H";}
						if (i == 2) {pattern = "C";}
						if (i == 3) {pattern = "D";}
						System.out.println(pattern + " "+ (j+1));
					}
				}
			}

		}
	}
}


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

long long findsum(string s,long long sum,long long ssum){//文字列に対し題意の和を返す
//ssumは＋が入らずに残ってるやつ
    
    string scut;//scutは入れた＋の後ろの数字列
    
    scut = s;
    long long x,y;

    x = s.at(0) -'0';
    y = s.at(1) -'0';
    
    if(s.size() == 2){//終了条件、最後の候補
        
        sum += sum + 10*(ssum + x)+y;
        sum += ssum + x+y;
        return sum;
    }
    
    scut.erase(scut.begin());
    
    return findsum(scut,sum+ssum+x,0)+findsum(scut,sum,10*(ssum+x));
}//左は＋が入る場合、右は入らない場合

int main (){
    string s;
    cin >> s;
    if(s.size() == 1){
        cout << s.at(0)-'0' << endl;
    }
    else{
        long long ans = findsum(s,0,0);
        cout << ans << endl;
    }
}

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

bool isp(int n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  for (int i = 3; i <= (int)sqrt(n); i += 2) if (n % i == 0) return false;
  return true;
}

int main() {
  int Q;
  cin >> Q;
  int N = 1000000;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    if (isp(i) && isp((i + 1) / 2)) V.at(i) = 1;
  }
  vector<int> R(N + 1);
  for (int i = 1; i <= N; i++) {
    R.at(i) = R.at(i - 1) + V.at(i - 1);
  }
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << R.at(r + 1) - R.at(l) << "\n";
  }
}

Measured memory_bytes: 11180
// https://arc061.contest.atcoder.jp/submissions/all
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int i=m;i<=n;i++)
const int M = 1e5 + 10;
const int inf = 0x3f3f3f3f;

//*************************************
int n,m,cnt;
int head[M];
struct node {
	int to,id,nxt;
} E[M << 2];
void add(int u,int v,int id) {
	E[++cnt] = {v,id,head[u]};
	head[u] = cnt;
}
//*************************************
int dis[M];
set<int> vis[M];
void a() {
	priority_queue<pair<int, int> > Q;
	Q.push({0,1});
	dis[1] = 0;
	while(!Q.empty()) {
		int now =  Q.top().second;
		int   d = -Q.top().first;
			  	   Q.pop();
		if(dis[now] < d) continue;
		for(int i=head[now]; i; i=E[i].nxt) {
			int    v = E[i].to;
			int   id = E[i].id;
			int cost = d + (!vis[now].count(id));
			if(dis[v] > cost) {
				dis[v] = cost;
				Q.push({-cost,v});
				vis[v].clear();
				vis[v].insert(id);
			} else if(dis[v] == cost) {
				vis[v].insert(id);
			}
		}
	}
	printf("%d\n",dis[n] == inf? -1:dis[n]);
}
//******************************************
void init() {
	rep(i,1,n) {
		head[i] = 0;
		dis[i] = inf;
		vis[i].clear();
	}
	cnt = 0;
}
int main() {
	while(~scanf("%d %d",&n,&m)) {
		init();
		while(m--) {
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			add(a,b,c);
			add(b,a,c);
		}
		a();
	}
}

Measured memory_bytes: 20216
#include <stdio.h>

int main(void){
	
	int i,j,t,n,w[100],cp;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&w[i]);
	}
	
	for(t=0; t<n; t++){
		cp = w[t];             
        for (j = t; j > 0 && w[j-1] > cp; j--){
            w[j] = w[j -1];
        }
        w[j] = cp;
		
		for(i=0; i<n; i++){
		
		printf("%d",w[i]);
			
			if(i != n-1){
				printf(" ");
			}
		}
		
		printf("\n");
		
		
	}
	
	return 0;
}



Measured memory_bytes: 2092
package main

import (
	"fmt"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	if s[0] == 'R' && s[1] == 'R' && s[2] == 'R' {
		fmt.Println(3)
	} else if s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R' {
		fmt.Println(2)
	} else if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
#include <iostream>
using namespace std;
#define endl '\n'
void fastIO() {
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}

int main() {
	fastIO();
	int a, b;
	cin >> a >> b;
	printf("%.3f\n", (double) a / b);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = Integer.parseInt(line1[i]);
        int[] ary1 = new int[n];
        for(int i = 0; i < n; i++)  ary1[ary[i] - 1] = i + 1;
        for(int i = 0; i < n; i++)  System.out.print(ary1[i] + " ");
    }
}

Measured memory_bytes: 54648
a, b, c, x, y = list(map(int, input().split()))

min_money=2*5000*10**5
for nc in range(0,2*10**5+1,2):
    if nc > 2*x and nc > 2*y:
        break
    if nc > 2*x:
        money = (y-nc//2)*b + nc*c
    elif nc > 2*y:
        money = (x-nc//2)*a + nc*c
    else:
        money = (x-nc//2)*a + (y-nc//2)*b + nc*c
    if min_money > money:
        min_money = money
            
print(min_money)

Measured memory_bytes: 3064
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}

const int MAXN = 100228;


int n;
int a[MAXN];
map<int, int> cnt;

int main() {
    fast_io();
    //read("input");
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n % 3 != 0) {
        for (int i = 0; i < n; i++) {
            if (a[i] != 0) {
                cout << "No\n";
                exit(0);
            }
        }       
    } else {
        for (int i = 0; i < n; i++) {
            cnt[a[i]]++;
        }
        if (sz(cnt) > 3) {
            cout << "No\n";
            exit(0);
        }
        for (auto x: cnt) {
            if (x.second % (n / 3) != 0) {
                cout << "No\n";
                exit(0);
            }
        }
        int t = 0;
        for (auto x: cnt) {
            for (int i = 0; i < (x.second) / (n / 3); i++) {
                t ^= x.first;
            }
        }
        if (t != 0) {
            cout << "No\n";
                exit(0);
        }
    }
    cout << "Yes\n";
    return 0;
}   
    

Measured memory_bytes: 4224
import java.util.Scanner;

class Main{

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

        double r = scan.nextDouble();
        double x;
        double y;
        
        x = r * r * Math.PI;
        y = r * 2 * Math.PI;
        
        System.out.printf("%f %f\n",x,y);
       
       
        
    }
}








Measured memory_bytes: 28412
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int mincost(int a[],int n,int k)
    {
        int dp[100001]={0},i,j;
        for(i=2;i<=n;i++)
            {
                int x,y;
                int ans=abs(a[i]-a[i-1])+dp[i-1];
                for(j=2;j<=k;j++)
                    {
                        if(i-j>0)
                        {
                            x=abs(a[i]-a[i-j])+dp[i-j];
                            ans=min(x,ans);
                        }
                    }   
                dp[i]=ans;
            }
        return dp[n];
    }


int main()
{
        int a[100001],i,n,k;
        cin >> n >> k;
        a[0]=99999; 
        for(i=1;i<=n;i++)
            {
                cin >> a[i]; 
            }
        cout << mincost(a,n,k);
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<int mod> class modint
{   
private:
    int val;
public:
    int value(){ return val; }
    modint(int x=0){ val=x%mod; }
    modint pow(int n){
        modint res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    modint inv(){ return pow(mod-2); }
    modint& operator+=(modint rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator-=(modint rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    modint& operator*=(modint rhs){ val=val*rhs.val%mod; return *this; }
    modint& operator/=(modint rhs){ *this*=rhs.inv(); return *this; }
    modint operator+(modint rhs){ return modint(val)+=rhs; }
    modint operator-(modint rhs){ return modint(val)-=rhs; }
    modint operator*(modint rhs){ return modint(val)*=rhs; }
    modint operator/(modint rhs){ return modint(val)/=rhs; }
    bool operator!=(modint rhs){ return (*this).value()!=rhs.value(); }
};

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

    int N; cin>>N;
    vector<vector<int>> G(N);
    for(int i=0;i<N-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    using mint=modint<1000000007>;
    vector<vector<mint>> dp(N,vector<mint>(2));
    function<mint(int,int,int)> dfs=[&](int v,int c,int p)
    {   
        if(dp[v][c]!=mint(0)) return dp[v][c];
        mint res=1;
        for(int u:G[v]) if(u!=p){
            if(c==0){
                res*=(dfs(u,0,v)+dfs(u,1,v));
            }else{
                res*=dfs(u,0,v);
            }
        }
        return dp[v][c]=res;
    };
    mint ans=dfs(0,0,-1)+dfs(0,1,-1);
    cout<<ans.value()<<endl;
    return 0;
}

Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int n;
   cin >> n;
   vector<int> w(n);
   for(int i = 0; i < n; i++) cin >> w[i];
   int allsum = 0;
   for(int i = 0; i < n; i++) allsum += w[i];
   int sum1 = 0;
   int sum2 = 0;
   int ans = 10000000;
   for(int i = 0; i < n; i++){
       sum1 += w[i];
       sum2 = allsum - sum1;
       int sa = abs(sum1 - sum2);
       ans = min(ans, sa);
   }
   cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int count1 = 0, count2 = 0;
        for (int i = 0; i < n; ++i) {
            int x;
            scanf("%d", &x);
            if(x == 1) count1++;
            else if(x >= 2) count2++;
        }
        if(!count2) puts("NA");
        else cout << count1+count2+1 << "\n";
    }
    return 0;
}


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

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

using namespace std;

int main(){
  int x;cin>>x;
  int dp[101000];
  rep(i,101000)dp[i]=-1;
  dp[0]=0;
  int prices[6] = {100,101,102,103,104,105};
  rep(i,x+1){
    for(auto p:prices){
      if(i-p>=0 && dp[i-p]>=0)dp[i]=dp[i-p]+p;
    }
  }

  cout<<(dp[x]>-1);

  return 0;
}

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

#define int long long
#define ll long long
#define F first 
#define S second 
#define pb push_back
#define ld long double

using namespace std ; 

const int MAXN = 1011 , MOD =  1e9 + 7 ;

char s[MAXN][MAXN] , t [MAXN][MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ;
	int n , m ; 
	cin >> n >> m ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> s[i] ; 
	for(int i = 0 ; i < m ; i ++ ) cin >> t[i] ; 
	for(int i = 0 ; i + m <= n ; i ++ ) for(int j = 0 ; j + m <= n ; j ++ ) 
	{
		bool f = 0 ; 
		for(int q = 0 ; q < m ; q ++ ) for(int w = 0 ; w < m ; w ++ ) f |= (t[q][w] != s[q+i][w+j] );
		if(!f) return cout << "Yes" << endl , 0 ; 
	}
	cout << "No" << endl ; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}

int main()
 {  fast();
	int t, n, k;
    //cin >> t;
    t=1;
	while(t--) {
     int n;
     string s;
     cin>>s;
     int count=0;
     int maxcount=0;
     fore(i,s.length()){
         if(s[i]=='R')count++;
         else 
         {
             maxcount=max(count,maxcount);
             count=0;
         }
     }
     if(count>0)maxcount=max(count,maxcount);
     cout<<maxcount<<endl;
     }}
       

	  


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var x []int
	var wa int
	out := math.MaxInt32

	for i := 0; i < n; i++ {
		x = append(x, nextInt())
	}

	sort.Ints(x)

	for i := 1; i <= 100; i++ {
		wa = 0
		for _, j := range x {
			wa += int(math.Pow(float64(j-i), 2))
		}
		if out > wa {
			out = wa
		}
	}
	fmt.Println(out)

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};

struct Node *root, *NIL;

void insert(int k){
    struct Node *y = NIL;
    struct Node *x = root;
    struct Node *z;

    z=(struct Node *)malloc(sizeof(struct Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!= NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
	else x = x->right;
    }
    
    z->parent = y;
    if(y == NIL){
        root = z;
    }
    else{
        if( z->key < y->key){
            y->left = z;
        }
	else y->right = z;
    }

}

void find(int key){
    struct Node *x = root;

    while(x != NIL){
        if(x->key > key){
            x = x->left;
        }
	else if(x->key < key) {
            x = x->right;
        }
	else{
            printf("yes\n");
            return;
        }
    }

    printf("no\n");
}

void inorder(struct Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(struct Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, a;
    char com[10];
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &a);
            insert(a);
        }
	else if(com[0] == 'f'){
            scanf("%d", &a);
            find(a);
        }
	else{
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");

        }
    }

    return 0;
}



Measured memory_bytes: 20440
n = gets.to_i
matrix = n.times.map { gets.split.map(&:to_i) }

ret = matrix.combination(2).count do |x, y|
  square = x.zip(y).inject(0) { |sum, s| sum + (s[0] - s[1])**2 }
  Math.sqrt(square) % 1 == 0
end
puts ret

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

typedef long long ll;

ll n, m, fa[100005], size[100005], st[100005], ed[100005], ans[100005];

ll find(ll x)
{
	if (fa[x] == x) return fa[x];
	return fa[x] = find(fa[x]);
}

ll merge(ll x, ll y)
{
	ll fx = find(x);
	ll fy = find(y);
	if (fx == fy) return 0;
	ll ret = size[fx] * size[fy];
	fa[fy] = fx;
	size[fx] += size[fy];
	return ret;
}

int main ()
{
	cin >> n >> m;
	for (ll i = 1; i <= m; i++)
	{
		cin >> st[i] >> ed[i];
	}
	for (ll i = 1; i <= n; i++)
	{
		fa[i] = i;
		size[i] = 1;
	}
	for (ll i = m; i >= 1; i--)
	{
		ans[i] = merge(st[i], ed[i]);
	}
	ans[0] = 0;
	for (ll i = 1; i <= m; i++)
	{
		ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main() {

  int n;
  cin >> n;
  vector<long long> vec;
  for(int i = 1; i <= n; i++){
    long long k;
    cin >> k;
    vec.push_back(k-i);
  }

  sort(vec.begin(),vec.end());
  long long m;
  if(n%2 == 0) m = (vec[n/2]+vec[n/2-1])/2;
  else m = vec[n/2];
  //cout << m << endl;
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(vec[i]-m);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    ab=[0]*M
    for i in range(M):
        ab[i]=list(map(int,readline().split()))

    ab.sort(key=lambda x:x[1])
    res=0
    for i in range(M):
        a=ab[i][0]
        b=ab[i][1]
        if i==0:
            bridge=b-1
            res+=1
        else:
            if a<=bridge:
                pass
            else:
                bridge=b-1
                res+=1
    
    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 29156
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int[] p = new int[8];
			for(int i = 0; i < 8; i++) {
				p[i] = sc.nextInt();
			}

			String t = "555555555";
			int max = 0;
			int[] c = {4, 1, 4, 1, 2, 1, 2, 1};
			for(int i = 0; i < 8; i++) {
				int v = 0;
				for(int j = 0; j < 8; j++) {
					v += Math.min(p[j], c[(i + j) % 8]);
				}
				if(max < v) {
					String g = "";
					for(int j = 0; j < 8; j++) {
						g += Integer.toString(c[(i + j) % 8]);
					}
					max = v;
					t = g;
				}else if(max == v) {
					String g = "";
					for(int j = 0; j < 8; j++) {
						g += Integer.toString(c[(i + j) % 8]);
					}
					if(t.compareTo(g) > 0) {
						t = g;
					}
				}
			}
			for(int i = 0; i < 8; i++) {
				if(i == 7) {
					System.out.println(t.charAt(i));
				}else {
					System.out.print(t.charAt(i) + " ");
				}
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 30340
/*
    If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b)
{
    a+=b; a%=MOD;
    if(a<0) a+=MOD;
    return a;
}
ll mult(ll a, ll b)
{
    if(a>MOD) a%=MOD;
    if(b>MOD) b%=MOD;
    ll ans=(a*b)%MOD;
    if(ans<0) ans+=MOD;
    return ans;
}
ll pw(ll a, ll b)
{
    ll r=1;
    while(b){
        if(b&1) r=mult(r,a);
        a=mult(a,a);
        b>>=1;
    }
    return r;
}

void solve(){
    ll n;
    cin>>n;
    ll ans=1;
    for(int i = 1 ; i <= n ;i++){
        ans=mult(i,ans);
    }
    cout<<ans<<endl;
}

int main(){
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;
        //cout<<"Case "<<k<<": ";
        solve();
    }
}



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

int main()
{
	int c[6];
	for (int i = 0; i < 6; i++) cin >> c[i];
	cout << (1 * c[0] + 5 * c[1] + 10 * c[2] + 50 * c[3] + 100 * c[4] + 500 * c[5] >= 1000) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))

using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

Measured memory_bytes: 3080
#import math
import fractions

def main():

    # 1 <= a <= b <= 10^18
    # 1 <= c,d <= 10^9

    a, b, c, d = map( int, input().split())
    count = 0

    ac = -(-a // c)
    bc = b // c

    ad = -(-a // d)
    bd = b // d

    cd = int(c * d / fractions.gcd(c, d))

    acd = -(-a // cd)
    bcd = b // cd

    cm_num = bc - ac + 1
    dm_num = bd - ad + 1
    cdm_num = bcd - acd + 1

    count = cm_num + dm_num - cdm_num

    total = b - a + 1

    print(total - count)

if __name__ == '__main__':
    main()



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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    for (int i = 0; i < h; i++){
        cin>>a[i];
    }
    for (int i = 0; i < h; i++){
        cout<<a[i]<<endl;
        cout<<a[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}












const int limit = 51;
int n,m;
bool vec[limit][limit];
bool vis[limit];

void DFS(int x){
    if(vis[x]) return;

    vis[x] = true;

    REP(i,n){
        if(vec[i][x]){
            DFS(i);
        }
    }
}
using namespace std;
int main(){
    int n;
    cin >> n;

    string ans = "",S;
    vector<map<char, int>> mv(n);
    REP(i,n){
        cin >> S;
        REP(j,S.size()){
            mv[i][S[j]] ++;
        }
    }

    for(auto x : mv[0]){
        bool fl = true;
        int e ,g=INF;

        REP(i,n){
            e = mv[i][x.first];
            g = min(e,g);
        }

        REP(i,g){
            ans += x.first; 
        }


    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout<<"----------------------------------\n";
#define mp make_pair
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

short arr[22][22];
LL lim=(LL)pow(2,22);
LL n;

LL dp[22][2097152];


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
        }
        base=base*base;
        y=y>>1;
    }
    return ans;
}

LL cal(LL index,LL mask)
{
    if(dp[index][mask]==-1)
    {
        if(index!=1)
        {
            LL ways=0;
            LL one=(LL)1;
            LL currmask=mask;
            for(LL i=1;i<=n;i++)
            {
                LL check=(one<<(i-1));
                LL p=(check&currmask);
                if(arr[index][i]==1 && (p!=0))
                {
                    LL t=~check;
                    LL give=(t)&currmask;          
                    if(dp[index-1][give]==-1)
                    {
                        dp[index-1][give]=cal(index-1,give);
                    }
                    ways+=dp[index-1][give];
                    ways%=mod;
                }
            }

            dp[index][mask]=(ways)%mod;
        }
        else
        {
            LL ways=0;
            LL one=1;
            LL currmask=mask;
            for(LL i=1;i<=n;i++)
            {
                LL check=(one<<(i-1));
                LL p=check&currmask;
                if(arr[index][i]==1 && (p!=0))
                {
                    ways++;
                    ways%=mod;
                }
            }

            dp[index][mask]=(ways)%mod;
        }        
    }
    return dp[index][mask];
}

int main()
{    
    fastinput;
    LL i,j,k,t,temp;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            cin>>arr[i][j];
        }
    }
     LL initialmask=POW(2,n)-1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=initialmask;j++)
        {
            dp[i][j]=-1;
        }
    }

   
    LL ans=cal(n,initialmask);
    cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 344320
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n = int(readline())

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1

    for i in range(2,n+1):
        dp[i] = dp[i-1] + dp[i-2]

    print(dp[n])    


if __name__ == "__main__":
    main()


Measured memory_bytes: 5604