akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    lint A[N];
    cins(A, A + N);
    lint sum_top[N], sum_back[N];
    sum_top[0] = A[0];
    for(int i = 1; i < N; i++){
        sum_top[i] = A[i] - sum_top[i - 1];
    }
    sum_back[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--){
        sum_back[i] = A[i] - sum_back[i + 1];
    }
    lint ans[N];
    ans[0] = sum_back[0];
    for(int i = 1; i < N; i++){
        ans[i] = sum_top[i - 1] + sum_back[i];
    }
    array_output(ans, ans + N);
}

Measured memory_bytes: 5632
n,w_max = map(int, input().split( ))
v = []
w = []
for _ in range(n):
    v_in,w_in = map(int, input().split( ))
    v.append(v_in)
    w.append(w_in)
#print(*v)
#print(*w)
v_max = sum(v)
#print(n,w_max,v_max)
lrg =100000000000001
#DP = [[lrg]*n]*(v_max*2)
DP = [lrg]*(v_max*2)
DP[0] = 0
#インデックスがずれててたりない
#DP[0] = [0]*n

#for u in range(v_max):
#    for i in range(n):
#        DP[u][i] = min(DP[u][i], DP[u-v[i]][i-1] + w[i])
#2次元の必要なし？
for i in range(n):
    for u in range(v_max,0,-1):#逆行必須
         DP[u] = min(DP[u], DP[u-v[i]] + w[i])



ans = []
for u in range(v_max+1):
    if DP[u] <= w_max:
        ans.append(u)
print(max(ans))



Measured memory_bytes: 5964
N,K=map(int,input().split());s=input();L=2*K+1;X=[0]*(2-int(s[0]))+[i+1 for i in range(N-1) if s[i]!=s[i+1]]+[N]*L;print(max([X[i+L]-X[i]for i in range(0,len(X)-L,2)]))

Measured memory_bytes: 9356
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int main()
{
    speed;
    ll t,i,j,a,b,x,y,e=0,ans=0,sum=0;
    cin>>a;
    cout<<(a+(a*a)+(a*a*a))<<endl;
}

Measured memory_bytes: 5952
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <cstdlib>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1
#define R 1000000007

#define MAXH 401
string s[MAXH];
int h, w;
int marked[MAXH][MAXH];

typedef pair<long,long> t;

t label(int col, int x, int y, int lab) {
  if (s[x][y] != (col==0 ? '#' : '.') || marked[x][y]>0)
    return t(0,0);
  marked[x][y] = lab;
  t difs[4] = { t(-1,0), t(1,0), t(0,-1), t(0,1) };
  t mysums(0,0);
  forr(i,0,3) {
    int xx = x + difs[i].first;
    int yy = y + difs[i].second;
    if (0<=xx && xx<h && 0<=yy && yy<w) {
      t tsums = label(1-col, xx, yy, lab);
      mysums.first += tsums.first;
      mysums.second += tsums.second;
    }
  }
  if (col==0) mysums.first++;
  else        mysums.second++;
  return mysums;
}

