akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

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

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n + 1);
	vector<ll>box(n + 1);
	for (ll i = 1;i <= n;++i) {
		cin >> a[i];
	}
	ll ans = 0;
	for (ll i = n;i >= 1;--i) {
		ll target = i;
		ll count = 0;
		ll j = 1;
		while (target*j <= n) {
			count += box[target * j];
			j++;
		}
		count %= 2;
		if (a[i] != count) {
			box[i]++;
			ans++;
		}
	}
	cout << ans << endl;
	rep(i, n + 1) {
		if (box[i]) {
			cout << i << endl;
		}
	}
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n+1); for(int i=1;i<=n;++i)cin>>a.at(i);
	vector<bool>v(n+1,false);
	vector<int>b;
	for(int i=n;i>=1;--i){
		int cnt=0;
		for(int j=i;j<=n;j+=i){
			cnt+=v.at(j);
		}
		if(cnt%2!=a.at(i)){
			v.at(i)=true;
			b.emplace_back(i);
		}
	}
	cout<<b.size()<<"\n"s;
	if(b.size()){
		cout<<b.back();
		for(auto i=b.rbegin()+1;i!=b.rend();++i)cout<<" "s<<*i;
		cout<<"\n"s;
	}
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


bool solve(){
    int H, W;
    cin >> H >> W;

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

    int x = 0, y = 0;
    while(true){
        if(field[y][x] != '#') return false;
        field[y][x] = '.';
        if(x == W-1 && y == H-1) break;
        char right = (x+1 < W) ? field[y][x+1] : '.';
        char down = (y+1 < H) ? field[y+1][x] : '.';
        if(right == '#' && down == '.'){
            x++;
        }else if(right == '.' && down == '#'){
            y++;
        }else{
            return false;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j] == '#') return false;
        }
    }
    return true;
}

