akhauriyash/Code-Regression huggingface dataset:
/**
  *  @Author: Pranta Sarker
  *
  */

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define pfn(x , k) printf(k , x)
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
#define clr clear()

typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;

const int mod = 1000007;
const int high = 1e5+3;

int main()
{
	fast;
	int x , N , i=0 , odd=0, even_no_four=0, four=0;
	cin >> N;
	for(i=0; i<N; i++)
	{
		cin >> x;

		if(x % 4 == 0) four+=1;
		else if(x % 2 == 0) even_no_four+=1;
		else if(x % 2 != 0) odd+=1;
	}

	int b1 = odd;
	int b2 = even_no_four;
	int b4 = four;

	if(b2 == 0)
	{
		if(b1 <= b4 + 1)
		{
			outn("Yes");
		}

		else
		{
			outn("No");
		}
	}

	if(b2 > 0)
	{
		if(b1 <= b4)
		{
			outn("Yes");
		}

		else
		{
			outn("No");
		}
	}

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
INF = 10**10
matches = [2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-INF for _ in range(N+100)]
dp[0] = 0

for i in range(N+1):
    for a in A:
        dp[i+matches[a-1]] = max(dp[i+matches[a-1]], dp[i]+1)

ans = ''
while N != 0:
    for a in A:
        if dp[N-matches[a-1]] == dp[N]-1:
            ans = ans+str(a)
            N -= matches[a-1]
            break

print(ans)


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

int main()
{
	int n;
	cin>>n;
	int a[n],temp;
	for(temp=0;temp<n;temp++)	cin>>a[temp];
	int cnt=0;
	for(temp=1;temp<n;temp++)
	{
		if(a[temp]==a[temp-1])
		{
			cnt++;
			a[temp]=10e8;
		}
	}
	cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int z[5];
	int k;
	int i,j;
	int yay=0;
	
	for(i=0;i<5;i++)	scanf("%d",&z[i]);
	scanf("%d",&k);
	
	for(i=0;i<4;i++){
		for(j=i+1;j<5;j++){
			if(z[j]-z[i]>k){
				yay=1;
				break;
			}
		}
	}
	
	if(yay==1)	printf(":(");
	else	printf("Yay!");
	
	return 0;
}

Measured memory_bytes: 128
import math
N = int(input())
X = list(map(int, input().split()))
E1 = 0
E2 = 0
x1 = math.floor(1/N*sum(X))
x2 = math.ceil(1/N*sum(X))
for i in range(N):
  E1 += (X[i]-x1)**2
  E2 += (X[i]-x2)**2
if E1 <= E2:
  print(E1)
else:
  print(E2)

Measured memory_bytes: 3064
n,k = map(int,input().split())
x = list(map(int,input().split()))
times = []
for i in range(n-k+1):
    tl =abs(x[i])
    tr = abs(x[i+k-1])
    tw = abs(x[i]-x[i+k-1])
    times.append(min(tl,tr)+tw)
print(min(times)) 

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

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

  double a = N/2+1;
  double ans1 = 1.0/2.0;

  if(N % 2 == 0) {
    cout << ans1 << endl;
  } else {
    cout << a / N << endl;
  }
}

Measured memory_bytes: 256
use std::cmp::max;
use std::io::*;
use std::str::FromStr;
use std::vec::Vec;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let mut fs: Vec<Vec<i64>> = Vec::new();
    for i in 0..n {
        fs.push(Vec::new());
        for _ in 0..10 {
            fs[i].push(read())
        }
    }

    let mut ps: Vec<Vec<i64>> = Vec::new();
    for i in 0..n {
        ps.push(Vec::new());
        for _ in 0..11 {
            ps[i].push(read())
        }
    }

    let ans = (1..1 << 10)
        .map(|i| {
            (0..n)
                .map(|j| {
                    let count = (0..10)
                        .filter(|k| i & (1 << k) != 0 && fs[j][*k as usize] == 1)
                        .collect::<Vec<_>>()
                        .len();
                    ps[j][count]
                }).sum()
        }).fold(-1 << 60, max);

    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <iostream>

struct 
{} undefined;

