akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 200100;

ll T,N,a,b,c,d,e,f,K,t,M;
int A[MAXN];
int B[MAXN];  
vi V;
string S;

int main(){
  cin>>N>>K>>M>>S;
  for (int i=1;i<=N;++i){
    if (S[i-1] == 'o')A[i] = 1;
    else A[i] = 0;
  }
  int lst = -INF;
  for (int i=1;i<=N;++i){
    if (A[i] == 0)continue;
    if (lst + M >= i)continue;
    lst = i;
    B[i]=1;
    V.pb(i);
    // cout<<i<<'\n';
  }
  if (SZ(V) != K){
    return 0;
  }
  V.clear();
  lst = INF;
  for (int i=N;i>=1;--i){
    if (A[i] == 0)continue;
    if (lst - M <= i)continue;
    lst = i;
    // cout<<i<<'\n';
    if (B[i] == 1)V.pb(i);
  }
  reverse(ALL(V));
  for (auto i :V)cout<<i<<'\n';
}

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

using namespace std;

int main()
{
    string N;
    cin >> N;
    int a = 0;
    for (int i = 0; i < N.size(); i++)
    {
        a += N[i] - '0';
    }
    if (a%9 == 0)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3692
N,M=map(int,input().split())
AB=[]

for i in range(N):
  A,B=map(int,input().split())
  AB.append([A,B])
  
AB.sort(key=lambda x: x[0])

ans=0
quantity=0

for i in AB:
  if quantity+i[1] < M:
    ans += i[0]*i[1]
    quantity += i[1]
  else:
    ans += i[0]*(M-quantity)
    break

print(ans)

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

#define REP(i, n ,N) for(int i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

string s;
ll K;
ll ans, tmp;
int main(){
	cin >> s >> K;
	string t = s;
	REP(i,1,t.size()){
		if(t[i-1] == t[i]){
			ans++;
			t[i] = 'x';
			i++;
		}
	}
	t = s + s;
	REP(i,1,t.size()){
		if(t[i-1] == t[i]){
			tmp++;
			t[i] = 'x';
			i++;
		}
	}

	if(tmp == ans * 2){
		p(ans * K);
	}else{
		if(t.back() == 'x'){
			p(ans * ((K + 1) / 2) + (ans + 1) * (K /2));
		}else{
			p(ans + (ans + 1) * (K-1));
		}

	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        char[] alp = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        int[] a = new int[26];
        for(int i = 0; i < w.length(); i++){
            for(int j = 0; j < 26; j++){
                if(w.charAt(i) == alp[j]){
                    a[j]++;
                    break;
                }
            }
        }
        boolean b = true;
        for(int i = 0; i < 26; i++){
            if(a[i] % 2 == 1){
                b = false;
                break;
            }
        }
        if(b == true){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23508
// 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
// 無効な値の定義
const int INV = -1;

int main(void)
{
    int n, u, num, v_num;
    int ary_graph[MAX_N + 1][MAX_N + 1];

    for(int i = 0; i < MAX_N + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = 0;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u;
        cin >> num;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;
            ary_graph[u][v_num] = 1;
        }
    }

    // 結果の表示をする
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if( j > 1 )
            {
                cout << " ";
            }

            cout << ary_graph[i][j];
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        puts("ARC");
    }else{
        puts("ABC");
    }
    return 0;
}

Measured memory_bytes: 3600
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
ans = [[0]*w for _ in range(h)]
num = 1

for i in range(h):
    if "#" not in s[i]:
        if i != 0:
            ans[i] = ans[i-1]
        continue
    first = True
    for j in range(w):
        if s[i][j] == '#':
            if first:
                first = False
            else:
                num += 1
        ans[i][j] = num
    num += 1

for k in range(h-2, -1, -1):
    if 0 in ans[k]:
        ans[k] = ans[k+1]
for l in range(h):
    print(*ans[l])


Measured memory_bytes: 12520
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N;
    cin >> N;
    V a(N + 2, 0), b(N + 2, 0);
    rep1(i, N)a[i] = 1;
    rep1(i, N)b[i] = 1;
    rep1(i, N){
        ll x;
        cin >> x;
        a[x] += i;
        b[x] += i;     
    }
    rep1(i, N)a[i] += a[i - 1];
    rrep1(i, N)b[i] += b[i + 1];
    rep1(i, N){
        cout << a[i] - a[1] + 1;
        if(i == N)cout << endl;
        else cout << " ";
    }
    rep1(i, N){
        cout << b[i] - b[N] + 1;
        if(i == N)cout << endl;
        else cout << " ";
    }
    
    return 0;
}

Measured memory_bytes: 896
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll N, M, D;

int main() {
    cin >> N >> M >> D;
    cout << fixed << setprecision(10) << (D == 0 ? 1.0 : 2.0) * (N-D) / N / N * (M-1) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
src = list(map(int,input().split()))

ans = 0
r = 0
tmp = 0
for l in range(N):
    while r < N and (tmp&src[r]) == 0:
        tmp += src[r]
        r += 1
    tmp -= src[l]
    ans += r - l
print(ans)


Measured memory_bytes: 24712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    while(cin>>n,n){
        long long int siz,ans=0;
        string str;
        cin>>siz>>str;
        for(int i=0;i<siz-2*n;i++){
            if(str[i]=='I'){
                int co=0;
                for(int j=i+1;j<siz;j+=2,co++)
                    if(str[j]!='O'||str[j+1]!='I')break;
                if(co>=n){
                    ans+=co-n+1;
                    i+=2*co;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2104
#include<stdio.h>
#include<algorithm>
using namespace std;
char con[]="kstnhmyrw";
char vow[]="aiueo";
char fli[]="TLURD";
char str[1024];
int main(){
	scanf("%s",str);
	for(int i=0;str[i];i+=2){
		if(str[i]=='0'){
			if(str[i+1]=='T')printf("wa");
			if(str[i+1]=='D')printf("wo");
			if(str[i+1]=='U')printf("nn");
		}else if(str[i]=='8'){
			if(str[i+1]=='T')printf("ya");
			if(str[i+1]=='U')printf("yu");
			if(str[i+1]=='D')printf("yo");
		}else{
			if(str[i]!='1')printf("%c",con[str[i]-'2']);
			for(int j=0;j<5;j++)if(str[i+1]==fli[j])printf("%c",vow[j]);
		}
	}
	printf("\n");
}

Measured memory_bytes: 948
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;

Int dp[2010][2010];
Int S[2010];
Int T[2010];

int main(void) {
    cin>>N>>M;
    for(int i = 1;i <= N;i++) {
        cin>>S[i];
    }
    for(int i = 1;i <= M;i++) {
        cin>>T[i];
    }

    for(int i = 0;i <= N;i++)
        dp[i][0] = 1;
    for(int j = 0;j <= M;j++)
        dp[0][j] = 1;

    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= M;j++) {
            if(S[i] == T[j]) {
                dp[i][j] = dp[i][j-1]+dp[i-1][j];
            } else {
                dp[i][j] = dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]+MOD;
            }

            dp[i][j] %= MOD;
        }
    }

    cout<<dp[N][M]<<endl;


    return 0;
}


Measured memory_bytes: 31744
/*
  -> ossan
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global

void solve()
{
    int n;
    cin >> n;
    int s = 0;
    unordered_map<int, int> freq;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        freq[t]++;
        s += t;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        s -= b * freq[b];
        s += c * freq[b];
        freq[c] += freq[b];
        freq[b] = 0;
        cout << s << '\n';
    }
}

signed main()
{
    Hiraishin
    // tests
    solve();
    return 0;
}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, raw_input().split())
    if m+f+r == -3:
        break

    if m == -1 or f == -1:
        print "F"
    elif m+f >= 80:
        print "A"
    elif m+f >= 65:
        print "B"
    elif m+f >= 50:
        print "C"
    elif m+f >= 30:
        if r >= 50:
            print "C"
        else:
            print "D"
    else:
        print "F"

Measured memory_bytes: 4208
S = input()

if len(S) < 26:
    for c in 'abcdefghijklmnopqrstuvwxyz':
        if c not in S:
            print(S + c)
            break
else:
    cs = {S[-1]}
    for i in range(25)[::-1]:
        if S[i] < S[i + 1]:
            for c in sorted(list(cs)):
                if c > S[i]:
                    print(S[:i] + c)
                    break
            break
        else:
            cs.add(S[i])
    else:
        print('-1')


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int count = 1;
    int now = 0;
    int bef = 0;
    for(int i = 1;i<n;i++){
      if(a[i-1]<a[i]){
        now = 1;
      }else if(a[i-1]>a[i]){
        now = -1;
      }else{
        continue;
      }
      if(bef == 0){
        bef = now;
      }
      if(bef != now){
        count++;
        bef = 0;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 59852
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
    li n, t;
    cin >> n >> t;

    vector<li> xs(n);
    rep(i, n) {
        cin >> xs[i];
    }
    xs.push_back(1e10);

    li ans = 0;
    rep(i, n) {
        ans += min(t, xs[i + 1] - xs[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double



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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



bool vis[100010];
vector<int>G[100010];

int grundy(int n, int pre) {
	//print(n);
	if (n == 1) {
		if (G[n].size() == 1) {
			return 1;
		}
		else {
			int res = 0;
			for (auto nex : G[n]) {
				res ^= (grundy(nex, n)+1);
			}
			return res;
		}
	}
	else {
		if (G[n].size() == 2) {
			int res = 0;
			for (auto nex : G[n]) {
				if (nex == pre)continue;
				res = grundy(nex, n);
			}
			res++;
			return res;
		}
		else {
			int res = 0;
			for (auto nex : G[n]) {
				if (nex == pre)continue;
				res ^= (grundy(nex, n)+1);
			}
			return res;
		}
	}
}


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

	int N; cin >> N;
	REP(i, N-1) {
		int x, y; cin >> x >> y;
		G[x].pb(y);
		G[y].pb(x);
	}
	ll res = grundy(1, -1);
	if (res == 0) {
		print("Bob");
	}
	else print("Alice");
}

Measured memory_bytes: 8832
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    int d,e,f;
    cin >> a >> b >> c;
    d = abs(a-b);
    e = abs(a-c);
    f = abs(b-c);
    cout << min(d+e,min(d+f,e+f)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#define endl "\n"
using namespace std;

int main(void) 
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k; cin >> n >> k;
  int res=1;
  for (int i = 0; i < n; i++)
  {
    if (i == 0)
    {
      res *= k;
    }
    else
    {
      res *= (k - 1);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
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() {
    vi c(9);
    REP(i, 9) cin >> c[i];
    if (c[0] - c[3] == c[1] - c[4] and c[1] - c[4] == c[2] - c[5] and c[2] - c[5] == c[0] - c[3]
        and c[6] - c[3] == c[7] - c[4] and c[7] - c[4] == c[8] - c[5] and c[8] - c[5] == c[6] - c[3]
        and c[0] - c[1] == c[3] - c[4] and c[3] - c[4] == c[6] - c[7] and c[6] - c[7] == c[0] - c[1]
        and c[2] - c[1] == c[5] - c[4] and c[5] - c[4] == c[8] - c[7] and c[8] - c[7] == c[2] - c[1]) {
            cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// Java program to find large factorials using BigInteger 
import java.math.BigInteger; 
import java.util.Scanner; 

public class Main
{

	// Driver method 
	public static void main(String args[]) throws Exception 
	{ 
    	Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
        BigInteger [] a = new BigInteger[N];
        String MX = "1000000000000000000";
        for(int i=0;i<N;i++)
        {
            String str = sc.next();
            a[i]=new BigInteger(str); 
            if(a[i].compareTo(new BigInteger("0"))==0)
            {
                System.out.println("0");
                return ;
            }
        }
        BigInteger f= a[0];
        for(int i=1;i<N;i++)
        {
            f=f.multiply(a[i]);
            if(f.compareTo(new BigInteger(MX))==1)
            {
                System.out.println("-1");
                return ;
            }
        }
		System.out.println(f); 
	} 
} 


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
  int n ;cin>>n;
  cout<<n*(n+1)/2<<endl;
}

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

int main() {
  int N,W;
  cin >> N;
  int S = N;
  for(; N>0; N /= 10){
    W += N%10;
  }
  if(S%W == 0){
    cout << "Yes" << endl;
  return 0;
  }
  cout << "No" << endl;
}


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

int n, k, max;
std::vector<int> box;

int gcd(int a, int b) {
  int tmp;
  if(a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0) {
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

// O(N) 1<=N<=10^5
bool configurable(int x) {
  if(max < x)
    return false;

  int g = box[0];
  for(int i = 1; i < n && g != 1; i++) {
    g = gcd(g, box[i]);
  }
  return x % g == 0;
}

int main() {
  std::cin >> n;
  std::cin >> k;
  box.resize(n);

  int x;
  max = -1;
  for(int i = 0; i < n; i++) {
    std::cin >> x;
    box[i] = x;
    if(max < x)
      max = x;
  }

  if(configurable(k)) {
    std::cout << "POSSIBLE\n";
  } else {
    std::cout << "IMPOSSIBLE\n";
  }
  return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()

r, w = 0, 0
for i in range(N):
    if S[i] == 'R':
        r += 1
    else:
        w += 1

res = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if S[i-1] == 'R':
        res[i] = res[i-1] + 1
    else:
        res[i] = res[i-1]

print(r-res[r])

Measured memory_bytes: 17304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  
  IN(N);
  ll table[N][N];
  REP(i, N) {
    IN(table[i][i]);
  }
  FOR(d, 1, N) {
    FOR(l, 0, N-d) {
      ll r = l + d;
      table[l][r] = max(table[l][l] - table[l+1][r], table[r][r] - table[l][r-1]);
      // DEBUG(table[l][r]);
    }
    // LN();
  }

  PRINT(table[0][N-1]);

}


Measured memory_bytes: 70400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]+=32;
  op(s);
  return 0;
}

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

int main(void){
    
    int N,M,C,count=0;
    cin >> N >> M >> C;
    vector<int> B{};
    
    for(int i=0;i<M;i++){
        int b_i;
        cin >> b_i;
        B.push_back(b_i);
    }
    
    
    for(int i=0;i<N;i++){
        int sum = 0;
        for(int j=0;j<M;j++){
            int a_i;
            cin >> a_i;
            sum += (B.at(j)*a_i);
        }
        if(sum + C > 0) count++;
    }
    
    
    cout << count << endl;
    
}

Measured memory_bytes: 3640
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <ctype.h>>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
string s;
int n;
LL dp[3003][3003],ans,pr[3003];
int main()
{
	cin >> n >> s;
	s = "#" + s;
	dp[1][1] = 1;
	for (int len = 2; len <= n; len++)
	{
		for (int i = 1; i <= len - 1; i++)
			pr[i] = (pr[i - 1] + dp[len - 1][i]) % mod;
		for (int i = 1; i <= len; i++)
		{
			int l, r;
			if (s[len - 1] == '<')
			{
				l = 1;
				r = i - 1;
			}
			else
			{
				r = len-1;
				l = i;
			}
			dp[len][i] += (pr[r] + mod - pr[l - 1]) % mod;
			dp[len][i] %= mod;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		ans += dp[n][i];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

/*



*/

Measured memory_bytes: 68992
n = int(input())
a = []
max_num = -1
for i in range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)

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

long long n,a,x[105],dp[55][2505],r;

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

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

    dp[0][0] = 1;
    for(long long i=0;i<n;i++)
    {
        for(long long j=n-1;j>=0;j--)
        {
            for(long long k=0;k<a*n;k++)
            {
                dp[j+1][k+x[i]]+=dp[j][k];
            }
        }
    }

    for(long long i=1;i<=n;i++)
        r+=dp[i][i*a];

    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 4572
N = input()
A = list(map(int, input().split()))

count = 0
A.sort()
for i in range(len(A) - 2):
  for j in range(i,len(A)):
    for k in range(j,len(A)):
      if not A[i] == A[j] and not A[i] == A[k] and not A[j] == A[k]:
        if A[k] < A[i]+A[j]:
          count += 1
print(count)

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

#define MAX 2000000000
#define MOD 1000000007


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

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

int N;
vector<int> A, B;

long long getMinSadness(int x){
    long long sad = 0;
    for(int i = 0; i < N; i++){
        sad += abs(A[i] - (x + i));
    }
    return sad;
}

int main(){
    cin >> N;

    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
        B.push_back(tmp - i);
    }
    sort(B.begin(), B.end());

    int b1 = B[N/2 - 1];
    int b2 = B[N/2];
    // cout << b1 << ' ' << b2 << endl;

    long long ans = min(getMinSadness(b1), getMinSadness(b2));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
using System.IO;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var P = cin.ReadInt;
            var Q = cin.ReadInt;
            var R = cin.ReadInt;
            var ans = 0;

            if (P <= Q)
            {
                ans = P;
                if (Q <= R)
                {
                    ans += Q;
                }
                else
                {
                    ans += R;
                }
            }
            else
            {
                ans = Q;
                if (P <= R)
                {
                    ans += P;
                }
                else
                {
                    ans += R;
                }
            }

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine
        {
            get { return _stream.ReadLine(); }
        }

        public int ReadInt
        {
            get { return int.Parse(Read); }
        }

        public long ReadLong
        {
            get { return long.Parse(Read); }
        }

        public double ReadDouble
        {
            get { return double.Parse(Read); }
        }

        public string[] ReadStrArray(long N)
        {
            var ret = new string[N];
            for (long i = 0; i < N; ++i) ret[i] = Read;
            return ret;
        }

        public int[] ReadIntArray(long N)
        {
            var ret = new int[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadInt;
            return ret;
        }

        public long[] ReadLongArray(long N)
        {
            var ret = new long[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadLong;
            return ret;
        }
    }
}

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

N = int(input())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

ans = 0

for i in reversed(range(N)):
    if (ans + A[i]) % B[i] != 0:
        ans += ((ans + A[i]) // B[i] + 1) * B[i] - (ans + A[i])

print(ans)

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

int a[1000];

int main() {
	// your code goes here
	int i, j, ans=0, n, k;
	cin>>n;
	for(i=0; i<2*n; ++i) {
		cin>>a[i];
	}
	sort(a, a+2*n);
	for(i=0; i<2*n; i+=2) {
		ans+=min(a[i], a[i+1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
i = 0
j = 0
cnt = 0
while True :
    K = i * 4 + j * 7
    if K == N :
        print('Yes')
        break
    elif N < K and cnt == 0 :
        print('No')
        break
    elif N < K :
        j += 1
        i = 0
        cnt = 0
    else :
        i += 1
        cnt += 1


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int k = sc.nextInt();
    	int i = 0;
    	int cnt=0;

    	for(i = Math.min(a,b); i > 0; i--){
    		if(a % i == 0){
    			if(b % i == 0){
    				cnt++;
    				if(cnt == k){
    					break;
    				}
    			}
    		}
    	}


    	// 出力
    	System.out.println(i);
    }
}

Measured memory_bytes: 23252
import itertools 
n, m, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

ls = list(range(n + m - 1))
mx = 0
for l in itertools.combinations(ls, m - 1):
    a = [0]
    idx = 0
    val = 1
    for i in range(n + m - 1): 
        if idx < m - 1 and i == l[idx]:
            val += 1
            idx += 1
        else: 
            a.append(val)
    #print(l, a)
    v = 0
    for i in query:
        if a[i[1]] - a[i[0]] == i[2]: v += i[3]
    mx = max(v, mx)
print(mx)


Measured memory_bytes: 9224
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}
impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap(); 
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0], tmp_var[1])
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0], tmp_var[1], tmp_var[2])
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());

    let (n, m) = input!(r, usize, usize);
    let mut requests: Vec<(usize, usize)> = Vec::with_capacity(m);
    for _ in 0..m {
        let request = input!(r, usize, usize);
        requests.push(request);
    }
    requests.sort_by(|a, b| b.1.cmp(&a.1));
    let mut count = 0;
    loop {
        if requests.len() == 0 { break; } 
        let request = requests.pop().unwrap();
        requests = requests.into_iter().filter(|a| a.0 >= request.1).collect();
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 11168
from fractions import gcd
from collections import Counter


def prime_factor(n):
    c = Counter()
    i = 2
    while i * i <= n:
        while (n % i == 0):
            c[i] += 1
            n = n//i
        i += 1
    if n != 1:
        c[n] += 1

    return c


a, b = map(int, input().split())
gcd = gcd(a, b)
c = prime_factor(gcd)

print(len(c) + 1)


Measured memory_bytes: 5304
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    ll ans = 0;
    vector<ll> lv, rv;
    lv.push_back(-1);
    rv.push_back(-1);
    rep(i,0,N){
        if(S[i] == '<') lv.push_back(i);
        else rv.push_back(i);
    }
    lv.push_back(N);
    rv.push_back(N);
    rep(i,0,N+1){
        ll p1 = lower_bound(rv.begin(), rv.end(), i) - rv.begin();
        ll p2 = lower_bound(lv.begin(), lv.end(), i) - lv.begin();
        ll v1 = i - rv[p1 - 1] -1;
        ll v2 = lv[p2] - i;
        ans += max(v1, v2);

    }
    print(ans);


}