int main() {
  cin >> h >> w;
  forr(i,0,h-1) {
    cin >> s[i];
  }
  vector<t> sums;
  sums.push_back(t(0,0));
  forr(i,0,h-1)
  forr(j,0,w-1) marked[i][j] = 0;

  int lab = 1;
  forr(i,0,h-1)
  forr(j,0,w-1)
    if (s[i][j] == '#' && marked[i][j] == 0) {
      sums.push_back(label(0,i,j,lab));
      lab++;
    }
  long psum = 0;
  forr(i,0,sums.size()-1)
    psum += sums[i].first * sums[i].second;
  cout << psum;

}


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

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			
			int[] price = new int[n];
			for(int i = 0 ; i < n; i++) {
				price[i] = sc.nextInt();
			}
			
			Arrays.sort(price);
			
			int sum = 0;
			for(int i = 0; i < k; i++) {
				sum += price[i];
			}
			
			System.out.println(sum);


		}catch(Exception e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 38760
x,y=gets.split.map &:to_i
sum=[]
mai=[]
if (x-y).abs>=4038
  puts 0
else
  for i in x..y
    sum << i%2019
  end
  sum.combination(2).each{ |i,j|
    mai << (i* j)%2019
   }
end
puts mai.min


Measured memory_bytes: 30288
#include<iostream>
#include <vector>
#include <math.h>
using namespace std;

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

    vector<int> a(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }

    vector<int> ans;
    vector<int> b(N+1, 0);

    for (int i = N; 1 <= i; --i) {
        int rest = 0;
        for (int j = 2; i * j <= N; ++j) {
            rest += b[i * j];
        }
        b[i] = (a[i] + rest) % 2;
        if (b[i]) {
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
        cout << *it << endl;
    }

    return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    LL N, K;
    cin >> N >> K;
    vector<LL>  a(N), f(N);
    for(int i = 0;i < N;i++)    cin >> a[i];
    for(int i = 0;i < N;i++)    cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    vector<P>   pp(N);
    for(int i = 0;i < N;i++){
        pp[i] = P(a[i]*f[i], f[i]);
    }
    LL cnt2 = 0;
    for(int i = 0;i < N;i++)    cnt2 += a[i];
    sort(pp.begin(), pp.end());
    vector<LL>  p2(N);
    for(int i = 0;i < N;i++)    p2[i] = pp[i].first;
    LL l = 0, r = 1e12;
    while(l+1 < r){
        LL mm = (l+r)/2;
        auto itr = lower_bound(p2.begin(), p2.end(), mm);
        int id = itr-p2.begin();
        if(itr == p2.end()){
            r = mm;
        }else{
            LL cnt = 0;
            for(int i = id;i < N;i++){
                cnt += (p2[i]-mm+pp[i].second-1)/(pp[i].second);
            }
            if(cnt <= K)    r = mm;
            else    l = mm;
        }
    }
    if(cnt2 <= K)   cout << 0 << endl;
    else    cout << r << endl;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << b + ((b % a == 0) ? a : -a) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, abs(b - c) - a) << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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


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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int dx=x2-x1, dy=y2-y1, x3,y3,x4,y4;
  x3 = x2-dy;
  y3 = y2+dx;
  x4 = x3-dx;
  y4 = y3-dy;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4;

  return 0;
}


Measured memory_bytes: 256
K = gets.chomp.to_i
A, B = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

def main
A.upto(B).each do |i|
  if (i%K == 0)
    print "OK\n"
    return;
  end
end

print "NG\n"
end

main




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

int main() {

    int N;
    string S;
    cin >> N >> S;

    vector<int> data(N, 0);
    int temp = 0;
    for(int i=0; i<N; i++) {
        if(S.substr(i,1) == "(") {
            temp++;
            data[i] = temp;
        }
        else {
            temp--;
            data[i] = temp;
        }
    }

    int min = *min_element(data.begin(), data.end());
//    cout << min << endl;
    for(int i=0; i<-min; i++) {
        S = "(" + S;
    }

//    cout << S << endl;


    temp = 0;
    vector<int> data2(S.size(), 0);
    for(int i=0; i<S.size(); i++) {
        if(S.substr(i,1) == "(") {
            temp++;
            data2[i] = temp;
        }
        else {
            temp--;
            data2[i] = temp;
        }
//        cout << temp << endl;
    }
//    cout << data2[S.size()-1] << endl;
    int size = data2[S.size()-1];
    for(int i=0; i<size; i++) {
        S += ")";
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
# D
N, M, Q = map(int, input().split())
dat_mat = [[0]*N for _ in range(N)]

for _ in range(M):
    L, R = map(int, input().split())
    dat_mat[L-1][R-1] += 1
    
dat_mat_left = [[0]*N for _ in range(N)]
dat_mat_res = [[0]*N for _ in range(N)]
for L in range(N):
    c = 0
    for R in range(L, N):
        c += dat_mat[L][R]
        dat_mat_left[L][R] = c
        
for R in range(N-1, -1, -1):
    c = 0
    for L in range(R, -1, -1):
        c += dat_mat_left[L][R]
        dat_mat_res[L][R] = c
        
res_list = [0]*Q
for q in range(Q):
    L, R = map(int, input().split())
    res_list[q] = dat_mat_res[L-1][R-1]

for a in res_list:
    print(a)

Measured memory_bytes: 16316
#import sys
#input = sys.stdin.readline
def main():
    a, b = map( int, input().split())
    if a > b:
        a, b = b, a
    if (b-a)%2 == 1:
        print("IMPOSSIBLE")
    else:
        print(a + (b-a)//2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        aa: [usize; n],
    }

    let mut set = HashSet::new();

    for a in aa {
        if set.contains(&a) {
            set.remove(&a);
        } else {
            set.insert(a);
        }
    }

    println!("{}", set.len());
}


Measured memory_bytes: 5556
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,k;
    string s,s2;
    cin >> n >> k >> s;
    ll ans=0,ans1=0,k1;
    s2=s;
    k1=k;
    for (ll i=1;i<n;i++){
        if (s[i-1]==s[i]){
            ans++;
        }
        if (k and s[i]=='L' and s[i-1]=='R'){
            ll j=i;
            while(j<n and s[j]=='L'){
                s[j]='R';
                j++;
            }
            k--;
            ans++;
        }
    }
    if (k and s[0]=='L'){
        ll i=0;
        while(i<n and s[i]=='L'){
            s[i]='R';
            i++;
        }
        if (i<n)ans++;
        k--;
    }
    if (k and s[n-1]=='R'){
        ll i=n-1;
        while(i>=0 and s[i]=='R'){
            s[i]='L';
            i--;
        }
        if (i>=0)ans++;
    }
    for (ll i=n-2;i>=0;i--){
        if (s2[i+1]==s2[i]){
            ans1++;
        }
        if (k1 and s2[i]=='R' and s2[i+1]=='L'){
            ll j=i;
            while(j>=0 and s2[j]=='R'){
                s2[j]='L';
                j--;
            }
            k1--;
            ans1++;
        }
    }
    if (k1 and s2[0]=='L'){
        ll i=0;
        while(i<n and s2[i]=='L'){
            s2[i]='R';
            i++;
        }
        if (i<n)ans1++;
        k1--;
    }
    if (k1 and s2[n-1]=='R'){
        ll i=n-1;
        while(i>=0 and s2[i]=='R'){
            s2[i]='L';
            i--;
        }
        if (i>=0)ans1++;
    }
    cout << max(ans,ans1) << endl;
    return 0;
}


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;