template <typename T , unsigned H , unsigned W>
auto input (T (& a) [H] [W]) -> bool
{
    bool result = static_cast <bool> (std::cin >> a [0] [0]);
    if (! result)
    {
        return false;
    }
    for (auto x = 1u; x < W; ++ x)
    {
        std::cin >> a [0] [x];
    }
    for (auto y = 1u; y < H; ++ y)
    {
        for (auto x = 0u; x < W; ++ x)
        {
            std::cin >> a [y] [x];
        }
    }
    return true;
}

template <unsigned H , unsigned W>
auto at (char (& a) [H] [W] , unsigned x , unsigned y) -> bool
{
    if (0 <= x && x < W && 0 <= y && y < H)
    {
        return a [y] [x] == '1';
    }
    else
    {
        return false;
    }
}

template <unsigned H , unsigned W>
auto check (char (& a) [H] [W]) -> char
{
    for (auto y = 0u; y < H; ++ y)
    {
        for (auto x = 0u; x < W; ++ x)
        {
            if (at (a , x , y))
            {
                // ??????????????? -> A,C,E,G
                if (at (a , x + 1 , y))
                {
                    // ??????????????? -> A,G
                    if (at (a , x , y + 1))
                    {
                        // ??????????????????????????? -> A
                        if (at (a , x + 1 , y + 1))
                        {
                            return 'A';
                        }
                        // ??????????????????????????? -> G
                        else
                        {
                            return 'G';
                        }
                    }
                    // ??????????????? -> C,E
                    else
                    {
                        // 2??????????????? -> C
                        if (at (a , x + 2 , y))
                        {
                            return 'C';
                        }
                        // 2?????????????????? -> E
                        else
                        {
                            return 'E';
                        }
                    }
                }
                // ??????????????? -> B,D,F
                else
                {
                    // 2??????????????? -> B
                    if (at (a , x , y + 2))
                    {
                        return 'B';
                    }
                    // ???????????????????????? -> F
                    else if (at (a , x + 1 , y + 1))
                    {
                        return 'F';
                    }
                    // ???????????????
                    else
                    {
                        return 'D';
                    }
                }
                throw undefined;
            }
        }
    }
    return 'X';
}

auto main () -> int
{
    char a [8] [8];
    while (input (a))
    {
        std::cout << check (a) << std::endl;
    }
}

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

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

typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long int> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvll;

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

  map<int, multiset<int>> jobs;

  for(int i=0;i<n;i++) {
    int a, b;
    cin >> a >> b;
    jobs[a].emplace(b);
  }

  auto it = jobs.begin();
  long long int ans = 0;
  multiset<int> jobsPool;

  for(int i=1;i<=m;i++) {
    if(it!=jobs.end() && it->first == i) {
      jobsPool.insert(it->second.begin(), it->second.end());
      it++;
    }

    if(jobsPool.empty()) continue;
    else {
      auto p = jobsPool.end();
      auto q = prev(p, 1);
      ans += *q;
      jobsPool.erase(q, p);
    }
  }

  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    ll ans=0;
    rep(i,n){
        ll a; cin>>a;
        while(a%2==0) a/=2, ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		int i, max = sc.nextInt();
		for (i = 0; i < max; i++) {
			double a = Math.pow(sc.nextInt(), 2);
			double b = Math.pow(sc.nextInt(), 2);
			double c = Math.pow(sc.nextInt(), 2);
			if (a + b == c || b + c == a || a + c == b) {
				ret.add("YES");
			} else {
				ret.add("NO");
			}
		}
		for (String text : ret) {
			System.out.println(text);
		}
	}
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

const int MAXN = 1e5 + 5;

ll a[MAXN], b[MAXN];

int main() {
    //freopen("", "rt", stdin);
    //freopen("", "wt", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &a[i], &b[i]);
    }
    ll sum = 0;
    for (int i = n-1; i >= 0; i--) {
        a[i] += sum;
        ll t = ceil((long double)a[i] / b[i]);
        sum += t * b[i] - a[i];
    }
    printf("%lld\n", sum);
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int gcd(int a, int b) {
	if (a % b == 0) {
		return b;
	}
	return gcd(b, a % b);
}

