akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  string S,T;
  cin >> S >> T;
  int l = S.length();
  rep(i,l)
  {
    bool flag = true;
    rep(j,l)
    {
      if(S[(j + i) % l] != T[j])
      {
        flag = false;
        break;
      }
    }
    if(flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int n, m;


vector <pair<int, int> > v[100009];

bool odw[100009];
int d[100009];

bool sukces = true;

void dfs2(int s){
	odw[s]=true;
	for(auto it=v[s].begin(); it!= v[s].end(); it++){
		if(odw[it->first] == false){
			d[it->first] = d[s] + it->second;
			dfs2(it->first);
		}
		else{
			if(d[it->first] != d[s] + it->second)
				sukces = false;
		}
		
	}
}

void dfs(){
	for(int i=1; i<=n; i++){
		if(odw[i]==false){
			d[i]=0;
			dfs2(i);
		}
	}
}


int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0; i<=n; i++)
		d[i]=-1;
	for(int i=0; i<m; i++){
		int l, r, d;
		cin>>l>>r>>d;
		v[l].push_back(make_pair(r, d));
		v[r].push_back(make_pair(l, -d));
	}
	dfs();
	if(sukces){
		cout<<"Yes";
	}
	else
		cout<<"No";
	
	
	return 0;
}


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


