akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string s,t;
    cin >> s >> t;
    vi start(26,-1);
    vi goal(26,-1);

    rep(i,s.size()){
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if(start[a] != -1 || goal[b] != -1){
            if(start[a] != b || goal[b] != a){
                No
            }
        }
        else {
            start[a] = b;
            goal[b] = a;

        }
        
    }
    Yes

    return 0;
}
    

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  double N,K;
  cin>>N>>K;
  double ans=0;
  for(int i=1;i<=N;i++){
    int sum=i;
    int cnt=0;
    while(K>sum){
     cnt++;
     sum*=2;
    }
    ans=ans+(double)1/(double)pow(2,cnt);
  }
  cout<<fixed<<setprecision(15)<<ans/N<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char str[4];
    while(cin>>str){
        int flag=1;
        for(int i=0;i<strlen(str)-1;i++){
            if(str[i]==str[i+1]){
                cout<<"Bad"<<endl;
                flag=0;
                break;
            }
        }
        if(flag)cout<<"Good"<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (1 << 29)
#define MOD 10000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  bool flag = true;
  int n;
  string s;
  cin >> n >> s;
  if(n & 1)flag = false;
  n >>= 1;
  if(s.substr(0,n) != s.substr(n,n))flag = false;
  if(flag)cout << "Yes";
  else cout << "No";


  return 0;
}

Measured memory_bytes: 256
/*
        Choo Lo jo mujhe tum kabhi, kho na jaoon main raat din
    Nazaron mein tum ho basey
        Keh do jo tum ek baar, Mere ho bas tum mere
    Nazaron mein tum ho basey
*/
 
#include<bits/stdc++.h>
#include<cstdio>
 
#define deb(x) cout << #x << " -> " << x << el
#define db double
#define ll long long int
#define ull unsigned long long int
#define umap unordered_map
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define umap unordered_map
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x,y) memset(x, y, sizeof(x))
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ppi pair<int, pii>
#define mat vector<vector<ll> > 
#define mod 1000000007
#define MAX 100005
 
using namespace std;

const int INF = 1e9 + 5;

void solve() {
	int n;
	sc(n);

	int h[n];
	f(i,0,n) {
		sc(h[i]);
	}

	vec<int> dp(n + 1, INF);
	dp[0] = 0;
	for(int i=0; i<n-1; ++i) {
		for(int j: { i + 1, i + 2 }) {
			if(j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n-1] << el;
}


int main() {
   // freopen("inp.txt", "r", stdin);
    int ccc = 1;
    // sc(ccc);
    while(ccc--) {
        solve();
    }
 
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i=0; i<N; i++){
	    cin >> A[i];
	}
	int count=0;
	for (int i=0; i<N; i+=2){
	    if (A[i]%2==1) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

char X, Y;

int main() {
	cin >> X >> Y;
	if (X < Y) {
		cout << "<" << endl;
	}
	else if (X > Y) {
		cout << ">" << endl;
	}
	else {
		cout << "=" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

def cost(n, a, m):

  hihumi = 0  #hihumi => 滝本ひふみ

  for i in range(n):
    hihumi += (a[i] - m) ** 2

  return hihumi

N = int(raw_input())
a = map(int, raw_input().split())

ans = 1000000000000

for i in range(min(a), max(a) + 1):
  if (ans > cost(N, a, i)):
    ans = cost(N, a, i)

print ans

Measured memory_bytes: 2568
import sys
from collections import deque
sys.setrecursionlimit(10 ** 8)

n, m = map(int, input().split())

aisles = [[] for _ in range(n)]
visited = [1] + [0] * (n - 1)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    aisles[a].append(b)
    aisles[b].append(a)

q = deque([0])

while q:
    v = q.pop()
    for nex in aisles[v]:
        if visited[nex] != 0:
            continue
        visited[nex] = v + 1
        q.appendleft(nex)

print("Yes")
for point in visited[1:]:
    print(point)


Measured memory_bytes: 94792
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long int LL;
const LL mod = 1000000000+7;
LL mul(LL a, LL b){ return ((a%mod)*(b%mod))%mod;   }
LL add(LL a, LL b){ return ((a%mod)+(b%mod))%mod;   }

void solve(){
	LL A,B,n;
	cin>>A>>B>>n;
	if(n<B){
		LL x = floor((A*n)/B)-A*floor(n/B);
		cout<<x<<endl;
		return;
	}
	else{
		LL x = floor((A*(B-1))/B)-A*floor((B-1)/B);
		cout<<x<<endl;
		return;
	}
	return ;
}

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

	solve();

	// int t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }

	return 0;
}


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

#define rep(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 10;
ld eps = 1e-12;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cout << fixed << setprecision(10);
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for(int a = 0; a <= k; ++a) {
        for(int b = 0; b <= k; ++b) {
            int c = s - a - b;
            if(0 <= c and c <= s && c <= k) {
                ++cnt;
            }
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
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 men = a * b;
    	int hen = a * 2 + b * 2;
        System.out.println(men + " " + hen);
    }

}

Measured memory_bytes: 26224
a,b,c = map(int, input().split())

if a <= b:
    if b <= c:
        print(a,b,c)
    elif c <= a:
        print(c,a,b)
    else:
        print(a,c,b)
else:
    if a <= c:
        print(b,a,c)
    elif c <= b:
        print(c,b,a)
    else:
        print(b,c,a)


Measured memory_bytes: 5592
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp update_pair
#define pb push_back
#define y2 y2228
const string FILENAME = "input";
const int MAXN = 5005;


int n, a, b;
int p[MAXN];
long long dp[MAXN][MAXN];


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  	//read(FILENAME);
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = 1e18;
		}	
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
            if (p[i] < j) {
                chkmin(dp[i + 1][j], dp[i][j] + b);
            } else {
               	chkmin(dp[i + 1][p[i]], dp[i][j]);
                chkmin(dp[i + 1][j], dp[i][j] + a);
            }
		}
	}
	long long ans = 1e18;
	for (int i = 0; i <= n; i++) {
		chkmin(ans, dp[n][i]);
	}
	cout << ans << '\n';
	return 0; 	
}