int main() {
	long long n;
	cin >> n;
	long long ans = 0;
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++) {
			for (int k = 1;k <= n;k++) {
				ans = ans + gcd(gcd(i, j), k);

			}

		}

	}
	cout << ans;

}

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

int main() 
{
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> v;

    for( int i=1 ; i <= max( A, B ) ; i++ )
    {
        if( 0 == (A%i) && 0 == (B%i) ) v.push_back(i);
    }

    // 順序反転
    reverse(v.begin(), v.end());
 	// 出力
    cout << v[K-1] << endl;
}



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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    double dmoto = n/1.08;
    int imoto=(int)dmoto;
    int ans=-1;
    for (int i = 0; i < 3; i++)
    {
        if((int)((imoto+i)*1.08)==n)
        {
            ans=imoto+i;
        }
    }
    
    if(ans>0)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[55],ans;
vector<int>v;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<=min(n,m);i++)
	{
		for(int j=0;j<=min(n-i,m-i);j++)
		{
			v.clear();
			for(int k=1;k<=i;k++)
			{
				v.push_back(a[k]);
			}
			for(int k=n;k>n-j;k--)
			{
				v.push_back(a[k]);
			}
			sort(v.begin(),v.end());
			int now=m-i-j,cnt=0;
			for(int k=0;k<v.size();k++)
			{
				cnt+=v[k];
			}
			for(int k=0;k<v.size();k++)
			{
				if(v[k]<0 && now)
				{
					now--;
					cnt-=v[k];
				}
			}
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int n, k, x;

int main() {
    ios::sync_with_stdio(0);

    cin >> n >> k;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        ans += min(x, k - x);
    }

    cout << 2 * ans << "\n";

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int a,b; cin>>a>>b;
        cout<<(a-1)*(b-1)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String tileStr = sc.next();
		sc.close();
		int ZERO_START = 0;
		int ONE_START = 0;
		for (int i = 0; i < tileStr.length(); i++) {
			char tmp = tileStr.charAt(i);
			if (i % 2 == 0) {
				if (tmp == '0') {
					ONE_START++;
				} else {
					ZERO_START++;
				}
			} else {
				if (tmp == '1') {
					ONE_START++;
				} else {
					ZERO_START++;
				}
			}
		}
		if (ZERO_START < ONE_START) {
			System.out.println(ZERO_START);
		} else {
			System.out.println(ONE_START);
		}
	}
}

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

int main() {
    int N, M, X, ans = 1e9;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }
    rep(i, (1 << N)) {
        vector<int> result(M);
        int cur = 0;
        rep(j, N) {
            if (i & (1 << j)) {
                cur += C[j];
                rep(k, M) {
                    result[k] += A[j][k];
                }
            }
        }
        bool ok = true;
        rep(j, M) {
            if (result[j] < X) ok = false;
        }
        if (ok) ans = min(ans, cur);
    }
    if (ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
n = int(input())
chars = 'Xabcdefghijklmnopqrstuvwxyz'
res = ''
while True:
    x = n%26 #最下位の位の文字を求める(係数が26でない最下位の位が余りとして出せる)
    if x == 0: #Xが26のときのみ余り0で対応させるため26に書き換え
        x = 26
    res += chars[x] #文字を正解リストに追加
    n -= x #xを左辺に持っていって右辺で10の位以上の数値を調べる
    if n == 0 :
        break
    n //= 26 #n-xは必ず26の倍数になっている。(xを移項しているから自明)
#最下位の位を余りとして扱うために26で割って係数を消している。
print(res[::-1])#resには1の位が一番初めに入っているので、反転させて表示

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

typedef long long ll;
typedef long double ld;
#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()
#define sp                    " "
#define sz                    size()

const int BIG=1e7+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;


int main() {
char x[27] ;
char j = 'a';
for (int i = 1 ; i < 27 ; i++ , j++){
    x[i]=j;
}
x[0]='z';
string s ="";
ll n = 123456789 ;
cin >> n ;
while (n>0){

    if (n==26 || n%26==0){s+='z'; n/=26 ; n--;}
    else {s+=x[n%26];n/=26;}
    //cout << n << sp;



}
reverse(s.begin() , s.end() );
cout << s ;

}


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

int ans;

signed main(){
  int h,w,K;cin>>h>>w>>K;
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<(1<<h);i++){
    for(int j=0;j<(1<<w);j++){
      int tmp=0;
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          if(((i>>k)&1)&&((j>>l)&1)&&s[k][l]=='#')tmp++;
        }
      }
      ans+=tmp==K;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  long long n;
  cin >> n;
  long long maxV = 1;
  for ( int i = 1; i <= floor(sqrt(n)); i++){
    if ( n % i == 0){
      maxV = i;
    }
  }

  cout << maxV + n / maxV - 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int x,n;
int main(){
	cin>>n;
	int ans=-1;
	int t=0;
	for (int i=1;i<=n;i++) {
		cin>>x;
		if (x>=ans){
			ans = x;
			t++;
		}
	}
	cout<<t<<endl;
	return 0;
}



Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(x) for x in stdin.readline().rstrip().split()]
C = [int(x) for x in stdin.readline().rstrip().split()]
a=0
for i in range(N):
    if V[i]-C[i] > 0:
        a += V[i] - C[i]