void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

bool compare(int &a, int &b){
    return a>b;
}

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n))+1;
}

ull pow (ll a, ll b);




/*


*/

ll BN ();
map<int ,int > mp;
int main()
{
    JULEE_DO_THE_THING;
    //freopen("test cases\\.txt", "r", stdin) ;
    int a, b, c; cin>>a>>b>>c;
    map<int, bool> mp;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    if(mp.size()==2)cout<<"Yes";
    else cout<<"No";
    return 0;
}


ll BN (){
    ll low = 0;
    ll up = 0;
    ll ans = 0;
    while(low<=up){
        ll mid = ((low+ up)/2);
        if(mid) {
            ans = mid;
            low = mid+1;
        }else up = mid-1;
    }
    return ans;
}


ull pow (ll a, ll b){
    ull res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
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;
}

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

    vector<int> a(3);
    for (auto &i : a) {
        cin >> i;
    }
    SORT(a);
    std::cout << a[0] + a[1] << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<char>::iterator it;
int main(){
    deque<char> x;
    string in;
    cin >> in;
    for(int i= 0;i < in.size();i++){
        x.push_back(in[i]);
    }
    int q, q1, t1;char x1;
    bool sum = 0;
    cin >> q;
    while(q--){
        cin >> q1;
        if(q1 == 1){
            sum = !sum;
        }
        else{
            cin >> t1 >> x1;
            if(!sum){
                if(t1 == 1){
                    x.push_front(x1);
                }
                else{
                    x.push_back(x1);
                }
            }
            else{
                if(t1 == 1){
                    x.push_back(x1);
                }
                else{
                    x.push_front(x1);
                }
            }
        }
    }
    if(sum%2== 0){
        for(it = x.begin();it!= x.end();it++){
            cout << *it;
        }
        return 0;
    }
    for(it = x.end()-1;it!= x.begin()-1;it--){
            cout << *it;
        }
}
/*
a
4
2 1 p
1
2 2 c
1

*/


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

int main() {
  int64_t N;
  cin>>N;
  string S;
  while(N>0){
    char Q='a';
    if(N%26!=0){
      Q+=(N%26-1);
    }
    else{
      Q='z';
      N--;
    }
    S.push_back(Q);
    N/=26;
  }
  reverse(S.begin(),S.end());
  cout<<S<<endl;
    
}


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