Measured memory_bytes: 195840
//AtCoder ABC058 B - Checkpoints
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
using Pos=pair<ll,ll>;

int main() {
    int N,M;
    cin>>N>>M;
    vector<Pos> ab(N);
    vector<Pos> cd(M);
    for(auto&& p:ab){
        cin>>p.first>>p.second;
    }
    for(auto&& p:cd){
        cin>>p.first>>p.second;
    }
    auto nearest = [&](Pos p){
        ll max_dist=INT64_MAX;
        ll ret=0;
        for(int i=0;i<cd.size();++i){
            ll cur_dst= abs(cd[i].first-p.first)+abs(cd[i].second-p.second);
            if (cur_dst < max_dist){
				max_dist = cur_dst;
				ret = i;
			}
        }
        return ret+1;
    };
    for(const auto&p:ab){
        auto idx=nearest(p);
        cout<<idx<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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

    return 0;
}


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

char func(int n, char a){
  rep(i, n){
    if(a == 'Z'){
      a = 'A';
      continue;
    }
    a++;
  }
  cout << a;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()){
    func(n, s.at(i));
  }
  cout << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    int m = 1 << n;
    multiset<int> kek;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        kek.insert(a);
    }
    vector<int> keks;
    keks.push_back(*(--kek.end()));
    kek.erase(--kek.end());
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1 << i); j++) {
            auto it = kek.lower_bound(keks[j]);
            if (it == kek.begin()) {
                cout << "No";
                return 0;
            }
            it--;
            keks.push_back(*it);
            kek.erase(it);
        }
    }
    cout << "Yes";
    return 0;  
}

Measured memory_bytes: 13688
n = gets.to_i
arr = gets.split.map(&:to_i)
fr = [0]*n
en = [0]*n

def gcd(a, b)
  b>0 ? gcd(b, a%b) : a
end

fr[0] = arr[0]

(1...n).each do |i|
  fr[i] = gcd(fr[i-1], arr[i])
end

en[n-1] = arr[n-1]

(n-2).downto(0) do |i|
  en[i] = gcd(en[i+1], arr[i])
end

res = [en[1], fr[n-2]].max

(1..n-2).each do |i|
  res = [res, gcd(fr[i-1], en[i+1])].max
end

p res


Measured memory_bytes: 12684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout((a+1)/2);
}

Measured memory_bytes: 256
def MP(lA,nA,lB,nB,lC,nC):
    res=0
    res+=abs(lA-A)+abs(lB-B)+abs(lC-C)
    res+=(nA+nB+nC-3)*10
    return res

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

ans=2**31-1