int main(){
    if(solve()) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl H;

void solve(void) {
  // 2**(1 + math.floor(math.log2(N))) - 1
  sl t = 1;
  while (t <= H) {
    t <<= 1;
  }
  cout << t - 1 << endl;
}

int main(void) {
  cin >> H;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m;
double dp[1<<16][22],x[111][111];
double dfs(int S,int dep){
    if(dep==m)return 1;
    if(dp[S][dep]!=-1)return dp[S][dep];
    double res=0;
    for(int i=0;i<n;i++){
        if(!((1<<i)&S))continue;
        double tmp=0,X=1;
        for(int j=dep;j<=m;j++){
            tmp+=X*(1.0-x[i][j])*dfs(S-(1<<i),j);
            X*=x[i][j];
        }
        res=max(res,tmp);
    }
    return dp[S][dep]=res;
}
int main(){
    r(i,1<<16)r(j,22)dp[i][j]=-1;
    cin>>n>>m;
    r(i,n)r(j,m)cin>>x[i][j];
    printf("%.9f\n",dfs((1<<n)-1,0));
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  // ll n,m,q;cin>>n>>m>>q;
  // rep(i,0,q){
  //   ll a,b,c,d;cin>>a>>b>>c>>d;

  // }
  ll a,b,n;cin>>a>>b>>n;

  ll ng=-1,ok=n+1;
  ll ma=0;
  while(ok-ng>1){
    ll mid=(ng+ok)/2;
    ll num=(ll)(floor(a*mid/b)-a*floor(mid/b));
    if(ma<=num){ma=num;ng=mid;}
    else {ok=mid;}
  }

  out(ma);

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;


int main()
{
	char a[110]{}, b[110]{}, c[110]{};
	scanf("%s%s%s", &a, &b, &c);
	int al, bl, cl;
	al = strlen(a);
	bl = strlen(b);
	cl = strlen(c);
	int ac, bc, cc;
	ac = bc = cc = -1;
	char temp = a[0];
	ac++;
	while (1)
	{
		if (temp == 'a')
		{
			ac++;
			if (ac >= al)
			{
				cout << "A" << endl;
				return 0;
			}
			temp = a[ac];
		}
		else if (temp == 'b')
		{
			bc++;
			if (bc >= bl)
			{
				cout << "B" << endl;
				return 0;
			}
			temp = b[bc];
		}
		else if (temp == 'c')
		{
			cc++;
			if (cc >= cl)
			{
				cout << "C" << endl;
				return 0;
			}
			temp = c[cc];
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
ID: cyxoier1
TASK: b
PROG: b.cpp
LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;

template<typename T>
inline void Read(T &n){
	char ch; bool flag=0;
	while(!isdigit(ch=getchar()))if(ch=='-')flag=1;
	for(n=ch^48;isdigit(ch=getchar());n=(n<<1)+(n<<3)+(ch^48));
	if(flag)n=-n;
}

char s[105];

int main(){
	cin>>s;
	int i=0, j=strlen(s)-1, ans=0;
	while(i<j){
		if(s[i]!=s[j]) ans++;
		i++, j--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
	N, *AB = map(int, open(0).read().split())
	B = AB[1::2]

	E = [[] for _ in range(N + 1)]
	for a, b in zip(*[iter(AB)] * 2):
		E[a].append(b)

	Q = deque([1])
	C = [0] * (N + 1)
	while Q:
		v = Q.popleft()
		c = 0
		for u in E[v]:
			c += 1 + (c + 1 == C[v])
			C[u] = c
			Q.append(u)

	print(max(C))
	for b in B:
		print(C[b])

main()

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	llong a, b, c;
	cin >> a >> b >> c;
	llong sum = 0;
	sum += min(a,c);
	a -= sum, c -= sum;
	if(c == 0){
		sum += b;
	}else{
		llong bc = min(b,c);
		sum += bc*2;
		b -= bc;
		c -= bc;
		if(c == 0)
			sum += b;
		else
			sum++;
	}

	cout << sum << endl;

	return 0;
}

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

int main(){
    string str;
    string a, b, c, d;
    cin >> str;
    a = str.at(2);
    b = str.at(3);
    c = str.at(4);
    d = str.at(5);

    if(a == b && c == d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    // size of restaurants
    let n = iter.next().unwrap().parse::<usize>().unwrap();

    // restaurants
    let mut restaurants: Vec<Restaurant> = Vec::with_capacity(n);
    // register
    for i in 0..n {
        restaurants.push(Restaurant {
            id: i+1,
            city: iter.next().unwrap().parse().unwrap(),
            point: iter.next().unwrap().parse().unwrap(),
        });
    }
    // sort
    restaurants.sort_by(|a, b| {
        match a.city.cmp(&b.city) {
            std::cmp::Ordering::Equal => {
                b.point.cmp(&a.point)
            }
            els => {
                els
            }
        }
    });
    // output
    for restaurant in restaurants {
        println!("{}", restaurant.id);
    }
}

struct Restaurant {
    pub id: usize,
    pub city: String,
    pub point: u8,
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long start = f(a-1,c,d);
        long end = f(b,c,d);

        System.out.print(end -start);
    }

    public static long f(long a, long b, long c) {
        long result = a;
        result -= a / b;
        result -= a / c;
        result += a / lcm(b, c);
        return result;
    }

    public static long gcd(long a, long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }
}

Measured memory_bytes: 21332
#include <iostream>

using namespace std;

int main(){
    int N;
    long A[100000];
    long x[100000];
    cin >> N;
    long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    sum = sum/2;
    //cout << sum << endl;
    long tmp = 0;
    for(int i = 0; i < N-1; i+=2){
        tmp += A[i];
    }
    x[N-1] = sum-tmp;
    for(int i = N-3; i >= 0; i-=2){
        tmp -= A[i];
        sum -= A[i+1];
        x[i] = sum-tmp;
    }
    for(int i = 0; i < N-1; i+=2){
        x[i+1] = A[i]-x[i];
    }
    for(int i = 0; i < N-1; i++) cout << 2*x[i] << ' ';
    cout << 2*x[N-1] << endl;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

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

		int dimensionCount = Integer.parseInt(sc.nextLine());

		String[] input = sc.nextLine().split("[\\s]+");
		int[] vectorXArray = new int[dimensionCount];
		for (int i = 0; i < input.length; i++)
			vectorXArray[i] = Integer.parseInt(input[i]);

		input = sc.nextLine().split("[\\s]+");
		int[] vectorYArray = new int[dimensionCount];
		for (int i = 0; i < input.length; i++)
			vectorYArray[i] = Integer.parseInt(input[i]);

		double D[] = Distance(vectorXArray, vectorYArray);

		double max = Math.abs(vectorXArray[0] - vectorYArray[0]);
		for (int i = 0; i < dimensionCount; i++) {
			max = Math.max(Math.abs(vectorXArray[i] - vectorYArray[i]), max);
		}

		for (double dis : D) {
			System.out.println(dis);
		}
		System.out.println(max);

	}

	static double[] Distance(int[] x, int[] y) {
		double[] distance = new double[3];
		for (int p = 1; p <= distance.length; p++) {
			double sum = 0;
			for (int i = 0; i < x.length; i++)
				sum += Math.pow(Math.abs(x[i] - y[i]), p);
			distance[p - 1] = Math.pow(sum, 1.0/p);
		}
		return distance;
	}

}



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

int main() {
	int N, ans = 0;
	cin >> N;

	vector<int> C(N), V(N);
	for (int i = 0; i < N; i++) cin >> C.at(i);
	for (int j = 0; j < N; j++) cin >> V.at(j);

	for (int i = 0; i < N; i++) {
		if (C.at(i) > V.at(i)) {
			ans += C.at(i) - V.at(i);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, x = 0, max  = 0;
  scanf("%d", &n);

  char s[n];
  scanf("%s", s);

  for(int i = 0; i < n; i++) {
    if(s[i] == 'I') {
      x++;
    }
    else if(s[i] == 'D') {
      x--;
    }
    if(max < x) {
      max  = x;
    }
  }
  printf("%d", max);
  return 0;
}

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

using namespace std;

#define MOD 1000000007
#define PB push_back
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef pair<int, int> PII;
typedef pair<int, string> PIS;
typedef pair<string, int> PSI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef set<double> SETD;
typedef multiset<int> MSETI;
typedef deque<int> DQI;
typedef deque<double> DQD;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2*b) << endl;
    return 0;
}

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

using namespace std;

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

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    vector<ll> a;
    for (int i = -150;i < 150;++i) {
        ll p = 1;
        for (int j = 0;j < 5;++j) p *= i;
        a.push_back(p);
    }
    ll x;
    cin >> x;
    int n = a.size();
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (a[i] == x+a[j]) {
        cout << i-150 << " " << j-150 << endl;
        return 0;
    }
}

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

int main() {
	
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll A = a[0];
	for (int i = 1; i < n; i++) {
		A = A ^ a[i];
	}
	for (int i = 0; i < n; i++) {
		cout << (A ^ a[i]) << " ";
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 4784
import sys
def main():
    for line in sys.stdin:
        H, W = map(int, line.split())
        if H == 0 and W == 0:
            break
        else:
            for _ in range(H):
                for _ in range(W):
                    print("#", end = "")
                print()
            print()


if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include<iostream>
#include<vector>

using namespace std;

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

void show(vector<int> vec){
    int cnt = 0;
    for(auto a: vec){
        cout << a;
        if(cnt!= vec.size()-1) cout << " ";
        else cout << endl;
        cnt++;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i < n;i++){
        cin >> A.at(i);
    }
    int cnt = 0;
    for(int i=1;i < A.size();i++){
        for(int j=1;j < A.size();j++){
            if(A.at(j) < A.at(j-1)) {
                swap(A.at(j),A.at(j-1));
                cnt++;
            }
        }
    }
    show(A);cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int A,B,C;
 cin>>A>>B>>C;
 if(A>B && B<C && C<A)cout<<"Yes"<<endl;
 else if(A<B && A<C && C<B)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;

 return 0;
}

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

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

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

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int gcd(int x, int y)
{
	int a = x, b = y, c = a%b;
	while (c != 0)
	{
		a = b;
		b = c;
		c = a%b;
	}
	return b;
}

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

	int a, b;
	while (cin >> a >> b)
	{
		int t = gcd(a, b);
		cout << t << " " << a*b / t << endl;
	}

	return 0;
}


Measured memory_bytes: 3140
import sys
input = sys.stdin.readline

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

mod = 10**9+7
ans = 1
P = [0, 0, 0]
for a in A:
    c = P.count(a)
    ans = ans*c%mod
    for i in range(3):
        if P[i] == a:
            P[i] += 1
            break
    #print(P)
print(ans)

Measured memory_bytes: 13308
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;

  ll ans=0;
  int index_w=-1;
  for(int i=0;i<S.size();++i){
    if(S.at(i)=='W'){
      if(index_w==-1){
	ans+=i;
	index_w=1;
	continue;
      }
      ans+=i-index_w;
      ++index_w;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3768
<?php
$input = trim(fgets(STDIN));
$input = preg_split('/\s/', $input);

$a = intval($input[0]);
$b = intval($input[1]);

if($b % $a == 0){
    puts($a + $b);
}
else{
    puts($b - $a);

}

function puts($str = ""){
    echo $str, "\n";
}

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

int main()
{
    // 整数の入力
    int N;
    int ans = 0;
    cin >> N;
    // 配列の入力
    int a[N];
    for ( int i = 0; i < N; i++ ) cin >> a[i];
    for(int i = 0; i < N; i++){
        ans = ans + a[i] - 1;
    }
    // 出力
    cout << ans << endl;
    return 0;
}

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



long long n,bb[200001],t,c[200001];
long double a[200001],aa[200001],b[200001],ma=0,d[200001],sh[200001];


int main()
{
    cin>>n;
    ref(i,n) {
        cin>>aa[i];
        if(aa[i]>ma) t=i;
        ma=max(aa[i],ma);
    }

    ref(i,n) cin>>bb[i];

    ref(i,n) {a[i]=aa[(i+t)%n];b[i]=bb[(i+t)%n];}

    a[n]=a[0];

    long long k=0;
    ref(i,n-1) k+=2*b[i+1]*(n-i-1);
    d[1]=-1*(lb(k)/lb(n));
    ref(i,n-1) {d[i+2]=2*d[i+1]-d[i]+2*b[i+1];}
    //cout<<d[n-1]<<endl;
    //cout<<d[n]<<endl;

    ref(i,n) a[i]=a[i]-d[i];

    c[0]=0,sh[0]=0;
    for(int i=1;i<=n;i++) {

        ll t=i-1;
        c[i]=i-1;

        while(true){


            if(sh[t]<(a[i]-a[t])/(i-t)) {t=c[t];c[i]=t;sh[i]=(a[i]-a[t])/(i-t);}
            else {sh[i]=(a[i]-a[t])/(i-t);break;}
            if(t==0) break;
    }

    }

    for(int i=n;i>0;i--) {
        for(int j=c[i]+1;j<i;j++) a[j]=a[c[i]]+(a[i]-a[c[i]])/lb(i-c[i])*lb(j-c[i]);
        i=c[i]+1;
    }

    long double ans=0;

    ref(i,n){
        ans+=a[i]+d[i];
    }
    lb tt;
    tt=ans/lb(n);
    if(ll(tt*pow(10,11))%10>=5) tt+=pow(10,-10);
    cout<<fixed<<setprecision(40)<<tt;
    return 0;
}




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

int main() {
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    double b = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    double c = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));    
    double S = abs(((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1))) / 2.0;
    double r = 2.0 * S / (a + b + c);
    cout << fixed << setprecision(10) << max({a,b,c}) / (2.0 + max({a,b,c}) / r) << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> QInClassPair;
    for (int i = 1; i <= n; i++)
    {
        int temp;
        cin >> temp;
        QInClassPair.push_back(make_pair(temp, i));
    }
    sort(QInClassPair.begin(), QInClassPair.end());
    for (int i = 0; i < n; i++)
    {
        cout << QInClassPair[i].second << " ";
    }
    
    return 0;
}

/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
//FAZAL_AHMAD
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define pb push_back
using ll = long long;

ll lcm(ll a,ll b){

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


void solve()
{

ll ans=-1e18;
ll a,b,c,d;
cin>>a>>b>>c>>d;
ans=max(ans,a*c);

ans=max(ans,a*d);

ans=max(ans,b*c);
ans=max(ans,b*d);
cout<<ans;
}



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

		solve();
	cout<<endl;
}






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

int main(void){
  int i, l, ans[26];
  char s[100000];
  scanf("%s",s);
  l = strlen(s);
  for(i=0;i<26;i++) ans[i]=1;
  for(i=0;i<l;i++) if(ans[s[i]-'a']==1) ans[s[i]-'a']=0;
  for(i=0;i<26;i++) if(ans[i]==1){ printf("%c\n",i+'a'); break;}
  if(i==26) printf("None\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,j,dp[4005][4005],a[200005],b[200005],c[4005][4005],mod=1e9+7,ans;
int main(){
	cin>>n;
	for (i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		dp[2001-a[i]][2001-b[i]]++;
	}
	c[0][0]=1;
	for (i=0;i<=4003;i++){
		for (j=0;j<=4003;j++){
			if (i>0) (dp[i][j]+=dp[i-1][j])%=mod;
			if (i>0) (c[i][j]+=c[i-1][j])%=mod;
			if (j>0) (dp[i][j]+=dp[i][j-1])%=mod;
			if (j>0) (c[i][j]+=c[i][j-1])%=mod;
		}
	}
	for (i=1;i<=n;i++){
		(ans+=dp[2001+a[i]][2001+b[i]])%=mod;
		(ans+=mod-c[a[i]*2][b[i]*2])%=mod;
	}
	cout<<((ans%mod+mod)%mod*((mod+1)/2)%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 253952
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];

    for(int i=0; i<n; i++) cin>>a[i];

    sort(a, a+n);

    cout<<a[n-1]-a[0]<<endl;

    return 0;
}



Measured memory_bytes: 3588
from itertools import accumulate

n,k=map(int,input().split())
p=list(map(int,input().split()))

x=[]
for i in p:
 x.append((i+1)/2)

b=[0]+list(accumulate(x))

ans=0
for i in range(n-k+1):
 ans=max(ans,b[i+k]-b[i])

print(ans)

Measured memory_bytes: 26368
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <math.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const int inf = 1e9;
const int mod = 998244353;

struct Line {
	LL ka,kb,ya,yb; //y=ka/kb*x+ya/yb,ka,ya>0
	bool operator==(const Line &v) const {
		return ka==v.ka&&kb==v.kb&&ya==v.ya&&yb==v.yb;
	}
	bool operator<(const Line &v) const {
		if (ka!=v.ka) return ka<v.ka;
		if (kb!=v.kb) return kb<v.kb;
		if (ya!=v.ya) return ya<v.ya;
		return yb<v.yb;
	}
}l[maxn];
LL gcd(LL n,LL m) {
	return m?gcd(m,n%m):n;
}
int n,tot,pw[maxn],ans,x[maxn],y[maxn];
int main()
{
	#ifdef Amberframe
		freopen("arc082e.in","r",stdin);
		freopen("arc082e.out","w",stdout);
	#endif
	scanf("%d",&n);pw[0]=1;
	for (int i=1;i<=n;i++) pw[i]=(pw[i-1]<<1)%mod;
	for (int i=1;i<=n;i++) scanf("%d %d",&x[i],&y[i]);
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++)
	if (x[i]==x[j]) {
		l[++tot]=(Line){inf,0,0,x[i]};
	}
	else {
		LL ka=y[i]-y[j],kb=x[i]-x[j];
		LL ya=((LL)y[i]*kb-ka*x[i]),yb=kb;
		LL kab=gcd(ka,kb);ka/=kab;kb/=kab;
		LL yab=gcd(ya,yb);ya/=yab;yb/=yab;
		if (ka<0) ka*=-1,kb*=-1;
		if (ya<0) ya*=-1,yb*=-1;
		l[++tot]=(Line){ka,kb,ya,yb};
	}
	sort(l+1,l+tot+1);
	for (int i=1;i<=tot;) {
		int pos=i;while (pos<=tot&&l[i]==l[pos]) pos++;
		int num=sqrt((pos-i)<<1)+1;i=pos;
		ans=((LL)ans-pw[num]+num+1)%mod;
	}
	ans=((LL)ans+pw[n]-n-1)%mod;
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 896
# keyence2019C - Exam and Wizard
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    pos, neg = [], []
    for i, j in zip(A, B):
        x = i - j
        if x >= 0:
            pos += [x]
        else:
            neg += [x]
    ans, shortage = len(neg), sum(neg)
    for i in sorted(pos, reverse=1):
        if shortage >= 0:
            print(ans)
            return
        ans += 1
        shortage += i
    print(ans if shortage >= 0 else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18884
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        long ans=0l;
        int k = in.nextInt();
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                for(int m=1;m<=k;m++){
                    ans+= gcd(i,gcd(j,m));
                }
            }
        }
        out.println(ans);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 32940
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long


int main(void){
	char X[200001];
	scanf("%s",X);
	int n=strlen(X);
	int s=0,ans=n;
	for(int i=0;i<n;i++){
		if(X[i]=='S')s++;
		else{
			if(s>0){
				s--;
				ans-=2;
			}
			else s=0;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


//<formula>  ::= "T" | "F" |
//"a" | "b" | "c" | "d" | "e" | "f" |
//"g" | "h" | "i" | "j" | "k" |
//"-" <formula> |
//"(" <formula> "*" <formula> ")" |
//"(" <formula> "+" <formula> ")" |
//"(" <formula> "->" <formula> ")"
bool formula(string &s,int &pos,vi vars){
	switch(s[pos]){
		case 'T':
			pos++;
			return true;
		case 'F':
			pos++;
			return false;
		case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'g':case 'h':case 'i':case 'j':case 'k':
			return vars[s[pos++]-'a'];
		case '-':
			pos++;
			return !formula(s,pos,vars);
		case '(':
			{
				pos++;
				bool l=formula(s,pos,vars);
				char op=s[pos];
				pos++;
				if(op=='-'){
					assert(s[pos]=='>');
					pos++;
				}
				bool r=formula(s,pos,vars);
				assert(s[pos]==')');
				pos++;
				switch(op){
					case '*':
						return l&r;
					case '+':
						return l|r;
					case '-':
						return r|(!l);
					default:
						assert(0);break;
				}
			}
		default:
			assert(0);break;
	}
}

//<equation> ::= <formula> "=" <formula>
bool equation(string &s,int &pos,vi vars){
	bool l=formula(s,pos,vars);
	assert(s[pos]=='=');
	pos++;
	bool r=formula(s,pos,vars);
	assert(s[pos]=='\0');
	return l==r;
}
int main(){
	string s;
	while(cin>>s,s!="#"){
		bool flag=true;
		REP(i,1<<11){
			vi vars(11);
			REP(j,11){
				vars[j]=((1<<j)&i);
			}
			int pos=0;
			if(!equation(s,pos,vars)){
				flag=false;
				break;
			}
		}
		cout<<(flag?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 1432
#include <stdio.h>
int main (){
	int a,b,inner,total;
	scanf ("%d",&a);
	scanf ("%d",&b);
	if (a<=10){
		inner = 100 * (10-a);
		total = b + inner;
		printf ("%d",total);
	}
	else{
		printf ("%d",b);
	}
	
	return 0;
}

Measured memory_bytes: 2132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> X;
  vector<int> Y;
  vector<int> H;
  int x,y,h;
  int ans_x,ans_y,ans_h;
  for(int i=0;i<N;++i){
    cin>>x>>y>>h;
    X.push_back(x);
    Y.push_back(y);
    H.push_back(h);
  }
  int tmp_h,cand_h;
  bool judge=true;
  for(int cx=0;cx<=100;++cx){
    for(int cy=0;cy<=100;++cy){
      //define temp height
      judge=true;
      for(int i=0;i<N;++i){
        if(H[i]>0){
          tmp_h=H[i]+abs(X[i]-cx)+abs(Y[i]-cy);
          break;
        }
        
      }
    //check if tmp_h is OK
      for(int j=0;j<N;++j){
        cand_h=tmp_h-abs(X[j]-cx)-abs(Y[j]-cy);
        cand_h=max(cand_h,0);
        if(cand_h!=H[j]){
          judge=false;
          break;
        }
      }
    if(judge){
      ans_x=cx;
      ans_y=cy;
      ans_h=tmp_h;
      break;
    }
    }
  }
  cout<<ans_x<<" "<<ans_y<<" "<<ans_h<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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


int main() {
    int n;
    cin >>n;
    vector<long long> vec(n+2);
    vec.at(0) = 2;
    vec.at(1) = 1;
    for(int i = 2; i < n+2; i++) {
        vec.at(i) = vec.at(i - 1) + vec.at(i - 2);
    }
        cout << vec.at(n) << endl;
    
    
}

Measured memory_bytes: 256
def main():
    N, X = map(int, input().split())
    L = [int(i) for i in input().split()]

    D, i = 0, 0
    count = 1
    while i < N and D + L[i] <= X:
        count += 1
        D += L[i]
        i += 1
    return count

if __name__ == '__main__':
    print(main())

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

int main() {
 	long long n;
 	cin >> n;
 	long long a[n + 1], suf[n + 1];
 	for(long long i = 1; i <= n; i++) {
        cin >> a[i];
 	}
 	suf[n] = 0;
 	long long ans = 0, MOD = 1e9 + 7;
 	for(long long i = n - 1; i > 0; i--) {
        suf[i] = suf[i + 1] + a[i + 1];
        suf[i] %= MOD;
 	}
 	for(long long i = 1; i <= n; i++) {
        ans += (suf[i] * a[i]);
        ans %= MOD;
 	}
 	cout << ans << endl;
}


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

int main() { 
    long double a, b, c;
    cin >> a >> b >> c;
    if(a+b+2*sqrt(a*b) < c) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    

    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n, m;
    ll a = 0, b = 0;
    cin >> n >> m;

    ll wa[n+5];
    memset(wa, 0, sizeof wa);
    bool ac[n+5];
    memset(ac, false, sizeof ac);

    while (m--) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (s == "AC" && !ac[p]) {
            ++a;
            ac[p] = true;
        }
        else if (s == "WA" && !ac[p])
            ++wa[p];
        if (s == "AC")
            ac[p] = true;
    }
    
    rep(i, 0, n)
        b += (ac[i] ? wa[i] : 0);
    cout << a << ' ' << b << '\n';


    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

ll pw(ll a){
  ll ret = 1;
  for(ll i = 0; i < a; i++){
    ret = ret * 2 % MOD;
  }
  return ret;
}

int main(){

  ll n;
  cin >> n;
  
  unordered_map<ll, ll> mp;
  for(ll i = 0; i < n; i++){
    ll in;
    cin >> in;
    mp[in]++;
  }
  
  if(n % 2 == 0){
    for(ll i = 1; i <= n - 1; i += 2){
      if(mp[i] != 2){
	cout << 0 << endl;
	return 0;
      }
    }
    cout << pw(n / 2) << endl;
      
    }else{
      if(mp[0] != 1){
	cout << 0 << endl;
	return 0;
      }
      for(ll i = 2; i <= n - 1; i += 2){
	if(mp[i] != 2){
	  cout << 0 << endl;
	  return 0;
	}
      }
      cout << pw(n / 2) << endl;

    }
  
}


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int solve(int n){
	int kai[31]={};
	kai[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			if(i-j>=0){
				kai[i]+=kai[i-j];
			}
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=kai[i];
	}
	return ((kai[n]+9)/10+364)/365;
}
int main(){

	while(1){
		int n;
		cin>>n;
		if(n==0)break;

		cout<<solve(n)<<endl;
	}
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, X[3];
string S[100005];
map<vector<int>, int> dp[100005];

int main() {
    cin >> N >> X[0] >> X[1] >> X[2];
    for_(i,0,N) cin >> S[i];

    auto entry = [&](int i, vector<int>& x, int c) {
        for_(k,0,3) {
            if (abs(x[k]) > 3) return;
            if (X[k] + x[k] < 0) return;
        }
        dp[i][x] = c;
    };

    dp[0][vector<int>(3,0)] = -1;
    for_(i,0,N) {
        int a = S[i][0] - 'A';
        int b = S[i][1] - 'A';
        for (auto it : dp[i]) {
            vector<int> x = it.first;
            x[a]++;
            x[b]--;
            entry(i+1, x, a);

            x[a] -= 2;
            x[b] += 2;
            entry(i+1, x, b);
        }
    }

    if (dp[N].size() == 0) {
        puts("No");
    }
    else {
        vector<char> ans;
        int i = N;

        vector<int> x = dp[N].begin()->first;
        while (i > 0) {
            int a = S[i - 1][0] - 'A';
            int b = S[i - 1][1] - 'A';

            int c = dp[i][x];
            ans.push_back(char(c + 'A'));

            if (c == a) {
                --x[a];
                ++x[b];
            }
            else {
                ++x[a];
                --x[b];
            }

            --i;
        }

        reverse(ALL(ans));
        puts("Yes");
        for (char c : ans) cout << c << endl;
    }
}

Measured memory_bytes: 112748
n = int(input())
dic = {}

for word in range(n):
    word = input()
    if not word in dic:
        dic[word] = 1
    else:
        dic[word] += 1
max_v = max(dic.values())
ans = [kv[0] for kv in dic.items() if kv[1] == max_v]

ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 32096
# coding: utf-8
# 整数の入力
num = input()
# 3 つ以上の同じ数字が連続して並んでいるか判定し、
# 並んでいれば"Yes"、並んでいなければ"No"を出力
if num[0] == num[1] == num[2] or num[1] == num[2] == num[3]:
    print("Yes")
else:
    print("No")

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

int main()
{
	int n,i,k=0;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	for (i=1; i<=n; i++)
		cin>>t[i]>>x[i]>>y[i];
	for (i=1; i<=n; i++)
		if (x[i]+y[i]<=t[i] && (x[i]+y[i]-t[i])%2==0)
			k++;
	if (k==n)
		cout<<"Yes";
	else
		cout<<"No";
	return 0; 
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int mat[575][575];

int
main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,q;
  int l,r;

  cin >> n >> m >> q;

  REP(i, m){
    cin >> l >> r;
    mat[l][r]++;    
  }

  FOR(i, 1, n+1){
    FOR(j, 1, n+1){
      mat[i][j] = mat[i][j] + mat[i][j-1] + mat[i-1][j] - mat[i-1][j-1];
    }
  }

  REP(i, q){
    cin >> l >> r;
    int ans = mat[r][r] - mat[r][l-1] - mat[l-1][r] + mat[l-1][l-1];
    cout << ans << endl;
  }

  
  
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,n;
  cin >> x >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans;
  for(int i=0;i<1000;i++){
    bool judge=true;
    for(int j=0;j<n;j++){
      if(x-i==a.at(j)){
        judge=false;
      }
    }
    if(judge){
      ans=x-i;
      break;
    }
    judge=true;
    for(int j=0;j<n;j++){
      if(x+i==a.at(j)){
        judge=false;
      }
    }
    if(judge){
      ans=x+i;
      break;
    }
  }
  cout << ans << endl;
}
  

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s; int x;;
  cin >> s >> x;
  for(int i = 0; i < s.size(); i += x) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin>>h>>w;
    char s[h][w];
    //int t[h][w];
    int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,1,0,-1,-1,1,-1,1};
    for(int i=0;i<h;i++){
        string ss;
        cin>>ss;
        for(int j=0;j<w;j++){
            s[i][j]=ss[j];
        }
    }
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }*/
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int pt=0;
            if(s[i][j]=='#')cout<<'#';
            else {
                for(int k=0;k<8;k++){
                    int nx=i+dx[k],ny=j+dy[k];
                    if(nx>=0 && nx<h && ny>=0 && ny<w){
                        if(s[nx][ny]=='#')pt++;
                    }
                }
                cout<<pt;
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int po(int x,int y)
{
	if(y == 0) return 1;
	int temp = po(x,y/2);
	if(y % 2 == 0) return temp * temp % mod;
	else return temp * temp % mod * x % mod;
}
int mul[2 * M], dv[2 * M];
int ckn(int k,int n)
{
	return mul[n] * dv[k] % mod * dv[n - k] % mod;
}
signed main(){
	int h, w , a , b;
	cin >> h >> w >> a >> b;
	mul[0] = dv[0] = 1;
	for(int i = 1 ; i <= h + w ; ++i)
	{
		mul[i] = mul[i - 1] * i % mod;
		dv[i] = dv[i - 1] * po(i,mod -2) % mod;
	}
	int ans = 0;
	for(int i = 1 ; i <= h - a ; ++i)
	{
		ans = (ans + ckn(i - 1,b + i - 2) * ckn(h - i,w - b + h - i - 1) % mod) % mod;
	}
	cout << ans;
}
	
	



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	vi b(n),ans;
	rep(i,n) cin >> b[i];
	int flag = 1;
	while(flag){
		flag = 0;
		for(int i = b.size()-1; i >= 0; i--){
			if(b[i] == i+1){
				ans.emplace_back(b[i]);
				b.erase(b.begin()+i);
				if(b[i] == i) i++;
				flag = 1;
				break;
			}
		}
	}
	if(b.size()) cout << -1 << endl;
	else{
		reverse(all(ans));
		for(auto x: ans) cout << x << endl;
	}
	return 0;	
}

Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
l = list(map(int,input().split()))
suml = sum(l)
accl = list(accumulate([0]+l))
ans = float('Inf')
for i in range(1,n):
    x = accl[i]
    j = abs(2*x - suml)
    ans = min(ans,j)
print(ans)


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


int lcs(string a, string b) {
	int dp[1009][1009];

	for (int i = 0; i <= a.size(); i++) {
		for (int j = 0; j <= b.size(); j++) {
			if (i == 0 || j == 0) dp[i][j] = 0;
			else if (a[i - 1] == b[j - 1])
				dp[i][j] = max(max(dp[i - 1][j - 1] + 1, dp[i - 1][j]), dp[i][j - 1]);
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	return dp[a.size()][b.size()];
}

int main() {
	int q;
	cin >> q;
	getchar();
	while (q--) {
		string a, b;
		getline(cin, a);
		getline(cin, b);
		/*cout << "=======" << a << "=======" << endl;
		cout << "=======" << b << "=======" << endl;*/
		cout << lcs(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 7092
#include <iostream>
#include <iomanip>

using namespace std;

int N;
double ans;

int main()
{
	cin >> N;
	while (N--)
	{
		double x;
		string u;
		cin >> x >> u;
		ans+=(u=="JPY"?x:380000*x);
	}
	cout << fixed << setprecision(7) << ans;
	return 0;
}

Measured memory_bytes: 256