akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

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 T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(0, 3) {
    if(n % 10 == 7)
      ans = 1;
    n /= 10;
  }
  if(ans)
    cout << "Yes\n";
  else
    cout << "No\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3636
n, q = map(int, input().split())
s = input().strip()
ac = [0 for _ in range(n)]
prevs = ''
for i, _s in enumerate(s):
  if prevs == 'A' and _s == 'C':
    ac[i] = ac[i-1] + 1
    prevs = _s
  else:
    ac[i] = ac[i-1]
    prevs = _s
for _ in range(q):
  l, r = map(int, input().split())
  print(ac[r-1] - ac[l-1])


Measured memory_bytes: 6104
unittest
{
	assert( [ "4", "2 3 5", "2 1 5", "1 2 5", "3 2 5" ].solve == "2 2 6" );
	assert( [ "2", "0 0 100", "1 1 98" ].solve == "0 0 100" );
	assert( [ "3", "99 1 191", "100 1 192", "99 0 192" ].solve == "100 0 193" );
	
	assert( [ "5", "100 100 0", "2 3 5", "2 1 5", "1 2 5", "3 2 5" ].solve == "2 2 6" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyhs = new long[ 3 ][ n ];
	foreach( ref xyh; xyhs )
	{
		input.popFront;
		xyh = input.front.split.to!( long[] );
	}
	xyhs.sort!( ( a, b ) => b[ 2 ] < a[ 2 ] );
	
	foreach( cx; 0L .. 101L )
	{
		LOOP: foreach( cy; 0L .. 101L )
		{
			auto ch = xyhs.front[ 2 ] + abs( xyhs.front[ 0 ] - cx ) + abs( xyhs.front[ 1 ] - cy );
			foreach( xyh; xyhs )
			{
				if( max( ch - abs( xyh[ 0 ] - cx ) - abs( xyh[ 1 ] - cy ), 0 ) != xyh[ 2 ] ) continue LOOP;
			}
			return format( "%s %s %s", cx, cy, ch );
		}
	}
	assert( false );
}


Measured memory_bytes: 2920
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define MOD 100000
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int ans=0;

void sum(int num, int s, int max)//??????????????°????????????????????????????????§???
{
  int i;
  if(num==0 && s==0)
    ans++;
  if(num<=0 || s<0 || max<0)return;

  for(i=max;i>=0;i--)
    sum(num-1,s-i,i-1);
  return;

}

int main()
{
  int n,s;
  while(1){
    cin>>n>>s;
    ans=0;
    if(n==0 && s==0)break;
    if(n*(19-n)/2<s || n*(n-1)/2>s){
      cout<<"0"<<endl;
      continue;
    }
    sum(n,s,9);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define     FAST            ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
int main()
{
    FAST;
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    ll sm=0;
    for(int i=0;i<k;i++)
    {
        sm+=ar[i];
    }

    cout<<sm<<endl;

    return 0;

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;

int main()
{
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vi sum(a);
    for(ll i=1;i<n;i++)
        sum[i]+=sum[i-1];
    ll diff=99999999999999ll;
    for(ll t=0;t<n-1;t++)
    {
        ll a1=sum[t];
        ll a2=sum[n-1]-sum[t];
        diff=min(diff,abs(a1-a2));
    }
    cout<<diff<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
 
using namespace std;
typedef long long ll;

int N, K;
int X[10001];
int Y[100001];
int diff[2001][2001];
int sum[2001][2001];



void sumup() {
    for (int x = 0; x < 2 * K; x ++) {
        for (int y = 0; y < 2 * K; y ++) {
            sum[x][y] = diff[x][y];
            if (y > 0) sum[x][y] += sum[x][y - 1];
            if (x > 0) sum[x][y] += sum[x - 1][y];
            if (x > 0 && y > 0) sum[x][y] -= sum[x - 1][y - 1];
        }
    }
}

void print() {
    for (int y = 0; y < 2 * K; y ++) {
        for (int x = 0; x < 2 * K; x ++) {
            printf("%2d", diff[x][y]);
        }
        printf("\n");
    }
    printf("-----------\n");
    sumup();
    for (int y = 0; y < 2 * K; y ++) {
        for (int x = 0; x < 2 * K; x ++) {
            printf("%2d", sum[x][y]);
        }
        printf("\n");
    }
    printf("-----------\n");
}

void add(int x0, int y0) {
    //printf("%d %d\n", x0, y0);
    int x1 = x0 + K - 1;
    int y1 = y0 + K - 1;
    x0 = max(x0, 0);
    x1 = min(x1, 2 * K - 1);
    y0 = max(y0, 0);
    y1 = min(y1, 2 * K - 1);
    if (x0 > x1) return;
    if (y0 > y1) return;
    diff[x0][y0] ++;
    diff[x1 + 1][y1 + 1] ++;
    diff[x0][y1 + 1] --;
    diff[x1 + 1][y0] --;
    //print();
}

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i ++) {
        char c;
        int x, y;
        cin >> x >> y >> c;
        if (c == 'W') {
            y += K;
        }
        x %= 2 * K;
        y %= 2 * K;
        if (x >= K) {
            x -= K;
            y = (y + K) % (2 * K);
        }
        add(x + 1, y + 1);
        add(x - K + 1, y - K + 1);
        add(x + K + 1, y - K + 1);
        add(x - K + 1, y + K + 1);
        add(x + K + 1, y + K + 1);
        add(x + 1, y - 2 * K + 1);
    }
    sumup();
    //print();
    int ans = 0;
    for (int x = 0; x < 2 * K; x ++) {
        for (int y = 0; y < 2 * K; y ++) {
            ans = max(ans, sum[x][y]);
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define N 100003
#define inf 1e9

int n,k,t1,t2,ans;
int a[N],f1[N],f2[N];

bool cmp(int x,int y){
	return x>y;	
}

int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
	  	scanf("%d",&a[i]);
	  	if (a[i]==0) k--;
	  	if (a[i]<0) f1[++t1]=a[i];
	  	if (a[i]>0) f2[++t2]=a[i];
	}
	if (k==0){
		printf("0\n");
		return 0;	
	}
	sort(f1+1,f1+1+t1,cmp);
	ans=inf;
	for (int i=0;i<=min(k,t1);i++){
		int p1=i,p2=k-i;
		if (p2>t2) continue;
		ans=min(ans,2*abs(f1[p1])+f2[p2]);
		ans=min(ans,abs(f1[p1])+2*f2[p2]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int D, N;
	cin >> D >> N;
	if (N == 100) N = 101;
	REP(i, D) {
		N *= 100;
	}
	cout << N << "\n";

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int64_t result = 0;
  for (int tmp=0; tmp<(1<<(S.size()-1)); tmp++) {
    bitset<10> bit_tmp(tmp);

    string S_n;
    for (int cnt=0; cnt<S.size(); cnt++) {
      S_n += S.at(cnt);
      if( bit_tmp.test(cnt) ) {
        result += stoll(S_n);
        S_n = "";
      }
    }

    if (S_n != "") {
      result += stoll(S_n);
    }
  }

  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, n, m, l;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++) cin >> vec.at(i);
  for(int i=0;i<N;i++) {
    n = vec.at(i);
    for(int j=0;j<N;j++){
      m = vec.at(j);
      if(n==m&&i!=j) vec.at(j)=0;
    }
  }
  l=0;
  for(int i=0;i<N;i++) if(vec.at(i)!=0) l++;
  cout << l << endl;
      
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

bool operator < (vector<int> v1, vector<int> v2){
	int tam = len(v1);
	for(int i=0; i<tam; ++i){
		if(v1[i]<v2[i]) return true;
		if(v1[i]>v2[i]) return false;
	}
	return false;
}
int32_t main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> vs(n), vx(n);
	for(auto &x:vs) cin >> x;
	for(auto &x:vx) cin >> x;
	if(vx<vs) swap(vx, vs);
	int ans = 0;
	do{

		if(vs==vx) break;
		else ++ ans;
	}while(next_permutation(all(vs)));

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,x;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	k=read(),x=read();
	for(int i=x-k+1;i<=x+k-1;i++)
	printf("%d ",i);
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int tmp=b/a;
    if(c<tmp){
        cout << c << endl;
    }else{
        cout << tmp << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N;
  cin>>N;
  while(N--){
    string s;
    cin>>s;
    int sum = 0;
    REP(i, s.size()) sum += s[i] -'0';
    int cnt = 0;
    while(sum / 10){
      sum -= 9;
      cnt += 1;
    }
    if((cnt + s.size()) % 2 == 0) cout<<"Fabre wins."<<endl;
    else cout<<"Audrey wins."<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxx=2000000000;

int n;
int p[110],dp[110][110];

int main (){
	cin>>n;
	for(int i=1;i<=n;i++){
		dp[i][i]=0;
		cin>>p[i-1]>>p[i];
	}
	for(int len=2;len<=n;len++){
		for(int i=1;i<=n-len+1;i++){
			int j=i+len-1;
			dp[i][j]=maxx;
			for(int k=i;k<j;k++) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
#define ull unsigned long long

vector<ll> rolling_hash(string A, string S) {
  ll al = A.size(), sl = S.size();
  vector<ll> res = {};
  if (al > sl) {
    return res;
  }
  ull cardinal = 1000000007;
  ull ah = 0, sh = 0;
  ull cardinal_pow = 1;
  for (ll i = 0; i < al; ++i) {
    ah = ah * cardinal + (A[i] - 'A');
    sh = sh * cardinal + (S[i] - 'A');
    cardinal_pow *= cardinal;
  }
  if (ah == sh) {
    res.push_back(0);
  }
  for (ll i = 0; i < sl - al; ++i) {
    sh = sh * cardinal - (S[i] - 'A') * cardinal_pow + (S[i + al] - 'A');
    if (sh == ah) {
      res.push_back(i + 1);
    }
  }
  return res;
}

int main() {
  string A, S;
  cin >> S >> A;
  vector<ll> ans = rolling_hash(A, S);
  for (ll i = 0; i < ans.size(); ++i) {
    cout << ans.at(i) << "\n";
  }
}



Measured memory_bytes: 13536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = -LINF;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
from collections import Counter

N = int(input())
l = list(map(int, input().split(' ')))
l_odd = l[0::2]
l_even = l[1::2]
dict_odd = Counter(l_odd)
dict_even = Counter(l_even)
most_odd = dict_odd.most_common()[0][0]
most_even = dict_even.most_common()[0][0]

if dict_odd.most_common()[0][1] == dict_even.most_common()[0][1] == N / 2:
    if most_odd == most_even:
        ans = N / 2
    else:
        ans = 0

elif dict_odd.most_common()[0][1] == N / 2:
    ans = N / 2 - dict_even.most_common()[0][1]

elif dict_even.most_common()[0][1] == N / 2:
    ans = N / 2 - dict_odd.most_common()[0][1]

elif most_odd != most_even:
    ans = N - dict_odd.most_common()[0][1] - dict_even.most_common()[0][1]

else:
    ans = N - max(dict_odd.most_common()[0][1] + dict_even.most_common()[1][1], dict_even.most_common()[0][1] + dict_odd.most_common()[1][1])

print(int(ans))

Measured memory_bytes: 19040
import java.util.Scanner;
class Main {
    public void kami() {
        		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a > b && a > c){
			int work = c;
			c = a;
			a = work;
			
			if(a > b){
				work = a;
				a = b;
				b = work;
			}
		}else if(b > a && b > c){
			int work = c;
			c = b;
			b = work;
			
			if(a > b){
				work = b;
				b = a;
				a = work;
			}
		}else if(c > a && c > b){
			if(a > b){
				int work = b;
				b = a;
				a = work;
			}
		}
		System.out.println(a + " " + b + " " + c);
    }
	public static void main(String[] args) {
        new Main().kami();
	}

}

Measured memory_bytes: 17216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll int64_t
using namespace std;

ll power(ll n){
    if(n==1) return 1;
    return power(n-1)*n%(ll)(pow(10,9)+7);
}

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
//#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

void _main()
{
    COMinit();

    ll N, A, B, C;
    cin >> N >> A >> B >> C;

    const ll PA = A * modinv(A + B, MOD) % MOD;
    const ll PB = B * modinv(A + B, MOD) % MOD;

    ll ans = 0;
    for (ll i = N; i < 2 * N; ++i)
    {
        ll tmp = ((modpow(PA, N, MOD) * modpow(PB, i - N, MOD) % MOD) + (modpow(PA, i - N, MOD) * modpow(PB, N, MOD) % MOD)) % MOD;
        tmp = (tmp * i) % MOD;
        tmp = (tmp * 100) % MOD;
        tmp = (tmp * modinv(100 - C, MOD)) % MOD;
        tmp = (tmp * COM(i - 1, N - 1)) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include <iostream>
#include <string>

using namespace std;

int main(void)
{

	string S;
	int w;
	cin >> S >> w;

	int l = S.length();

	for (int i = 0; i < l; ++i)
	{
		if (i%w == 0)
		{
			cout << S.at(i);
		}
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

#define MAXN 100005

int n,m,cnt;
long long ans;
int a[MAXN],fa[MAXN];
vector <int> E[MAXN];
vector <int> G;

int find(int x)
{
    if(fa[x]==x)
        return x;
    return fa[x]=find(fa[x]);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        fa[i]=i;
    }
    cnt=n;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        u++,v++;
        if(find(u)!=find(v))
        {
            fa[find(u)]=find(v);
            cnt--;
        }
    }
    if(cnt==1)
    {
        printf("0");
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        //printf("%d %d\n",i,find(i));
        E[find(i)].push_back(a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if((int)E[i].size()==0)
            continue;
        sort(E[i].begin(),E[i].end());
        ans+=E[i][0];
        for(int j=1;j<(int)E[i].size();j++)
            G.push_back(E[i][j]);
    }
    //printf("%d\n",ans);
    sort(G.begin(),G.end());
    cnt-=2;
    if(cnt>(int)G.size())
    {
        printf("Impossible");
        return 0;
    }
    for(int i=0;i<cnt;i++)
        ans+=G[i];
    printf("%lld",ans);
}


Measured memory_bytes: 6528
l = int(input())
l-=1

node = 1
ans = []
while l:
    half = l // 2
    half = l - half
    if l % 2 == 0:
        ans.append((node, -1, l))
        l -= 1
    ans.append((node, node+1, 0))
    ans.append((node, node+1, half))
    l -= half
    node += 1

print("{} {}".format(node, len(ans)))
for a, b, c in ans:
    if b == -1:b = node
    print("{} {} {}".format(a, b, c))
    

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


const LL INF = 100000000;
LL d[200+1][200+1];


int main(void) 
{
	int N,M,R;
	cin >> N >> M >> R;
	vector<int> v(R);
	int rs = 1;
	
	for(int i=0; i<R; i++) {
		cin >> v[i];
		rs *= (i+1); 
	}

	for( int i=1; i<= N;i++) {
		for( int j=1; j<=N; j++) {
			d[i][j] = INF;
			if (i == j) {
				d[i][j] = 0;
			}
		}
	}

	for( int i=0; i< M; i++) {
		int A,B,C;
		cin >> A >> B >> C;
		d[A][B] = C;
		d[B][A] = C;
	}

	for (int i = 1; i <= N; i++)  {
		for (int j = 1; j <= N; j++) { 
			for (int k = 1; k <= N; k++) { 
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}

	LL cost=INF;
	for(int i = 0; i < rs; ++i) {
		LL c = 0;
		int j = 0;
		int prev = 0;
		for(auto x : v) {
			if ( j>0 ) {
				c += d[prev][x];
				c = min(c, INF);
			}
			
			prev = x;
			j++;
		} 
		cost = min(cost , c);
		next_permutation(v.begin(), v.end());     
	}
	
	cout << cost <<endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin >>A>>B;
  	int c=B-1;
  	int d=A-1;
  	if(c%d==0){
      cout<<c/d<<endl;
    }
  	else{
      cout<<c/d+1<<endl;
    }
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	int 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 k;
	cin >> k;

	cout << a[k-1] << endl;



}

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

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

    vector<int> v;
    for (int i = 1; i < 1e4; i++) {
        if (A % i == 0 && B % i == 0) {
            v.push_back(i);
        }
    }
    cout << *(v.rbegin() + K - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split(' ').flat_map(str::parse).collect()
}

fn main() {
    let l1 = read::<u32>();

    let s_ = l1.get(0).unwrap();

    let h = s_ / 60 / 60;
    let m = s_ / 60 % 60;
    let s = s_ % 60;

    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
#include <stdio.h>

int main(void){
    int a,b;
    while(scanf("%d %d",&a,&b)==2){
        int reminder;
        int gcd;
        long lcm;
        int x=a,y=b;
        while(1){
            reminder=a%b;
            if(reminder==0) break;
            a=b;
            b=reminder;
        }
        gcd=b;
        lcm=(x/gcd)*(y/gcd)*gcd;
        printf("%d %ld\n",gcd,lcm);
    }
    return 0;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int inpa[1010];
int inpb[1010];

int dp[1010][10010];

int solve(int ind, int remh, int n) {
    if(ind == n) {
        if(remh > 0) return 100000000;
        else return 0;
    }

    if(remh <= 0) return 0;

    if(dp[ind][remh] != -1) return dp[ind][remh];

    int res = 100000000;

    res = min(res, inpb[ind] + solve(ind, remh - inpa[ind], n));
    res = min(res, solve(ind + 1, remh, n));

    dp[ind][remh] = res;

    return res;

}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    memset(dp, -1, sizeof(dp));

    
    int h,n;
    cin>>h>>n;

    for(int i = 0; i < n; i++) {
        cin>>inpa[i]>>inpb[i];
    }

    cout<<solve(0, h, n)<<endl;
    return 0;


}


Measured memory_bytes: 40320
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n,k =  map(int, sys.stdin.readline().split())
s=  list(sys.stdin.readline().rstrip())
ans=0

for i in range(1,n):
        if s[i] == s[i-1]:
                ans +=1
print(min(ans+k*2,n-1))
#連続するLRをグループ単位で見るのがポイント
#n-1(限度) - 異なるグループの個数(=グループの個数)
#初期値＋2k（1回の操作で最大＋２）とn-1のminをとる

Measured memory_bytes: 6108
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def parunyasu(a, b, p, q):
  reans = ans
  rd1, rq1, d1, nd1, nq1, q1, _ = naobou(a, q)
  rd2, rq2, d2, nd2, nq2, q2, newans = naobou(b, p)

  if reans <= newans:
    t[d1 - 1] = q1
    t[d2 - 1] = q2
    return newans
  else:
    ayaneru(rd2, rq2, d2, nd2, nq2)
    ayaneru(rd1, rq1, d1, nd1, nq1)
    return reans

def ayaneru(rd, rq, d, nd, nq):
  ZL[rd].insert(rq, d)
  del ZL[nd][nq + 1]

def naobou(d, q):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  return rd, rq, d, nd, nq, q, ans

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

RD = [0] * 26
t = [0] * D
for i in range(D):
  RD[0] += 1
  ma = s[i][0] + RD[0] * c[0]
  man = 0
  for j in range(1, 26):
    RD[j] += 1
    k = s[i][j] + RD[j] * c[j]
    if k > ma:
      ma = k
      man = j
  t[i] = man + 1
  RD[man] = 0

ans = rieshon()
while time.time() - startTime < 1.8:
  l = random.randrange(min(D - 1, 26)) + 1
  d = random.randrange(D - l) + 1
  p = t[d - 1]
  q = t[d + l - 1]
  if p == q: continue
  ans = parunyasu(d, d + l, p, q)

for i in range(D):
  print(t[i])


Measured memory_bytes: 87292
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    const int INF = 1e9;
    cin>>N>>M;
    vector<int> A(M,0);
    vector<int> B(M,0);
    vector<vector<int>> mat(M,vector<int>());
    for(int i=0;i<M;i++){
        cin>>A[i]>>B[i];
        for(int j=0;j<B[i];j++){
            int temp;
            cin>>temp;
            mat[i].push_back(temp);
        }
    }
    vector<int> dp(5000,INF);
    dp[0]=0;
    for(int i=0;i<M;i++){
        int curr=0;
        for(int j=0;j<mat[i].size();j++){
            curr|=(1<<(mat[i][j]-1));
        }
        //cout<<curr<<endl;
        for(int k=0;k<(1<<N);k++){
            dp[curr|k]=min(dp[curr|k],dp[k]+A[i]);
            //cout<<dp[curr|k]<<endl;
        }
    }
    if(dp[(1<<N)-1]==INF){
        cout<<-1<<endl;
    }else{
        cout<<dp[(1<<N)-1]<<endl;
    }
    return 0;
}

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

int main(void)
{
        int i ,N, M, P, sum;

        while(1){
                cin >> N >> M >> P;
                if(N == 0 && M == 0 && P == 0){
                        break;
                }

                sum = 0;
                vector<int> rate(N);
                for(i = 0; i < N; i++){
                        cin >> rate[i];
                        sum += rate[i];
                }
                sum = sum * (100 - P);

                if(rate[M - 1] == 0){
                        cout << "0" << endl;
                }else{
                        cout << sum / rate[M - 1] << endl;
                }
        }
        return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a < c && c < b) || (c < a && b < c)) { 
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = [input() for i in range(3)]
t = [[0] * len(s[i]) for i in range(3)]
for i in range(3):
	for j in range(len(s[i])):
		if s[i][j] == 'a':
			t[i][j] += 0
		elif s[i][j] == 'b':
			t[i][j] += 1
		else:
			t[i][j] += 2

player = 0
now = [0] * 3
while now[player] != len(s[player]):
	now[player] += 1
	player = t[player][now[player] - 1]
if player == 0 : print('A')
elif player == 1 : print('B')
else : print('C')

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

int main() {
	long long N, X[100000], Cur = 0, ANS = 1, MOD = 1000000007;
	vector<long long> V;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];
	for (int i = 0; i < N; i++) {
		if (Cur >= X[i]) {
			V.push_back(i + 1);
		}
		else {
			Cur += 2;
		}
	}
	for (int i = 0; i < V.size(); i++) {
		ANS *= (V[i] - i);
		ANS %= MOD;
	}
	for (int i = V.size(); i < N; i++) {
		ANS *= (N - i);
		ANS %= MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
const int kuai=100;
int aa,bb;
char a[1000][1000];
int main(){
	scanf("%d%d",&aa,&bb);
	for (int i=1;i<=kuai;i++)
		for (int j=1;j<=kuai;j++)
			a[i][j]='.';
	for (int i=1;i<=kuai;i++)
		a[1][i]='#';
	aa--;
	int now=3;
	while (aa)
	{
		for (int i=1;i<=kuai;i++)
			a[now][i]='#';
		a[now-1][1]='#';
		aa--;
		int pnow=3;
		while (aa)
		{
			a[now-1][pnow]='#';
			pnow+=2;
			aa--;
			if ((aa==0)||(pnow>kuai))
			  break;
		}
		now+=2;
	}
	bb--;
	if (bb)
	for (int i=kuai;(i);i-=2)
	{
		for (int j=(i&1)+1;j<=kuai;j+=2)
		{
			a[i][j]='#';
			bb--;
			if (bb==0)
			  break;
		}
		if (bb==0)
		  break;
	}
	cout<<kuai<<' '<<kuai<<endl;
	for (int i=1;i<=kuai;i++)
	{
	  for (int j=1;j<=kuai;j++)
		printf("%c",a[i][j]);
	  printf("\n");
	}
}
			

			

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int N;
    cin>>N;
    map<string, int> data;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        data[s]+=1;
    }
    int datamax=0;
    for(auto d:data){
        datamax=max(datamax,d.second);   
    }
    vector<string> ans;
    for(auto d:data){
        if (d.second == datamax) {
            ans.push_back(d.first);
    }
  }
  
  sort(ans.begin(), ans.end());
  
  for (auto a:ans) {
    cout << a << endl;
  }
  
  return 0;
    }


Measured memory_bytes: 27376
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	p := make([]int,n)
	for i,_ := range p {
		fmt.Scan(&p[i])
	}
	
	cnt := 0
	for i := 1; i < len(p)-1; i++ {
		target := []int{p[i-1],p[i],p[i+1]}
		sort.Ints(target)
		if p[i] == target[1] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
import math
a,b=map(int,input().split())
num=math.gcd(a,b)
if num==1:
    print(1)
else:
    def f(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    l1=f(num)
    print(len(l1)+1)


Measured memory_bytes: 9324
s=input()
flag=True
count=0

if(s[0]!='A'):
    flag=False

for i in range(2,len(s)-1):
    if(s[i]=='C'):
        count+=1
if(count!=1):
    flag=False

for i in s:
    if(i.islower()==False and i!='A' and i!='C'):
        flag=False

if(flag==True):
    print("AC")
else:
    print("WA")






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

int a[5010];
long long int s[5010];
int main(void){
    int n;
    while(cin >> n && n) {
        rep(i, n) cin >> a[i];
        s[0] = 0;
        rep(i, n) s[i+1] = a[i]+s[i];
        long long int ans = numeric_limits<long long int>::min();
        rep(i, n+1) {
            for(int j=i+1; j<n+1; ++j) {
                ans = max(ans, s[j]-s[i]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int x;
    int ans;
    cin >> x;
    if( x < 600){
        ans = 8;
    }else if ( x < 800){
        ans = 7;
    }else if ( x < 1000){
        ans = 6;
    }else if( x < 1200){
        ans = 5;
    }else if( x < 1400){
        ans = 4;
    }else if ( x < 1600){
        ans = 3;
    }else if (x < 1800){
        ans = 2;
    }else{
        ans= 1;
    }
    cout << ans << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include <cstring>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1,INF);
  for(int i=1;i<=n;i*=6){
    a[i] = 1;
  }
  for(int i=1;i<=n;i*=9){
    a[i] = 1;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;i+j<=n;j*=6){
      chmin(a[i+j],a[i]+1);
    }
    for(int j=1;i+j<=n;j*=9){
      chmin(a[i+j],a[i]+1);
    }
  }
  // for(int i=0;i<=n;i++){
  //   cout << a[i] << " ";
  // }
  cout << a[n];
}


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

int main() {

  int A[3],ans=0;
  for (int i=0; i<3; i++)
    cin >> A[i];

  int len = sizeof(A) / sizeof(int);
  sort(A, A+len);

  ans  = abs(A[1]-A[2]);
  ans += abs(A[0]-A[1]);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
working_list = list(map(int, input().split()))
exchange_count = 0  # 交換回数、つまり、列の乱れの程度を示す反転数あるいは転倒数を記録する。
i = 0
flag = True
while flag:
    flag = False
    for j in range(N-1, i, -1):
        if working_list[j] < working_list[j-1]:
            working_list[j-1], working_list[j] = working_list[j], working_list[j-1]
            flag = True
            exchange_count += 1
    i += 1

print(*working_list)
print(exchange_count)



Measured memory_bytes: 5608
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var a = toInt(input[0].split(' '));
	var b = toInt(input[1].split(' '));
	var c = toInt(input[2].split(' '));
	var i = [a,b,c].sort((a,b)=>a-b);
	console.log(i[0]+i[1]+i[2]*10)
	return 0;
}

Measured memory_bytes: 21192
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> answers = new ArrayList<Integer>();
		for(;;){
			int a = scan.nextInt();
			String op = scan.next();
			char o = op.charAt(0);
			int b = scan.nextInt();
			if(o == '?'){
				break;
			}
			int ans = 0;
			switch(o){
				case '+' :
					ans = a + b;
					break;
				case '-' :
					ans = a - b;
					break;
				case '*' :
					ans = a * b;
					break;
				case '/' :
					ans = a / b;
					break;
				default :
					break;
			}
			answers.add(ans);
		}

		for(int an : answers){
			System.out.printf("%d\n", an);
		}
	}
}

Measured memory_bytes: 26520
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N = int(input())

s = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        s += i

print(s)


Measured memory_bytes: 72740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
int main()
{
     ios;
     int n;
     cin >> n;
     double ans = 0, x = 1;
     for (int i = 0, a; i < n; ++i)
     {
          cin >> a;
          ans += x / a;
     }
     cout << x / ans << '\n';
     return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
const int INF = 1001001001;
const int di[] = {0, 1, 0, -1};
const int dj[] = {1, 0, -1, 0};
int main() {
  int  h, w, ans = 0;
  scanf("%d %d", &h, &w);
  vector<string> str(h);
  rep(i, h) cin >> str[i];
  rep(si, h) rep(sj, w) {
    if (str[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i, j));
    };
    update(si, sj, 0);
    while(!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir, 4) {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (str[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j] + 1);
      }
    }
    rep(i, h) rep(j, w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,M,count=0;
  cin>>N;
  cin>>M;
  
  while(M--)
  {
    for(int i=0;i<M;i++)
      count++;
  }
  while(N--)
  {
    for(int j=0;j<N;j++)
      count++;
  }
  cout<<count;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if (a * a * b > 2 * x) {
        ans = atan(a * b * b / 2 / x);
    } else {
        ans = atan(2 * (a * a * b - x) / a / a / a);
    }
    cout << setprecision(12) << ans / M_PI * 180 << endl;
}


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

v = [i for i in range(1,N+1)]
e = [[]]*(N+1)
for i in range(M):
  a, b = map(int,input().split())
  e[a] = e[a] + [b]
  e[b] = e[b] + [a]

def dfs(v, e):
  for num in v:
    if(len(e[num]) == 1):
      tmp_num = e[num][0]
      v.remove(num)
      e[num] = []
      e[tmp_num].remove(num)
      #print(e,v)
      return dfs(v, e)+1
  return 0
print(dfs(v, e))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
lint dp[200][200];
bool visited[200];
set<lint> st0, st1;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	lint x[5];
	REP(i, 5) {
		cin >> x[i];
	}
	lint ans = 0;
	REP(i, 5) {
		if (x[i] != i + 1) {
			ans = i + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f 0 = 0
f n = g n + f (n-1)
  where
    g n
      | mod n 5 == 0 = 1 + g (div n 5)
      | otherwise = 0

main = takeWhile (/=0) . map read . lines <$> getContents >>= mapM_ (print . f)

Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+1,K=2500;
int lp[N],pr[N],cpr=0;
void calc_primes(int n){ 
    assert(n<N);
    for(int i=2;i<=n;++i){
        if(!lp[i])pr[cpr++]=lp[i]=i;
        for(int j=0;j<cpr&&pr[j]<=lp[i]&&i*pr[j]<=n;++j)lp[i*pr[j]]=pr[j];
    }
} 
int a[N];
int32_t main(){
    calc_primes(K);
    int n;
    cin>>n;
    map<vector<pii>,int> cnt;
    int ans=0,eq=0;
    forn(i,n){
        cin>>a[i];
        dbg(a[i]);  
        vector<pii> v;
        forn(j,cpr){
            int cub=pr[j]*pr[j]*pr[j];
            while(a[i]%cub==0){
                a[i]/=cub;
            }
            if(a[i]%(pr[j]*pr[j])==0){
                a[i]/=pr[j]*pr[j];
                v.pb(pr[j],2);
            }
            if(a[i]%pr[j]==0){
                a[i]/=pr[j];
                v.pb(pr[j],1);
            }
        }
        if(a[i]>1){
            if(a[i]>K*K){
                int x=sqrtl(a[i]);
                if(x*x!=a[i]){
                    ans++;
                    dbg("++");
                    continue;
                }else{
                    v.pb(x,2);
                }
            }else{
                v.pb(a[i],1);
            }
        }
        cnt[v]++;
    }

    for(auto&p:cnt){
        vector<pii> comp=p.f;
        // dbg("====");
        // for(pii z:comp)dbg(z.f,z.s);
        // dbg(p.s);
        for(pii&x:comp)x.s^=3;
        int x=p.s,ot=0;
        auto it=cnt.find(comp);
        if(it!=cnt.end())ot=it->s;
        if(comp.empty())ans+=min(1ll,x);
        else if(x>ot)ans+=x;
        else if(x==ot)eq+=x;
        // dbg(x,ot);
    }
    ans+=eq/2;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 13700