for k in range(1<<(2*N)): # kは0~4^N-1,2進で2N桁以下
    lA=lB=lC=0 # 各長さの竹を作るの使う竹の長さの初期値の合計
    nA=nB=nC=0 # 各長さの竹を作るのに使う竹の本数
    for i in range(N):
        ti=(k//(4**i))%4 # kの下から2i桁目，2i+1桁目
        if ti==1: # 長さliの竹を長さAの竹に使用
            lA+=l[i]
            nA+=1
        elif ti==2: # B
            lB+=l[i]
            nB+=1
        elif ti==3: # C
            lC+=l[i]
            nC+=1
    if nA>0 and nB>0 and nC>0:
        ans=min(ans,MP(lA,nA,lB,nB,lC,nC))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll modinv(ll a, ll m=mod) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<ll> A(n);
  vector<ll> pos, neg;
  rep(i, n) {
    cin >> A[i];
    if(A[i] >= 0) pos.push_back(A[i]);
    else          neg.push_back(-A[i]);
  }
  if(n==k) {
    ll ans = 1;
    rep(i, n) (ans *= A[i]) %= mod;
    cout << (mod+ans)%mod << "\n";
  } else if((int)neg.size()==n && k%2) {
    sort(all(neg));
    ll ans = 1;
    rep(i, k) (ans *= neg[i]) %= mod;
    cout << (mod-ans) << "\n";
  } else {
    auto comp = [&](ll a1, ll a2) {
      return abs(a1) > abs(a2);
    };
    sort(all(A), comp);
    sort(all(pos), comp);
    sort(all(neg), comp);
    ll ans = 1;
    int pi=0, ni=0;
    rep(i, k) {
      (ans *= A[i]) %= mod;
      (A[i]>=0 ? pi : ni)++;
    }
    if(ans >= 0) {
      cout << ans << "\n";
    } else if(pi == 0) {
      cout << (-ans * modinv(neg[ni-1]) % mod) * pos[pi] % mod << "\n";
    } else if(ni == (int)neg.size()) {
      cout << (-ans * modinv(neg[ni-1]) % mod) * pos[pi] % mod << "\n";
    } else { // ni is always greater than 0
      if(pos[pi-1] * pos[pi] > neg[ni-1] * neg[ni]) {
        cout << (-ans * modinv(neg[ni-1]) % mod) * pos[pi] % mod << "\n";
      } else {
        cout << (-ans * modinv(pos[pi-1]) % mod) * neg[ni] % mod << "\n";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 6832
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
void solve() {
    string s;
    while(cin >> s) {
        string t = ""; t += s[0];
        for (int i = 1; i < s.size(); i++) {
            if(s[i] != s[i - 1])
                t += s[i];
        }
        //cout << t << endl;
        cout << t.size() - 1 << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
vector<int> G[MAX_N],G2[MAX_N*3];
queue<P> Q;
bool visit[MAX_N*3];
int d[MAX_N*3];

int main()
{
	int N,M;
	cin >> N >> M;
	rep(i,M)
	{
		int u,v;
		cin >> u >> v;
		u--; v--;
		G[u].push_back(v);
	}
	int S,T;
	cin >> S >> T;
	S--; T--;
	rep(i,N)
	{
		rep(j,G[i].size())
		{
			G2[i].push_back(N+G[i][j]);
			G2[N+i].push_back(2*N+G[i][j]);
			G2[2*N+i].push_back(G[i][j]);
		}
	}
	Q.push(P(S,0));
	while(!Q.empty())
	{
		P p = Q.front();
		Q.pop();
		if (!visit[p.first])
		{
			visit[p.first] = true;
			d[p.first] = p.second;
			rep(i,G2[p.first].size())
			{
				Q.push(P(G2[p.first][i],p.second+1));
			}
		}
	}
	if (d[T] == 0) cout << "-1" << endl;
	else cout << d[T] / 3 << endl;
	return 0;
}

Measured memory_bytes: 23552
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll h, w;

ll del(ll a, ll b, ll c){
    return max(max(a, b), c) - min(min(a, b), c);
}

ll solve(){
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0) return 0;
    ll ans = min(h, w);
    for(int i = 1; i < h; ++i){
        ll s1 = i * w;
        ll s2 = (h - i) * (w / 2);
        ll s3 = h * w - s1 - s2;
        ans = min(ans, del(s1, s2, s3));
    }
    for(int i = 1; i < w; ++i){
        ll s1 = i * h;
        ll s2 = (w - i) * (h / 2);
        ll s3 = h * w - s1 - s2;
        ans = min(ans, del(s1, s2, s3));
    }
    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

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

    ll n,m;
    cin>>n>>m;
    vector<ll> ans(m+1);
    FOR(i,0,n){
      ll in;
      cin>>in;
      FOR(i,0,in){
        ll x;
        cin>>x;
        ans[x]++;
      }
    }

    ll res=0;
    FOR(i,0,m+1){
      if(ans[i]==n){
        res += 1;
      }
    }
    cout<<res<<endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

double q;
int N;


double ans0;
vpint G[111111];

double dfs(int v,int p){
    double res=0;
    for(auto &e:G[v]){
        if(e.fi==p)continue;
        double tmp=dfs(e.fi,v);
        res+=q*(e.se+tmp);
    }
    return res;
}

double dfs2(int v,int p){
    double res=ans0;
    for(auto &e:G[v]){
        if(e.fi==p)continue;
        double tmp=dfs2(e.fi,v);
        res+=q*(e.se+tmp);
    }
    return res;
}

signed main(){
    cin>>q>>N;
    rep(i,N-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,c});
    }
    ans0=dfs(0,-1);
    printf("%.20f\n",dfs2(0,-1));
    return 0;
}

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

using namespace std;

#define min(a,b) a > b ? b : a

int main()
{
    int n;
    int k;
    scanf("%d",&n);
    scanf("%d",&k);
    int* hei = new int[n];
    for(int i=0;i<n;i++)
    scanf("%d",&hei[i]);
    int* ans = new int[n];//it tells the cost to reach i+1th stone
    ans[0]=0;
    ans[1]= abs(hei[1]-hei[0]);
    for(int i=2;i<n;i++)
    ans[i]=2147483647;
    for(int i=2;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(j>i) break;
            ans[i]=min(ans[i],ans[i-j]+abs(hei[i]-hei[i-j]));
        }
    }
    cout<<ans[n-1];
    return 0;
}

Measured memory_bytes: 1024
A,B,C=map(int,input().split())
K=int(input())
if(A==max(A,B,C)):
    print(A*(2**K)+B+C)
elif(B==max(A,B,C)):
    print(A+B*(2**K)+C)
else:
    print(A+B+C*(2**K))

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
  int n,m,t[111],p,x,i,j,sum;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&t[i]);
  }
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d%d",&p,&x);
    sum=0;
    for(j=0;j<n;j++){
      sum+=t[j];
    }
    sum+=x-t[p-1];
    printf("%d\n",sum);
  }
}

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

