akhauriyash/Code-Regression huggingface dataset:
let solve lst =
  let diag c xs = (List.nth xs 0 = c && List.nth xs 4 = c && List.nth xs 8 = c) ||
                    (List.nth xs 2 = c && List.nth xs 4 = c && List.nth xs 6 = c) in
  let hor c xs = List.exists (fun x -> List.nth xs (x+0) = c && List.nth xs (x+1) = c && List.nth xs (x+2) = c) [0;3;6] in
  let ver c xs = List.exists (fun x -> List.nth xs (x+0) = c && List.nth xs (x+3) = c && List.nth xs (x+6) = c) [0;1;2] in
  if diag "o" lst || hor "o" lst || ver "o" lst then "o" else if diag "x" lst || hor "x" lst || ver "x" lst then "x" else "d"

let _ =
  try
    while true do
      let lst = Str.split (Str.regexp "") (read_line ()) in
      Printf.printf "%s\n" @@ solve lst
    done
  with
    End_of_file -> ()

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
string S;
bool s[220000];
int mod = 1e9 + 7;
signed main() {
    cin >> N >> S;
    for (int i = 0; i < 2 * N; i++) { s[i] = S[i] == 'B'; }
    int c = 1;
    for (int i = 2 * N - 2; i >= 0; i--) { s[i] ^= c, c ^= 1; }
    int b = 0;
    for (int i = 0; i < 2 * N; i++) { b += s[i]; }
    if (b != N) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1, w = 0;
    for (int i = 0; i < 2 * N; i++) {
        if (s[i]) { (ans *= w) %= mod, w--; }
        else { w++; }
    }
    for (int i = 2; i <= N; i++) { (ans *= i) %= mod; }
    cout << ans << endl;
}

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

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

    vector<pair<long long, long long>> vec(N);
    //入力
    for(int i=0; i<N; i++){
        long long place, change;
        cin >> place >> change;

        long long max, min;

        max = place + change;
        min = place - change;

        vec[i] = make_pair(max, min);
    }

    //sort関数でmaxが小さい順にソートする
    sort(vec.begin(), vec.end());

    int count = 0;
    long long just_max = 0;
    //maxが小さい順に、既に選択されたものと被っていなければcountをプラスする
    for(int i=0; i<N; i++){
        if(just_max <= vec[i].second || i==0){//被っていないか確認する
            count++;
            just_max = vec[i].first;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int n;
int a[maxn];
int sqr(int x) { return x * x;}
int f(int x)
{
	int ret = 0;
	for(int i = 1; i <= n; ++i) ret += sqr(a[i] - x);
	return ret;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	int l = -100, r = 100;
	while(r - l >= 3)
	{
		int lm = l + (r - l) / 3;
		int rm = r - (r - l) / 3;
		if(f(lm) < f(rm)) r = rm;
		else l = lm;
	}
	int ans = f(l);
	for(int i = l + 1; i <= r; ++i) ans = min(ans, f(i));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long T = scan.nextLong();
        int[] t = new int[N];
        for (int i = 0; i < N; i++) {
            t[i] = scan.nextInt();
        }
        long answer = 0;
        for (int i = 1; i< N; i++) {
            if (t[i-1]+T < t[i]) {
                answer += T;
            } else {
                answer += t[i]-t[i-1];
            }
        }
        answer += T;
        System.out.println(answer);
    }
}


Measured memory_bytes: 65200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <ctime>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 10;
bool flag;
int a[maxn], b[maxn], c[maxn][maxn];

bool judge(int x) {
    b[1] = x;
    for(int i = 1; i <= 3; ++i) {
        a[i] = c[i][1] - b[1];
    }
    for(int i = 2; i <= 3; ++i) {
        b[i] = c[1][i] - a[1];
    }
    for(int i = 2; i <= 3; ++i) {
        for(int j = 2; j <= 3; ++j) {
            if(a[i] + b[j] != c[i][j]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    #ifdef LOCAL
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d", &c[1][1]) != EOF) {
        flag = false;
        for(int i = 1; i <= 3; ++i) {
            for(int j = 1; j <= 3; ++j) {
                if(i != 1 || j != 1) {
                    scanf("%d", &c[i][j]);
                }
            }
        }
        for(int i = -1000; i <= 1000; ++i) {
            if(judge(i)) {
                flag = true;
                break;
            }
        }
        if(flag) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<P> p;
	REP(i, n) {
		ll a;
		cin >> a;
		p.pb(P(a, 0));
	}
	REP(i, n) {
		ll b;
		cin >> b;
		p.pb(P(b, 1));
	}
	sort(ALL(p));
	ll ca = 0, cb = 0;
	ll ans = 1;
	REP(i, 2 * n) {
		if(p[i].second == 0) {
			if(cb == 0) ca++;
			else {
				ans *= cb; ans %= MOD;
				cb--;
			}
		} else {
			if(ca == 0) cb++;
			else {
				ans *= ca; ans %= MOD;
				ca--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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



Measured memory_bytes: 6384
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e5+9;
using namespace std;
int main()
{
	ll n,m,v,p,i,a[maxn]={0},ans=0;
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ans=p;
	v-=(p-1);
	ll sum=a[n-p+1],b=a[n-p+1];
	for(i=n-p;i>=1;i--)
	{
		if(v-i<=0)
		{
			if(a[i]+m>=b)ans++;
		}
		else
		{
			if(sum+(v-i)*m<=(n-p+1-i)*(a[i]+m)&&b<=a[i]+m)ans++;
		}
		sum+=a[i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;


ll a[N] , x  , n;
void f(ll s) {
	while (s < n && a[s] == a[s + 1]) s ++ ;
	if (s == n) {
		x = 1; 
		return ;
	}
	if (a[s] > a[s + 1]) x = 0 ;
	else x = 1 ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n ;
    for (int i = 1 ; i <= n ; i ++) cin >> a[i] ;
    ll po = 1 ;
    ll ans = 0 ;
    while (po <= n) {
    	f(po) ;
    	if (x == 1) {
    		while (po < n && a[po + 1] >= a[po]) po ++ ;
    		ans ++ ;
		}
		else {
			while (po < n && a[po + 1] <= a[po]) po ++ ;
			ans ++ ;
		}
		po ++ ;
	}
    cout << ans ;
    return (0) ;
}

Measured memory_bytes: 1024
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n;
vi p,po,a,b;

signed main(){
    I(n);
    p.resize(n);
    po.resize(n);
    int nind = 0;
    REP(i,n) {
        I(p[i]);
        po[p[i]-1] = i;
    }
    a.resize(n);
    b.resize(n);
    a[n-1] = n*n+1;
    b[n-1] = n*n+1;
    REPN(i,n-1){
        int diff = (po[i] - po[i+1]);
        // cerr << diff << endl;
        a[i] = a[i+1] - 1;
        b[i] = b[i+1] + 1;
        (diff < 0 ? a[i] : b[i]) += diff;
    }
    REP(i,n-1) printf("%lld ",a[i]);
    printf("%lld\n",a[n-1]);
    REP(i,n-1) printf("%lld ",b[i]);
    printf("%lld\n",b[n-1]);

    // REP(i,n) cerr << a[i] + b[i] << " ";
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1, s2;
    cin >> s1 >> s2;
    int n1=s1.size(), n2;
    d(n1)
    map<char, char> mp1, mp2;
    bool ok = true;
    for(int i=0; i<n1; i++)
    {
        char c1 = s1[i];
        char c2 = s2[i];
        if(mp1.count(c1)!=0 or mp2.count(c2)!=0)
        {
            if(mp1[c1]!=c2 || mp2[c2]!=c1)
            {
                ok = false;
                break;
            }
        }
        else
        {
            mp1[c1] = c2;
            mp2[c2] = c1;
        }
    }
    // damp(mp)
    cout << (ok?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int n;
void dfs(int x, string s) {
  if (x == n) {
    cout << s << endl;
    return;
  }

  if (x == 1 && s[0] > 'a')
    return;

  rep(i, 0, n) {
    char maxc = 'a';
    rep(j, 0, (int)s.size()) chmax(maxc, s[j]);
    if (x && (char)(maxc + 1) < (char)('a' + i))
      break;
    dfs(x + 1, s + string{(char)('a' + i)});
  }
}

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

  cin >> n;
  dfs(0, "");
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a,b,d,r;
    double f,fa,fb;
    cin >> a >> b;

    fa=a;
    fb=b;
    
    d = a / b;
    r = a % b;
    f = fa / fb;
    
    printf("%d %d %.8lf\n", d, r, f);
    return 0;
}
    

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

int main(){
  string S,T;
  cin >> S >> T;
  int count=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=2*1e5+4;
signed main(){
    fast_io;
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(auto & z : a) cin>>z;
    map<ll,ll>mp;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;
    }
    cout<<ans;
    return 0;
}
/*
    32+4+4=40
    40
    если WA , то чекер говно, поэтому почекай l8 строчку
    YA
    X.X..
    .....
    .....
    ..X..
    .XXX..
    .XXXX
    .XXXX n/2=2+n
*/


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

pair<pair<string, int>, int> p[110];

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int t;
    string s;
    cin >> s >> t;
    
    p[i] = make_pair(make_pair(s, -t), i);
    
  }
  
  sort(p, p+N);
  for (int i = 0; i < N; i++) {
    cout << p[i].second + 1 << endl;
  }

  
  
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    ans = N//2*min(8*Q, 4*H, 2*S, D) + N%2*min(4*Q, 2*H, S)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint x, y;
    cin >> x >> y;

    lint res = 0;
    lint cur = x;
    while (cur <= y) {
        cur *= 2;
        res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[100005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int n, m, x;
    cin >> n >> m >> x;
    int min1 = min(n + m, min(n + x, m + x));
    cout << min1 << "\n";

    return 0;
}


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    long n,d;
    cin >> n;
    d = -1;
    for(long i = 1; i <= sqrt(n); i++) {
        if(n%i==0){
            d = max(i,d);
        }
    }
    long b = n/d;
    cout << b-1 + d-1 <<endl;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << '+';
    }
    else if(a*b==15){
        cout << '*';
    }
    else{
        cout << 'x';
    }
}

Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
mod = 10**9+7
n = int(input())
ans=0
ans+=pow(10, n, mod)
ans-=pow(9, n, mod)*2
ans+=pow(8, n, mod)
print(ans%mod)


Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
#define MAX5 100010
#define pb push_back
#define mp make_pair
typedef long long int ll;

vector<ll> vec[MAX5];
ll dp[MAX5];

ll dfs(ll src)
{
    
    if(dp[src] != -1)
    return dp[src];
    
   
    ll s=-1;

    for(ll i=0;i<vec[src].size();i++)
    {
          s = max(s,dfs(vec[src][i]));
          
    }
    return dp[src]=s+1;
}
int main()
{
    memset(dp , -1, sizeof dp);
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        vec[x].pb(y);
    }
    ll maxx = 0;
    
    for(ll i=1;i<=n;i++)
    if(dp[i] == -1)
            dfs(i);
    for(int i = 0 ; i<n ;i++)
    maxx = max(dp[i+1] , maxx);
    cout<<maxx<<'\n';
    return 0;
}

Measured memory_bytes: 8576
import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,999):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for e in sys.stdin:print(a[int(e)])


Measured memory_bytes: 44856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61)
typedef long long int ll;

int main() {
	int N, K;
	cin >> N >> K;
	cout << !!(N%K) << endl;
}

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

int main()
{
  vector<int> A(5);

  for(int i=0; i<5; i++){
    cin >> A[i];
  }

  int sum = 0;
  int min_sum = 99999999;
  for(int j=0; j<5; j++){
    sum = 0;
    for(int i=0; i<5; i++){
      if(i == j){
        continue;
      }
      if(A[i] % 10 == 0){
        sum += (A[i]/10)*10;
      }else{
        sum += (A[i]/10)*10 + 10;
      }
    }
    sum += A[j];
    if(min_sum > sum){
      min_sum = sum;
    }
  }
  cout << min_sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		long K = Long.parseLong(s.next());
		int[] A = new int[N + 1];
		for(int i = 1; i < N + 1; i++) {
			A[i] = s.nextInt();
		}
		
		List<Integer> list = new ArrayList<Integer>();
		list.add(1);
		Map<Integer, Integer> map = new HashMap<>();
		map.put(1, 0);
		
		int loopStart = 0;
		int now = 1;
		for(int i = 1; i < N + 1; i++) {
			now = A[now];
			if(Objects.nonNull(map.get(now))) {
				loopStart = map.get(now);
				break;
			}
			map.put(now, i);
			list.add(now);
		}
		
		int size = list.size();
		
		int count = (int)((K - loopStart)%(size - loopStart));
		
		if(K < loopStart) {
			System.out.println(list.get((int)K));
		}else {
			System.out.println(list.get(loopStart + count));
		}
    }
}

Measured memory_bytes: 75968
#include <bits/stdc++.h>
using namespace std;
int main()
{
  
  int n;
  cin>>n;
  double arr[n];
  for ( int i=0;i<n;i++)
    	cin>>arr[i];
 	sort ( arr,arr+n);
  for ( int i=0;i<n-1;i++)
    arr[i+1]=(arr[i]+arr[i+1])/2;
  cout<<arr[n-1];
}

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


class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		int[][] data = new int[H+1][W+1];
		for(int i= 1;i <= H;i++){
			for(int j = 1;j <= W;j++){
				data[i][j] = scan.nextInt();
			}
		}
		ArrayList<Pair> pairs = new ArrayList<Pair>();
		
		int count = 0;
		for(int i= 1;i <= H;i++){
			for(int j = 1;j <= W;j++){
				if(data[i][j] % 2 != 0){
					if(j+1 <= W){
						if(data[i][j+1] % 2 != 0){
							
							data[i][j] --;
							data[i][j+1]++;
							
							count++;
							Pair aPair = new Pair(i,j);
							Pair bPair = new Pair(i,j+1);
							pairs.add(aPair);
							pairs.add(bPair);


						}else if(i+1 <= H && data[i+1][j] % 2 != 0){

							data[i][j]--;
							data[i+1][j]++;
							
							count++;
							Pair aPair = new Pair(i,j);
							Pair bPair = new Pair(i+1,j);
							pairs.add(aPair);
							pairs.add(bPair);

						}else{

							data[i][j]--;
							data[i][j+1]++;
							
							count++;
							Pair aPair = new Pair(i,j);
							Pair bPair = new Pair(i,j+1);
							pairs.add(aPair);
							pairs.add(bPair);

						}
					}else if(i+1 <= H){

						data[i][j]--;
						data[i+1][j]++;
						
						count++;
						Pair aPair = new Pair(i,j);
						Pair bPair = new Pair(i+1,j);
						pairs.add(aPair);
						pairs.add(bPair);

					}
				}
			}
		}
		
		System.out.println(count);
		for(int i = 0;i < pairs.size();i=i+2){
			System.out.print(pairs.get(i).from+" "+pairs.get(i).end + " "+pairs.get(i+1).from+" "+pairs.get(i+1).end );
			System.out.println();
		}
		



	}
}
class Pair implements Comparable{
	int from;
	int end;
	
	public Pair(int a,int b) {
		this.from = a;
		this.end = b;
		
	}
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 104360
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("NO"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vl a(n);
  rep(i,n) scanf("%lld",&a[i]);
  ll s = 0, c = 0;
  rep(i,n) {
    s += a[i];
    c += i+1;
  }
  if (s%c != 0) dame;
  ll d = s/c;
  vl x(n);
  rep(i,n) {
    int j = (i+1)%n;
    ll e = a[j]-a[i]-d;
    e = -e;
    if (e < 0) dame;
    if (e%n) dame;
    e /= n;
    x[j] = e;
  }
  s = c = 0;
  vl y(n);
  rep(ti,2)rep(i,n) {
    c -= y[i]; s -= y[i]*n;
    y[i] = 0;
    c += x[i];
    y[i] = x[i]; x[i] = 0;
    s += c;
    a[i] -= s;
  }
  rep(i,n) if (a[i]) dame;
  cout<<"YES"<<endl;
  return 0;
}






















Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		st.insert(a);
	}
	int ans = st.size();
	cout << ans - 1 + ans % 2 << endl;
	return 0;
}

Measured memory_bytes: 8272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,i,j;
    scanf("%lld %lld",&n,&k);
    long long int ar[n+9],val[n+9]={0};
    for(i=1;i<=n+1;i++)
    {
        val[i]=999999999;
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&ar[i]);
    }
    val[1]=0;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=k && i-j>=1;j++)
        {
            val[i]=min(abs(ar[i]-ar[i-j])+val[i-j],val[i]);
        }
    }
    printf("%lld\n",val[n]);
}


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