print(a)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  unordered_set<string> st;
  rep (i, N) {
    string S;
    cin >> S;
    st.insert(S);
  }

  if (st.size() == 4) cout << "Four" << endl;
  else cout << "Three" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
//https://qiita.com/drken/items/dc53c683d6de8aeacf5a
#include<bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;
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 long long INF = 1LL << 60;

//input
int N;
long long h[100010];

//DP table
long long dp[100010];

int main(){
    int N; cin >> N;
    for(int i = 0; i < N; ++i) cin >> h[i];

    //initialization(Because we treat Minimization problem, initialize with INF)
    for(int i = 0; i < N; i++)dp[i] = INF;
    
    // initial condition
    dp[0] = 0;

    // loop
    for(int i = 0; i < N; ++i){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i>1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    // output an answer
    cout << dp[N-1] << endl;
}


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

using namespace std;
int main() {
  int num[3];
  for (int i = 0; i < 3; i++) {
    cin >> num[i];
  }

  int cnt5 = 0, cnt7 = 0;
  for (int i = 0; i < 3; i++) {
    if (num[i] == 5) cnt5++;
    if (num[i] == 7) cnt7++;
  }

  cout << (cnt5 == 2 && cnt7 == 1 ? "YES" : "NO");

  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in edge[0]:
    if n-1 in edge[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 41904
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int r;

	std::cin >> r;
	std::cout << (3 * r * r) << "\n";
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Rainy Season
 */

#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 N = 3;

/* typedef */

/* global variables */

char s[N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  int maxc = 0;
  for (int i = 0; i < N;) {
    while (i < N && s[i] == 'S') i++;
    if (i >= N) break;

    int j = i;
    while (j < N && s[j] == 'R') j++;
    int c = j - i;
    if (maxc < c) maxc = c;
    i = j;
  }

  printf("%d\n", maxc);
  return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
using namespace std;
 
#define MAXN 3010
 
string s,t;
string ans;
 
int dp[MAXN][MAXN];
 
void dfs(int i, int j) {
  int val = dp[i][j];
  
  if (val == 0) return;
  
  if (i == 0 && j == 0) {
    ans += s[0];
    return;
  }
  
  if (i == 0) {
    ans += s[0];
    return;
  }
  
  if (j == 0) {
    ans += t[0];
    return;
  }
  
  if (val == dp[i-1][j]) {
    dfs(i-1,j);
  } else if (val == dp[i][j-1]) {
    dfs(i,j-1);
  } else {
	ans += s[i];
    dfs(i-1,j-1);
  }
}
 
int main() {
	cin >> s >> t;
  	int n = (int)s.length(), m = (int)t.length();
  	for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        dp[i][j] = -1;
      }
    }
  	if (s[0] == t[0]) {
      dp[0][0] = 1;
    } else {
      dp[0][0] = 0;
    }
  	for (int i = 1; i < n; i++) {
      dp[i][0] = max(dp[i-1][0],(s[i]==t[0]?1:0));
    } 
  	for (int i = 1; i < m; i++) {
      dp[0][i] = max(dp[0][i-1],(s[0]==t[i]?1:0));
    }
  	for (int i = 1; i < n; i++) {
      for (int j = 1; j < m; j++) {
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        
        if (s[i] == t[j]) dp[i][j] = max(dp[i][j],1+dp[i-1][j-1]);
      }
    }
  	dfs(n-1,m-1);
  	for (int i = ans.length()-1; i >= 0; i--) {
      cout << ans[i];
    }
  cout << endl;
}

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

using namespace std;

#define MAX_N 100
#define MAX_C 20
#define MAX_R 10010
#define INF (1<<29)

struct State {
    int d, v;
    
    State(int d, int v) 
        : d(d), v(v) {}
    
    bool operator < (const State &s) const {
        return d > s.d;
    }
};

int N, M, C, mc[MAX_C];
vector<int> q[MAX_C];
int cost[MAX_C][MAX_R];
int dist[MAX_N][MAX_N][MAX_C];

int get_cost(int c, int d)
{
    int n = q[c].size();
    if (q[c][n-1] < d) {
        return cost[c][q[c][n-1]] + (d - q[c][n-1]) * mc[c];
    } else {
        return cost[c][d];
    }
}

int dijkstra(int src, int dst)
{
    int d[MAX_N];
    fill(d, d + MAX_N, INF);    
    d[src] = 0;
    
    priority_queue<State> Q;
    Q.push(State(0, src));
    
    while (!Q.empty()) {
        State s = Q.top(); Q.pop();
        int dd = s.d, v = s.v;
        if (v == dst) return dd;
        for (int i = 0; i < N; i++) {
            if (v == i) continue;
            for (int j = 0; j < C; j++) {
                if (dist[v][i][j] == INF) continue;
                int ncost = get_cost(j, dist[v][i][j]) + d[v];
                if (ncost < d[i]) {
                    d[i] = ncost;
                    Q.push(State(d[i], i));                    
                }
            }
        }
    }
    return -1;
}

void init()
{
    for (int i = 0; i < C; i++) {
        q[i].clear();
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < C; k++) {
                dist[i][j][k] = (i != j ? INF : 0);
            }
        }
    }

}