int main() {
  int N, sum=0, light=1;
  cin >> N;
  
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  
  while (light != 2) {
    sum++;
    light = A.at(light-1);
    
    if (sum > N+1) {
      cout << -1 << endl;
      break;
    }
  }
  
  
  if (light == 2) {
    cout << sum << endl;
  }
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
int main(){
    ll n;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<"Alice"<<endl;
    }
    else{
        cout<<"Borys"<<endl;
    }
}

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

int main(){
  int d[10]={0,0,1,2,0,-1,2,0,1,2},cnt,ans,c;
  string s;
  while(1){
    cin>>s;
    if(s=="#") break;
    ans=(1e9);
    for(int i=0;i<2;i++){
      c=i;
      cnt=0;
      for(int j=1;j<s.size();j++){
	int k=s[j-1]-'0',t=s[j]-'0';
	if((!c&&d[k]>d[t])||(c&&d[k]<d[t])) cnt++;
	else c=!c;
      }
      ans=min(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXN 1001024
#define INF 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
//素数列挙
ll prime[MAXN] ;//segment_sieve [a,b)
bool is_prime[MAXN];
int sieve(int n){
	int res = 0;
	fill(is_prime,is_prime+MAXN,true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2;i<=n;i++){
		if(!is_prime[i])continue;
		prime[res++] = i;
		for(int j = 2*i;j<=n;j+=i)is_prime[j] = false;
	}
	return res;	
}
bool is_prime_ab[MAXN];
ll segment_sieve(ll a,ll b){
	fill(is_prime,is_prime+MAXN,true);
	fill(is_prime_ab,is_prime_ab+MAXN,true);
	for(int i=2;i*i <= b-1 ;i++){
		if(!is_prime[i]) continue;
		for(ll j = 2*i;j*j<=b-1;j+=i)is_prime[j] = false;
		for(ll j = a-a%i;j<b;j += i){
			if(j< a) continue;
			if(is_prime_ab[j-a]) is_prime_ab[j-a] = false;
		}
	}
	ll res = 0;
	for(ll i = a;i< b ;i++ )if(is_prime_ab[i-a] ) prime[res++] = i;
	return res;
}

bool is_primef(ll n){
	if(n==1) return false;
	for(ll i=2;i*i<=n;i++)
		if(n%i==0)return false;
	return true;
}

vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1;i*i<=n;i++){
		if(n%i != 0) continue;
		res.push_back(i);
		if(n/i== i)continue;
		res.push_back(n/i);
	}
	return res;
}
map<ll,ll> prime_factors(ll n){
	map<ll,ll> res;
	if(n<=1){
		res[n] = 1;
		return res;
	}
	
	//for(int i=2,_n = n;i*i<=_n;i++){
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n /= i;
		}
	}
	if(n!=1)res[n] = 1;
	return res;
}

//1からnまででnと互いにそなものの数
ll euler_phi(ll n){
	ll cnt = n;
	map<ll,ll> res = prime_factors(n);
	for(auto it = res.begin(),end = res.end();it!=end;it++){
		cnt = cnt/it->first*(it->first-1);
	}
	return cnt;
}
ll pow(ll n,ll m){
	vector<ll> a(33);
	a[0] = n;
	for(int i=1;i<32;i++){
	a[i] = (a[i-1]*a[i-1])%INF;
	}
	ll res = 1;
	for(int i=0;i<32;i++){
	if( ( m&(1<<i) ) ){
		res = (res*a[i])%INF;
		}
	}
	return res;
}

int main(){
	ll n,m;
	cin>>n>>m;
	cout<<pow(n,m)<<endl;
	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int N,X,temp;
int x[100005];
int ans;

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

int main(){
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> temp;
        x[i] = abs(temp-X);
        ans = gcd(ans,x[i]);
    }
    
    cout << ans <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++) b[i] = a[i];
  sort(b.begin(),b.end());
  for(i=0;i<n;i++){
    if(a[i]!=b[n-1]) cout << b[n-1] << "\n";
    else cout << b[n-2] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3200
#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;

//struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long int
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(vv,it) for(auto &it : vv)
#define prep(vv,it) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/

int arr[10000005];
void call(int n)
{
    for (int i = 1; i < n + 2; i++)
        for (int j = i; j < n + 2; j += i)
            arr[j]++;
}

signed main()
{
    int n; cin >> n; call(n);
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += arr[i] * i;
    }
    cout << ans << endll;
}


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