Measured memory_bytes: 7188
#include<iostream>
#include<cmath>
#include<string>

#define ll long long

using namespace std;

int main()
{
	ll n;
  	cin>>n;
  	string ans="";
  
 	while(n)
    {
      ll div = n/26;
      ll mod = n%26;
      if(mod==0)
      {
        div--;
        ans = (char)('z')+ans;
      }
      else
        ans = (char)(('a'+mod-1))+ans;
      n=div;
    }
  	cout<<ans;
	return 0;
}


Measured memory_bytes: 3600
import java.util.*

fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map { it.toInt() }
    for(i in 1 .. 9) {
        for (j in 1 .. 9) {
            if (i * j == N) {
                print("Yes")
                return
            }
        }
    }
    print("No")
}


Measured memory_bytes: 37720
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var n = sc.nextInt();
        var v = sc.ArrayInt(n);
        var dic1 = new List<int>();
        var dic2 = new List<int>();
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                dic2.Add(v[i]);
            } else {
                dic1.Add(v[i]);
            }
        }

        var cnt1 = dic1.GroupBy(i => i).Select(grp => new { Num = grp.Key, Cnt = grp.Count() }).OrderByDescending(grp => grp.Cnt).ToArray();
        var cnt2 = dic2.GroupBy(i => i).Select(grp => new { Num = grp.Key, Cnt = grp.Count() }).OrderByDescending(grp => grp.Cnt).ToArray();

        var c1 = cnt1[0].Cnt;
        var c2 = cnt2[0].Cnt;

        if (cnt1[0].Num == cnt2[0].Num) {
            if (cnt1.Length == 1 && cnt2.Length == 1) {
                c1 = 0;
                WriteLine(n - (c1 + c2));
            }else if (cnt1.Length == 1) {
                WriteLine(n - (cnt1[0].Cnt + cnt2[1].Cnt));
            } else if (cnt2.Length == 1) {
                WriteLine(n - (cnt1[1].Cnt + cnt2[0].Cnt));
            } else {
                WriteLine(Math.Min(n - (cnt1[0].Cnt + cnt2[1].Cnt), n - (cnt1[1].Cnt + cnt2[0].Cnt)));

            }
            return;
        }

        WriteLine(n - (c1 + c2));
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 39076
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
using namespace std;

