akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
sl=[input() for i in range(h)]
ll=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if sl[i][j]=='.':
            if j==0:
                ll[i][j]=1
            else:
                ll[i][j]=ll[i][j-1]+1
        else:
            ll[i][j]=0
rl=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w-1,-1,-1):
        if sl[i][j]=='.':
            if j==w-1:
                rl[i][j]=1
            else:
                rl[i][j]=rl[i][j+1]+1
        else:
            rl[i][j]=0
ul=[[0]*w for i in range(h)]
for j in range(w):
    for i in range(h):
        if sl[i][j]=='.':
            if i==0:
                ul[i][j]=1
            else:
                ul[i][j]=ul[i-1][j]+1
        else:
            ul[i][j]=0
dl=[[0]*w for i in range(h)]
for j in range(w):
    for i in range(h-1,-1,-1):
        if sl[i][j]=='.':
            if i==h-1:
                dl[i][j]=1
            else:
                dl[i][j]=dl[i+1][j]+1
        else:
            dl[i][j]=0
ans=0
for i in range(h):
    for j in range(w):
            ans=max(ans,ll[i][j]+rl[i][j]+ul[i][j]+dl[i][j]-3)
print(ans)

Measured memory_bytes: 184196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,count = 0;
  cin>>n;
  int h[n];
  for(int i=0;i<n;++i){
    cin>>h[i];
  }
  for(int i=0;i<n;++i){
    int f=0;
    for(int j=0;j<i;++j){
      if(h[i]<h[j]){
        f=1;
      }
    }
    if(f==0){
      count++;
    }
  }
  cout<<count;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a*b > c*d){
    cout << a*b << endl;
  }else if(a*b < c*d) {
    cout << c*d << endl;
  }else{
    cout << a*b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

def func():
    try:
        word=input().rstrip().lower()
        words=[]
        while(True):
            line=input().rstrip()
            if(line == "END_OF_TEXT"):
                break
            else:
                words.extend(line.lower().split(" "))
    except:
        return inputError()

    print(words.count(word))
    

def inputError():
    print("input Error")
    return -1
 
func()

Measured memory_bytes: 7504
#include <stdio.h>
#include <string.h>
int main() {
  char str[3];

  scanf("%s", str);

  char *charR = "R";
  int count = 0;
  int flag = 0;
  for (int i = 0; i < 3; i++) {
    // printf("%c ", str[i]);
    // strcmp(&str[i], charR)
    if (str[i] == 'R') {
      if (flag == 1) {
        count++;
        flag = 1;
      } else {
        count = 1;
        flag = 1;
      }
    } else {
      flag = 0;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int n,a,m=-1,sum=0;
	bool flag=false;
	vector<int>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		m=(max(m,a));
	}
	v.push_back(0);
	for(int i=0;i<m;i++)
	{
		flag=false;
		for(int j=0;j<v.size();j++)
		{
			if(v[j])
			{
				flag=true;
				v[j]--;
			}
			else if(!v[j]&&flag)
			{
				sum++;
				flag=false;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  vector<Int> A(1<<N);
  cin>>A;
  multiset<Int> S;
  for(Int i=0;i<(1<<N);i++) S.insert(A[i]);

  auto get=[&](Int x){
    auto it = S.lower_bound(x);
    if(it == S.begin()) return S.end();
    return --it;
  };

  priority_queue<Int> Q;
  Q.push(*(--S.end()));
  S.erase(--S.end());

  for(Int i=0;i<N;i++){
    priority_queue<Int> tmp;
    while(!Q.empty()){
      Int a = Q.top(); Q.pop();
      tmp.push(a);
      auto it = get(a);
      if(it == S.end()) {
        cout<<"No"<<endl;
        return 0;
      }
      tmp.push(*it);
      S.erase(it);
    }
    Q = tmp;

  }
  cout<<"Yes"<<endl;


  return 0;
}


Measured memory_bytes: 19536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
ll dp[100005][4];
int main() {
    string S;   
    cin>>S;
    int N = S.size();
    dp[0][0] = 1;
    //
    rep(i,N){
        if(S[i] == '?'){
            rep(j,4){
                dp[i+1][j] += 3*dp[i][j]%MOD;
            }
            rep(k,3){
                dp[i+1][k+1] += dp[i][k];
                dp[i+1][k+1] %= MOD;
            }
        }
        else{
            rep(j,4){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            dp[i+1][S[i]-'A'+1] += dp[i][S[i]-'A'];
            dp[i+1][S[i]-'A'+1] %= MOD;
        }
    }
    cout<<dp[N][3]%MOD<<endl;

}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();   /*tate-bou*/
	int n = sc.nextInt();   /*yoko-bou*/
	int[] values = new int[w];
	for (int i = 0; i < values.length; i++) {
		values[i] = i + 1;  /*store numbers 1,2,3,4,.... in "values"*/
	}
	for (int i = 0; i < n; i++) {
		String str = sc.next();
		String[] ab = str.split(",");
		int a = Integer.parseInt(ab[0]) - 1;
		int b = Integer.parseInt(ab[1]) - 1;
		/*use "a" and "b" to control "values"*/
		int box;
		box = values[a];
		values[a] = values[b];
		values[b] = box;
		/*-----------------------------------*/
	}
	/*out-put of "values"*/
	for (int i = 0; i < w; i++) {
		System.out.println(values[i]);
	}
	/*-------------------*/
}
}

Measured memory_bytes: 26216
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int H, N;
  cin >> H >> N;
  bool ans = false;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    H -= A;
    if(H<=0)ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

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

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

	int gusu = 0;
	int kisu = 0;

	for (int i = 0; i < tmp.size(); i++) {
		if (i % 2 == 0) { //奇数
			if (!(tmp[i] == 'R' || tmp[i] == 'U' || tmp[i] == 'D')) {
				kisu++;
				
			}
		}
		else {	//偶数
			if (!(tmp[i] == 'L' || tmp[i] == 'U' || tmp[i] == 'D')) {
				gusu++;
				//cout << tmp[i] << endl;
			}
		}
	}

	if (gusu == 0 && kisu == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def ii2ss(n):
    return [sys.stdin.readline() for _ in range(n)]

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

def main(ss):
    H = sp2nn(ss[1])
    hmax = -1
    count = 0
    for h in H:
        if h >= hmax:
            count += 1
            hmax = h
    print(count)

main(ii2ss(2))

Measured memory_bytes: 3060
/*
 * 2426.cc: Treasure Hunt
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;

/* typedef */

typedef pair<int,int> pii;
typedef map<int,int> mii;

/* global variables */

int xs[MAX_N], ys[MAX_N], sums[MAX_N + 1][MAX_N + 1];
pii pts[MAX_N];
mii xmap, ymap;

/* subroutines */

/* main */

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> xs[i] >> ys[i];
    pts[i] = pii(xs[i], ys[i]);
  }

  sort(xs, xs + n);
  sort(ys, ys + n);
  int xn = unique(xs, xs + n) - xs;
  int yn = unique(ys, ys + n) - ys;
  //printf("%d,%d\n", xn, yn);

  for (int i = 0; i < xn; i++) xmap[xs[i]] = i;
  for (int i = 0; i < yn; i++) ymap[ys[i]] = i;

  for (int i = 0; i < n; i++)
    sums[xmap[pts[i].first] + 1][ymap[pts[i].second] + 1]++;

  for (int x = 1; x <= xn; x++)
    for (int y = 1; y <= yn; y++) sums[x][y] += sums[x][y - 1];
  for (int y = 1; y <= yn; y++)
    for (int x = 1; x <= xn; x++) sums[x][y] += sums[x - 1][y];
  //printf("%d\n", sums[xn][yn]);

  while (m--) {
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;

    int xi0 = lower_bound(xs, xs + xn, x0) - xs;
    int yi0 = lower_bound(ys, ys + yn, y0) - ys;
    int xi1 = upper_bound(xs, xs + xn, x1) - xs;
    int yi1 = upper_bound(ys, ys + yn, y1) - ys;
    
    int sum =
      sums[xi1][yi1] - sums[xi1][yi0] - sums[xi0][yi1] + sums[xi0][yi0];
    printf("%d\n", sum);
  }

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int top_bit(ll n){
    int ans = 0;
    while(n>0){
        n /= 2;
        ans++;
    }
    return ans;
}

string digit(ll n){
    string ans;
    while(n>0){
        if(n%2==1)ans += '1';
        else ans += '0';
        n/= 2;
    }
    reverse(ALL(ans));
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);

    ll sum = 0;
    REP(i,N){
        cin >> a[i];
        if(i>1) sum ^= a[i];
    }
    
    ll A=0;
    ll B=0;
    ll sa = a[0]+a[1]-sum;
    if(sa<0){
        cout << -1 << endl;
        return 0;
    }
    bool next = false;
    REPR(i,50){
        bool s_bit = sum & (1LL<<i);
        bool d_bit = (a[0]+a[1]) & (1LL<<i);
        if(!next){
            if(!s_bit && !d_bit){
                next = false;
            }else if(!s_bit && d_bit){
                next = true;
            }else if(s_bit && d_bit){
                B += pow(2,i);
                next = false;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }else{
            if(!s_bit && !d_bit){
                A += pow(2,i);
                B += pow(2,i);
                next = false;
            }else if(!s_bit && d_bit){
                A += pow(2,i);
                B += pow(2,i);
                next = true;
            }else if(s_bit && d_bit){
                cout << -1 << endl;
                return 0;
            }else{
                B += pow(2,i);
                next = true;
            }
        }
    }
    if(next){
        cout << -1 << endl;
                return 0;
    }

    if(A>a[0]){
        cout << -1 << endl;
        return 0;
    }

    REPR(i,50){
        bool aa = A & (1LL<<i);
        bool bb = B & (1LL<<i);
        if(!aa && bb){
            if(A+pow(2,i) <= a[0]){
                A += pow(2,i);
                B -= pow(2,i);
            }
        }
    }
    if(A==0) cout << -1 << endl;
    else cout << a[0]-A << endl;
    

    return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    string s,m;
    m="ABC";
    cin>>n;
    cin>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]==m[0]&&s[i+1]==m[1]&&s[i+2]==m[2]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int K,X;
    cin>>K>>X;
    cout<<X-K+1;
    for(int i=X-K+2;i<=X+K-1;i++){
        cout<<" "<<i;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll gcd(ll a,ll b){if(a<b)swap(a,b);return b?gcd(b,a%b):a;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x;
  cin>>x;
  ll g = gcd(x, 360);
  cout<<360/g<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int R, G; cin >> R >> G;
    cout << 2 * G - R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b;
  cin >> r >> g >>b;
  int ans = r*100+g*10+b;
  if(ans%4==0){
    cout <<"YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int main() {
	int n;
	int count = 0;
	cin >> n;

	for (int i = 1; i<=n; i++) {
		for (int j = 100; j <= 10000; j *= 100) {
			if (i / 10 == 0 || 0 < i / j && i / j < 10) {
				count++;
				break;
			}
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 binom(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N, K;

int main()
{
    binom_init();
    cin >> N >> K;
    ll ans = 0;
    for (int i = 0; i <= min(N - 1, K); i++)
    {
        ll comb_num = binom(N, i) * binom(N - 1, i);
        comb_num %= MOD;
        ans += comb_num;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 500000;

int N, K;
int arr[MAX_N+1];
int idx[MAX_N+1];

int ans[MAX_N+1];
int mn[MAX_N+1];
vector<int> v;

void pro(int x, int y){
	if(x==y)	return;
	int m = (x+y)/2;
	pro(x, m); pro(m+1, y);
	int i1 = x, i2 = m+1;
	mn[m] = idx[m];
	for(int i=m-1; i>=x; i--){
		mn[i] = min(mn[i+1], idx[i]);
	}
	while(1){
		if(i1==m+1 && i2==y+1)	break;
		if(i1==m+1){
			v.pb(idx[i2]); i2++;
		}else if(i2==y+1){
			v.pb(idx[i1]); i1++;
		}else{
			if(mn[i1]>=idx[i2]+K){
				v.pb(idx[i2]); i2++;
			}else{
				v.pb(idx[i1]); i1++;
			}
		}
	}
	for(int i=0; i<v.size(); i++){
		idx[x+i] = v[i];
		//cout<<x+i<<" "<<v[i]<<endl;
	}//cout<<endl;
	while(!v.empty())	v.pop_back();
}

int main(){
	scanf("%d%d", &N, &K);
	for(int i=1; i<=N; i++){
		int x; scanf("%d", &x);
		arr[i] = x;
		idx[x] = i;
	}
	pro(1, N);
	for(int i=1; i<=N; i++){
		ans[idx[i]] = i;
	}
	for(int i=1; i<=N; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
typedef long long ll;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  ll N,K;
  cin >> N >> K;
  ll res = 0;
  for(ll i=K;i<=N+1;i++){
    res += i*N - i*(i-1) + 1;
  }
  cout << res%1000000007 << endl;
  
}

Measured memory_bytes: 3524
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val snackHolders = hashSetOf<String>()
    for (i in 0 until k) {
        readLine()
        snackHolders.addAll(readLine()!!.split(" "))
    }
    println(n - snackHolders.size)
}

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

using namespace std;

typedef long long ll;

ll cnt(ll x) {
    if (x % 2 != 0) return 0;
    return cnt(x / 2) + 1;
}

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    if (x % 2 != 0 || y % 2 != 0 || z % 2 != 0) cout << 0 << endl;
    else if (x == y && y == z && z == x) cout << -1 << endl;
    else cout << min(cnt(x + y), min(cnt(y + z), cnt(z + x))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    string s;
    cin >> s;
    if (s[0] == 'S') {
        cout << "Cloudy";
    } else if (s[0] == 'C') {
        cout << "Rainy";
    } else {
        cout << "Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
data = [list(map(int, input().split(" "))) for i in range(N)]
dp = [[0] * 3 for i in range(N+1)]
dp[0][0]=0
dp[0][1]=0
dp[0][2]=0
ans=0
for i in range(0,N):
    for k in range(3):
        for j in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + data[i][k])
ans = max(dp[N][0], dp[N][1])
print(max(ans, dp[N][2]))

Measured memory_bytes: 74108
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let v: Vec<u64> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (a, b) = (v[0], v[1]);
    
    println!("{}", if a >= 13 { b } else if a > 5 { b / 2 } else { 0 });
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950288
int main(void){
    double r, s, l;
    scanf("%lf",&r);
    0 < r < 10000;
    s = r * r * PI;
    l = 2 * r * PI;
    printf("%f %f\n",s, l);
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> x;
vector <int> a;
int main() {

  int q;
  cin >> q;
  for(int o=0;o<q;o++) {
    
    int n,m;
    cin >> n >> m;
    a.clear();
    x.resize(n);
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=1;i<n;i++) a.push_back(x[i]-x[i-1]);
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i=0;i<n-m;i++)  ans+= a[i];
    cout << ans <<endl;

  }

  return 0;

}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
bool solve(int x) {
	string s = to_string(x);
	for(int i = 1; i < s.size(); i++) {
		if(s[i - 1] + 1 != s[i]) return false;
	}
	return true;
}
int n, a[1009];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ret = -1;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			if(solve(a[i] * a[j])) ret = max(ret, a[i] * a[j]);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3304
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def floor_sum_1(n, m, a, b):
    ret = 0
    if a >= m:
        ret += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ret += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ret
    ret += (n - (x_max + a - 1) // a) * y_max
    ret += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ret


def floor_sum(n, m, a, b):
    ret = 0
    while True:
        if a >= m:
            ret += (n - 1) * n * (a // m) // 2
            a %= m
        if b >= m:
            ret += n * (b // m)
            b %= m
        if a * n + b < m:
            return ret
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        ret += (n - (x_max + a - 1) // a) * y_max
        n = y_max
        m, a, b = a, m, (a - x_max % a) % a


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    # parse input
    T = int(input())
    for _t in range(T):
        N, M, A, B = map(int, input().split())
        print(floor_sum(N, M, A, B))


# tests
T1 = """
5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
13
0
314095480
499999999500000000
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 70080
def main():
    c = []
    for i in range(3):
        c.append(list(map(int, input().split())))
    for a1 in range(101):
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        if b1 < 0 or b2 < 0 or b3 < 0:
            continue
        a2_1 = c[1][0] - b1
        a2_2 = c[1][1] - b2
        a2_3 = c[1][2] - b3
        if a2_1 < 0 or a2_2 < 0 or a2_3 < 0:
            continue
        if a2_1 != a2_2 or a2_2 != a2_3 or a2_1 != a2_3:
            continue

        a3_1 = c[2][0] - b1
        a3_2 = c[2][1] - b2
        a3_3 = c[2][2] - b3
        if a3_1 < 0 or a3_2 < 0 or a3_3 < 0:
            continue
        if a3_1 != a3_2 or a3_2 != a3_3 or a3_1 != a3_3:
            continue

        print("Yes")
        return

    print("No")

if __name__ == "__main__":
    main()


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

int main()
{
    
    cin>>N;
 	ll H[N];
    for(int i=0;i<N;i++)
    {
        cin>>H[i];
    }
  
  ll ans = 0;
  for(int j=0;j<N-1;j++){
    ll Ans = 0;
    for(int k=j;k<N;k++){
			if(H[k]>=H[k+1]){
				Ans++;
			}else{
				break;
			}
     }
    if(ans<Ans) ans=Ans;
    if(ans>N-j-1) break;
    }
 
        cout<<ans;
    cout<<endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    string S;
    char a[3] = {0};
    char b[3] = {0};
    string ans = "NA";
    
    cin >> S;
    
    a[0] = S[0];
    a[1] = S[1];
    b[0] = S[2];
    b[1] = S[3];
    
    int x = atoi(a);
    int y = atoi(b);
    if (x >= 1 && x <= 12) {
        if (y >= 1 && y <= 12) {
            ans = "AMBIGUOUS";
        } else {
            ans = "MMYY";
        }
    } else {
        if (y >= 1 && y <= 12) {
            ans = "YYMM";
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

/* Dise??¢??°?????£?¨? */
void Dice(char p, int d[]);
/* Count??¢??°?????£?¨? */
int Count(int d[]);

int main(void){

	int d[6], d2[6], i, flg = 0;
	char str[2][4] = { "No","Yes" };

	for(i = 0; i < 6; i++)
		scanf("%d", &d[i]);		/* ????????????????????????????????\ */
	for(i = 0; i < 6; i++)
		scanf("%d", &d2[i]);	/* ????????????????????????????????\ */
			if(Count(d) >= 10){
				printf("Yes\n");
    	return 0;
	}
			if(d[0] == d2[0]);

	else if(d[5] == d2[0]) Dice('N', d), Dice('N', d);
		else if(d[1] == d2[0]) Dice('N', d);
			else if(d[4] == d2[0]) Dice('S', d);
				else if(d[2] == d2[0]) Dice('W', d);
					else if(d[3] == d2[0]) Dice('E', d);

	if(d[1] == d2[1]);
		else if(d[4] == d2[1]) Dice('L', d), Dice('L', d);
			else if(d[2] == d2[1]) Dice('R', d);
				else if(d[3] == d2[1]) Dice('L', d);
					for(i = 3; i < 6; i++) {
						if(d[i] != d2[i]) break;
						if(i==5) flg = 1;
	}
	printf("%s\n", str[flg]);

	return 0;
}





/* Dise??¢??°???????????????????????????????????? */
void Dice(char p, int d[]){
	int tmp;
		if (p == 'S'){ tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp;
	}
		if (p == 'W'){ tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp;
	}
		if (p == 'E'){ tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp;
	}
		if (p == 'N'){ tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp;
	}
		if (p == 'L'){ tmp = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = tmp;
	}
		if (p == 'R'){ tmp = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp;
	}
}



/* Count??¢??°??????????????°???????????? */
int Count(int d[]){
	int cnt = 0, i, j;
	for (i = 0; i < 5; i++){
		for (j = i + 1; j < 6; j++)
			if (d[i] == d[j])++cnt;
	}

	return cnt;
}

Measured memory_bytes: 580
// C - Splitting Pile
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vl &A){
	ll sumY = 0, sumX = 0, minA = LLONG_MAX;
	rp(i, 0, N) sumY += A[i];
	rp(i, 0, N-1){
		sumY -= A[i];
		sumX += A[i];
		minA = min(minA, abs(sumX - sumY));
	}
	return minA;
}

int main(){
	int N; cin>>N;
	vl A(N); rp(i, 0, N) cin>>A[i];
	cout<< solve(N, A) <<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[200009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < 2 * n - 1; i++) scanf("%d", &a[i]);
	int l = 0, r = 2 * n;
	while (r - l > 1) {
		int m = (l + r) >> 1, c = 0;
		for (int i = 0; i < n; i++) if (a[2 * i] >= m) c++;
		bool ok = true;
		if (!(c == n || (a[n - 1] >= m && (a[n - 2] >= m || a[n] >= m)))) {
			int pl = n - 1, pr = n - 1;
			while (pl != 0) {
				if (a[pl] >= m && a[pl - 1] >= m) break;
				if (a[pl] < m && a[pl - 1] < m) ok = false;
				pl--;
			}
			if (pl == 0) ok = false;
			while (pr != 2 * n - 2) {
				if (a[pr] >= m && a[pr + 1] >= m) break;
				if (a[pr] < m && a[pr + 1] < m) ok = false;
				pr++;
			}
			if (pr == 2 * n - 2) ok = false;
		}
		for (int i = 0; i < 2; i++) {
			int cur = 0;
			while (cur < 2 * n - 1) {
				if (a[cur] < m) cur++;
				else {
					bool f = false; int st = cur;
					while (a[cur] >= m || a[cur + 1] >= m) {
						if (a[cur] >= m && a[cur + 1] >= m && !f) {
							f = true;
							if (st <= n - 1 && n - 1 <= cur && st + cur <= 2 * (n - 1)) ok = true;
						}
						cur++;
					}
				}
			}
			reverse(a, a + 2 * n - 1);
		}
		if (ok) l = m;
		else r = m;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 896
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	X := make([]int, N)
	Y := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&X[i])
		Y[i] = X[i]
	}
	sort.Ints(Y)

	for i := 0; i < N; i++ {
		if X[i] < Y[N/2] {
			fmt.Println(Y[N/2])
		} else {
			fmt.Println(Y[N/2-1])
		}
	}
}


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

int main()
{

        int N;
        cin >> N;
        long long A[N];
        int o_cnt = 0;
        int e_cnt = 0;
        for (int i = 0; i < N; ++i) {
                cin >> A[i];
                if (A[i] % 2 == 0) {
                        e_cnt++;
                }
                else {
                        o_cnt++;
                }
        }

        if (o_cnt % 2 != 0) {
                cout << "NO" << endl;
                exit(0);
        }
        int amari = o_cnt % 2;
        e_cnt += (o_cnt / 2 + amari);
        if (e_cnt == 1) {
                cout << "YES" << endl;
                exit(0);
        }
        int ans = e_cnt / 2;
        amari = e_cnt % 2;
        ans += amari;
                        cout << "YES" << endl;


}


Measured memory_bytes: 1024
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a//gcd(a,b)*b

n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
    b=lcm(b,i)
print(b)





Measured memory_bytes: 5600
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_V 500
#define INF (1<<29)
 
struct edge{ int to,cap,rev; };
 
vector<edge> G[MAX_V];
bool used[MAX_V];
 
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}
 
int dfs(int v,int t,int f){
  if(v == t) return f;
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,INF);
    if(f == 0) return flow;
    flow += f;
  }
}
 
void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
  }
}
 
int main(){
  int H,W,C,M,Nw,Nc,Nm;
  while(cin >> H >> W >> C >> M >> Nw >> Nc >> Nm, H != -1){
    int k,a;
    init();
    for(int i = 0 ; i < W ; i++){
      cin >> k;
      while(k--){
        cin >> a; a--;
        add_edge(a,H+i,1);
      }
    }
    for(int i = 0 ; i < W ; i++){
      add_edge(H+i,H+W+i,1);
    }
    
    for(int i = 0 ; i < C ; i++){
      cin >> k;
      while(k--){
        cin >> a; a--;
        add_edge(H+W+a,H+W*2+i,1);
      }
    }
    for(int i = 0 ; i < C ; i++){
      add_edge(H+W*2+i,H+W*2+C+i,1);
    }

    for(int i = 0 ; i < M ; i++){
      cin >> k;
      while(k--){
        cin >> a; a--;
        add_edge(H+W*2+C+a,H+W*2+C*2+i,1);
      }
    }
    
    int S = H+W*2+C*2+M,T = S+1;
    for(int i = 0 ; i < H ; i++){
      add_edge(S,i,1);
    }
    for(int i = 0 ; i < M ; i++){
      add_edge(H+W*2+C*2+i,T,1);
    }

    int Wnot = T+1,Wnot2 = Wnot+1;
    for(int i = 0 ; i < H ; i++){
      add_edge(i,Wnot,1);
    }
    add_edge(Wnot,Wnot2,Nw);
    for(int i = 0 ; i < C ; i++){
      add_edge(Wnot2,H+W*2+i,1);
    }

    int Cnot = Wnot2+1,Cnot2 = Cnot+1;
    for(int i = 0 ; i < W ; i++){
      add_edge(H+W+i,Cnot,1);
    }
    add_edge(Cnot,Cnot2,Nc);
    for(int i = 0 ; i < M ; i++){
      add_edge(Cnot2,H+W*2+C*2+i,1);
    }

    int Mnot = Cnot2+1;
    for(int i = 0 ; i < C ; i++){
      add_edge(H+W*2+C+i,Mnot,1);
    }
    add_edge(Mnot,T,Nm);
    cout << max_flow(S,T) << endl;
  }
  return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;

	int cnt = 0;
	for(int i = A; i <= B; ++i) {
		string number = to_string(i);
		string reverse = "";
		for(int k = number.size() - 1; k >= 0; --k) {
			reverse += number.at(k);
		}
		// 回文数かどうかを判定し、そうであればcntをインクリメントする
		if(reverse == number) {
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  int sum=0;
  for(int i=1;i<N+1;i++){
    cin >> A.at(i);
    sum+=abs(A.at(i-1)-A.at(i));
  }
  sum+=abs(A.at(N)-A.at(N+1));

  for(int i=1;i<N+1;i++){
    int a=sum-abs(A.at(i-1)-A.at(i))-abs(A.at(i)-A.at(i+1));
    a+=abs(A.at(i-1)-A.at(i+1));
    cout << a << endl;
  }

  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
template<class T> T at(vector<T> v, int i) {return v[i % v.size()];}

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
}

D sr(D a) {return sqrt(max(a, (D)0));}

D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}
P vec(L a) {return a.b - a.a;}

D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}

struct C{P c; D r;};

pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

D aCTnc(D r, P p1, P p2) {return sig(abs((p1 + p2) / (D)2), r) <= 0 ? det(p1, p2) / 2 : r * r * arg(0, p1, p2) / 2;}
D aCT(D r, P p1, P p2) {
  if (!sig(r) || near(0, p1) || near(0, p2) || near(p1, p2)) return 0;
  pair<P, P> pp = pCL((C){0, r}, (L){p1, p2});
  if ((p1 < pp.first) != (pp.first < p2) && (p1 < pp.second) != (pp.second < p2)) return aCTnc(r, p1, p2);
  return aCTnc(r, p1, pp.first) + aCTnc(r, pp.first, pp.second) + aCTnc(r, pp.second, p2);
}
D aCPol(C c, Pol pol) {D res = 0; rep (i, pol.size()) res += aCT(c.r, pol[i] - c.c, at(pol, i + 1) - c.c); return res;}

int main() {
    D w, h, s;
    while (true) {
        cin >> w >> h >> s;
        if (w == 0) break;
        D l = 0, u = (w + h);
        Pol pol;
        pol.push_back((P){w / 2, h / 2});
        pol.push_back((P){w, h / 2});
        pol.push_back((P){w, h});
        pol.push_back((P){w / 2, h});
        rep (i, 100) {
            D m = (l + u) / 2;
            if (aCPol((C){0, m}, pol) * 4 < s) l = m;
            else u = m;
        }
        printf("%.12Lf\n", l * l * 4);
    }
}

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

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			int[] line = new int[3];
			for (int i = 0; i < 3; i++) {
				line[i] = scanner.nextInt();
			}

			Arrays.sort(line);

			StringBuffer buffer = new StringBuffer().append(line[2]).append(line[1]);

			int result = Integer.parseInt(buffer.toString()) + line[0];

			System.out.println(result);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

void solve(int left, int right, vector<int> v){
    if(right == 0){
        for(int i=0;i<v.size();++i){
            cout << v[i];
            if(i+1 == v.size())cout << endl;
            else cout << " ";
        }
    }else{
        for(int i=right;i>0;--i){
            if(i <= left){
                v.push_back(i);
                solve(i, right - i, v);
                v.pop_back();
            }
        }
    }
}

int main(){
    int n;
    while(cin >> n, n != 0){
        for(int i=n;i>0;--i){
            vector<int> v;
            v.push_back(i);
            solve(i, n - i, v);
            v.pop_back();
        }
    }

    return 0;
}


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

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define LOOP(N) for(int i=(int)(N); i--;)
#define REP(i, N) for(int i=0; i<(N); ++i)
#define FOR(i, start, end) for(int i=(int)(start); i<(end); ++i)
#define ALL(a) (a).begin(),(a).end()

class FastIO {
public:
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
    ~FastIO() {}

    template <class T>
    void scan(T &v) {
        cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        cout << v;
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(" ");
        print(rest...);
    }
    template <class T>
    void print(vector<T> v) {
        for (T t: v) {
            print(t);
            print(" ");
        }
        print("\b\n");
    }
    template <class T>
    void prints(T v) {
        print(v);
        cout << "\n";
    }
};

void _main(FastIO&);
int main() {
    FastIO io;
    _main(io);
}



void _main(FastIO &io) {
    ll N; io.scan(N);
    
    cout << (N - 1) * N / 2;
}

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

const int N = 100001;

int main()
{
    int n;
    cin >> n;
    int x[3];
    int count[3] = { 0 };
    int xc = 0;
    for (int i=0; i < n; ++i) {
        int a;
        cin >> a;
        int idx = -1;
        for (int j=0; j < xc; ++j) {
            if (x[j] == a) {
                idx = j;
                break;
            }
        }
        if (idx == -1)
        {
            if (xc == 3) {
                cout << "No" << endl;
                return 0;
            }
            count[xc] = 1;
            x[xc++] = a;
        }
        else {
            ++count[idx];
        }
    }

    if (xc==1) {
        if (x[0] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    if (xc==2) {
        if (x[0] != 0 && x[1] != 0)
            cout << "No" << endl;
        else if (count[0]*2==count[1] || count[0]==count[1]*2)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
    }

    int ct = count[0];
    for (int i=0; i < xc; ++i) {
        if (count[i] != ct) {
            cout << "No" << endl;
            return 0;
        }
        for (int j=i+1; j < xc; ++j) {
            int l = x[i]^x[j];
            bool isBad = true;
            for (int k=0; k < xc; ++k) {
                if (l == x[k]) {
                    isBad = false;
                }
            }
            if (isBad)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        int h;
        int m;
        int s;
        h=S/3600;
        m=(S%3600)/60;
        s=(S%3600)%60;
        System.out.println(h+":"+m+":"+s);
    }

}



Measured memory_bytes: 26268
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	n=n%10;
	switch(n){
		case 0:
		cout<<"pon"<<endl;
		break;
		case 1:
		cout<<"pon"<<endl;
		break;
		case 6:
		cout<<"pon"<<endl;
		break;
		case 8:
		cout<<"pon"<<endl;
		break;
		case 3:
		cout<<"bon"<<endl;
		break;
		default:
		cout<<"hon"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
	int n; cin>>n;
	string s; cin>>s;
	int pocz = 0, kon = n-1;
	while(pocz<n&&s[pocz]!='W') pocz++;
	while(kon>=0&&s[kon]!='R') kon--;
	int wyn = 0;
	while(pocz<kon){
		wyn++;
		pocz++;
		kon--;
		while(pocz<n&&s[pocz]!='W') pocz++;
		while(kon>=0&&s[kon]!='R') kon--;
		if(pocz>=n||kon<0) break;
	}

	cout<<wyn;
	return 0;
}


Measured memory_bytes: 3788
# Square869120Contest #4 B - Buildings are Colorful!　

import sys

N, K = map(int, sys.stdin.readline().strip().split())
a = list(map(int, sys.stdin.readline().strip().split()))


def dfs(height=a[0], cost=0, target=K, can_see=1, i=1):
    if can_see >= target:
        # print('height', height)
        # print('can_see', can_see)
        # print('cost', cost)
        return cost

    # 端まで探索したとき
    if i == len(a):
        return float('inf')

    # 建物 i を選ばない場合
    if height >= a[i]:
        cost1 = dfs(height=height, cost=cost, target=K, can_see=can_see, i=i+1)
    else:
        cost1 = dfs(height=a[i], cost=cost, target=K, can_see=can_see+1, i=i+1)
    # print('cost1', cost1, 'can_see', can_see, 'i', i)

    # 建物　i を選んだ場合
    cost += max(0, height + 1 - a[i])
    height = max(a[i], height + 1)
    cost2 = dfs(height=height, cost=cost, target=K, can_see=can_see+1, i=i+1)
    # print('cost2', cost2)

    return min(cost1, cost2)


print(dfs(a[0], cost=0, target=K, can_see=1, i=1))



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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<ll> v(3*N);
  for(int i = 0; i < 3*N; i++){
    cin >> v.at(i);
  }
  sort(v.rbegin(), v.rend());
  ll sum = 0;
  int num = 0;
  int index = 1;
  while(true){
    sum += v.at(index);
    index += 2;
    num++;
    if(num == N) break;
  }
  cout << sum << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//公約数列挙
//昇順
vll div(ll n) {
  vll vec(1, 1);
  for (ll i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) vec.push_back(i);
  }
  if (sqrt(n) == (ll)sqrt(n)) {
    for (ll i = vec.size() - 2; i >= 0; i--) vec.push_back(n / vec[i]);
  }
  else {
    for (ll i = vec.size() - 1; i >= 0; i--) vec.push_back(n / vec[i]);
  }
  return vec;
}

vll comdiv(ll a, ll b) {
  if (a > b) swap(a, b);
  vll vec1 = div(a);
  vll vec2(0);
  for (ll i = 0; i < vec1.size(); i++) {
    if (b % vec1[i] == 0) vec2.push_back(vec1[i]);
  }
  return vec2;
}

//素数判定
bool is_prime(ll n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (ll i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  vll v = comdiv(a, b);
  ll ans = 0;
  for (ll i = 0; i < v.size(); i++) {
    if (is_prime(v[i])) ans++;
  }
  cout << ans + 1 << endl;
}

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

int main(){
	int a,b;
	char op;
	cin >> a >> op >> b;
	while(op != '?'){
	    if(op == '+'){
	        cout << a + b << endl;
	    }else if(op == '-'){
	        cout << a - b << endl;
	    }else if(op == '/'){
	        cout << a / b << endl;
	    }if(op == '*'){
	        cout << a * b << endl;
	    }
	    cin >> a >> op >> b;
	}
	
	return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner kbScanner = new Scanner(System.in);
		
		int sec = kbScanner.nextInt();
		
		int hour = 0, minute = 0, second = 0;
		
		hour = sec / 3600;
		sec -= hour * 3600;
		minute = sec / 60;
		sec -= minute * 60;
		second = sec;
		
		System.out.println(hour + ":" + minute + ":" + second);
	}
}

Measured memory_bytes: 26172
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

int main()
{
    ll n;
    ll k;
    ll q;
    ll a[100005];
    ll p[100005] = {0};
    
    cin >> n >> k >> q;
    for (ll i = 0;i < q;i++){
        cin >> a[i];
        p[a[i]-1]++;
    }
    for (ll i = 0;i < n;i++){
        if (q-p[i] >= k){
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
}


Measured memory_bytes: 2176