# define ll long long
using namespace std;

int main()
{                                 
	ll x;
	cin >> x;     
	ll ans = 0;
	ans += (x/11) * 2;
	x %= 11;   
	if (x) {
		x -= 6;
		ans++;
	}
	if (x > 0) {
		x -= 5;
		ans++;
		}
	cout << ans;
	return 0;
}	


Measured memory_bytes: 256
fn atcoder_beginner_contest_999() -> Result<String, &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_e| "input failed")?;

    Ok(
    // String -> char iterator
    input.trim_right()
        .chars()
        .map(|c| {
            if c == '9' {
                '1'
            }
            else {
                '9'
            }
        })
        .collect()
    )
}

fn main() {
    println!("{}", atcoder_beginner_contest_999().unwrap());
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(12); }; }aaaa;

const double PI = acos(-1);
const double PI_2 = asin(1);

int N;
vector<pair<int, int>> E;

int main() {
    cin >> N;
    int decr = 0;
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            decr++;
            continue;
        }
        E.emplace_back(x, y);
    }
    N = E.size();
    if (N == 0) {
        write(0);
        return 0;
    }

    vector<pair<double, int>> arg;
    rep(i, N) {
        double a;

        if (E[i].first == 0) {
            if (E[i].second > 0) {
                a = PI_2;
            }
            else {
                a = PI + PI_2;
            }
        }
        else if (E[i].second == 0) {
            if (E[i].first > 0) {
                a = 0;
            }
            else {
                a = PI;
            }
        }
        else {
            if (E[i].first > 0) {
                a = atan((double)E[i].second / E[i].first);
            }
            else {
                a = atan((double)E[i].second / E[i].first) + PI;
            }
        }

        arg.emplace_back(a, i);
        arg.emplace_back(a + 2 * PI, i);
    }
    sort(all(arg));

    vector<pair<ll, ll>> sum(2 * N + 1);
    rep(i, 2 * N) {
        sum[i + 1] = pair<ll, ll>(sum[i].first + E[arg[i].second].first, sum[i].second + E[arg[i].second].second);
    }

    double ans = hypot(sum[N].first, sum[N].second);
    rep(i, 0, N) rep(j, i + 1, i + N) {
        ll x = sum[j].first - sum[i].first;
        ll y = sum[j].second - sum[i].second;
        ans = max(ans, hypot(x, y));
    }

    write(ans);
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    char c, r;
    cin >> c;
    switch(c){
        case 'A':
            r = 'T';
            break;
        case 'T':
            r = 'A';
            break;
        case 'C':
            r = 'G';
            break;
        case 'G':
            r = 'C';
            break;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int i,n,k,ans=0;
	cin>>n>>k;
	for(i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(i=n;i>n-k;i--){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

struct magic {
  int a;
  int b;
};

int main() {
  int h, n;
  cin >> h >> n;
  vector<magic> ms(n);
  for (auto &v : ms) {
    int a, b;
    cin >> a >> b;
    v = {a, b};
  }

  vector<int> vec(h+1, INT_MAX);
  vec[0] = 0;
  for (int i = 1; i <= h; ++i) {
    for (auto &m : ms) {
      int idx = max(0, i - m.a);
      vec[i] = min(vec[i], vec[idx] + m.b);
    }
  }

  cout << *vec.rbegin() << endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b<a+c&&a+b<b+c)
	{
		cout<<a+b;
		return 0;
	}
	else if(a+c<a+b&&a+c<b+c)
	{
		cout<<a+c;
		return 0;
	}
	else if(b+c<a+b&&b+c<a+c)
	{
		cout<<b+c;
		return 0;
	}
	cout<<a+b;
	return 0;
}

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

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

    int ans = t.size();
    for (int start = 0; start <= s.size() - t.size(); start++)
    {
        int diff = 0;
        for(int i = 0; i < t.size();i++)
        {
            if(t[i] != s[start + i])
            {
                diff++;
            }
        }
        ans = min(ans,diff);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
n,k= map(int,input().split())
r,s,p= map(int,input().split())
pdic = {'r':p,'s':r,'p':s}
jan= input()
words=['']*k
junbite=[]
junbisu=[]
for i in range(n):words[i%k]+=jan[i]
for i in range(k):
    pre=''
    count=1
    tempte=[]
    tempsu=[]
    for j,c in enumerate(words[i]):
        if j==0:pre=c
        else:
            if pre==c:count+=1
            else:
                tempte.append(pre)
                tempsu.append(count)
                count=1
                pre=c
    else:
        tempte.append(pre)
        tempsu.append(count)
    junbite.append(tempte)
    junbisu.append(tempsu)
g=0
for i in range(k):
    for te,su in zip(junbite[i],junbisu[i]):
        point = su//2
        if su%2==1:point+=1
        g += pdic[te]*point
print(g)


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

int N;
double sum = 0, p[3000], DP[3000][3000]={{0}};

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> p[i];
    DP[0][0]=1;
    for(int i=1;i<=N;i++){
        for(int k=0;k<=i;k++) {
            if(k==0) DP[i][k] = DP[i-1][k]*(1-p[i-1]);
            else DP[i][k] = DP[i-1][k-1]*p[i-1] + DP[i-1][k]*(1-p[i-1]);
        }
    }
    for(int i=N/2+1;i<=N;i++) sum += DP[N][i];
    cout << fixed << setprecision(10) << sum << endl;
    return 0;
}

Measured memory_bytes: 68864
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<memory.h>
#include<ctime>
#include<cstdio>
#include<map>
#include<stack>

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	long long ans=k*pow(k-1,n-1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int a = 0, b = 0;

  rep(i,0,s.size()-1) {
    if (i % 2 == 0) {
      if (s[i] != '0') a++;
    } else {
      if (s[i] != '1') a++;
    }
  }

  rep(i,0,s.size()-1) {
    if (i % 2 == 0) {
      if (s[i] != '1') b++;
    } else {
      if (s[i] != '0') b++;
    }
  }

  cout << min(a, b) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific

typedef unsigned int ui;

using namespace std;

int main(void)
{
    ui x; cin >> x;
    double n = (sqrt(8. * x + 1) - 1) / 2.;
    cout << static_cast<int>(ceil(n)) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


if a == [i for i in range(1, n+1)]:
    print(0)
    
else:
    b = 0
    number = 1
    for i in range(n):
        if a[i] == number:
            number += 1
        else:
            b += 1
    if number == 1:
        print(-1)
    elif b == (n - number + 1):
        print(b)
    else:
        print(-1)    

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

int main(){
  int n;
 string mp;
 cin>>n>>mp;
  int a=0,b=0;
  while(mp[a]=='<')a++;
  while(n-1-b&&mp[n-1-b]=='>')b++;
  cout <<n-min(a,b)<<endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  int count = 0;
  bool flag = false;
  for (int i = 0; i < n; ++i) {
        if (s.substr(i) == t.substr(0, n-i)) {count = i + n;flag = true; break;}
    }
  cout << (flag ? count : 2 * n) << endl;
}


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

typedef long long ll;
typedef pair<int, int> ii;

void mySort(vector<int> &inp)
{
    sort(inp.begin(), inp.end());
    reverse(inp.begin(), inp.end());
}

int main()
{
    int x, y, a, b, c;
    scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);

    vector<int> red, green, cand;
    for (int i = 0; i < a; i++) {
        int num;
        scanf("%d", &num);
        red.push_back(num);
    }
    for (int i = 0; i < b; i++) {
        int num;
        scanf("%d", &num);
        green.push_back(num);
    }
    for (int i = 0; i < c; i++) {
        int num;
        scanf("%d", &num);
        cand.push_back(num);
    }

    mySort(red);
    mySort(green);
    mySort(cand);

    vector<int> orig;
    for (int i = 0; i < x; i++)
        orig.push_back(red[i]);
    for (int i = 0; i < y; i++)
        orig.push_back(green[i]);
    mySort(orig);

    int j = 0;
    for (int i = x + y - 1; i >= 0 && j < c; i--) {
        if (cand[j] > orig[i]) {
            orig[i] = cand[j];
            j++;
        }
    }

    ll ans = 0;
    for (int i = 0; i < x + y; i++)
        ans += orig[i];
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2552
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI a(n);
    REP(i, n) {
        cin >> a[i];
    }

    vector <PII> vp;
    REP(i,n){
        vp.PB(MP(a[i],i));
    }
    SORT(vp);
    int ans=0 ;
    REP(i,n){
        if (vp[i].SND%2!=i%2){
            ans++;
        }
    }

    cout << ans/2 << ENDL;

    return 0;
}

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }





signed main()
{
	string S;
	cin >> S;
	int ans = 700;
	REP(i, 3) if (S[i] == 'o') ans += 100;
	cout << ans << endl;
}


Measured memory_bytes: 3116
S = input()
K = int(input())
 
if len(S) == 1:
    print(K // 2)
    exit()

chkd, flg = 0, 1
cnt = 0
cnt_list =[]
 
for i in range(1, len(S)):
    cnt += 1
    if S[i] != S[i-1]:
        flg = 0
    if chkd == 1:
        chkd = 0
        continue
    if S[i] == S[i-1]:
        cnt_list.append(cnt)
        chkd = 1
 
# 2個連続の場合
S2 = S*2
chkd = 0
cnt = 0
cnt_list2 =[]
 
for i in range(1, len(S2)):
    cnt += 1
    if chkd == 1:
        chkd = 0
        continue
    if S2[i] == S2[i-1]:
        cnt_list2.append(cnt)
        chkd = 1

if flg: # 全部同じ場合
    print(len(S)*K // 2)
elif S[0] == S[-1]:
    print(len(cnt_list) + (len(cnt_list2)-len(cnt_list)) * (K - 1))
else :
    print(len(cnt_list)*K)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector <vector<int>> vec;
vector <int> dp;
vector <int> vis;

void dfs(int i){
    //cout<<i<<endl;
    if(vec[i].size()==0){dp[i]=0;vis[i]=2;}
    vis[i]=1;
    for(auto v:vec[i]){
        if(dp[v]==-1)dfs(v);
        dp[i]=max(dp[v]+1,dp[i]);
    }
    vis[i]=2;
}

int main() {
    int n,m;
    cin>>n>>m;
    vec.assign(n,vector <int>(0));
    dp.assign(n,-1);
    vis.assign(n,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        vec[a].pb(b);
    }
    int mx=-1;
    for(int i=0;i<n;i++){
    if(dp[i]==-1)dfs(i);
    mx=max(mx,dp[i]);}
    cout<<mx<<endl;
    
    
}

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

int main(){
  int n, m; cin >> n >> m;
  vector<int> l(m), r(m);
  for (int i = 0; i < m; i++){
    cin >> l.at(i) >> r.at(i);
  }
  sort(l.rbegin(), l.rend());
  sort(r.begin(), r.end());
  cout << max( (r.at(0)-l.at(0)+1), 0) << endl;
}

Measured memory_bytes: 1024
class UnionFind:
    """Union-Find: O(α(N))"""

    __slots__ = ["_data_size", "_first_idx", "_parents"]

    def __init__(self, data_size: int, is_zero_origin: bool = True) -> None:
        self._data_size = data_size
        self._first_idx = 0 if is_zero_origin else 1
        self._parents = [-1] * (data_size + self._first_idx)

    def _find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self._find(self._parents[x])
        return self._parents[x]

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected or not."""
        return self._find(x) == self._find(y)

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self._find(x), self._find(y)
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x


def unionfind():
    # https://judge.yosupo.jp/problem/unionfind
    # https://atcoder.jp/contests/practice2/tasks/practice2_a
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    unionfind()


Measured memory_bytes: 144920
/* Those who cannot remember the past are condemned to repeat it.*/
/* author:Ajeet */

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int sz=1e7+5;
#define mod 1000000007
#define ull unsigned long long int

int main()
{
    fast_cin();

    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n,greater<int>());
    int ans=0;
    for(int i=0;i<n;i++){
        sum+=arr[i];
        if(sum<k) ans++;
        else sum-=arr[i],ans=0;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
l = int(input())-1
cnt = 0
for i in range(21):
    if l>>i==0:
        digit = i
        break
    if cnt>0 and (l>>i)&1:
        cnt += 1
    if cnt==0 and (l>>i)&1==0:
        cnt = 1
        z = i
if cnt==0:
    print(digit+1, digit*2)
    for i in range(digit):
        print(i+1, i+2, 0)
        print(i+1, i+2, 2**(digit-i-1))
else:
    cnt -= 1
    print(digit, digit*2+cnt-2)
    accu = 2**(digit-1)
    for i in range(digit-1):
        print(i+1, i+2, 0)
        print(i+1, i+2, 2**(digit-i-2))
        if cnt>1 and (l>>(digit-i-2))&1:
            print(1, i+2, accu)
            accu += 2**(digit-i-2)
            cnt -= 1
        elif z==digit-i-2:
            print(1, i+2, accu)

Measured memory_bytes: 9252
def cumulative_sum(l):
    cumu = [0]
    s = 0
    for num in l:
        s += num
        cumu.append(s)
    return cumu

N = int(input())
A = list(map(int,input().split()))

A.sort()

C = cumulative_sum(A)

AM = [C[i+1] for i in range(N)]

k = 1
for i in range(N):
    AM[i] = max(AM[i],AM[max(0,i-1)])
    for j in range(max(k,i+1),N):
        if AM[i]*2 >= A[j]:
            AM[i] += A[j]
            k = j+1
        else:
            break

S = sum(A)
ans = 0
for i in range(N):
    if AM[i] == S:
        ans += 1
print(ans)



Measured memory_bytes: 14480
import math

num = int(input())
sum = 0

for a in range(1, num + 1):
  for b in range(1, num + 1):
    gcd_ab = math.gcd(a, b)
    for c in range(1, num + 1):
      sum += math.gcd(gcd_ab, c)

print(sum)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int cnt[19][19];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int a=i;
    int s=a%10,t;
    while(a){
      t=a%10;
      a/=10;
    }
    cnt[t][s]++;
  }
  ll ans=0;
  for(int i=1;i<=10;i++){
    for(int j=1;j<=10;j++){
      ans+=cnt[i][j]*cnt[j][i];
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    A = [0] + list(map(int, input().split()))
    acc = list(accumulate(A))
    xor = [0]
    for i in range(N):
        xor.append(xor[-1]^A[i+1])
        
    l, r = 1, 1
    res = 0
    while l <= N:
        if acc[r]-acc[l-1] == (xor[r]^xor[l-1]):
            r += 1
            if r == N+1:
                res += (r-l+1)*(r-l)//2
                break
        else:
            temp = l
            l += 1
            while acc[r]-acc[l-1] != (xor[r]^xor[l-1]):
                l += 1
            if l-temp == 1:
                res += r-temp
            else:
                res += (r-temp+r-temp-l+temp+1)*(l-temp)//2
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 84224