int main(){
    int N;
    std::cin >> N;
    std::vector<int> d(N);
    for(int i = 0; i < N; ++i) std::cin >> d[i];
    std::sort(d.begin(),d.end(),greater<int>());
    
    int layer = 1;
    for(int i = 1; i < N; ++i)
    {
        // std::cout << d[i] << "\n";
        if(d[i] < d[i-1]) ++layer;
    }
    std::cout << layer << "\n";
}

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

int main() {
  string str;
  int n, k;
  cin >> n >> k >> str;

  if(str[k-1] == 'A')
    str[k-1] = 'a';
  else if(str[k-1] == 'B')
    str[k-1] = 'b';
  else if(str[k-1] == 'C')
    str[k-1] = 'c';

  cout << str << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
const int MOD = 1000000007;

int N;
int e[1010];

vector<P> factorize(int n) {
    vector<P> res;
    for (int i=2; i*i<=n; i++) {
        int cnt = 0;
        while (n%i==0) {
            cnt++;
            n /= i;
        }
        if (cnt>0) res.pb(P(i, cnt));
    }
    if (n!=1) res.pb(P(n, 1));
    return res;
}
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int i=1; i<=N; i++) {
        vector<P> fs = factorize(i);
        rep(j, fs.size()) e[fs[j].first] += fs[j].second;
    }
    int ans = 1;
    rep(i, 1010) {
        ans *= e[i]+1;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

#define SIZE 100

using namespace std;

void bubbleSort(int, int[]);

int main(void) {
	int n, list[SIZE];
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> list[i];
	}

	bubbleSort(n, list);

	return 0;
}

