akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	stack<int> S;
	string s;
	int a, b;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b + a);
		}else if (s[0] == '-') {
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b - a);
		}else if (s[0] == '*') {
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b * a);
		}
		else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    ll ans,N,K;
    cin>>N>>K;
    if(K%2==0){
        ll X=N/K,Y=(N+K/2)/K;
        ans=X*X*X+Y*Y*Y;
    }
    else{
        ll X=N/K;
        ans=X*X*X;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

int main() {
	int i,n,k;
	cin>>n>>k;
	int h[n];
	for(i=0;i<n;i++)
	    cin>>h[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
	   dp[i]=INT_MAX;
	for(i=2;i<n;i++)
	{
	    for(int x=1;x<=min(i,k);x++)
	    {
	        dp[i]=min(dp[i],dp[i-x]+abs(h[i]-h[i-x]));
	    }
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4428
import numpy as np

H, W = map(int,input().split())
#A = [input() for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
mod = 10**9+7

eq = A == '.'

dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if eq[i][j]:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % mod

print(dp[-1][-1])


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

int main()
{
  int N;
  long A[200010]={0};
  cin>>N;
  long length=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    length+=A[i];
  }
  long half=length/2;
  long bar=0;
  long barl=0;
  for(int i=0;i<N;i++){
    if(bar<half){
      bar+=A[i];
      barl=bar;
      if(bar>half) barl=barl-A[i];
    }
  }
  half=length-bar;
  long halfl=length-barl;
  cout<<min(max(half-bar,bar-half),max(halfl-barl,barl-halfl))<<endl;
}

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

int main() {
    vector<int> v(3, 0);
    for(int i = 0; i < 3; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());

    for(int i = 0; i < 3; ++i) {
        if(v[i] % 2 == 0) {
            cout << "0\n";
            return 0;
        }
    }

    cout << 1LL * v[0] * v[1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
ll p(ll a,ll b){return a+b;}
ll e(){return 0;};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vll a(n);
    
    for (size_t i = 0; i < n; i++)
    {
        
        cin >> a[i];

    }
    atcoder::segtree<ll,p,e> seg(a);
    for (size_t i = 0; i < q; i++)
    {
        int t,a,b;
        cin>>t>>a>>b;
        if(t)
        {
            cout<<seg.prod(a,b)<<'\n';
        }
        else
        {
            seg.set(a,seg.get(a)+b);
        }
        
    }
    
    
    
    return 0;
}

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


int main() {
  int A;
  cin >> A;
  
  string ans = "No";
  
  for ( int i = 0 ; i<9 ; i++){
    for(int j = 0 ; j<9 ; j++){
      if((i+1) * (j+1) == A ) ans = "Yes";
    }
  }
 
  cout << ans << endl;
  
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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 (b<a) { a=b; return 1; } return 0; }

int main() {
	ll h,n;
	cin >> h >> n;
	vector<int> a(n);
	ll acc = 0;
	rep(i,n) {
		cin >> a[i];
		acc += a[i];
	}
	if (acc >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    vector<bool> d(4);
    REPS(c, s) {
        if (c == 'S') d[0] = true;
        if (c == 'N') d[1] = true;
        if (c == 'W') d[2] = true;
        if (c == 'E') d[3] = true;
    }
    if (d[0] ^ d[1] == false and d[2] ^ d[3] == false) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
int main() {
 	int a[3];
  	int max = -1;
  	for (int i = 0; i < 3; ++i) {
     	scanf("%d", &a[i]);
      	max = std::max(max, a[i]);
    }
  	printf("%d\n", a[0] + a[1] + a[2] - max);
  	return 0;
}

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

int main() {
	string a;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
	if(a[0]==a[5]&&a[1]==a[4]&&a[2]==a[3]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  string S; cin >> S;
  
  int ans = 1;
  char now = S[0];
  for(int i=1; i<N; i++){
    if(S[i] != now){
      ans++;
      now = S[i];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int cond[MAX], n;
stack<int> S;

void set(int m)
{
	int u, v;
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
}

void dfs(int x, int id)
{
	S.push(x);
	cond[x] = id;

	int i, v;
	while (!S.empty()) {
		int u = S.top();
		S.pop();
		for (i = 0; i < (int)G[u].size(); i++) {
			v = G[u][i];			
			if (cond[v] == 0) {				
				cond[v] = id;
				S.push(v);
			}
		}
	}
}

void searchFriends()
{
	int id = 1;
	for (int i = 0; i < n; i++)
		if (cond[i] == 0) dfs(i, id++);
}

int main()
{
	int m, q, u, v;
	cin >> n >> m;

	set(m);
	searchFriends();

	cin >> q;
	
	for (int i = 0; i < q; i++) {
		cin >> u >> v;
		if (cond[u] != 0 && cond[v] != 0 && cond[u] == cond[v])
			cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
	{
    if(s[i]=='C')
    t++;
    if(t!=0&&s[i]=='F')
    t=t-100000000000;
    }
    if(t<0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{
	int t ;
	cin>>t;
	vector <int> arr(t);
	for(auto &i:arr)
	{
		cin>>i;
	}
	vector <int> dp(t,0);
	if(true){
	dp[t-1] = 0;
	dp[t-2] = abs(arr[t-1]-arr[t-2]);
	// dp[t-3] = min (abs(arr[t-1]-arr[t-3]);)+
	// for(int i =t-1;i>0;i++)
	FORD(i,t-3,0)
	{
dp[i] = min(abs(arr[i]-arr[i+1])+dp[i+1],abs(arr[i]-arr[i+2])+dp[i+2]);
	}}
cout<<dp[0];
    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
edges = [set() for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a - 1].add(b - 1)
    edges[b - 1].add(a - 1)
hei = set()
cur = 0
paths = []
f = False
while True:
    hei.add(cur + 1)
    paths.append(cur + 1)
    for i in edges[cur]:
        if not (i + 1 in hei):
            cur = i
            break
    else:
        break
cur = 0
paths = list(reversed(paths[1:]))
f = False
while True:
    hei.add(cur + 1)
    paths.append(cur + 1)
    for i in edges[cur]:
        if not (i + 1 in hei):
            cur = i
            break
    else:
        break
print(len(paths))
print(*paths)

Measured memory_bytes: 49896
# nCrの左項には nn しか来ない場合、1!～(n-1)!は保持しなくてよいバージョン 
def prepare(n, MOD):
  # n! の計算
  f = 1
  for m in range(1, n+1):
    f *= m
    f %= MOD
  fn = f
  # n!^-1 の計算
  inv = pow(f, MOD-2, MOD)
  # n!^-1 - 1!^-1 の計算
  invs = [1]*(n+1)
  invs[n] = inv
  for m in range(n, 1, -1):
    inv *= m
    inv %= MOD
    invs[m-1] = inv
    
  return fn, invs

MOD = 10**9+7
x, y = map(int, input().split())

d, m = divmod(x+y, 3)
if m != 0 or x/y > 2 or y/x > 2:
  print(0)
  exit()
c = abs(d-x)
f, invs = prepare(d, MOD)
ans = f * invs[c] * invs[d-c] % MOD
print(ans)

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: isize = iterator.next().unwrap().parse().unwrap();
    let g: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();
    let n: isize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for ri in 0..=3000 {
        for gi in 0..=3000 {
            let rest = n - ri * r - gi * g;
            if rest >= 0 && rest % b == 0 {
                ans += 1;
            }
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2116
#include<stdio.h>
int main (){
	int H,A,yeet=0;
		scanf("%d",&H);
		scanf("%d",&A);
	while(H > 0)
	{
	H = H - A;
	yeet++;
	
		}
	printf("%d\n",yeet);
	
	return 0;
}

Measured memory_bytes: 1728
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0){
        int nn=n/2;
        int dame=0;
        for(int i=0;i<nn;i++){
            if(s[i]==s[i+nn]){

            }
            else{
                dame++;
            }

        }
        if(dame==0){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
n = gets.strip.to_i
if n > 0 && n < 10
  puts 'Yes'
  exit
end

flag = 'No'
(2..9).each do |i|
  if n % i == 0 && (2..9).include?(n / i)
    flag = 'Yes'
    break
  end
end

puts flag

Measured memory_bytes: 1788
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fineam> //http://www.cplusplus.com/reference/fineam/fineam/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifineam inFile("input.txt");
std::ofineam outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    int n;
    cin >> n;

    vector<pairi> arr(n);

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].first;
        arr[i].second = i + 1;
    }
    sort(arr.begin(), arr.end(), [](pairi &a, pairi &b) { return (a.first < b.first); });
    for (int i = 0; i < n; i++)
    {
        cout << arr[i].second << " ";
    }
}

Measured memory_bytes: 1664
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

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

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 2e5 + 5;
 
int n;
int m;
int a[maxn];
bool have[maxn];


void exec()
{
    read(n);
    read(m);
    have[1] = true;
    for (int i = 1; i <= n; ++ i) {
        a[i] = 1;
    }
    for (int i = 1; i <= m; ++ i) {
        int u, v;
        read(u), read(v);
        ++ a[v];
        if (have[u]) have[v] = true;
        if (!-- a[u]) have[u] = false;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++ i) if (have[i]) ++ ans;
    write(ans);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 768
#include<iostream>
#include<vector>
using namespace std;
 
void dfs(vector<vector<int> > &g, vector<bool> &used, int v = 0){
  used[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    if(used[g[v][i]] == true)continue;
    dfs(g, used, g[v][i]);
  }
}
 
int main(){
  int n, m, k;
  std::cin >> n >> m;
  vector<vector<int> > l(n + m);
  for (int i = 0; i < n; i++) {
    std::cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      std::cin >> tmp;
      l[i].emplace_back(tmp - 1 + n);
      l[tmp - 1 + n].emplace_back(i);
    }
  }
  vector<bool> used(n + m, false);
  dfs(l, used);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    flag &= used[i];
  }
  std::cout << ((flag == true)?"YES":"NO") << std::endl;
  return 0;
}

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

int n, m;
int a, b;

signed main()
{
	cin >> n;
	cin >> m;



	int ans = m;
	rep(i,n) {
		cin >> a >> b;
		m += a - b;
		ans = max(ans, m);
		if (m < 0) {
			cout << 0 << endl;
			return 0;
 		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main() {
	int x[3000],y[3000];
	int i=0,j,work=0;
	while (1) {
		scanf("%d %d", &x[i],&y[i]);
		if (x[i] == 0 && y[i] == 0) break;
		if (x[i] > y[i]) {
			work = x[i];
			x[i] = y[i];
			y[i] = work;
		}
		i++;
	}
	for (j = 0;j < i;j++) {
		printf("%d %d\n",x[j],y[j]);
	}
	return 0;
}


Measured memory_bytes: 1980
from itertools import accumulate


def resolve():
    N, K = map(int, input().split())
    S = input()

    # even:1
    # odd:0
    # 1-0-1-0-1 の配列にする. 両端は1にする
    L = []
    pre = "1"
    cnt = 0
    for i in range(N):
        if pre == S[i]:
            cnt += 1
        else:
            L.append(cnt)
            cnt = 1
        pre = S[i]
    L.append(cnt)
    # 最後が0で終わっていたら、仮の1を付け足す。(値が0なので影響ない)
    if pre == "0":
        L.append(0)

    # 1-0-1-0-1の配列を作成し、K＝2だとする。
    # 0を2個含めた個数は, 1＝3、0＝2の長さが作成できる
    length = 2 * K + 1

    # 0をすべて変換できる
    if len(L) <= length:
        return print(N)

    acc = [0] + list(accumulate(L))
    ans = 0
    for i in range(0, len(L) - length + 1, 2):
        ans = max(ans, acc[i + length] - acc[i])

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 14732
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	string s,t;
	cin>>s>>t;
	int ans=0;
	REP(i,SZ(s)) if(s[i]==t[i]) ans++;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
H, W, M = map(int, input().split())

Ms = set([])

lstH = [0]*(H+1)
lstW = [0]*(W+1)

for _ in range(M):
  h, w =  map(int, input().split())
  lstH[h] += 1
  lstW[w] += 1
  Ms.add((h,w))

sH = set([])
sW = set([])
mH = max(lstH)
mW = max(lstW)

for i in range(1,H+1):
  if lstH[i] == mH:
    sH.add(i)
for i in range(1,W+1):
  if lstW[i] == mW:
    sW.add(i)
    
if len(sH)*len(sW) > 3* 10**5:
  print(mH+mW)
else:
  lst = set([])
  for h in sH:
    for w in sW:
      lst.add((h,w))
  for l in lst:
    if l not in Ms:
      print(mH+mW)
      exit()
  print(mH+mW-1)

Measured memory_bytes: 180484
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B, M; cin >> A >> B >> M;
    vec a(A); cin >> a;
    vec b(B); cin >> b;

    int ma = INF, mb = INF;
    REP(i, A) Min(ma, a[i]);
    REP(i, B) Min(mb, b[i]);
    int ans = ma + mb;
    REP(i, M){
        int x, y, c; cin >> x >> y >> c;
        x--; y--;
        Min(ans, a[x] + b[y] - c);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

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

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  int N;

  cin >> N;

  vector<pair<ll, ll>> vp(N);

  REP(i, 0, N){
    cin >> vp[i].first >> vp[i].second;
  }

  ll a, b;
  a = vp[0].first;
  b = vp[0].second;

  REP(i, 1, N){
    ll x, y;

    // x = (ll)ceil((double)a / (double)vp[i].first);
    // y = (ll)ceil((double)b / (double)vp[i].second);

    x = a / vp[i].first;
    if(a % vp[i].first != 0){
      x++;
    }

    y = b / vp[i].second;
    if(b % vp[i].second != 0){
      y++;
    }

    if(x < y){
      x = y;
    }
    a = vp[i].first * x;
    b = vp[i].second * x;
  }
  ll ans = a + b;

  cout << ans << endl;

  return 0;
}


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

int n, x;
int p[110], cnt[110];

inline void solve(int T) {
    cin >> x >> n;
    memset(cnt, 0, sizeof(cnt));
    rep(i, 1, n) cin >> p[i], cnt[p[i]] = 1;
    for(int i = 0; x - i >= 0 && x + i <= 101; i++) {
        if(x - i >= 0 && !cnt[x - i]) {
            cout << x - i << endl;
            return;
        }
        if(x - i <= 101 && !cnt[x + i]) {
            cout << x + i << endl;
            return;
        }
    }

}   
int main()
{
//     ios_base::sync_with_stdio(0);
//     cin.tie(0);
//     cout.tie(0);
 
    // freopen("in.txt", "r", stdin);
    // freopen("out2.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        "\n"
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define um           unordered_map<ll,ll>
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
#define int ll 
using namespace std;
int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

int n;
cin>>n;
n=n%10;
if(n==1||n==0||n==8||n==6)
cout<<"pon"<<endl;
else if(n==2||n==4||n==5||n==7||n==9)
cout<<"hon"<<endl;
else
cout<<"bon";
return 0;
}

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

using namespace std;

int main()
{

  char arr[105][105];

  int flagH[105],flagW[105];
    int h,w;

    cin>>h>>w;

    int i,j;

     for(i=0;i<h;i++){

        for(j=0;j<w;j++){

            cin>>arr[i][j];
        }

     } /// end of scan

    int cnt1 =0 , cnt2 =0;

     for(i=0;i<h;i++){

        for(j=0;j<w;j++){

        if(arr[i][j]=='.')cnt1++;

        }

        if(cnt1 == w){
            flagH[i]=1;
        }
        else{
            flagH[i]=0;
        }
              cnt1 =0;
     }

       




     for(i=0;i<w;i++){

        for(j=0;j<h;j++){

        if(arr[j][i]=='.')cnt2++;

        }

        if(cnt2 == h){
            flagW[i]=1;
        }
        else{
            flagW[i]=0;
        }

            cnt2 =0;
     }

       


     for(i=0;i<h;i++){

        for(j=0;j<w;j++){

          if(flagH[i]==0){

           if(flagW[j]==0){
            printf("%c",arr[i][j]);
          }
          }

        }

        if(flagH[i]==0){
          printf("\n");
        }

     }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int N;
    int k;
    cin >> N;
    k = (int)sqrt(2*N)+1;
    if(k*(k-1) == 2*N){
        cout << "Yes" << endl;
        cout << k << endl;
        for(int i = 0; i < k; i++){
            cout << k-1 << ' ';
            for(int j = 0; j < k-1; j++){
                if(i+j <= k-2){
                    cout << ((k-1 + k-1-i+1)*i)/2 + j+1 << ' ';
                }else{
                    cout << i+(k-1 + j)*(k-1-j-1)/2 << ' ';
                }
            }
            cout << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
{-
ITP1_5-A
Structured Program I - Print a Rectangle
Time Limit : 1 sec, Memory Limit : 65536 KB
????????¢?????????

??????H cm ?????? W cm ???????????¢?????????????????°?????????????????????????????????

1 cm ?? 1cm ???????????¢??? '#'??§??¨????????????
Input

??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
Output

????????????????????????????????????H ?? W ?????? '#' ??§????????????????????¢???????????????????????????

?????????????????????????????????????????????????????\??????????????????
Constraints

H, W ??? 300
Sample Input

3 4
5 6
2 2
0 0

Sample Output

####
####
####

######
######
######
######
######

##
##

-}
import Data.List.Split
import Text.Printf

main = do
  s <- getLine
  let [h,w] = map (\x-> read x::Int) $ splitOn " " s
  if h==0 && w==0 then return()
    else do
      mapM_ (\x->putStrLn $ aux w) [1..h]
      printf "\n"
      main

aux :: Int -> String
aux w = foldr (\x acc-> "#" ++ acc) "" [1..w]

Measured memory_bytes: 4148
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn main() {
    let mut v:Vec<u64> = procon_read();
    if v[0]/v[2] < v[1] {
        println!("Yes");
    }else if v[0]/v[2] == v[1] && v[0]%v[2] == 0 {
        println!("Yes");
    }else {
        println!("No");
    }
}

Measured memory_bytes: 2116
-- | Main entry point to the application.
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace

rInt :: String -> Int
rInt str = read str :: Int

-- | The main entry point.
main :: IO ()
main = do
    [n] <- (map rInt . words) <$> getLine
    putStrLn $ show (n * n * n)

Measured memory_bytes: 3564
n,m,c = map(int,input().split())
b_lis = list(map(int,input().split()))
num = 0
for i in range(n):
    to = 0
    a_lis = list(map(int,input().split()))  
    for s in range(m):
        to += a_lis[s]*b_lis[s]
        if s == m-1:
            to += c
            if to>0:
                num += 1
print(num)

Measured memory_bytes: 3060
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int count = 0;
		int sum = 0;
		int sum2 = 0;
		while(stdIn.hasNext()) {
			count++;
			String[] in = stdIn.next().split(",");
			int a = Integer.parseInt(in[0]);
			int b = Integer.parseInt(in[1]);
			sum += a*b;
			sum2 += b;
		}
		System.out.println(sum);
		double ave = sum2/(double)count*10;
		if(ave%10 >= 5) {
			ave += 10-ave%10;
		}
		else {
			ave -= (ave*10)%10;
		}
		ave /=10;
		
		System.out.println((int)ave);
	}
}

Measured memory_bytes: 17116
use std::cmp::{Eq, Ord, Ordering, Reverse};
use std::collections::BinaryHeap;

use proconio::input;

struct Constant {
    c: Vec<i32>,
    s: Vec<Vec<i32>>,
}

#[derive(Eq, Clone)]
struct State {
    cur_seq: Vec<usize>,
    sat: i32,
}

impl State {
    fn calc(&mut self, c: &Constant) {
        let mut last = vec![0; 26];
        self.sat = 0;

        for i in 0..self.cur_seq.len() {
            last[self.cur_seq[i]] = i + 1;
            let mut diff = c.s[i][self.cur_seq[i]];
            for k in 0..26 {
                diff -= c.c[k] * ((i + 1 - last[k] as usize) as i32);
            }

            self.sat += diff;
        }
    }

    fn change(&mut self, c: &Constant, d: usize, q: usize) {
        self.sat -= c.s[d][self.cur_seq[d]];
        self.sat += c.s[d][q];

        let mut last = vec![0; 26];
        for i in 0..self.cur_seq.len() {
            last[self.cur_seq[i]] = (i + 1) as i32;
            let j = self.cur_seq[d];
            self.sat += c.c[j] * ((i + 1 - last[j] as usize) as i32);
            self.sat += c.c[q] * ((i + 1 - last[q] as usize) as i32);
        }

        last = vec![0; 26];
        let p = self.cur_seq[d];
        self.cur_seq[d] = q;
        for i in 0..self.cur_seq.len() {
            last[self.cur_seq[i]] = (i + 1) as i32;

            self.sat -= c.c[p] * ((i + 1 - last[p] as usize) as i32);
            self.sat -= c.c[q] * ((i + 1 - last[q] as usize) as i32);
        }
    }
}

impl Ord for State {
    fn cmp(&self, other: &Self) -> Ordering {
        self.sat.cmp(&other.sat)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.sat.cmp(&other.sat))
    }
}

impl PartialEq for State {
    fn eq(&self, other: &Self) -> bool {
        self.sat == other.sat
    }
}

fn main() {
    input! {
        d: usize,
        c: [i32;26],
        s: [[i32;26]; d],
    }

    let c = Constant { c, s };

    let state = State {
        cur_seq: vec![],
        sat: 0,
    };

    let mut heap = BinaryHeap::new();
    heap.push(Reverse(state));

    for i in 0..d {
        // if i % 10 == 0 {
        //     dbg!(i, heap.len());
        // }
        let mut new_heap = BinaryHeap::new();

        for state in heap.iter() {
            let mut new_state = state.0.clone();
            new_state.cur_seq.push(0);
            new_state.calc(&c);
            new_heap.push(Reverse(new_state.clone()));
            if new_heap.len() > 20 {
                new_heap.pop();
            }
            for j in 1..26 {
                new_state.change(&c, i, j);
                if new_state.sat <= new_heap.peek().unwrap().0.sat {
                    continue;
                }
                new_heap.push(Reverse(new_state.clone()));
                if new_heap.len() > 20 {
                    new_heap.pop();
                }
            }
        }
        // dbg!(i, heap.len(), new_heap.len());
        heap = new_heap;
    }

    while heap.len() > 1 {
        heap.pop();
    }

    let answer = heap.pop().unwrap().0;
    // dbg!(answer.sat);
    for i in answer.cur_seq {
        println!("{}", i + 1);
    }
}


Measured memory_bytes: 2748
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, syurui, cnt, a[100005];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	syurui = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1])cnt++;
		else syurui++;
	}
	if (cnt % 2)cout << syurui - 1 << endl;
	else cout << syurui << endl;
	endre;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x;cin>>x;
  cout<<yesno(x>=30)<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int MOD = 1e9 + 7;

void solve()
{
    ll n;
    cin >> n;
    ll ans = (n + 1) * n / 2;
    P(ans - n);
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long LL;
int main(){
    LL n;
    LL ans=0;
    scanf("%lld",&n);
    if(n<3){
        printf("0\n");
        return 0;
    }
    for(LL i=1;i*i<n;i++){
        if(n%i==0){
            if(n/i>i+1)
            ans+=(n/i-1);
        }
    }
    printf("%lld\n",ans );
}



Measured memory_bytes: 128
n,a,b=map(int,input().split())
s=list(input())
count=0
cnt=0
for i in range(n):
  if(cnt>=a+b):
    print("No")
  else:
    if(s[i]=="a"):
      print("Yes")
      cnt+=1
    elif(s[i]=="b"):
      if(count<b):
        print("Yes")
        count+=1
        cnt+=1
      else:
        print("No")
    else:
      print("No")

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    long table[n + 1][13];
    table[0][0] = 1;
    for (int l = 1; l < 13; l++) {
        table[0][l] = 0;
    }
    for (int i = 0; i < n; i++) {
        char c = s[i];
        if (c == '?') {
            for (int l = 0; l < 13; l++) {
                table[i + 1][l] = 0;
            }
            for (int j = 0; j < 13; j++) {
                for (int l = 0; l < 10; l++) {
                    int k = (10 * j + l) % 13;
                    table[i + 1][k] += table[i][j];
                    table[i + 1][k] %= MOD;
                }
            }
        } else {
            int l = c - '0';
            for (int j = 0; j < 13; j++) {
                int k = (10 * j + l) % 13;
                table[i + 1][k] = table[i][j];
            }
        }
    }
    cout << table[n][5] << endl;
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll n, A[4001], memo[4001][4001] = {}, ans = 0;
bool calced[2001][2001][2];
ll solve(int s, int e, bool JOI){
	if(memo[s][e]) return memo[s][e];
	if(s == e){
		if(JOI){
			return memo[s][e]=A[s];
		} else{
			return memo[s][e]=0;
		}
	}
	
	if(JOI){
		return memo[s][e]=max(solve(s + 1, e, 0) + A[s], solve(s,  e - 1, 0) + A[e]);
	} else{
		if(A[s] > A[e]){
			return memo[s][e]=solve(s + 1, e, 1);
		} else{
			return memo[s][e]=solve(s, e - 1, 1);
		}
	}
}

int main() {
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> A[i];
		A[i + n] = A[i];
	}
	
	for(int i = 0; i < n; i++){
		ans = max(ans, solve(i, i + n - 1, 1));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 126368
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{ 
	speed
	int n,k;cin>>n>>k;
	std::vector<int> inp(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];
	}
	int pres=0;
	for(int i=0;i<k;++i){pres+=inp[i];}
	int tot=pres;
	int r=k,l=0;
	for(int i=k;i<n;++i)
	{
		pres-=inp[l];
		pres+=inp[r];
		tot=max(tot,pres);
		++l;++r;
	}
	printf("%.10lf",(tot+k)/(2*1.0));
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int cnt_a = 0, cnt_b = 0, cnt_c = 0;
  string s;
  cin >> s;
  for (auto&& c : s) {
    if (c == 'a') {
      cnt_a++;
    } else if (c == 'b') {
      cnt_b++;
    } else {
      cnt_c++;
    }
  }
  if (max({cnt_a, cnt_b, cnt_c}) - min({cnt_a, cnt_b, cnt_c}) < 2) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a==b&&c==d&&a!=c || a==c&&b==d&&a!=b || a==d&&b==c&&a!=b){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

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

    if((A<=C&&C<=B)||(B<=C&&C<=A)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int R;

signed main() {

    in(R);
    out(3*R*R);

    return 0;
}


Measured memory_bytes: 256
@pow2 = (0..30).to_a.map do |i|
  2**i
end

def t(n)
  @pow2.reverse.each do |p|
    return @pow2.index(p) if n.to_f/p.to_f == (n/p).to_i
  end
end
def solve(list)
  s = 0
  l = list.map do |n|
    s += t(n.to_i)
  end
  puts s
end

def main
  gets
  list = gets.chomp.split(" ")
  solve(list)
end

main

Measured memory_bytes: 5244