const int MAX_N = 200005;

int n;

int arr[MAX_N];

int main() {
  int min, ans;
  std::cin >> n;
  ans = 0;
  min = n + 1;
  for (int i = 1; i <= n; ++i) {
    std::cin >> arr[i];
    if (arr[i] <= min) {
      min = arr[i];
      ++ans;
    }
  }
  std::cout << ans << "\n";
  return 0;
}


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

int main()
{
    string s,t,ans="";
    cin>>s>>t;

    int n = s.length() , m = t.length(),i,j;

    int dp[n+1][m+1];

    for(i=0;i<n;i++)
        for(j=0;j<=m;j++)
            dp[i][j]=0;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+2;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    ans = "";

    i=n;
    j=m;

    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}
int N;

bool judge(ll val) {
	char c;
#ifdef DEBUG
	if (val <= N && to_string(val) <= to_string(N) ||
			val > N && to_string(val) > to_string(N) ) {
		c = 'Y';
	} else {
		c = 'N';
	}
#else
	cout << "? " << val << el;
	fflush(stdout);
	cin >> c;
#endif
	return (c == 'Y');
}

int main() {
#ifdef DEBUG
	cin >> N;
#endif
	ll n = 1;
	ll big = 1000000000;
	ll L = 0;
	while (n <= big) {
		char c;
		if (!judge(n)) break;
		n *= 10;
		L++;
	}
	if (n <= big) {
		ll ng = n / 10, ok = n - 1;
		while (llabs(ng - ok) > 1) {
			ll m = (ng + ok) / 2;
			ll v = m * 10;
			if (judge(v)) ok = m;
			else ng = m;
		}
		cout << "! " << ok << el;
	} else {
		ll n = 2;
		while (!judge(n)) n *= 10;
		cout << "! " << n / 2 << el;
	}
	return (0);
}

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

int main(){
    string str;
    cin >> str;
    int i, m, b;
    while(str != "-"){
        cin >> m;
        for(i = 0; i < m; i++){
            cin >> b;
            str = str.substr(b, str.size() - b) + str.substr(0, b);
        }
        cout << str << endl;
        cin >> str;
    }
}



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

using namespace std;
int n,k;
vector<int> v;
void back(){
	int i = v.size();
	int j = v[i-1];
	if(i==k){
		v.pop_back();
		if(j!=1){
			v.push_back(j-1);
		}
	}else{
		v.pop_back();
		if(j!=1){
			v.push_back(j-1);
			while(v.size()!=k){
				v.push_back(n);
			}
		}
	}
}

int main(){
	cin >> n >> k;
	int i;
	if(n%2==0){
		cout << n/2 << " ";
		for(i=0;i<k-1;i++){
			cout << n << " ";
		}
	}else{
		for(i=0;i<k;i++){
			v.push_back(n/2+1);
		}
		
		for(i=0;i<k/2;i++){
			back();
		}
		
		for(i=0;i<v.size();i++){
			cout << v[i] << " ";
		}
	}
}
	

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n),diff;
    int sum=0;
    rep(i,0,n){
        cin>>v[i];
        if(i==0)diff.pb(abs(v[i]));
        else diff.pb(abs(v[i-1]-v[i]));
        sum+=diff[i];
        
    }
    sum+=abs(v[v.size()-1]);
    rep(i,0,n){
       if(i==0)cout<<sum-abs(v[i])-abs(v[i]-v[i+1])+abs(v[i+1])<<endl;
       else if(i==n-1) cout<<sum-abs(v[i-1]-v[i])-abs(v[n-1])+abs(v[n-2])<<endl;
       else cout<<sum-abs(v[i-1]-v[i])-abs(v[i]-v[i+1])+abs(v[i-1]-v[i+1])<<endl;
       
    }
   

    
    
    return 0;
}


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