void bubbleSort(int n, int list[]) {
	int count = 0;
	int tmp;
	bool flag = true;
	for (int i = 0; i < n; i++) {
		while (flag) {
			flag = false;
			for (int j = n - 1; j >= i + 1; j--) {
				if (list[j] < list[j - 1]) {
					tmp = list[j];
					list[j] = list[j - 1];
					list[j - 1] = tmp;
					count++;
					flag = true;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << list[i];
	}
	cout << "\n" << count << "\n";
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {
	Int N;
	cin >> N;
	
	vector<Int> a(N,0);
	vector<Int> temp(N,0);
	for (Int i = 0; i < N; i++)cin >> a[i];
	temp = a;
	sort(temp.begin(), temp.end());

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		if (a[i] == temp[N - 1])ans = temp[N - 2];
		else ans = temp[N - 1];
		cout << ans << endl;
	}

}

Measured memory_bytes: 4736
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
int count(int n){
    int res = 0;
    while(n%2==0){
        res++;
        n /= 2;
    }
    return res;
}
int main(){
    int N;
    cin >> N;
    int ans = 50;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        ans = min(ans, count(a));
    }
    cout << ans <<endl;



    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> p;
  for(int i=0;i<N;i++){
  	int a;
  	cin >> a;
  	p.push_back(a);
  }
  sort(p.begin(), p.end());

  int sum = 0;
  for(int i=0;i<N-1;i++){
  	sum += p[i];
  }
  sum += p[N-1]/2;
  cout << sum <<endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
	ll n;cin>>n;vector<ll>a(n);REP(i,n){cin>>a[i];a[i]-=i+1;}
	sort(ALL(a));
	ll ans1=0,ans2=0;
	REP(i,n){
		ans1+=abs(a[(n-1)/2]-a[i]);
		ans2+=abs(a[(n+1)/2]-a[i]);
	}
	cout<<min(ans1,ans2)<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

void change_ans(int i,int n){
    ans[i]=n;
}

void solve_C(){
    int M;
    cin>>M;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        change_ans(from,to);
        cout<<man_calc(false)<<endl;
    }
}

signed main(){
    inp();
    ans_inp();
    solve_C();
    return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    if(N % 2 == 1){
        for(int i=0; i<M; i++){
            cout << i+1 << " " << N-i << endl;
        }
    }
    else{
        int cnt = 0;
        for(int i=0; i<N/4 && cnt < M; i++){
            cnt++;
            cout << i+1 << " " << N / 2 - i << endl;
        }
        for(int i=0; cnt < M; i++){
            cnt++;
            cout << i+1 + N / 2 << " " << N - i - 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
total_cost = 0
total_amount = 0
n = 0

while True :
    try :
        cost, amount = map(int, input().split(','))
        n += 1
        total_cost += cost * amount
        total_amount += amount
        
    except EOFError :
        break

print(total_cost)
float_total_amount = total_amount / n - total_amount // n
if float_total_amount < 0.5 :
    print(total_amount // n)
else :
    print(total_amount // n + 1)


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

int main()
{
	int N;
	vector<int> A,B;
	cin.sync_with_stdio(false);
	cin >> N;
	A.reserve(N),B.reserve(N);
	for (int i = 0, a; i < N; i++) {
		cin >> a;
		A.push_back(a);
		B.push_back(a);
	}
	sort(B.begin(), B.end());
	ll res = 0;
	for (int i = 0;i < N;i++) {
		if ((lower_bound(B.begin(), B.end(), A[i]) - B.begin()) % 2 != i % 2)
			res++;
	}
	cout << res / 2 << endl;
	return 0;
}


Measured memory_bytes: 1024