void warshall_floyd()
{
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int l = 0; l < C; l++) {
                    dist[i][j][l] = min(dist[i][j][l],
                                        dist[i][k][l] + dist[k][j][l]);
                }
            }
        }
    }
}

int main()
{
    int src, dst;
    while (cin >> N >> M >> C >> src >> dst, N) {
        init();
        src--; dst--;
        for (int i = 0; i < M; i++) {
            int a, b, c, d;
            cin >> a >> b >> d >> c;
            a--; b--; c--;
            dist[a][b][c] = min(dist[a][b][c], d);
            dist[b][a][c] = min(dist[b][a][c], d);
        }        

        warshall_floyd();
        vector<int> p(C);
        for (int i = 0; i < C; i++) {
            cin >> p[i];
        }       
        
        for (int i = 0; i < C; i++) {
            vector<int> r(p[i]);
            q[i].resize(p[i]+1, 0);
            for (int j = 1; j < p[i]; j++) {
                cin >> q[i][j];
            }            
            q[i][p[i]] = q[i][p[i]-1] + 1;
            
            for (int j = 0; j < p[i]; j++) {
                cin >> r[j];
                mc[i] = r[j];
            }
            
            cost[i][0] = 0;
            for (int j = 0; j < p[i]; j++) {
                for (int k = q[i][j]+1; k <= q[i][j+1]; k++) {
                    cost[i][k] = cost[i][k-1] + r[j];
                }
            }
        }
        cout << dijkstra(src, dst) << endl;
    }
    return 0;
}

Measured memory_bytes: 2872
n, m = map(int, input().split())

if m == 0:
  l = [-1]
else:
  l = [int(input())-1 for _ in range(m)]
res = [0, 1]
skip = 0