using namespace std;

typedef long long ll;
const int MAX_N = (1<<18)-1;

vector<ll> x, dat[MAX_N];

void init(int k, int l, int r)
{
    if (r - l == 1) {
        dat[k].push_back(x[l]);
    } else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(),
              dat[k].begin());
    }
}

int query(int i, int j, ll x, int k, int l, int r)
{
    if (j <= l || r <= i) {
        return 0;
    } else if (i <= l && r <= j) {
        return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
    } else {
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
}

int main()
{
    ll D, Q, l, r, e;
    scanf("%lld", &D);
    x.resize(D);
    for (int i = 0; i < D; i++) {
        scanf("%lld", &x[i]);
    }    
    
    init(0, 0, D);
    
    scanf("%lld", &Q);
    while (Q--) {
        scanf("%lld %lld %lld", &l, &r, &e);
        l--; r--;
        ll a = min(x[l], x[r]) - e, b = max(x[l], x[r]) + e;        
        printf("%lld\n", query(l, r+1, a-1, 0, 0, D) +
                         (r - l + 1) - query(l, r+1, b, 0, 0, D));
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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

    ll x,y;
    cin >> x >> y;
    if (y-x >= x) return cout << x << "\n" , 0;

    if (x >= y)
    {
        ll tmp = x/y;
        x -= tmp*y;
    }


    ll c=100 , mn = x;
    while(c > 0)
    {
        if (x == 0) break;
        c--;
        x = abs(x-y);
        mn = min(mn , x);
    }
    cout << mn << "\n";

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;

void main() {
  auto N = readln.chomp.to!int;
  auto An = readln.split.to!(double[]);

  double sum = 0;
  foreach(a; An) {
    sum += 1.0 / a;
  }

  writefln("%.10f", 1.0f/sum);
}


Measured memory_bytes: 256
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let alls = [for i in scanner.Next() -> (int i) - 48]

    let rec g list r su sa =
        function
        | [] -> su::list, sa::r
        | x::xs ->
            let h = string x
            let c, d = g list r (su + x) (sa + "+" + h) xs
            let e, f = g list r (su - x) (sa + "-" + h) xs
            c @ e, d @ f
    
    let p, q = g [] [] alls.[0] (string alls.[0]) alls.[1..3]
    List.tryFindIndex ((=) 7) p
    |> function
        | Some(x) -> q.[x]
        | None -> ""
    |> printfn "%s=7"


    0


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int k, t, mx;
vi a(100);

int main() {
	cin >> k >> t;
	rep(i,t) {
		cin >> a[i];
		chmax(mx, a[i]);
	}
	cout << max(2*mx-k-1, 0) << ln;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
string ans;
vector<P> vec;
bool dfs(int rem){
    if(rem == 0)return 1;
    //if(rem < 0)return 0;
    for(auto p:vec){
        if(p.first <= rem){
            if(dfs(rem - p.first)){
                ans.push_back(p.second + '0');
                return 1;
            }
        }
    }
    return rem == 0;
}
main(){
    int N,M;
    cin >> N >> M;
    int num[] = {2,5,5,4,5,6,3,7,6};
    int use[9] = {};
    rep(i,0,M){
        int a;
        cin >> a;
        use[a-1] = 1;
    }
    
    rep(i,0,9){
        if(!use[i])continue;
        rep(j,0,9){
            if(!use[j] || i == j)continue;
            /*
            if(num[j] % num[i] == 0){
                if(num[i] < num[j] || num[i] == num[j] && i > j)
                use[j] = 0;
            }*/
            if(num[i] == num[j]){
                if(i < j)use[i] = 0;
                else use[j] = 0;
            }
        }
    }
    
    rep(i,0,9){
        if(use[i])vec.emplace_back(num[i], i+1);
    }
    sort(vec.begin(), vec.end());
    /*
    for(auto p:vec){
        cout << p.first << "," << p.second << endl;
    }
    */
    //dfs(N);
    int dp[N+1] = {},co[N+1][10];
    dp[0] = 1;
    rep(i,0,10)rep(j,0,N+1)co[j][i] = 0;
    rep(i,0,N){
    for(auto p:vec){
            if(p.first + i > N)break;
            if(dp[i + p.first] < dp[i] + 1){
                dp[i + p.first] = dp[i] + 1;
                rep(k,0,10)co[i + p.first][k] = co[i][k];
                co[i + p.first][p.second]++;
            }else if(dp[i + p.first] == dp[i] + 1){
                bool flag = false;
                for(int k = 9;k >= 0;k--){
                    int a = co[i + p.first][k];
                    int b = co[i][k];
                    if(k == p.second)b++;
                    if(a != b){
                        if(a < b)flag = true;   
                        break;
                    }
                }
                if(!flag)continue;
                rep(k,0,10)co[i + p.first][k] = co[i][k];
                co[i + p.first][p.second]++;
            }
        }
    }
    /*
    cout << dp[N] << endl;
    rep(i,0,10)cout << " " << co[N][i] << endl;
    */
    for(int i = 9;i >= 1;i--)ans += string(co[N][i], '0' + i);
    //sort(ans.rbegin(), ans.rend());
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		ArrayList<Long> color = new ArrayList<Long>();
		long small = Long.MAX_VALUE;
		long max = Long.MIN_VALUE;
		for (int i = 0; i < N; i++) {
			long a = scn.nextLong();
			if(i==0) {
				color.add(a);
				continue;
			}
			int pos = check(color,a);
			if(pos == color.size()-1) {
				if(color.get(color.size()-1) >= a) {
					color.add(a);
					continue;
				}
			}
			if(pos == 1) {
				if(a > color.get(0)) {
					color.set(0, a);
					continue;
				}
			}
			color.set(pos, a);
		}
		System.out.println(color.size());
	}

	public static int check(ArrayList<Long> color, long elem) {
		int upper = 0; // 下限
		int lower = color.size() - 1; // 上限
		while ((lower-upper)>1) {
			int mid = (lower + upper) / 2;
			if(color.get(mid) < elem) {
				lower = mid;
			}else {
				upper = mid;
			}
		}
		return lower;
	}

}


Measured memory_bytes: 62536
#include <cstdio>

int main(){
  int a[4];
  for(int i = 0 ; i < 4 ; i++) scanf("%d", &a[i] );
  int sum = 0;
  if(a[0] > a[1]){
    for(int i = 0 ; i < a[1] ; i++){
      sum += a[2];
    }
    for(int i = a[1] ; i < a[0]; i++){
      sum += a[3];
    }
  }else{
    sum = a[2] * a[0];
  }
  printf("%d\n", sum );
}


Measured memory_bytes: 128
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  vector<string> a(n);
  REP(i,n) cin >> a[i];
  
  vector<string> b(m);
  REP(i,m) cin >> b[i];
  
  REP(i,n-m+1) REP(j,n-m+1){
    bool flag = true;
    REP(x,m) REP(y,m){
      if(a[i+x][j+y] != b[x][y]) flag = false;
    }
    if(flag){
      cout  << "Yes" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
# c行すべての場合を試す
def rec(all,a,k)
    if k == a.length
      all << a.dup
    else
      a[k] = true
      rec(all,a,k+1)
      a[k] = false
      rec(all,a,k+1)
    end
end

# ひっくり返す
def rev(ary)
  0.upto(ary.length-1) do |i|
    ary[i] = 1 - ary[i]
  end
end

loop do
  c,r = gets.split(" ").map(&:to_i)
  break if c ==0 && r ==0
  senbei = []*c
  c.times {|i| senbei[i] = gets.split(" ").map(&:to_i)}

  # c行についてはすべての場合を試す.最大で1024通り
  a = Array.new(c) {false}
  all = []
  rec(all,a,1)

  # main
  max = 0
  all.each do |col|
    cnt = 0
    # 横をひっくり返す
    c.times do |i|
      if col[i]
        rev(senbei[i])
      end
    end

    # 縦の煎餅を数える
    r.times do |i|
      cnt_zero = 0
      c.times do |j|
        cnt_zero += 1 if senbei[j][i] == 0
      end
      cnt += 2 * cnt_zero > c ? cnt_zero : c - cnt_zero
    end

    max = cnt if cnt > max

    # 横をもとに戻す
    c.times do |i|
      if col[i]
        rev(senbei[i])
      end
    end
  end

  puts max
end

Measured memory_bytes: 9948
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a=700;
  string s;
  cin >> s;
  rep(i,0,3){
    if(s[i]=='o') a+=100;
  }
  co(a);
  
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  long long ans = 0;
  int q = x/500;
  x = x % 500;
  int q2 = x/5;
  
  ans = (q*1000) + (q2*5);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


if __name__ == "__main__":
    all_primes = primes(110000)
    while True:
        n = int(input())
        if n == 0:
            break
        s = sum([all_primes[i] for i in range(n)])
        print(s)



Measured memory_bytes: 6744
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

struct Data
{
  vector<i64> s;
  i64 p = 0;
};

int main()
{
  i64 n;
  cin >> n;
  vector<i64> ind(n);
  for (i64 i = 0; i < n; i++)
  {
    i64 p;
    cin >> p;
    ind[p - 1] = i;
  }
  i64 ans = 0, cnt = 1;
  for (i64 i = 0; i < n - 1; i++)
    if (ind[i] < ind[i + 1])
      cnt++;
    else
    {
      ans = max(ans, cnt);
      cnt = 1;
    }
  ans = max(ans, cnt);
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#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 pii pll
#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+5,B=60;
int a[N],c[B],b[B];
void add(int x){
    for(int i=B-1;i>=0;--i){
        if(x>>i&1){
            if(b[i]==-1){
                b[i]=x;
                break;
            }else x^=b[i];
        }
    }
}
int32_t main(){
    int n;
    cin>>n;
    forn(i,n){
        cin>>a[i];
        forn(j,B)if(a[i]>>j&1)c[j]^=1;
    }
    int kek=0;
    forn(j,B){
        if(c[j]){
            kek+=1ll<<j;
            forn(i,n)if(a[i]>>j&1)a[i]^=1ll<<j;
        }
    }
    memset(b,-1,sizeof b);
    forn(i,n)add(a[i]);
    int kok=0;
    for(int i=B-1;i>=0;--i)
        if(b[i]!=-1&&!(kok>>i&1))
            kok^=b[i];
    cout<<kok+kek+kok<<'\n';
    return 0;
}


Measured memory_bytes: 4376
#include <iostream>
using namespace std;
int main(void){
    int a;
     while (1){if (cin >>a){
         if(a%39==0) cout <<"3C39" <<endl;
         else if (a%39<10) cout <<"3C0"<<a%39<<endl;
         else cout <<"3C"<<a%39<<endl;
     } 
         
         else break;
         
         }

}


Measured memory_bytes: 3076
#include<stdio.h>
int main(void)
{
	int a,b,c,cnt,x;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;	x=0;
	while(1){
		x+=a;
		cnt++;
		if(cnt%7==0)	x+=b;
		if(c<=x)	break;
	}
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N, A, B, C;
    vector<int> l;
    int dfs(int i, int a, int b, int c) {
        if (i == N) {
            if (a == 0 || b == 0 || c == 0) return 10000;
            int res = 0;
            res += abs(a - A);
            res += abs(b - B);
            res += abs(c - C);
            return res;
        }
        int res = 10000;
        res = min(res, dfs(i + 1, a, b, c));
        res = min(res, dfs(i + 1, a + l[i], b, c) + 10 * (a > 0));
        res = min(res, dfs(i + 1, a, b + l[i], c) + 10 * (b > 0));
        res = min(res, dfs(i + 1, a, b, c + l[i]) + 10 * (c > 0));
        return res;
    }
    void input() {
        cin >> N >> A >> B >> C;
        l.resize(N);
        REP(i, N) { cin >> l[i]; }
    }
    void output() { cout << dfs(0, 0, 0, 0) << endl; }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val lines = mutableListOf<String>()
    lines.add(readLine()!!)
    println(answer(lines.joinToString("\n")))
}

fun answer(input: String): String {
    return if (input.replace("hi", "").length === 0) { "Yes" } else { "No" }
}


Measured memory_bytes: 38204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

const int MxN = (int) 1e5 + 9;
vector<int> adj[MxN + 9];
int deg[MxN + 9];
multiset<pair<int, int>> res;
bool vis[MxN + 9];

void flip(const int u, const int v) {
	pair<int, int> p = { u, v };
	if (!res.count(p))
		swap(p.first, p.second);
	assert(res.count(p));

	--deg[p.first];
	assert(deg[p.first] >= 0);
	res.erase(res.find(p));
	swap(p.first, p.second);
	res.insert(p);
	++deg[p.first];
}

void dfs(const int u) {
	vis[u] = true;
	for (const int v : adj[u])
		if (!vis[v]) {
			dfs(v);
			if (deg[v] & 1)
				flip(u, v);
		}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		res.insert( { u, v });
		++deg[u];
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	assert((int)res.size() == m);

	dfs(1);
	assert(m % 2 == deg[1] % 2);

	assert(res.size() == m);
	if (deg[1] % 2) {
		cout << -1;
		return 0;
	}
	for (auto p : res)
		cout << p.first << ' ' << p.second << '\n';
	return 0;
}


Measured memory_bytes: 16768
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	std::sort(b,b+a);
	if(b[a-1]-b[0]>1){
		printf("No\n");return 0;
	}
	int L=0;
	for(int i=0;i<a;i++)if(b[0]==b[i])L++;
	int R=a-L;
	//printf("%d %d\n",L,R);
	bool ok=true;
	if(b[0]==b[a-1]){
		if(a<b[0]*2&&a!=b[0]+1){
			ok=false;
		}
	}else{
		if(b[a-1]<L+1||b[a-1]>L+R/2){
			ok=false;
		}
	}
	if(ok)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// Eratosthenesの篩
vector<bool> primeno(1000100, true);
void Eratosthenes(int n) {
    primeno.at(0) = primeno.at(1) = false;
    int limit = sqrt(n)+1;
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i)) {
            for(int j = 0; i*(j+2) < n; ++j) {
                primeno.at(i*(j+2)) = false;
            }
        }
    }
}

int a, d, n;

int main() {
    Eratosthenes(1000100);
    while(1) {
        cin >> a >> d >> n;
        if(a == 0 && d == 0 && n == 0) break;
        int now = a;
        if(primeno[now]) n--;
        while(n != 0) {
            now += d;
            if(primeno[now]) n--;
        }
        cout << now << endl;
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll x;
  cin>>x;
  if(x<1200) {
cout<<"ABC"<<endl;
  }
  else {
cout<<"ARC"<<endl;
  }
}

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

int main(){
    int a, b;

    while(cin >> a >> b, a != 0){
        for(int y = 0; y < a; y++){
            for(int x = 0; x < b; x++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088