akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{
    static int w;
    static int h;
    static int[][] vWalls;
    static int[][] hWalls;
    static State[][] mazes;
    static Queue<State> queue;
    static class State {
        int x, y, minStep;
        State(int x, int y) {
            this.x = x;
            this.y = y;
            this.minStep = 0;
        }
    }

    static int bfs() {
        while(!queue.isEmpty()) {
            State p = queue.remove();//先頭要素を取り出す
            int x = p.x;
            int y = p.y;
            if(x == w-1 && y == h-1) {
                return p.minStep;
            }
            if(x+1 < w && vWalls[x][y] == 0  && mazes[x+1][y].minStep == 0) {
                mazes[x+1][y].minStep = p.minStep + 1;
                queue.add(mazes[x+1][y]);//行き先を訪問に加える
            }
            if(x-1 >= 0 && vWalls[x-1][y] == 0  && mazes[x-1][y].minStep == 0) {
                mazes[x-1][y].minStep = p.minStep + 1;
                queue.add(mazes[x-1][y]);
            }
            if(y + 1 < h && hWalls[x][y] == 0  && mazes[x][y+1].minStep == 0) {
                mazes[x][y+1].minStep = p.minStep + 1;
                queue.add(mazes[x][y+1]);
            }
            if(y-1 >= 0  && hWalls[x][y-1]==0 && mazes[x][y-1].minStep == 0) {
                mazes[x][y-1].minStep = p.minStep + 1;
                queue.add(mazes[x][y-1]);
            }
        }
        return 0;
    }

    public  static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while(sc.hasNext()) {
                w = sc.nextInt();
                h = sc.nextInt();
                if(w == 0 && h == 0) {
                    break;
                }
                vWalls = new int[w-1][h];
                hWalls = new int[w][h];
                mazes = new State[w][h];
                for(int y = 0; y < h-1; y++) {
                    for(int x = 0; x < w - 1; x++) {
                        vWalls[x][y] = sc.nextInt();
                    }
                    for(int x = 0; x < w ; x++) {
                        hWalls[x][y] = sc.nextInt();
                    }
                }
                for(int x = 0; x < w - 1; x++) {
                    vWalls[x][h-1] = sc.nextInt();
                }
                for(int y = 0; y < h; y++) {
                    for(int x = 0; x < w; x++) {
                        mazes[x][y] = new State(x,y);
                    }
                }
                queue = new LinkedList<>();
                mazes[0][0].minStep = 1;
                queue.add(mazes[0][0]);
                System.out.println(bfs());
            }
        }
    }
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    rep(i, N){
        int a; cin >> a;
        if(a % 2 == 0){
            if(a % 3 > 0 && a % 5 > 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

const int mxN = 2e5;
int n, m, ans[mxN];
vector<int> adj[mxN];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<int> q;
    q.push(0);
    memset(ans, -1, sizeof(ans));
    ans[0] = 0;

    while (q.size())
    {
        int x = q.front();
        q.pop();

        for (int u : adj[x])
        {
            if (ans[u] == -1)
            {
                ans[u] = x;
                q.push(u);
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (ans[i] == -1)
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    for (int i = 1; i < n; i++)
    {
        cout << ans[i] + 1 << "\n";
    }
}

Measured memory_bytes: 13256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    cin >> N;
    bool seven = false;

    while (N) {
        if (N%10 == 7) {
            seven = true;
            break;
        }

        N /= 10;
    }

    cout << (seven ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

int main(){
    int a,b;
    cin >> a >> b;

    vector<string> x(2);
    string A,B;
    rep(i,b){
        A += to_string(a);
    }
    rep(i,a){
        B += to_string(b);
    }
    x[0] = A;
    x[1] = B;
    sort(x.begin(),x.end());

    cout << x[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+100;
const int mod = 1e9+7;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
inline bool read(ll &num) {
    char in;bool IsN=false;
    in=getchar();
    if(in==EOF) return false;
    while(in!='-'&&(in<'0'||in>'9')) in=getchar();
    if(in=='-'){ IsN=true;num=0;}
    else num=in-'0';
    while(in=getchar(),in>='0'&&in<='9'){
            num*=10,num+=in-'0';
    } 
    if(IsN) num=-num;
    return true;
}
ll dp[500][500],sum[N],a[N];
int main(){
    int n,k;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    memset(dp,llINF,sizeof(dp));
    for(int i=1;i<=n;i++) dp[i][i]=0;
    for(int len=1;len<=n;len++){
        for(int i=1;i<=n;i++){
            int j=i+len-1;
            if(j<=n){
                for(int k=i;k<j&&k<n;k++){
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
                }
            }
        }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>
#define MAX 100000

typedef struct
{
  char mark;
  int num;
}CARD;

CARD L[MAX/2+2],R[MAX/2+2];

void merge(CARD*,int,int,int,int);
void mergesort(CARD*,int,int,int);
int partition(CARD*,int,int,int);
void quicksort(CARD*,int,int,int);

int main()
{
  int n,i,y,flag=1;
  char x[10];
  scanf("%d",&n);
  CARD A[MAX],B[MAX];
  
for(i=0;i<n;i++){
 scanf("%s %d",x,&y);
 A[i].mark=B[i].mark=x[0];
 A[i].num=B[i].num=y;
                 }
 mergesort(A,n,0,n);
 quicksort(B,n,0,n-1);

 for(i=0;i<n;i++){
   if(A[i].num!=B[i].num) flag=0;
   if(A[i].mark!=B[i].mark) flag=0;
                 }
 if(flag==1)
   printf("Stable\n");
 else 
   printf("Not stable\n");
 for(i=0;i<n;i++){
   printf("%c %d\n",B[i].mark,B[i].num);
                 }
 return 0;
}
void merge(CARD *A,int n,int left,int mid,int right)
{
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  int i,j,k;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].num=R[n2].num=2000000000;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num) A[k]=L[i++];
    else A[k] = R[j++];
                        }
}
void mergesort(CARD* A,int n,int left,int right)
{
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
                  }
}
int partition(CARD*B,int n,int p,int r)
{
  CARD x,s;
  int i,j;
  x=B[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(B[j].num<=x.num){
      i++;
      s=B[i];
      B[i]=B[j];
      B[j]=s;          }
                 }
  s=B[i+1];
  B[i+1]=B[r];
  B[r]=s;

  return i+1;
}

void quicksort(CARD *B,int n,int p,int r)
{
  int q;
  if(p<r){
    q=partition(B,n,p,r);
    quicksort(B,n,p,q-1);
    quicksort(B,n,q+1,r);
          }
}




Measured memory_bytes: 4036
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  char s[3];
  cin >> s[0] >> s[1] >> s[2];

  sort(s, s+3);
  if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import math


def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


n = int(input())
mod = 10**9 + 7
ans = {}
for i in range(2, n+1):
    for s in trial_division(i):
        if s == 1:
            continue
        if s in ans.keys():
            ans[s] += 1
        else:
            ans[s] = 1
w = 1
for i in ans.values():
    w *= (i+1)
    w %= mod
print(w)


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    double X;
    ist >> X;

    /* ------- 計算 ------- */

    double money = 100;
    int year = 0;

    while (money < X)
    {
        money *= 1.01;
        money = floor(money);
        year++;
    }

    ost << year << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3708
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,m = m()

mi = 2019

if m-n >= 2019:
	print(0)
	exit()
else:
	n %= 2019
	m %= 2019
	if n > m:
		print(0)
		exit()
	else:
		for i in range(n,m):
			for j in range(i+1,m+1):
				if (i * j) % 2019 <= mi:
					mi = (i * j) % 2019
print(mi)

Measured memory_bytes: 42092
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] l = new int[n];
		int sum = 0;

		for(int i = 0; i < n; i++){
			l[i] = sc.nextInt();
			sum += l[i];
		}

		Arrays.sort(l);

		System.out.println(l[n - 1] < sum - l[n - 1] ? "Yes" : "No");
	}

}


Measured memory_bytes: 23636
import numpy as np

H,W = map(int,input().split())
hw = np.array([list(input()) for _ in range(H)])

gyo = np.all(hw == ".",axis=1)
retu= np.all(hw == ".",axis=0)

for i in range(H):
    if not gyo[i]==True:
        for j in range(W):
            if not retu[j]==True:
                print(hw[i][j],end="")
        print()

Measured memory_bytes: 27280
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x
#define FLAG1 1 

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string S;
    ll Q;
    cin >> S >> Q;

    deque<char> s;
    REP(i,S.size()){
      s.push_back(S[i]);
    }

    //本文
    int flag = 0;
    REP(i,Q){
      ll T = 0;
      cin >> T;
      if(T==1){
        if(flag == 0) flag =1;
        else flag =0;
      }
      else if(T==2){
        ll F = 0;
        string c="";
        cin >> F >> c;
        if(flag==1){
        if(F==2) s.push_front(c[0]);
        else if(F==1) s.push_back(c[0]);
        }
        else if (flag==0){
        if(F==1) s.push_front(c[0]);
        else if(F==2) s.push_back(c[0]);
        }
      }
    }
    string ans;
    REP(i,s.size()){
      ans += s[i];
    }
    if(flag==1){
      reverse(ans.begin(),ans.end());
    }
    
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 4280
#include<iostream>
    #include<vector>
    using namespace std;
    int main()
    {

        int N;
        cin >> N;
        vector<int> toukouJyun(N + 1, -1); 
        for(int i = 1; i <= N; i++){
            int index;
            cin >> index;
            toukouJyun.at(index) = i;
        }
        bool notFirst = false;
        for(int i = 1; i <= N; i++){
            int student_id = toukouJyun.at(i);
            if(student_id != -1){
                if (notFirst){
                    cout << ' ';
                }
                cout << toukouJyun.at(i);
                notFirst = true;
            }
        }
        return 0;
    }

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
 
void solve(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    sort(begin(h),end(h));
    int cnt=0;
    rep(i,n){
        if(h[i]>=k)++cnt;
    }
    cout<<cnt<<endl;
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin >> n;
	ll a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
    ll ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i+1; j < n; ++j) ans += (a[i]*a[j]);
	}
cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int x, tmp, max = 1;
	cin >> x;
	FOR(i,2,32){
		tmp = i*i;
		while(1){
			if(tmp > x){
				break;
			}else if(tmp * i > x){
				if(tmp > max) max = tmp;
				break;
			}
			tmp *= i;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
taro_p = hana_p = 0
for n in range(N):
  tw,hw = input().split()
  if tw == hw:
    taro_p += 1
    hana_p += 1
  elif tw < hw:
    hana_p += 3
  else :
    taro_p += 3

print(taro_p,hana_p)

Measured memory_bytes: 7716
/* Work 3_4
 * AtCoder 81
 * cy_an */

#include <stdio.h>

int main(void){
    int n, i, for_flag = 1;           // 変数宣言
    scanf("%d", &n);                  // nを入力

    for(i = 1; i < 10; i++){          // 1から9で除算
        if(n / i < 10 && n % i == 0){ // 商が10未満かつ余りが0の場合
            printf("Yes\n"); for_flag--; break; // "Yes"を出力、フラグを0、ループ終了
        }
    }
    if(for_flag){                     // forでbreakしていない=フラグが1のとき
        printf("No\n");               // "No"を出力
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a[3];
  int i,j,t,c;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    t=i;
    for(j=i+1;j<3;j++){
      if(a[t]>a[j]){
    t=j;
      }
    }
    c=a[i];
    a[i]=a[t];
    a[t]=c;
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    string T = S.substr(0, N / 2);
    T = T + T;
    if(S == T)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

int dy[4]={0,0,1,-1};
int dx[4]={1,-1,0,0};
int main(){
	int n;
	cin>>n;
	cout<<n/3<<endl;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	int T;scanf("%d",&T);
	while(T--)
	{
		ll a,b;scanf("%lld%lld",&a,&b);
		if(a>b) swap(a,b);
		if(a==b || a+1==b) printf("%lld\n",2*(a-1));
		else
		{
			ll c=(ll)floor(sqrt(a*b));
			if(c*c==b*a) c--;
			if(c*(c+1)>=a*b) printf("%lld\n",2*c-2);
			else printf("%lld\n",2*c-1);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(){
	double r;
	
	cin >> r;
	
	cout << fixed << setprecision(6) << r * r * M_PI <<" ";
	cout << fixed << setprecision(6) << 2 * r * M_PI << endl;
	
}

Measured memory_bytes: 1288
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  string s; read(s);
  int c = 0, d = 0;
  rep(i, 0, 3) {
    if (s[i] == 'R') c++;
    else c = 0;
    chmax(d, c);
  }
  chmax(d, c);
  write(d);
}



Measured memory_bytes: 3600
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


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



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	double L;
	double V;
	cin>>L;
	V=(L*L*L)/27;
	printf("%.10f\n", V);
	return 0;

}







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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, l;
  cin >> n >> l;
  int ans = 0, min = 1000, diff;
  REP(i, n) {
    int taste = l + i;
    if (min > abs(taste)) {
      min = abs(taste);
      diff = taste;
    }
    ans += taste;
  }
  ans -= diff;
  print(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

 struct node{
            int key;
            struct node *next;
            struct node *prev;
            };

 typedef struct node *NodePointer;
 NodePointer nil;

 NodePointer listSearch(int key){
       NodePointer i;
       for(i=nil;i->next!=nil;i=i->next){
             if(i->next->key==key)return i->next;
             }
       return NULL;
       }

 void init(){
       nil=malloc(sizeof(struct node));
       nil->next=nil;
       nil->prev=nil;
       }

 void printList(){
       NodePointer cur=nil->next;
       int isf=1;
       while(1){
          if(cur==nil)break;
          if(isf==0)printf(" ");
          printf("%d",cur->key);
          cur=cur->next;
          isf=0;
          }
       printf("\n");
       }

 void deleteNode(NodePointer t){
       t->next->prev=t->prev;
       t->prev->next=t->next;
       free(t);
       }

 void deleteFirst(){
       NodePointer t=nil->next;
       if(t==nil)return;
       deleteNode(t);
       }

 void deleteLast(){
       NodePointer i;
       i=nil->prev;
       deleteNode(i);
       }

 void delete(int key){
       NodePointer i;
       i=listSearch(key);
       if(i!=NULL)deleteNode(i);
       }

 void insert(int key){
       NodePointer x;
       x=malloc(sizeof(struct node));
       x->key=key;
       x->next=nil->next;
       nil->next->prev=x;
       nil->next=x;
       x->prev=nil;
       }

 int main(){
       int key,n,i;
       int size=0;
       char com[20];
       int np=0,nd=0;scanf("%d",&n);
       init();
       for(i=0;i<n;i++){
            scanf("%s%d",&com,&key);
            if(com[0]=='i'){
                 insert(key);
                 np++;
                 size++;
                 }
            else if(com[0]=='d'){
                 if(strlen(com)>6){
                      if(com[6]=='F')deleteFirst();
                      else if(com[6]=='L')deleteLast();    
                      }
                 else {
                       delete(key);nd++;
                       }
                 size--;
                 }
            }
       printList();
       return 0;
       }







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

int main(){
  int R;
  cin >> R;
  
  if(R < 1200){cout << "ABC"<< endl;}
  else if(R < 2800){cout << "ARC"<< endl;}
  else {cout << "AGC"<< endl;}
  
  
  return 0;
}

Measured memory_bytes: 256
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main(){
  var lines = input,
    N = lines[0].split(' ')[0] - 0,
    Q = lines[0].split(' ')[1] - 0,
    pair,
    name = 'kogakubu10gokan';
  for(var i = 1; i <= N; i++) {
    pair = lines[i].split(' ');
    if(Q < pair[0] - 0) {
      break;
    }
    name = pair[1];
  }
  console.log(name);
}

Measured memory_bytes: 7648
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

struct RangeMinimumQuery{
    int n;
    std::vector<int> dat;

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1, std::numeric_limits<int>::max());
    }

    void update(int k, int a){
        k += n - 1;
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = std::min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return std::numeric_limits<int>::max();
        if(a <= l && r <= b) return dat[k];
        else{
            int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return std::min(vl, vr);
        }
    }

    int query(int a, int b){
        return query(a, b, 0, 0, n);
    }
};

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    RangeMinimumQuery rmq;
    rmq.init(n);
    while(q--){
        int com, x, y;
        cin >> com >> x >> y;
        if(com){
            cout << rmq.query(x, y + 1) << "\n";
        }else{
            rmq.update(x, y);
        }
    }
}


Measured memory_bytes: 3864
using System;

public class B
{
	public static void Main()
	{
		string[] list = new string[]
		{
			"erase",
			"dream",
			"eraser",
			"dreamer"
		};
		string s = Console.ReadLine();
		while(0 < s.Length)
		{
			bool flag = false;
			for (int i = 0; i < list.Length; i++)
			{
				if (s.Substring(s.Length - list[i].Length, list[i].Length) == list[i])
				{
					flag = true;
					s = s.Substring(0, s.Length - list[i].Length);
					break;
				}
			}
			if (flag) continue;
			Console.WriteLine("NO");
			return;
		}
		Console.WriteLine("YES");
	}
}

Measured memory_bytes: 31200
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

	int bingo[3][3];
	rep(i, 3) {
		rep(j, 3) cin >> bingo[i][j];
	}

	int n;
	cin >> n;
	rep(i, n) {
		int b;
		cin >> b;
		rep(j, 3) {
			rep(k, 3) if (bingo[j][k] == b) bingo[j][k] = 0;
		}
	}

	bool ans = false;
	rep(i, 3) {
		if (bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0) ans = true;
		if (bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0) ans = true;
	}

	if (!ans) {
		if (bingo[1][1] == 0) {
			if ((bingo[0][0] == 0 && bingo[2][2] == 0) || bingo[0][2] == 0 && bingo[2][0] == 0) {
				ans = true;
			}
		}
	}

	if (ans)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


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

using namespace std;

#define pb push_back
#define ll long long

int main()
{
    int cases, n;
    ll sum = 0, cnt = 0, a, b, c, x, f2;
    bool flag = false;



    cin >> a >> b >> x;

    ll f1 = b/x;

    if( a <= 1) f2 = 0;
    else f2 = (a-1)/x;

    ll ans = f1 - f2;
    if( ans < 0)ans = 0;

    if( a == 0 || b == 0)ans++;

    cout << ans << endl;



    return 0;
}



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

int main() {
  int x,y;
  cin>>x>>y;
  if((x+y)%2==0){
cout<<(x+y)/2<<endl;
    

  
  
  }
  
  
  else{
    cout<<(x+y)/2+1<<endl;

    
    
    
    
    
  }
}


Measured memory_bytes: 256
//c
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int K = sc.nextInt();

		int[] tree = new int[N];

		for(int i=0;i<N;i++) tree[i] = sc.nextInt();

		sort(tree);

		int max_min = 1000000000;

		for(int i=0;i+K-1<N;i++) {

			//System.out.println(tree[i]);
			if(tree[i+K-1]-tree[i] < max_min) max_min = tree[i+K-1]-tree[i];
		}

		System.out.println(max_min);

	}

	public static void sort(int[] a) {

		int h;

		for(h=1; h<a.length/9; h=h*3+1);

		for(;h>0;h/=3) {

			for(int i=h; i<a.length; i++) {

				for(int j=i; j>=h && a[j-h]>a[j]; j-=h) {

					int temp = a[j];

					a[j] = a[j-h];

					a[j-h] = temp;
				}

			}
		}
	}


}


Measured memory_bytes: 49716
s = gets.chomp.chars
n= 753
array = []
for i in(0..s.size-3)
array.push([s[i],s[i+1],s[i+2]].map!(&:to_i))
end

puts (array.min_by{|a| ((a[0]*100+a[1]*10+a[2]*1)-n).abs}.join.to_i-n).abs


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 2 *1e9 +7;

int main(){
	int x,y;
	cin >> x >> y;
	int ans = inf;
	if(x <= y) ans = min(ans, y-x);
	if(-x <= y) ans = min(ans, y+x+1);
	if(x <= -y) ans = min(ans, -y-x+1);
	if(-x <= -y) ans = min(ans, -y+x+2);
	cout << ans << endl;
	return 0;
}


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

int main(){
    int k; cin >> k;
    
    //kが2の倍数かそうでないか
    if(k%2 == 0){
        cout << "-1" << endl;
    }else{
        long long int a = 7;
        for(int i=0; i<k; i++){
            if(a % k == 0){
                cout << i+1 << endl;
                exit(0);
            }else{
                a %= k;
                a = 10*a + 7;
            }
        }

        cout << "-1" << endl;
    }
}

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

string f[11];
int ans[11];
int n;
int w[11],s[11];

void solve(){
	for(int i=1; i<=n; i++)
		ans[i] = i;
	for(int k=1; k<=n; k++){
		for(int i=n; i>k; i--){
			if(s[ans[i]] > s[ans[i-1]]){
				int tmp = ans[i];
				ans[i] = ans[i-1];
				ans[i-1] = tmp;
			}
		}
	}
	bool flag = true;
	for(int i=1; i<=n; i++){
		if(i==n&&!flag){
			i=1;
			flag = true;
		}else if(i==n)
			break;
		if(w[ans[i]] < w[ans[i+1]]){
			int tmp = w[ans[i]];
			for(int k=i+2; k<=n; k++)
				tmp += w[ans[k]];
			if(s[ans[i+1]] >= tmp){
				tmp = ans[i];
				ans[i] = ans[i+1];
				ans[i+1] = tmp;
				flag = false;
			}
		}
	}
}

int main(){
	while(true){
		cin >> n;
		if(!n)
			return 0;
		for(int i=1; i<=n; i++)
			cin >> f[i] >> w[i] >> s[i];
		solve();
		for(int i=1; i<=n; i++)
			cout << f[ans[i]] << endl;
	}
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int p[100001]={0,1,};

int main(void){
    int i;
    char a[15][100]={"KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA",
                "AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA",
                "KIHBARA","AKIHABA","AKIHBARA","KIHABARA","AKIHABARA"};
    char s[100];
    chin(s);
    rep(i,15){
        if(strcmp(s,a[i])==0){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

int main(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin>>a[i]>>b[i]>>c[i];

  vector<vector<int>> dp(410, vector<int>(410, INF));
  dp[0][0]=0;
  rep(i,n){
    vector<vector<int>> nxt(410, vector<int>(410, INF));
    rep(j,410-a[i])rep(k,410-b[i])if(dp[j][k]<INF){
      nxt[j][k] = min(dp[j][k], nxt[j][k]);
      nxt[j+a[i]][k+b[i]] = min(nxt[j+a[i]][k+b[i]], dp[j][k]+c[i]);
    }
    swap(dp,nxt);
  }

  int res=INF;
  int p=ma, q=mb;
  while(p<=400 && q<=400){
    res = min(res, dp[p][q]);
    p += ma; q += mb;
  }
  if(res==INF) res=-1;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1640
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)

    q = deque([0])
    seen = [-1] * n
    seen[0] = 0

    while q:
        u = q.popleft()

        for v in g[u]:
            if seen[v] == -1 or seen[v] > seen[u] + 1:
                seen[v] = seen[u] + 1
                q.append(v)

    if seen[n - 1] == 2:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 77004
def solve():
    w, h, v, t, x, y, p, q = map(int, input().split())
    def count(a, b):
        res = 0
        C = v*t
        ky = 0
        while 1:
            B = b + 2*h*ky
            D = C**2 - (B - y)**2
            if D < 0:
                break
            SQ = D**.5 + 1e-7
            k0 = int((x - a - SQ) // (2*w))
            k1 = int((x - a + SQ) // (2*w))
            res += max(k1 - k0, 0)
            ky += 1
        ky = -1
        while 1:
            B = b + 2*h*ky
            D = C**2 - (B - y)**2
            if D < 0:
                break
            SQ = D**.5 + 1e-7
            k0 = int((x - a - SQ) // (2*w))
            k1 = int((x - a + SQ) // (2*w))
            res += max(k1 - k0, 0)
            ky -= 1
        return res
    ans = 0
    for a in [p, 2*w-p]:
        for b in [q, 2*h-q]:
            ans += count(a, b)
    print(ans)
solve()


Measured memory_bytes: 5716
#include<stdio.h>
int main(){
    int i, n, debt=100000;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        debt*=1.05;
        if(debt%1000>0)debt=debt-debt%1000+1000;
    }
    printf("%d\n", debt);
    return 0;
}

Measured memory_bytes: 592
#include<atcoder/all>
using namespace atcoder;

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

int main() {
    int T; scanf("%d", &T);
    while (T--) {
        LL n, m, a, b; scanf("%lld%lld%lld%lld", &n, &m, &a, &b);
        printf("%lld\n", floor_sum(n, m, a, b));
    }

    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll n,x,m;
    cin >> n >> x >> m;
    if(n == 1){
        cout << x << endl;
        return 0;
    }
    set<ll> memo;
    vector<ll> ans(m+1000,0);
    ans[0] = x;
    ll now = x;
    memo.insert(x);
    ll check = 0,endnum = 0;;
    ll state = 0;
    // ??
    if(n < 300000){
        ll ansk = x;
        rep(i,n-1){
            x *= x;
            x %= m;
            ansk += x;
        }
        cout << ansk << endl;
        return 0;
    }


    rep(i,1LL,min(m+1,n)){
        now *= now;
        now %= m;
        ans[i] = now;
        if(memo.find(now) == memo.end()){
            // 存在しない
            memo.insert(now);
        }else{
            state = 1;
            check = now;
            endnum = i - 1;
            break;
        }
    }
    // ここより下
    if(state == 0){
        ll anss = 0;
        rep(i,n) {
            anss += ans[i];
        }
        cout << anss << endl;
        return 0;
    }
    // ここより上
    ll start = 0;
    rep(i,m){
        if(ans[i] == check){
            start = i;
            break;
        }
    }
    // ここより上
    ll res = 0;
    ll sum = 0;
    rep(i,start){
        res += ans[i];
    }
    n -= start;
    
    rep(i,endnum - start + 1){
        sum += ans[i + start];
    }
    if(start > endnum){
        cout << "a" << endl;
        return 0;
    }

    ll div = n/(endnum - start + 1);
    res += sum * div;

    rep(i,n % div){
        res += ans[i+start];
    }
    cout << res << endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cstdlib>
#include <ctime>

using namespace std;

//#define HOME
void jakos() {
#ifdef HOME
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

#define endl '\n'
#define int long long
typedef long long ll;

const int mod = 1e9 + 7;
const int base = 179;
const int INF = 1e9;
const int N = 1e5 + 7;

signed main() {
    jakos();

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes" << endl;
    }
    else if (a == c && a != b) {
        cout << "Yes" << endl;
    }
    else if (b == c && b != a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        k: usize,
        s: chars
    }

    let mut now = 0;

    for i in 1..n {
        if s[i] == s[i - 1] {
            now += 1;
        }
    }

    println!("{}", cmp::min(n - 1, now + 2 * k));
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <stdio.h>
#include <string.h>
int main()
{   char s1[101],s2[101];
	int i,n1,j,n,flag,g;
	scanf("%s%s",s1,s2);
	n=strlen(s1);
	n1=strlen(s2);
	for(j=0;j<n;j++)
	     {g=s1[0];flag=0;
	      for(i=0;i<n-1;i++)
	         s1[i]=s1[i+1];
	      s1[n-1]=g;
	      for(i=0;i<n;i++)
		  if(s1[i]==s2[i])
		      flag++;
	      if(flag==n)break;
	 }
	if(flag==n)
	      printf("Yes\n");
	else
	      printf("No\n");
	
}

Measured memory_bytes: 128
#include <string>
#include <iostream>
using namespace std;
int main(){
  string S;
  cin>>S;
  int f=1;
  int Ccount=0;
  for(int i=0;i<S.length()&&f==1;i++){
    if(i==0){
      if(S[i]!='A') f=0;
    }else if(2<=i && S[i]=='C' && i<=S.length()-2){
      Ccount++;
      if(Ccount>1) f=0;
    }else{
      if(S[i]<'a' || S[i]>'z') f=0;
    }
  }
  if(f==1 && Ccount==1) cout<<"AC\n";
  else cout<<"WA\n";
  return 0;
}

Measured memory_bytes: 256