int main() {
  int r, D, x;
  cin >> r >> D >> x;

  rep(_,10) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


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

int main(){
  ll n;
  cin >> n;
  string s = "";
  while( n != 0 ){
    n--;
    s = s + string(1,'a'+n%26);
    n /= 26;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3612
use proconio::input;

fn main() {
    input! {
        n: String
    }

    let mut sum_of_digits = 0;
    for c in n.chars() {
        sum_of_digits += c.to_digit(10).unwrap();
        sum_of_digits %= 9;
    }

    let res = if sum_of_digits == 0 {
        "Yes"
    } else {
        "No"
    };

    println!("{}", res);
}


Measured memory_bytes: 2368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa;
bool used[100015];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>sa;
	used[0]=true;
	for(i=0;i<sa.size();i++){
		if(!used[i])continue;
		if(i<=sa.size()-5 && sa[i]=='d' && sa[i+1]=='r' && sa[i+2]=='e' && sa[i+3]=='a' && sa[i+4]=='m'){
			used[i+5]=true;
		}
		if(i<=sa.size()-7 && sa[i]=='d' && sa[i+1]=='r' && sa[i+2]=='e' && sa[i+3]=='a' && sa[i+4]=='m' && sa[i+5]=='e' && sa[i+6]=='r'){
			used[i+7]=true;
		}
		if(i<=sa.size()-5 && sa[i]=='e' && sa[i+1]=='r' && sa[i+2]=='a' && sa[i+3]=='s' && sa[i+4]=='e'){
			used[i+5]=true;
		}
		if(i<=sa.size()-6 && sa[i]=='e' && sa[i+1]=='r' && sa[i+2]=='a' && sa[i+3]=='s' && sa[i+4]=='e' && sa[i+5]=='r'){
			used[i+6]=true;
		}
	}
	if(used[sa.size()])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N,A = list(map(int,input().split(" ")))
nums = list(map(int,input().split(" ")))

dp = [[[0 for i in range(4000)]for j in range(51)]for k in range(51)]

# dp[i][j][k] → i枚のうちj枚を選んで 和が kになる組み合わせ
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(3000):
            if dp[i][j][k] != 0:
                dp[i+1][j][k] += dp[i][j][k]    #i枚目を選ばなかった世界線
                dp[i + 1][j + 1][k + nums[i]]  += dp[i][j][k]          #i枚目を選んだ世界線


ans = 0
for j in range(1,N+1):
    ans += dp[N][j][j*A]
print(ans)

Measured memory_bytes: 98164
n,k=map(int,input().split())
s=input()
ans=0
changecount=0
for i in range(n):
  if s[i]=='R' and i!=n-1 and s[i+1]=='R':
    ans+=1
  if s[i]=='L' and i!=0 and s[i-1]=='L':
    ans+=1
  if i>0:
    if s[i]!=s[i-1]:
      changecount+=1
for i in range(k):
  if changecount==1:
    ans+=1
    break
  if changecount==0:
    break
  changecount-=2
  ans+=2
print(ans)
      

Measured memory_bytes: 73404
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli A, B;
	cin >> A >> B;

	if (A * B % 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main(){

  int i,N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  cin >> N;
  
  
  for(i=1;i<=N;i++)
    cin >> A.at(i);
  
  for(i=1;i<=N;i++)
    cin >> B.at(i);
  
  for(i=1;i<=N-1;i++)
    cin >> C.at(i);
  
  int sum=0;
  for(i=1;i<=N;i++){
    sum += B.at(A.at(i));
    if(i>1 && A.at(i)-A.at(i-1) == 1)
      sum += C.at(A.at(i-1));
  }
  cout << sum;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <vector>

int main(int argc, char* argv[]){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    std::vector<int> list = { a, b, c };

    for (int i = 0; i < list.size(); i++){
        int small = list[i];
        int smallIndex = i;


        for (int j = i + 1; j < list.size(); j++) {
            if (list[j] < small) {
                small = list[j];
                smallIndex = j;
            }
        }

        if (list[i] != small){
            int temp = list[i];
            list[i] = small;
            list[smallIndex] = temp;
        }
    }

    for(auto i = 0; i < list.size(); i++ ){
        // at last
        if(i == list.size() - 1){
            printf("%d", list[i]);
            continue;
        }
        printf("%d ", list[i]);
    }
    printf("\n");
}


Measured memory_bytes: 2748
A1 = [int(_) for _ in input().split()]
A2 = [int(_) for _ in input().split()]
A3 = [int(_) for _ in input().split()]
P = [A1, A2, A3]
for i in range(3):
    P.append([A1[i], A2[i], A3[i]])
P.append([A1[0], A2[1], A3[2]])
P.append([A1[2], A2[1], A3[0]])


N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
for p in P:
    if len(set(p) & set(B)) == 3:
        print('Yes')
        break
else:
    print('No')





Measured memory_bytes: 3316
#include <stdio.h>
void swap_int(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap_char(char* x, char* y) {
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void sort(int* array, int n, int mode) {
    int i, j;
    if (mode) {  // 1 is ascending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] > array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    } else {  // 0 is descending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] < array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    }
}
int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}
int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}

int main(void) {
    static int n, m, l[100000], r[100000];
    int i, j, k;
    int flg;
    int ans = 0;
    int min = 999999, max = -1;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d %d", &l[i], &r[i]);
        if (l[i] > max) {
            max = l[i];
        }
        if (r[i] < min) {
            min = r[i];
        }
    }

    int temp = min - max + 1;
    if (temp < 0) {
        printf("0\n");
    } else {
        printf("%d\n", temp);
    }

    /*for (i = 1; i <= n; i++) {
        flg = 0;
        for (j = 0; j < m; j++) {
            if (!(l[j] <= i && i <= r[j])) {
                flg = 1;
                break;
            }
        }
        if (!flg) {
            ans++;
        }
    }

    printf("%d\n", ans);*/
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

#define REP(i, n) for(ll i = 0; i < n; ++i)
#define REP3(i, B, E) for(ll i = B; i <= E; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

template<class T> T& chmin(T &obj, T val){ return obj = min(obj, val); }
template<class T> T& chmax(T &obj, T val){ return obj = max(obj, val); }

// 二分探索 : [low, high) の範囲で述語 pred がtrue を返す最大の値を返す
template<class Pred>
ll bsearch(ll low, ll high, Pred pred){
    while(low + 1 < high){
        const ll mid = low + (high - low) / 2;
        if(pred(mid)){ low = mid; }
        else{ high = mid; }
    }
    return low;
}

int main() {
    auto N = read<ll>();
    auto S = read<string>();
    
    for(auto& c : S){
        c = 'A' + (N + c - 'A') % 26; 
    }
    write(S);
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define M 5005
#define MOD 1000000007
#define ll long long

int n, m;
ll ans, f[M][M][2];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		f[0][i][0] = 1;
	f[0][0][1] = 1;

	for (int i = 0; i < m; i++)
		for (int j = 0; j <= n; j++)
		{
			if (j > 0)
			{
				if (j == 1) (f[i+1][j-1][1] += f[i][j][0]) %= MOD;
				else (f[i+1][j-1][0] += f[i][j][0]) %= MOD;
				(f[i+1][j-1][1] += f[i][j][1]) %= MOD;
				if (j == 1) (f[i+1][j][1] += f[i][j][0]) %= MOD;
				else (f[i+1][j][0] += f[i][j][0]) %= MOD;
				(f[i+1][j][1] += f[i][j][1]) %= MOD;
			}
			if (j < n)
			{
				(f[i+1][j+1][0] += f[i][j][0]) %= MOD;
				(f[i+1][j+1][1] += f[i][j][1]) %= MOD;
				(f[i+1][j][0] += f[i][j][0]) %= MOD;
				(f[i+1][j][1] += f[i][j][1]) %= MOD;
			}
		}

	for (int i = 0; i <= n; i++)
		(ans += f[m][i][1]) %= MOD;

	cout << ans;

	return 0;
}

Measured memory_bytes: 155864
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    ll s = 0;
    for (int i = 1; i <= n; i ++)
    	for (int j = 1; j <= n; j ++)
    		for (int k = 1; k <= n; k ++)
    			s += __gcd(i, __gcd(k, j));
    cout << s;
    return (0);
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
const int inf = 1e+9;
int main()
{
  int n,k,s;
  cin >> n >> k >> s;
  if(s==inf){
    rep(i,k){
      cout << s << " ";
    }
    rep(i,n-k){
      cout << 1 << " ";
    }
    cout  << "\n";
  }
  else{
    rep(i,k){
      cout << s << " ";
    }
    rep(i,n-k){
      cout << inf << " ";
    }
    cout  << "\n";
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define MAX_V 101
using namespace std;

/* ?????£?????????????§£ O(|V|+|E|) */
int V; //????????°
vector<int> G[MAX_V]; //??°???????????£??\??????????????¨???
vector<int> rG[MAX_V];//?????????????????????????????°??????
vector<int> vs;       //??°?????????????????????
bool used[MAX_V];     //?????§???????????????
int cmp[MAX_V];       //?±????????????£?????????????????????????????????

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);
  return k;
}

double p[MAX_V];

int main(){
  while(cin>>V,V){
    for(int i=0;i<V;i++) G[i].clear(),rG[i].clear();
    
    for(int i=0,m;i<V;i++){
      cin>>p[i]>>m;
      for(int j=0,a;j<m;j++)cin>>a,add_edge(i,a-1);
    }
    int n=scc();
    vector<double> col(n,1);
    vector<bool> root(n,1);

    for(int i=0;i<V;i++){
      col[cmp[i]]*=p[i];
      for(int j=0;j<G[i].size();j++)
	if(cmp[G[i][j]]!=cmp[i]) root[cmp[G[i][j]]]=0;
    }
    double ans=1;
    for(int i=0;i<n;i++)if(root[i])ans*=1-col[i];
    printf("%.10f\n",ans);
  }
  return 0;
}

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

int main(){
  float n;
  cin >> n;
  float ans = n/3;
  cout << setprecision(16) << ans*ans*ans << endl;
  return 0;
}


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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = i;
    int cnt = 0;
    while (tmp > 0) {
      cnt++;
      tmp /= 10;
    }
    ans += cnt & 1;
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 256
num_vacation_days, num_homework = map(int, input().split())
day_homework_costs = map(int, input().split())

for day_homework_cost in day_homework_costs:
    num_vacation_days -= day_homework_cost
    if num_vacation_days < 0:
        num_vacation_days = -1
        break

print(num_vacation_days)


Measured memory_bytes: 9648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

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

int main() {
	string str;
	cin >> str;
	REP(i, str.size()) {
		if (str[i] == ',') putchar(' ');
		else putchar(str[i]);
	}
	puts("");
	return 0;
}

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

using namespace std;

const int IINF = INT_MAX;

class RMQ{
private:
  int limit,N;
  vector<int> dat;
public:
  void init(int n_){
    N = n_;
    limit = 1;
    while(limit<n_) limit*=2;
    dat.clear();
    dat.resize(2*limit,IINF);
  }
  
  int _build(int cur,int L,int R,const vector<int> &buf){
    if( !( 0 <= cur && cur < 2*limit ) ) return IINF;
    if( L == R-1 ) {
      if( L >= N ) return IINF;
      dat[cur] = buf[L];
    } else {
      int vl = _build(cur*2+1,L,(L+R)/2,buf);
      int vr = _build(cur*2+2,(L+R)/2,R,buf);
      dat[cur] = min(vl,vr);
    }
    return dat[cur];
  }

  void build(const vector<int> &buf){ _build(0,0,limit,buf); };

  void update(int k,int a){
    k += limit-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = 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 IINF;
    else if(a<=l && r<=b)return dat[k];
    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 min(vl,vr);
  }

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

int main(){
  int N,Q;
  cin >> N >> Q;

  RMQ rmq;
  rmq.init(N);
  /* 
    vector<int> init;
    // input initial values to initi
    rmq.build(init);
   */
  for(int i=0;i<Q;i++) {
    int opr,x,y;
    cin >> opr >> x >> y;
    if( opr == 0 ) rmq.update(x,y);
    else if( opr == 1 ) printf("%d\n",rmq.query(x,y+1));
  }
  return 0;
}

Measured memory_bytes: 2052
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;

fn compare(s: &Vec<char>, t: &Vec<char>, mut n: usize) -> bool {
    let mut i = 0;
    loop {
        if i == t.len() {
            break;
        }
        if n == s.len() {
            return false;
        }
        if s[n] == t[i] || s[n] == '?' {
            n += 1;
            i += 1;
        } else {
            return false;
        }
    }
    true
}

fn main() {
    let mut s = str2vec(&input_line_str());
    let t = str2vec(&input_line_str());
    let mut count = 9999;
    for z in 0..s.len() {
        if compare(&s, &t, z) {
            count = z;
        }
    }
    if count == 9999 {
        println!("UNRESTORABLE");
        return;
    } else {
        for z in count..count + t.len() {
            s[z] = t[z - count];
        }
        for z in 0..s.len() {
            if s[z] == '?' {
                s[z] = 'a';
            }
        }
    }
    for z in s {
        print!("{}", z);
    }
    println!("");
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#include <string.h>


int main()
{
    int N,M,X,i,F1,F2;
    int A[200];
    scanf("%d%d%d",&N,&M,&X);
    F1=0;
    F2=0;
    for(i=1;i<=M;i++)
    {
        scanf("%d",&A[i]);
        if(A[i]>X)
            F1++;
        if(A[i]<X)
            F2++;
    }
    printf("%d\n",F1<F2?F1:F2);
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
typedef pair<ll, ll> pll;

int main()
{

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);

    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

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

    if (0 >= a && 0 <= b) {
        cout << "Zero\n";
        return 0;
    }

    if (a > 0) {
        cout << "Positive\n";
        return 0;
    }

    if (b > 0) {
        b = -1;
    }

    int cnt = b - a + 1;
    if (cnt & 1) {
        cout << "Negative\n";
    } else {
        cout << "Positive\n";
        return 0;
    }

}


Measured memory_bytes: 764
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}


vector<string> results;

string run_command(string& str, vector<string>& commands) {
	auto _str = str;
	int a = stoi(commands[1]);
	int b = stoi(commands[2]);
	int print_num = b - a + 1;
	
	if (commands[0] == "print") {
		results.emplace_back(_str.substr(a, print_num));
	}
	else if (commands[0] == "reverse") {
		reverse(_str.begin() + a, _str.begin() + b + 1);
	}
	else if (commands[0] == "replace") {
		_str.replace(_str.begin() + a, _str.begin() + b + 1, commands[3]);
	}

	return _str;
}


double calc_variance(vector<double> vec) {
	double ave = accumulate(vec.begin(), vec.end(), 0.0) / vec.size();

	double sq_sum = 0.0;
	for (auto&& v : vec) {
		sq_sum += v * v;
	}

	double var = sq_sum / vec.size() - ave * ave;
	return var;
}


int main() {

	int n;
	vector<double> ans;
	while (cin >> n, n != 0)
	{
		string scores;
		getline(cin, scores);
		if (scores == "") getline(cin, scores);
		auto s_i = split(scores, ' ');
		vector<double> vec;

		for (auto&& s : s_i) {
			vec.emplace_back(stod(s));
		}
		auto var = calc_variance(vec);
		ans.emplace_back(sqrt(var));
	}

	for (auto&& a : ans) {
		printf("%.8lf\n", a);
	}
	return 0;
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  int r,A=1;
  vector<int> p(N);
  for(int i=1;i<N;i++){
    if(S[i-1]==S[i]){
      A++;
    }
    else if(S[i-1]=='R'){
      r=i-1;
      p[r]+=(A+1)/2;
      p[r+1]+=A/2;
      A=1;
    }
    else{
      p[r]+=A/2;
      p[r+1]+=(A+1)/2;
      A=1;
    }
  }
  p[r]+=A/2;
  p[r+1]+=(A+1)/2;
  for(int i=0;i<N;i++){
    cout<<p[i];
    if(i!=N-1){
      cout<<" ";
    }
  }
}

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

using namespace std;

int main() {

	string a, b;
	cin >> a >> b;

	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (long i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if(a[i]<b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
		
	}

	cout << "EQUAL" << endl;
	return 0;

}

Measured memory_bytes: 256
result_score = []
while True:
    m,f,r = map(int,input().split())
    m <= 50
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        result_score.append("F")
    elif m+f >= 80:
        result_score.append("A")
    elif m+f < 80 and m+f >= 65:
        result_score.append("B")
    elif m+f < 65 and m+f >= 50 or r >= 50:
        result_score.append("C")
    elif m+f < 50 and m+f >= 30:
        result_score.append("D")
    elif m+f < 30:
        result_score.append("F")

for i in result_score:
    print(i)



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int c[10][10];
int h,w;

int lim;
bool used[10];
void search(int from,int current_pos,int current_weight){
    if(current_weight>=lim){
        return;
    }
    if(current_weight+c[current_pos][1]<lim){
        lim=c[from][1]=current_weight+c[current_pos][1];
    }
    for(int i=0;i<10;i++){
        if(used[i]){
            continue;
        }
        int check=c[current_pos][i];
        used[i]=true;
        search(from,i,current_weight+check);
        used[i]=false;
    }
}

void clear_used(){
    for(int i=0;i<10;i++){
        used[i]=false;
    }
    used[1]=true;
}

int main(){
    int ans=0;
    cin >> h;
    cin >> w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            int a;
            cin >> a;
            if(a!=-1){
                clear_used();
                lim=c[a][1];
                search(a,a,0);
                ans+=c[a][1];
            }
        }
    }

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



Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
for i in range(0, 1000):
    i = str(i).zfill(3)

    try:
        id1 = s.index(i[0])
        id2 = s.index(i[1], id1+1)
        id3 = s.index(i[2], id2+1)
        ans += 1
    except ValueError:
        continue

print(ans)

Measured memory_bytes: 3060
import heapq as hq
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
hq.heapify(a)
for i in range(m):
    minprice = hq.heappop(a)
    hq.heappush(a, (-minprice // 2) * -1)
print(-sum(a))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(i,a,b,c) for(ll i=a;i<b;i+=c)
#define r(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define mod 1000000007
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s; cin >> s;
    if(s=="AAA" || s == "BBB") cout << "No";
    else cout << "Yes";
    return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define REP(i,k,N) for(int i=k;i<(int)(N);i++)
#define rrep(i,N) for(int i=N-1;i>=(int)0;i--)

#define vi vector<int>
#define pb push_back

int main(){
//    ifstream in("a_in.txt");
//    cin.rdbuf(in.rdbuf());

    int n,r;
    int cd[51];
    int p,c;
    int tmp[51];
    while(cin>>n>>r,n!=0){
        rep(i,n){
            cd[i]=n-i;
        }
        rep(i,r){
            cin >> p >>c;
            rep(j,c){
                tmp[j]=cd[p+j-1];
            }
            rrep(j,p){
                cd[j+c-1] = cd[j-1];
            }
            rep(j,c){
                cd[j]=tmp[j];
            }

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

    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

vector < ll > graph[601];
vector < ll > graph2[601];

int main()
{
    fastIO;
    double dp[601], dp2[601], ans;
    ll n, m, i, j, k, stat = -1;fo(i,601)graph[i].clear();
    cin>>n>>m;dp[n] = 0.0;dp2[n]=0.0;
    fo(i,m) {
        cin>>j>>k;
        graph[j].pb(k);
        graph2[j].pb(k);
    }
    for(i=n-1;i>0;i--) {
        double temp = 0, den = graph[i].size();
        for(auto xx:graph[i]) {
            temp += (dp2[xx] + 1.0);
        }
        dp2[i] = temp/den;
    }
    ans = dp2[1];
    ll ii;Fo(ii,1,n+1) {
        if(graph[ii].size()<2)continue;
        stat=1;
        ll px = ii, py;double mx = 0;
        for(auto xx:graph[ii]) {
            if(mx<dp2[xx]) {
                mx = dp2[xx];
                py = xx;
            }
        }
        vector < ll > tle;tle.clear();
        for(auto xx:graph[ii]) {
            if(xx!=py)tle.pb(xx);
        }
        for(i=n-1;i>=0;i--) {
            if(i!=ii) {
                double temp = 0, den = graph[i].size();
                for(auto xx:graph[i]) {
                    temp += (dp[xx] + 1.0);
                }
                dp[i] = temp/den;
            }
            else {
                double temp = 0, den = tle.size();
                for(auto xx:tle) {
                    temp += (dp[xx] + 1.0);
                }
                dp[i] = temp/den;
            }
        }
        ans = min(ans, dp[1]);
    }
    printf("%.10lf",ans);
}   

Measured memory_bytes: 4736
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif

puts n/3


Measured memory_bytes: 2300
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    }
    println!("{}", if b - a == c - b { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int a[N];
int main(){
	int i,j,k,ca=0,n=0,m;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",&a[i]);
	ll ans=0;
	int p=1;
	rep(i,0,n){
		if(a[i]==p){p++;continue;}
		if(a[i]<p)continue;
		int x=(a[i]-1)/p;ans+=x;
		a[i]-=(x-1)*p;
		a[i]=1;
		p=max(a[i]+1,p);
		//cerr<<i<<" "<<a[i]<<" "<<k<<" "<<p<<"\n";
	}
	printf("%lld\n",ans);
    return 0;
}




Measured memory_bytes: 768
N, b, r = list(map(int, input().split()))
if b==0 and r==0:
  print(0)
  exit()
  
c = N//(b+r)
if N%(b+r) == 0:
  print(b*c)
else:
  if N%(b+r) <= b:
    print(c*b + N%(b+r))
  else:
    print(b*c + b)  

Measured memory_bytes: 3060
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let mut a: [u32; 100] = [0; 100];
    let n = get!(u32);
    let (d, x) = get!(u32, u32);
    for i in 0..n {
        let tmp = get!(u32);
        a[i as usize] = tmp;
    }
    let mut sum: u32 = 0;
    for i in 0..n {
        sum += (d-1)/a[i as usize]+1;
    }
    println!("{}", sum+x);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

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

  long long ret1 = std::abs(b * c * (a % 2));
  long long ret2 = std::abs(a * c * (b % 2));
  long long ret3 = std::abs(b * a * (c % 2));

  cout << std::min(ret1, std::min(ret2, ret3)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,a = 0;
    string s;
    cin >> s;
    n = stoi(s);
    rep(i, s.size())a += s[i] - '0';
    if (n % a == 0) {
        Yes;
    }else{
        No;
    }
    return 0;
}


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


void solve(long long N, std::vector<long long> v){
    sort(v.begin(), v.end());
    double res = v[0];
    for(int i=1;i<N;++i){
        res = (res + v[i]) * 0.5;
    }
    cout<<std::setprecision(20)<<res<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(v));
    return 0;
}


Measured memory_bytes: 256
/*
hey stop, don't skip the shit till it's solved
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],b[n],c[n-1];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>b[i];
}
for(int i=0;i<n-1;i++)
{
cin>>c[i];
}
int ans=b[a[0]-1];
for(int i=1;i<n;i++)
{
ans+=b[a[i]-1];
if(a[i]==a[i-1]+1)
{
ans+=c[a[i-1]-1];
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 3580
_ = input()
s = input()

cands = ['SSS', 'SWW', 'WWS', 'WSW'] if s[0] == 'o' else ['WSS', 'SSW', 'SWS', 'WWW']

d = {
    'o':{'SS': 'S', 'SW': 'W', 'WW': 'S', 'WS': 'W'},
    'x':{'SS': 'W', 'SW': 'S', 'WW': 'W', 'WS': 'S'}
}

for char in s[1:]:
    for i in range(len(cands)):
        cands[i] += d[char][cands[i][-2:]]

for cand in cands:
    if cand[:2] == cand[-2:]:
        print(cand[1:-1])
        break
else:
    print(-1)

Measured memory_bytes: 3948
import java.util.*;
import java.io.*;
class Main
{
	static StringBuilder sb;
	public static final boolean ONLINE_JUDGE=false;
	public static void main(String []args)throws IOException
	{
		sb=new StringBuilder();
		Scanner sc=new Scanner(System.in);
		if(ONLINE_JUDGE)
		{
			File file=new File("output.txt");
			sc=new Scanner(new FileReader(new File("input.txt")));
			PrintStream ps=new PrintStream(file);
			System.setOut(ps);
		}
		int t=1;
		for(int tt=1;tt<=t;tt++)
		{
			int n=sc.nextInt();
			int a[][]=new int[n][3];
			for(int i=0;i<n;i++)
			{
				a[i][0]=sc.nextInt();
				a[i][1]=sc.nextInt();
				a[i][2]=sc.nextInt();
			}
			int dp[][]=new int[n][3];
			for(int i=0;i<3;i++)
				dp[0][i]=a[0][i];
			for(int i=1;i<n;i++)
			{
				dp[i][0]=Math.max(dp[i-1][1],dp[i-1][2])+a[i][0];
				dp[i][1]=Math.max(dp[i-1][0],dp[i-1][2])+a[i][1];
				dp[i][2]=Math.max(dp[i-1][0],dp[i-1][1])+a[i][2];
			}
			System.out.println(Math.max(Math.max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
		}
	}
}

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


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

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

int f[100][10];
int p[100][11];

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

    int n;
    cin >> n;

    rep(i, n){
        rep(j, 10){
            cin >> f[i][j];
        }
    }
    rep(i, n){
        rep(j, 11){
            cin >> p[i][j];
        }
    }

    int s[10];

    long long int value = INT64_MIN;

    for (int bit = 1; bit < (1<<10); bit++){
        for (int i = 0; i < 10; i++){
            if(bit&(1<<i)){
                s[i] = 1;
            }else{
                s[i] = 0;
            }
        }

        long long int temp= 0;

        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++){
                if(s[j]*f[i][j]==1){
                    cnt++;
                }
            }
            temp += p[i][cnt];
        }

        value = max(value, temp);
    }

    cout << value << endl;
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	s := make(stus, n)

	for i := 0; i < n; i++ {
		s[i].num = i+1
		s[i].c = scanInt()
	}

	sort.Sort(s)
	
	for i := 0; i < n; i++ {
		fmt.Fprint(wr, s[i].num)
		if i == n-1 {
			break
		}
		fmt.Fprint(wr, " ")
	}

	fmt.Fprintln(wr)
	wr.Flush()

}

type stu struct {
	num int
	c int
}

type stus []stu

func (a stus) Len() int           { return len(a) }
func (a stus) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a stus) Less(i, j int) bool { return a[i].c < a[j].c }


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  cout<<(S.size()>=4&&S.at(0)=='Y'&&S.at(1)=='A'&&S.at(2)=='K'&&S.at(3)=='I'? "Yes":"No")<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int c = sc1.nextInt();
		int ans = 0;

		for ( int i = a ; i <= b ; i++) {
			if (c % i == 0) {
				ans++;
			}
		}

		System.out.println(ans);

		sc1.close();

	}

}


Measured memory_bytes: 26276
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    ans = left[::-1] + right
else:
    ans = right[::-1] + left

print(*ans, sep=' ')


Measured memory_bytes: 26020
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
int32_t main()
{
    //_READ
    int n, m;
    cin >> n >> m;
    int power = 1ll << n;
    vector<int> cost(power , 1e18); //keys->cost
    for (int temp = 0; temp < m; temp++)
    {
        int a, b;
        cin >> a >> b;
        int mask = 0;
        for (int i = 0; i < b; i++)
        {
            int input;
            cin >> input;
            input--;
            mask |= (1ll << input);
        }
        cost[mask] = min(cost[mask], a);
    }
    vector<vector<int>> items;
    for (int i = 1; i < (int)cost.size(); i++)
        if (cost[i] != 1e18)
            items.push_back({i, cost[i]});
    // weight, price
    n = items.size();

    vector<vector<int>> dp(n, vector<int>(power, 1e18));
    for(int i=0;i<n;i++)
        dp[i][0]=0;
    for (int i = 0; i < n; i++)
    {
        int weight = items[i][0];
        int price = items[i][1];
        if (i == 0)
        {
            dp[i][weight]=min(dp[i][weight],price);
            continue;
        }
        for(int j=0;j<power;j++)
        {
            int new_weight=j|weight;
            dp[i][new_weight]=min(dp[i][new_weight],dp[i-1][j]+price);
        }
        for(int j=0;j<power;j++)
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
    int ans=1e18;
    for(int i=0;i<n;i++)
    {
        ans=min(ans,dp[i][power-1]);
    }
    if(ans==1e18)
        ans=-1;
    cout<<ans;
    return 0;
}
//16:54

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

int main(){
	string a;
	while(cin >> a){
		if(!a.compare("-"))
			break;
		int t;
		cin >> t;
		int sum = 0;
		for(int i = 0; i < t; i++){
			int temp;
			cin >> temp;
			sum += temp;
		}
		sum %= a.length();
		for(int i = sum; i < a.length(); i++){
			cout << a[i];
		}
		for(int i = 0; i < sum; i++){
			cout << a[i];
		}
		cout << endl;
	}
}


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

int main()
{
  int N;
  string S;

  cin >> N;

  for (int i = 0; i < N; i++)
  {
    cin >> S;
    if (S == "Y")
    {
      cout << "Four" << endl;
      exit(0);
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256