int main() {
    int n,y;cin>>n>>y;
    for (int i=0;i<=n;i++) {
        int a=y-10000*i;
        int b=a-1000*(n-i);
        if (b%4000)
            continue;
        int j=b/4000;
        int k=n-i-j;
        if (0<=j&&0<=k) {
            cout<<i<<' '<<j<<' '<<k<<endl;
            return 0;
        }
    }
    cout<<"-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll N;

void build(ll cur_val, int state, ll &cnt) {
  if (N < cur_val) return;
  if (state == 0b111) cnt++;
  build(cur_val * 10 + 7, state | 0b001, cnt);
  build(cur_val * 10 + 5, state | 0b010, cnt);
  build(cur_val * 10 + 3, state | 0b100, cnt);
}

int main() {
  cin >> N;
  ll ans = 0;
  build(0, 0, ans);
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	char S[H][W];
	bool Sb[H][W];
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> S[i][j] ;
			if(S[i][j] == '#'){
				Sb[i][j] = true;
			}else{
				Sb[i][j] = false;
			}
		}
	}

	bool ans = true;

	for(int i = 0; i < H-1; i++){
		for(int j = 0; j < W-1; j++){
			if(S[i][j] == '#'){
				if(S[i+1][j] == '#'){
					Sb[i+1][j] = false;
				}
				if(S[i][j+1] == '#'){
					Sb[i][j+1] = false;
				}
			}
			if(Sb[i][j] && S[i+1][j] == '.' && S[i][j+1] == '.'){
					ans = false;
					break;
			}
		}
	}

	if(ans){
		for(int i = 0; i < W-1; i++){
			if(Sb[H-1][i] && S[H-1][i+1] == '.'){
				ans = false;
				break;
			}
			if(S[H-1][i] == '#')
				Sb[H-1][i+1] = false;
		}
	}

	if(ans){
		for(int i = 0; i < H-1; i++){
			if(Sb[i][W-1] && S[i+1][W-1] == '.'){
				ans = false;
				break;
			}
			if(S[i][W-1] == '#')
				Sb[i+1][W-1] = false;
		}
	}

	if(ans){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vector<string> s(n);
    rep(i,n){
        string t;cin >> t;
        sort(ALL(t));
        s[i] = t;
    }
    sort(ALL(s));
    ll ans = 0;
    int cnt = 0;
    for(int i=0;i<n-1;i++){
        if(s[i] == s[i+1]){
            cnt++;
        }else if(cnt!=0){
            ans += (cnt/2.0)*(cnt+1);
            cnt = 0;
        }
    }
    if(cnt!=0){
        ans += (cnt/2.0)*(cnt+1);
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

struct Point{ double x, y; };

int dis(Point a, Point b){
    return abs(a.x - b.x) + abs(a.y - b.y);
}

int main(){
    int n, inp[4], ans = INF;
    struct Point p[4];
    cin >> n;
    rep(i,4){
        cin >> inp[i];
        inp[i]--;
    }
    range(i,1,n + 1){
        rep(j,4){
            p[j].x = inp[j] % i;
            p[j].y = inp[j] / i;
        }
        ans = min(ans, dis(p[0], p[1]) + dis(p[2],p[3]) );
    }
    cout << ans << endl;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m) {
    return power(a, m - 2, m);
}
int32_t main() {
    nitin;
    int n;
    cin>>n;
    int sum=0;
    int ssum=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        sum=(sum+a)%mod;
        ssum=(ssum+a*a)%mod;
    }
    sum=(sum*sum)%mod;
    sum=(sum-ssum+mod)%mod;
    cout<<(sum*modi(2,mod))%mod<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h> 
int cmpDec(const void *a, const void *b)//递减
{
    return *(int *)b - *(int *)a;
} 
int main()
{
	int n,t;
	scanf("%d",&n);
	int a[n+1];
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
    qsort(a, n, sizeof(a[0]), cmpDec);
    int b=a[n/2-1],c=a[n/2];
	printf("%d",b-c);
    return 0;
}

Measured memory_bytes: 1020
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr, n);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr, n) {
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = n << 1; i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140160
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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(){
    int N;
    cin>>N;
    out(N*N);
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if(X <= 3) ans += 100000*(4-X);
    if(Y <= 3) ans += 100000*(4-Y);
    if(X==1&&Y==1) ans += 400000;
    cout << ans << endl;
    return 0;
}

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

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

    vector<int> count;
    vector<char> sign;
    sign.push_back(s.at(0));
    int ct = 0;
    for(char c : s) {
        if(c == sign.at(sign.size()-1)) ct++;
        else {
            count.push_back(ct);
            ct = 1;
            sign.push_back(c);
        }
    }
    count.push_back(ct);

    ll ans = 0;
    rep(i, count.size()) {
        ans += ((ll) count.at(i)*(count.at(i)+1))/2;
        if(i+1 < count.size() && sign.at(i) == '<') {
            if(count.at(i) <= count.at(i+1)) ans -= count.at(i);
            else ans -= count.at(i+1);
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;

  return 0;
}


Measured memory_bytes: 3588
loop do
  h,w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  count_h = 0
  count_w = 0
  h.times{
    w.times{
      if count_w % 2 == 0 || count_w == 0
        print "#"
      else
        print "."
      end
      count_w += 1
     }

     if count_h % 2 == 0 || count_h == 0
       count_w = 1
     else
       count_w = 0
     end
     count_h += 1
    puts
   }
   puts
end



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

int main() {
	for(int a = 1; a <= 9; ++a) {
		for(int b = 1; b <= 9; ++b) {
			cout << a << "x" << b << "=" << a * b << "\n";
		}
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll K,N;
    cin >> K >> N;
    vector<ll> vec(N);
    for (ll i = 0;i<N;i++) {
        ll a; cin >> a;
        vec.at(i) = a;
    }
    vector<ll> len(N);
    for (ll i = 0;i<N-1;i++) {
        len.at(i) = vec.at(i+1) - vec.at(i);
    }
    len.at(N-1) = K - vec.at(N-1) + vec.at(0);
    sort(len.begin(),len.end());
    ll ans = 0;
    for (ll i = 0;i<N-1;i++) {
        ans += len.at(i);
    }
    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> x(N), y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    // x軸方向のすべての区間の総和を求める
    // x[i]座標に注目したとき、x[i]座標を右端に持つ区間の数はi個で、左端に持つ区間の数はN-1-i個.
    // 区間の総和はx[r] - x[l] (l<r). x[i]は区間の総和に対してプラスにi個、マイナスにN-1-i個寄与する。
    mint sumX = 0; // x方向の距離の総和
    rep(i, N) {
        sumX += mint(i) * mint(x[i]);
        sumX -= mint(N - 1 - i) * mint(x[i]);
    }

    mint sumY = 0; // y方向の距離の総和
    rep(i, M) {
        sumY += mint(i) * mint(y[i]);
        sumY -= mint(M - 1 - i) * mint(y[i]);
    }

    cout << (sumX * sumY).x << endl;
}

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

using namespace std;

int main() {
	vector<int>A(32);
	A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int N;
	cin >> N;
	cout << A.at(N - 1) << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] l = new long[n+1];
        if(n == 1) {
            System.out.println(1);
        }else {
            l[0] = 2;
            l[1] = 1;
            for(int i=2; i<=n; i++) {
                l[i] = l[i-1] + l[i-2];
                if(i == n) {
                    System.out.println(l[i]);
                    break;
                }
            }
        }
    }
}

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

const int INF = 0x7fffffff;

int st[1 << 18];

void init(int n){
    int nn = 1;
    while(nn < n) nn *= 2;
    fill(st, st + 2 * nn - 1, INF);
}

void update(int i, int a, int k, int l, int r){
    if(i < l || r <= i) return;
    if(r - l == 1) st[k] = a;
    else{
        int chl = 2 * k + 1;
        int chr = 2 * k + 2;
        update(i, a, chl, l, (l + r) / 2);
        update(i, a, chr, (l + r) / 2, r);
        st[k] = min(st[chl], st[chr]);
    }
}


int find(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return st[k];
    int res_l = find(a, b, 2 * k + 1, l, (l + r) / 2);
    int res_r = find(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(res_l, res_r);
}

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    init(n);
    for(int i = 0; i < q; i++){
        int c, x, y;
        scanf("%d%d%d", &c, &x, &y);
        if(c == 0){
            update(x, y, 0, 0, n);
        }else{
            int ret = find(x, y+1, 0, 0, n);
            printf("%d\n", ret);
        }
    }
    
    return 0;
}

Measured memory_bytes: 2212
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main(){
    let n : usize = read!();
    let mut sp = Vec::with_capacity(n);
    for i in 0..n{
        let si : String = read!();
        let pi : usize = read!();
        sp.push((si,pi,i));
    }
    sp.sort_by(|(si,pi,_i),(sj,pj,_j) | si.cmp(sj).then(pj.cmp(pi))  );
    
    for (_si,_pi,i) in sp{
        println!("{}", i+1);
    }
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b/a;
  ans = min(ans, c);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572