for i in range(n):
  if i == l[skip]:
    res[0] = res[1]
    res[1] = 0
    if skip < m-1:
      skip += 1
  else:
    tmp = res[1]
    res[1] += res[0]
    res[0] = tmp
    res[1] %= 10**9 + 7
    res[0] %= 10**9 + 7
      
print(res[1])


Measured memory_bytes: 7056
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		ArrayList<BigDecimal> arrayA = new ArrayList<>(10);
		ArrayList<BigDecimal> arrayB = new ArrayList<>(10);
		for(BigDecimal i = BigDecimal.ZERO; i.compareTo(BigDecimal.ONE) < 0; i = i.add(BigDecimal.valueOf(0.1))) {
			arrayA.add(BigDecimal.valueOf(A).add(i).divide(BigDecimal.valueOf(0.08), RoundingMode.CEILING));
			arrayB.add(BigDecimal.valueOf(B).add(i).divide(BigDecimal.valueOf(0.10), RoundingMode.CEILING));
		}

		int result = Integer.MAX_VALUE;
		for(BigDecimal a : arrayA) {
			for(BigDecimal b : arrayB) {
				if(a.compareTo(b) == 0 && a.intValue() < result) {
					result = a.intValue();
				}
			}
		}
		if(result == Integer.MAX_VALUE) {
			result = -1;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
N = input()

dp = [[0] * 10 for _ in range(10)]

for i in range(1, int(N) + 1):
    c = str(i)
    dp[int(c[0])][int(c[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += dp[i][j] * dp[j][i]

print(ans)


Measured memory_bytes: 40300
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}



int main() {
	int N;
	cin >> N;
	string*w = new string[N];
	for (int i = 0; i < N; i++) {
		cin >> w[i];
	}
	for (int i = 1; i < N; i++) {
		if (w[i][0] != w[i - 1][w[i - 1].size() - 1]) {
			cout << "No";
			return 0;
		}
	}
	map<string, int> ma;
	for (int i = 0; i < N; i++) {
		ma[w[i]]++;
	}
	for (auto itr : ma) {
		if (itr.second > 1) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;
	int tmp;

	cin >> N;

	for (int i = 1; i <= 9; i++) {
		if (N % i == 0) {
			tmp = N / i;
			if (tmp > 0 && tmp < 10) {
				cout << "Yes" << endl;

				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 di[4] = {0,1,0,-1};
int32 dj[4] = {1,0,-1,0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h)cin >> s[i];
  int32 ans = 0;
  REP(i,h)REP(j,w){
    if(s[i][j] == '#')continue;
    vector<vector<int32>> dist(h, vector<int32>(w,INF));
    dist[i][j] = 0;
    queue<pii> que;
    que.push(pii(i,j));
    while(!que.empty()){
      int32 ci,cj;
      tie(ci,cj) = que.front();que.pop();
      REP(k,4){
        int32 ni = ci + di[k];
        int32 nj = cj + dj[k];
        if(ni < 0 || h <= ni)continue;
        if(nj < 0 || w <= nj)continue;
        if(s[ni][nj] == '#')continue;
        if(dist[ni][nj] > dist[ci][cj] + 1){
          dist[ni][nj] = dist[ci][cj] + 1;
          ans = max(dist[ni][nj], ans);
          que.push(pii(ni,nj));
        }
      }
    }
    // REP(x,h){
    //   REP(y,w){
    //     cout << dist[x][y] << " ";
    //   }
    //   cout << endl;
    // }
    // cout << endl;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
NM = input().split()
N = int(NM[0])
M = int(NM[1])
prob = []
probStatus = []
for i in range(M):
    pS = input().split()
    prob.append(int(pS[0]))
    probStatus.append(pS[1])
correctAr = [0] * N
penaltyAr = [0] * N
submissions = [''] * N
for i in range(M):
    if probStatus[i] == 'AC' and submissions[prob[i] - 1] == '':
        correctAr[prob[i] - 1] += 1
        submissions[prob[i] - 1] = 'AC'
    elif probStatus[i] == 'WA' and submissions[prob[i] - 1] == '':
        penaltyAr[prob[i] - 1] += 1
correct = 0
penalty = 0
for i in range(N):
    if submissions[i] == 'AC':
        correct += correctAr[i]
        penalty += penaltyAr[i]

print(correct, penalty)


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

int main() {
	vector<int> c(9);
  		for(int i=0;i<9;i++){
          cin>>c.at(i);
        }
  if((c.at(0)+c.at(4)+c.at(8)==c.at(0)+c.at(5)+c.at(7))&&(c.at(0)+c.at(4)+c.at(8)==c.at(1)+c.at(3)+c.at(8))&&(c.at(0)+c.at(4)+c.at(8)==c.at(2)+c.at(3)+c.at(7))&&(c.at(0)+c.at(4)+c.at(8)==c.at(2)+c.at(4)+c.at(6))&&(c.at(0)+c.at(4)+c.at(8)==c.at(1)+c.at(5)+c.at(6))){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main(){
    int n,m,c; cin>>n>>m>>c;
    int a[21],b[21];
    int ans=0;
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        int x=0;
        for(int j=0;j<m;j++){
            cin>>a[j];
            x+=a[j]*b[j];
        }
        x+=c;
        if(x>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

void shuffle(string* str, vector<int> h){
    
    long sn = str->length();
    unsigned long m = h.size();
    
    for(unsigned long i=0; i<m; i++){
        
        string s = "";
        for(long j=0; j<sn; j++){
            s += (*str)[(h[i]+j)%sn];
        }
        
        *str = s;
        
    }
    
}

int main() {
    
    vector<string> v_str;
    vector< vector<int> > v_h;
    
    while(true){
        string str;
        cin >> str;
        
        if(str=="-") break;
    
        int m;
        cin >> m;
    
        vector<int> h;
        for(int i=0; i<m; i++){
            int a;
            cin >> a;
            h.push_back(a);
        }
        
        v_str.push_back(str);
        v_h.push_back(h);
        
    }
    
    unsigned long hn = v_h.size();
    for(unsigned long i=0; i<hn; i++){
        shuffle(&v_str[i], v_h[i]);
        cout << v_str[i] << endl;
    }
    
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	int N;
	cin >> N;
	N-=1;

	int a, b, c, curra, currb, currc, ans = -1;
	cin >> a >> b >> c;
	while(N--){
		cin >> curra >> currb >> currc;
		curra+=max(b, c);
		currb+=max(a, c);
		currc+=max(a, b);
		a = curra;
		b = currb;
		c = currc;
	}		
	ans = max({a, b, c});
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 3648
n=int(input())
x=[list(map(int,input().split())) for _ in range(n)]
x=sorted(x,key=lambda x: x[1])

a=[0]*n
a[0]=x[0][0]
for i in range(1,n):
    a[i]=a[i-1]+x[i][0]

for j in range(n):
    if a[j] > x[j][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 58260
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N;
    cin>>N;
    int n=0;
    for(int i=0;i<N.size();i++){
        n+=N[i]-'0';
    }
    cout<<(stoi(N)%n==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t 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; }



int main() {
	ll H, W;
	cin >> H >> W;
	ll cost = H * W;
	if (cost % 2 == 1) {
		cost++;
	}
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << cost / 2 << endl;
}

Measured memory_bytes: 3624
n = int(input())
a_list = input().split()

a_list_reverse = a_list[::-1]
# print(a_list_reverse)

rusekiwa = [0] * (len(a_list_reverse) - 1)
sum_v = 0
for i in range(len(a_list_reverse) - 1):
    sum_v += int(a_list_reverse[i])
    rusekiwa[i] = sum_v
# print(rusekiwa)

ans = 0
for i in range(len(a_list) - 1):
    v = int(a_list[i]) * rusekiwa[-1 - (i)]
    # print(v)
    # v = v % (10 ** 9 + 7)
    ans += v
    ans = ans % (10 ** 9 + 7)

# ans = ans % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 35640
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    ll h, w;
    cin >> h >> w;
    ll n;
    n = h * w;
    n++;
    n /= 2;
    if(h == 1 || w == 1){
        cout << 1 << endl;
    }
    else{
        cout << n << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,a[5000][5000];
int main(){
	cin>>n;
	for(int i=1;i*(i-1)/2<=n;i++){
		if(i*(i-1)/2==n){
			puts("Yes");
			k=i;
			cout<<k<<endl;
			break;
		}
	}
	if(!k){
		puts("No");
		return 0;
	}
	for(int i=1;i<=k-1;i++){
		for(int j=1;j<=i;j++){
			if(j==1){
				if(i==1)a[i][j]=1;
				else a[i][j]=a[i-1][i-1]+1;
			}
			else a[i][j]=a[i][j-1]+1;
		}
	}
	for(int i=1;i<=k;i++){
		cout<<k-1<<" ";
		if(i!=k){
			for(int j=1;j<=i;j++)cout<<a[i][j]<<" ";
			for(int j=i+1;j<=k-1;j++)cout<<a[j][i]<<" ";
		}
		else for(int i=1;i<=k-1;i++)cout<<a[i][i]<<" ";
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a=1;
    int n=0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        a=a*i;
        a=a%1000000007;
    }
    printf("%lld", a);
}

Measured memory_bytes: 256
n = int(input())
A = sorted(map(int, input().split()))[::-1]
# print(A)
loop = 0
scoreA = 0
scoreB = 0
for e in A:
    if loop % 2 == 0:
        scoreA += e
    else:
        scoreB += e
    loop += 1
print(scoreA - scoreB)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    for(ll i=1;i<=3;i++)
    {
        if(i!=a && i!=b){

           cout<<i<<endl;
        }
    }
  return 0;
}


Measured memory_bytes: 3576
n, l = list(map(int, input().split()))
arr = [_ for _ in range(l, l + n)]
_sum = sum(arr)
tmp = 1000
for i in range(1, n + 1):
    n_sum = sum(arr[:i - 1] + arr[i:])
    if abs(_sum - n_sum) < tmp:
        tmp = abs(_sum - n_sum)
        ans = n_sum
print(ans)


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

int main()
{
	int w, h;
	int m, n;

	while (1) {
		cin >> h >> w;

		if (h == 0 && w == 0) {
			break;
		}
		else {
			for (m = 0; m < h; m++) {
				for (n = 0; n < w; n++) {
					cout << "#";
				}
				cout << endl;
			}
			cout << "\n";
		}
	}
    return 0;
}




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

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


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

Measured memory_bytes: 3624
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                             //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

bool check(string s)
{
  int n=s.L();
  int i=0;
  while(i<n/2)
  {
    if(s[i]!=s[n-i-1]) re 0;
    i++;
  }
  re 1;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    // cin>>n;
    string s;
    cin>>s;
    n=s.L();
    string t=s;
    if(check(s.substr(0,n/2)) && check(t.substr(n/2+1,n/2)) && check(s))
    cout<<"Yes";
    else cout<<"No";

  }


  return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
string S;
ll ans;

int main(){


    
    cin >> N;
    cin >> S;

    ll cntR=0;
    ll cntG=0;
    ll cntB=0;
    vint value;
    string target;
    rep(ni,N){
        target = S.substr(ni,1);
        //cout << target << endl;
        if(target=="R"){
            cntR++;
            value.push_back(1);
        }else if(target=="G"){
            cntG++;
            value.push_back(10);

        }else if(target=="B"){
            cntB++;
            value.push_back(100);
        }
    }
    //rep(ni,value.size()) cout << value[ni] << endl;

    ans = cntR * cntG * cntB;
    //cout << cntR * cntG<< endl;
    //cout << ans << endl;
    for( int bef = 1 ; bef < N ; bef++ ){
        for( int start = 0 ; start <N ; start++ ){
            int next = start + bef;
            int last = start + bef + bef;
            if(last<N){
                if(value[start]+value[next]+value[last]==111){
                    ans--;
                }
            }
        }
    }
    if(ans<0) ans = 0;
    cout << ans << endl;


}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int INF = 1e9;
constexpr long double eps = 1e-8;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int res = 0;
    for(int i = 0; i < N; ++i) {
        if(a[i] == i + 1) {
            if(i == N - 1) {
                swap(a[i], a[i - 1]);
            } else {
                swap(a[i], a[i + 1]);
            }
            res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 640