akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	gg := make([][]int, n)
	for i := 0; i < n; i++ {
		gg[i] = make([]int, 0)
	}

	ee := make([]Edge, (n-1)*2)
	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		ee[i].a = a
		ee[i].b = b
		ee[i+n-1].a = b
		ee[i+n-1].b = a
		gg[a] = append(gg[a], i)
		gg[b] = append(gg[b], i+n-1)
	}

	ans := make([]int, n-1)

	dfs(0, 0, 0, ee, gg)

	k := 0
	for i := 0; i < len(ee); i++ {
		if ee[i].c != 0 {
			ans[i%(n-1)] = ee[i].c
			if k < ee[i].c {
				k = ee[i].c
			}
		}
	}
	fmt.Fprintln(writer, k)
	for i := 0; i < n-1; i++ {
		fmt.Fprintln(writer, ans[i])
	}

	writer.Flush()
}

type Edge struct {
	a, b, c int
}

func dfs(i, p, c int, ee []Edge, gg [][]int) {
	index := 0
	for _, e := range gg[i] {
		if p == ee[e].b {
			continue
		}
		index++
		if index == c {
			index++
		}
		ee[e].c = index
		dfs(ee[e].b, i, index, ee, gg)
	}
}


Measured memory_bytes: 25088
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, K;
vector<int> h;

int main()
{
    cin >> N >> K;
    h.resize(N);
    cin >> h;
    vector<int> dp(N, 1E9);
    dp[0] = 0;

    REP(i, N)
    FOR(k, 1, K + 1) if (i + k < N) Min(dp[i + k], dp[i] + abs(h[i + k] - h[i]));
    cout << dp.back() << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3144
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string s;
    cin >> s;
    cout << (s[0] - '0') + (s[1] - '0') + (s[2] - '0') << endl;
    

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-
# 桁DP
# 1以上n以下の整数であって、 10進法で表したときに、0でない数字がちょうど
# k個あるようなものの個数

n = input()
k = int(input())
l = len(n)
#dp[i][j][status]   status=0 は小さいのが未確定=i文字まで同じ
#                   status=1 は小さいことが確定
# i桁目まで決めて、0でない桁がj個
# 初期値は1 からスタート s=0,i=0,j=0
dp = [[[0]*2 for j in range(k+1)] for i in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    ni = int(n[i])
    for j in range(k+1):
        for st in range(2):
            for x in range(10):
                i_ = i+1
                j_ = j
                st_ = st
                if x != 0:
                    j_ += 1
                if j_ > k:
                    continue
                if st_ == 0 and x > ni:
                    continue
                if st_ == 0 and x < ni:
                    st_ = 1
                dp[i_][j_][st_] += dp[i][j][st]

print(sum(dp[l][k]))


Measured memory_bytes: 9144
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - 次のアルファベット / Next Letter
            var s = Console.ReadLine().ToCharArray();
            int K = int.Parse(Console.ReadLine());

            //"a"から"z"のアルファベット
            var dic = GetAlphabets();

            //文字列sのアルファベットを、0～25のインデックスに変換したもの
            var S = new int[s.Length];

            for(int i = 0; i < s.Length; i++)
            {
                S[i] = dic[s[i]];
            }

            //文字列sの先頭から順に、aに変えていく
            for(int i = 0; i < S.Length; i++)
            {
                if (S[i] > 0)
                {
                    if (26 - S[i] <= K)
                    {
                        K -= 26 - S[i];
                        s[i] = 'a';
                    }
                }
            }

            //文字列sが"aaaaz"のケースなど、まだ操作が残っているときは
            //残りの回数分、最後の文字を変える
            var last = s[s.Length - 1];
            K %= 26;

            var query = dic.First(x => x.Value == ((dic[last] + K) % 26));
            s[s.Length - 1] = query.Key;

            Console.WriteLine(String.Join("", s));
        }        

        static Dictionary<char, int> GetAlphabets()
        {
            var dic = new Dictionary<char, int>();
            int i = 0;

            for(char c = 'a'; c <= 'z'; c++)
            {
                dic.Add(c, i);
                i++;
            }

            return dic;
        }
    }
}

Measured memory_bytes: 16992
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var a1 = (int)a.Min();
        var a2 =(int) a.Max();
        var ret = 9999999999999L;
        for (int i = a1; i <= a2; i++)
            ret = Math.Min(ret, getA(a, i));
        Console.WriteLine(ret);
    }
    public static long getA (long[] a, int n)
    {
        var ret = 0L;
        for (int i = 0; i < a.Length; i++)
            ret += (a[i] - n) * (a[i] - n);
        return ret;
    }
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n; string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R')++cnt;
    }
    if(cnt * 2 > n)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main() {
  vector<vector<bool>> bingo_hit(3, vector<bool>(3, false));
  unordered_map<int, pair<int, int>> bingo;
  
  for (size_t y = 0; y < 3; ++y) {
    for (size_t x = 0; x < 3; ++x) {
      int n;
      cin >> n;
      bingo[n] = make_pair(y, x);
    } 
  }
  int N;
  cin >> N;
  for (size_t n = 0; n < N; ++n) {
    int lottery;
    cin >> lottery;
    if (bingo.count(lottery)) {
      pair<int, int> pos = bingo[lottery];
      bingo_hit[pos.first][pos.second] = true;
    }
  }
  
  bool res = 
    (bingo_hit[0][0] && bingo_hit[0][1] && bingo_hit[0][2])
    || (bingo_hit[1][0] && bingo_hit[1][1] && bingo_hit[1][2])
    || (bingo_hit[2][0] && bingo_hit[2][1] && bingo_hit[2][2])
    || (bingo_hit[0][0] && bingo_hit[1][0] && bingo_hit[2][0])
    || (bingo_hit[0][1] && bingo_hit[1][1] && bingo_hit[2][1])
    || (bingo_hit[0][2] && bingo_hit[1][2] && bingo_hit[2][2])
    || (bingo_hit[0][0] && bingo_hit[1][1] && bingo_hit[2][2])
    || (bingo_hit[0][2] && bingo_hit[1][1] && bingo_hit[2][0]);
                                      
  if (res) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0; 
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

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

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll a;
	string b;
	cin >> a >> b;

	ll ll_b0 = b[0] - '0';
	ll ll_b1 = b[2] - '0';
	ll ll_b2 = b[3] - '0';

	ll res = 0;
	res = a * ll_b1 * 10LL + a * ll_b2;
	res /= 100LL;
	res += a * ll_b0;

	cout << res << endl;

	return 0;
}

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

	solve();

	return 0;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    rep(i,100){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}


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

int32_t main(){
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    double dp[n+1][n+1]={0};
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=dp[i-1][j]*(1-p[i]);
            if(j>0)dp[i][j]+=dp[i-1][j-1]*p[i];
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<std::fixed;
    cout<<std::setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 74004
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;

int dp[N];
int ile[N];
vvi G(N);

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

    cin >> n >> m;

    FOR(i, m){
    	int a, b;
    	cin >> a >> b;

    	G[b].pb(a);
    	ile[a]++;
    }
    queue<int> kol;
    for(int i = 1; i <= n; i++)
    	if(ile[i] == 0)
    		kol.push(i);
    int ans = 0;
    while(sz(kol)){
    	int x = kol.front();
    	kol.pop();
    	for(auto&u: G[x]){
    		dp[u] = max(dp[u], dp[x]+1);
    		setmax(ans, dp[u]);
    		ile[u]--;
    		if(ile[u] == 0)
    			kol.push(u);
    	}
    }
    cout << ans << '\n';

}

Measured memory_bytes: 31360
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int A = sc.nextInt();
	int tmp = N;
	int flag = 0;
	
	while(A >= 0){
	    if(tmp % 500 == 0){
		flag = 1;;
		break;
	    }else{
		tmp -= 1;
		A -= 1;
		flag = 0;
	    }
	}

	if(flag == 1){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
	
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    string s;
    while(cin >> s, s != "#"){
        int n = s.size();
        auto dp = make_v(n+1, 3, 3, 2, INF<int>);
        for (int i = 0; i < 3; ++i) {
            for (int j = i; j < 3; ++j) {
                for (int k = 0; k < 2; ++k) {
                    dp[0][i][j][k] = 0;
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            int now = (s[i]-'1')%3;
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 3; ++k) {
                    if(now <= k){
                        chmin(dp[i+1][now][k][0], dp[i][j][k][1]);
                        chmin(dp[i+1][now][k][0], dp[i][j][k][0]+1);
                    }
                    if(j <= now){
                        chmin(dp[i+1][j][now][1], dp[i][j][k][1]+1);
                        chmin(dp[i+1][j][now][1], dp[i][j][k][0]);
                    }
                }
            }
        }
        int ans = INF<int>;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 2; ++k) {
                    chmin(ans, dp.back()[i][j][k]);
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 64560
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	if(n%k != 0)
		cout << 1;
	else
		cout << 0;
	return 0;
}

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

typedef long long ll;

int main(void) {
	ll X;
	cin >> X;

	const int INF = 3760;
	const int a = 100;
	int n = 0;
	ll b = (ll)a;
	while (true) {
		++n;
		b += b / 100;
		if (b >= X)
			break;
	}

	cout << n << '\n';
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;cin>>n>>m;
	int ans=0;
	int b;
	for(int i=0;i<m;i++){
		int a;cin>>a;
		if(i==0)ans=max(ans,a-1);
		else ans=max(ans,(a-b)/2);
		b=a;
	}
	ans=max(ans,n-b);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3112
package main 

 import(
     "bufio"
     "fmt"
     "os"
     
     )
var r = bufio.NewReader(os.Stdin)

func main(){
     var x int
     fmt.Fscan(r,&x)
     
     
     x2 := x * x*x
     fmt.Println(x2)
}


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

long long a, b, c;

int main(){
	scanf("%lld%lld%lld", &a, &b, &c);
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) printf("0\n");
	else printf("%lld\n", min(a * b, min(a * c, b * c)));
	return 0;
}


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

 int main() {
   int N, X;
   cin >> N >>X;
   int L[110];
   int  res = 0;
   for (int i = 0; i < N; i++) {
    cin >> L[i];
   }
   int sum = 0;
   for (int i = 0; sum <= X; i++) {
    res++;
    sum += L[i];

   }
   cout << res << '\n';
 }


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

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

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    
    string ans;
    if (a1 + a2 + a3 > 21) { ans = "bust"; }
    else { ans = "win"; }
    
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define MOD 1000000007

typedef vector<int> vi;
typedef pair<int,int> pii;
int main(void) {
  int i,j;
  int n,a;
  cin>>n;
  vi num(n,0);
  rep(i,n){
    cin>>a;
    num[a]++;
  }
  if(n%2){
    if(num[0]!=1){
      cout<<"0"<<endl;
      return 0;
    }
    loop(i,1,n)
      if(i%2 && num[i]){
        cout<<"0"<<endl;
        return 0;
      }else if(i%2==0 && num[i]!=2){
        cout<<"0"<<endl;
        return 0;
      }
  }else{
    rep(i,n)
      if(i%2 && num[i]!=2){
        cout<<"0"<<endl;
        return 0;
      }else if(i%2==0 && num[i]){
        cout<<"0"<<endl;
        return 0;
      }
  }
  a=1;
  rep(i,n/2)
    a=(a*2)%MOD;
  cout<<a<<endl;
}


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

int main() {
  long long n;
  cin>>n;
  string s_n = to_string(n);
  int len = s_n.length();
  int ans = 0;
  bool flag = true;
  for (int i=1; i<s_n.length(); i++) {
    if (s_n[i] != '9') {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout<<(len - 1) * 9 + s_n[0] - '0';
    return 0;
  }
  if (s_n[0] == '1') {
    ans = (len - 1) * 9;
  } else {
    ans = (len - 1) * 9 + s_n[0] - 1 - '0';
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

def aaa(k):
    sum = 0
    for i in range(k):
        a = i + 1
        for j in range(k):
            b = j + 1
            d = math.gcd(a, b)
            for h in range(k):
                c = h + 1
                
                e = math.gcd(c, d)
                
                sum += e
    return sum


k = int(input())
result = aaa(k)
print(result)


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

int main()
{
	string S;
	int i,ans=0;
	cin>>S;
	for(i=0;i<S.size()/2;i++){
		if(S.at(i)!=S.at(S.size()-i-1)){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


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

int n,m,h,d,map[11][30];

bool amida() {
  int x = m;
  for ( int i = 0; i < d; i++ ) {
    if ( map[x-1][i] != 0 ) {
      x--;
    }else if ( map[x][i] != 0 ) {
      x++;
    }
  }
  if ( x == h ) return true;
  return false;
}

int main() {

  while(true) {

    cin >> n;
    if ( n == 0 ) break;

    cin >> m >> h >> d;

    char input;

    for ( int i = 0; i < d; i++ ) {

      for ( int j = 0; j < n+1; j++ ) {

	if ( j == 0 || j == n ) {
	  map[j][i] = 0;
	}else {
	  cin >> input;
	  map[j][i] = input - '0';
	}

      }

    }

    if ( amida() ) {
      cout << 0 << endl;
    }else {

      bool flag = false;

      for ( int i = 0; i < d; i++ ) {

	for ( int j = 1; j < n; j++ ) {

	  if ( map[j-1][i] + map[j][i] + map[j+1][i] == 0 ) {

	    map[j][i] = 1;
	    if ( amida() ) {
	      cout << i+1 << " " << j << endl;
	      flag = true;
	      break;
	    }
	    map[j][i] = 0;

	  }

	}

	if ( flag ) break;

      }

      if ( flag == false ) {
	cout << 1 << endl;
      }

    }

  }
}

Measured memory_bytes: 1160
s = input()
a = 'Yes'
for i in range(len(s)):
  if i%2==0:
    if s[i]!='R' and s[i]!='U' and s[i]!='D':
      a = 'No'
  else:
    if s[i]!='L' and s[i]!='U' and s[i]!='D':
      a = 'No'
print(a)

Measured memory_bytes: 9080
#include <iostream>
using namespace std;
const int lim = 1e6 + 2;
int a[lim],lp[lim],pr[lim],avail[lim];
int n , cnt = 0;
int _gcd(int a,int b){
    if (b == 0) return a;
    return _gcd(b , a % b);
}
void sieve(){
    for (int i = 2; i <= lim; i++){
        if (lp[i] == 0) lp[i] = pr[++cnt] = i;
        int j = 1;
        while (j <= cnt && pr[j] * i <= lim && pr[j] <= lp[i]){
            lp[pr[j] * i] = pr[j];
            j++;
        }
    }
}
bool pairwise_coprime(){
    for (int i = 1; i <= n; i++){
        int save = a[i];
        while (save > 1){
            int temp = lp[save];
            if (avail[temp] > 0) return false;
            while (save % temp == 0) save /= temp;
            avail[temp]++;
        }
    }
    return true;
}
bool setwise_coprime(){
    int temp = a[1];
    for (int i = 2; i <= n; i++) temp = _gcd(temp,a[i]);
    if (temp == 1) return true; else return false;
}
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    fill(avail + 1,avail + lim,0);
    fill(lp + 1,lp + lim,0);
    sieve();
    if (pairwise_coprime() == true){
        cout << "pairwise coprime";
        return 0;
    }
    if (setwise_coprime() == true){
        cout << "setwise coprime";
        return 0;
    }
    cout << "not coprime";
    return 0;
}

Measured memory_bytes: 15056
#include <bits/stdc++.h>
using namespace std;
long int maxjoy(int n,int w,long int arr[][2])
{
  long int dp[n+1][w+1];
  for(long int i=0;i<=n;i++)
  {
      for(long int j=0;j<=w;j++)
      {
          if(i==0||j==0)
            dp[i][j]=0;
          else if(arr[i-1][0]<=j)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i-1][0]]+arr[i-1][1]);
          else
            dp[i][j]=dp[i-1][j];
      }
  }
  return dp[n][w];
}
int main() {
    long int n,w;
    cin>>n>>w;
    long int arr[n][2];
    for(long int i=0;i<n;i++)
    {
        cin>>arr[i][0]>>arr[i][1];
    }
    cout<<maxjoy(n,w,arr);
    return 0;
}


Measured memory_bytes: 79104
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    a_lst.sort()
    a_set_lst = list(set(a_lst))
    a_set_lst.sort()

    count_lst = []
    count = 1
    if n == 1:
        count_lst.append(count)
    else:
        for i in range(n - 1):
            a1 = a_lst[i]
            a2 = a_lst[i + 1]

            if a1 == a2:
                count += 1
                if i == n - 2:
                    count_lst.append(count)
            else:
                count_lst.append(count)
                count = 1
        if a_lst[-1] != a_lst[-2]:
            count_lst.append(count)

    minimum = 0
    for i in range(len(a_set_lst)):
        number = a_set_lst[i]
        count = count_lst[i]

        if count < number:
            minimum += count
        else:
            minimum += count - number

    print(minimum)


if __name__ == '__main__':
    main()

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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h;
    ans /= 2;
    int ans1 = 0;
    if(2 * x == w && 2 * y == h){
        ans1 =1;
    }
    printf("%.6f %d\n", ans, ans1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    long long n,k,i,ans,b;
    cin >> n >> k;
    int a[n];
    for (i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    ans=a[k-1]-a[0];
    for (i=0;i<=n-k;i++){
        b=a[k+i-1]-a[i];
        if (ans>b)
            ans=b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var a = cin.nextInt();
            var b = cin.nextInt();

            Console.WriteLine(Math.Min(a*n,b));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

        public string[] ArrayString(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = next();
            }
            return Array;
        }

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

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

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

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

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


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

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


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

int main() {
    int K; cin >> K;
    int ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
ll n, a, b;
ll sig(ll v){
	return (v * (v-1))/2;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> a >> b;
	if(n < a+b-1 || n > max(sig(a) + sig(b), a*b))eout(-1);
	if(a*b >= n){
		vector<pair<int,int>> res(b);
		res[0] = {n-a+1, n};
		for(int sum = n-a, i = 1;i < b;++i){
			res[i] = {res[i-1].first - min(a, sum-(b-i-1)), res[i-1].first-1};
			sum -= res[i].second - res[i].first + 1;
		}
		for(auto o : res){
			while(o.first <= o.second)cout << o.first++ << ' ';
		}
	}
	else{
		eout(-1);
		// assert(false)
		vector<pair<int,int>> res;
		int sum = 0;
	}
}

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


int main() {

    string s; cin >> s;
    vector<ll> m(3,0);
    string ans = "NO";
    rep(i,s.length()){
        m[(int)(s[i]-'a')] ++;
    }

    if(abs(m[0]-m[1]) <= 1 && abs(m[0]-m[2]) <= 1 && abs(m[1]-m[2]) <= 1){
        ans = "YES";
    }

    cout << ans;
    return 0;
}











Measured memory_bytes: 3732
a = input()
a = [bool(int(a[i])) for i in range(len(a))]
b = True
c = 0
d = 0
for i in range(len(a)):
    if b is a[i]:
        c += 1
    if b is not a[i]:
        d += 1
    b = not b
print(min(c, d))


Measured memory_bytes: 3956
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from random import randint
import sys
M = 2 * (10**5)
def main(D, C, S):
    def evaluate(i, t, satisfaction, last):
        satisfaction += S[i][t]
        last[t] = i
        for j, c in enumerate(C):
            satisfaction -= c * (i - last[j])
        return (satisfaction, last)

    ans = []
    satisfaction = 0
    last = [-1] * 26
    count = [BinaryIndexedTree(D) for _ in range(26)]
    for i in range(D):
        tt = -1
        ts = -10**10
        tl = None
        ps = satisfaction
        pl = last[:]
        for t in range(26):
            s, l = evaluate(i, t, ps, pl[:])
            if ts < s:
                tt = t
                ts = s
                tl = l
        ans.append(tt + 1)
        satisfaction = ts
        last = tl
        count[tt].add(i, 1)

    for i in range(M):
        tmp_s = satisfaction
        d = randint(0, D - 1)
        new = randint(0, 25)
        old = ans[d] - 1
        tmp_s += S[d][new] - S[d][old]
        cnt_old = count[old].query(d)
        nxt_d_old = count[old].bisect(lambda x: x < cnt_old + 1)
        pre_d_old = count[old].bisect(lambda x: x < cnt_old - 1) if cnt_old > 1 else -1
        tmp_s -= C[old] * (nxt_d_old - d) * (d - pre_d_old)
        ans[d] = new + 1
        count[old].add(d, -1)
        count[new].add(d, 1)
        cnt_new = count[new].query(d)
        nxt_d_new = count[new].bisect(lambda x: x < cnt_new + 1)
        pre_d_new = count[new].bisect(lambda x: x < cnt_new - 1) if cnt_new > 1 else -1
        tmp_s += C[new] * (nxt_d_new - d) * (d - pre_d_new)
        if tmp_s < satisfaction:
            ans[d] = old + 1
            count[old].add(d, 1)
            count[new].add(d, -1)
        else:
            satisfaction = tmp_s

    return ans

class BinaryIndexedTree:
    def __init__(self, n=None, f=lambda x, y: x + y, identity=0, initial_values=None):
        assert(n or initial_values)
        self.__f, self.__id, = f, identity
        self.__n = len(initial_values) if initial_values else n
        self.__d = [identity] * (self.__n + 1)
        if initial_values:
            for i, v in enumerate(initial_values): self.add(i, v)

    def add(self, i, v):
        n, f, d = self.__n, self.__f, self.__d
        i += 1
        while i <= n:
            d[i] = f(d[i], v)
            i += -i & i

    def query(self, r):
        res, f, d = self.__id, self.__f, self.__d
        r += 1
        while r:
            res = f(res, d[r])
            r -= -r & r
        return res

    def bisect(self, func):
        n, f, d, v = self.__n, self.__f, self.__d, self.__id
        x, i = 0, 1 << (n.bit_length() - 1)
        while i > 0:
            if x + i <= n and func(f(v, d[x + i])): v, x = f(v, d[x + i]), x + i
            i >>= 1
        return x

if __name__ == '__main__':
    input = sys.stdin.readline
    D = int(input())
    *C, = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(D)]
    ans = main(D, C, S)
    for a in ans:
        print(a)


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

using namespace std;

#define ll long long

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

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

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

	vector < pair < ll, ll >> CB(M);
	for (int i = 0; i < M; i++) {
		CB[i] = make_pair(C[i], B[i]);
	}

	sort(A.begin(), A.end(), greater < ll > ());
	sort(CB.begin(), CB.end(), greater < pair < ll, ll > >());

	ll sum = 0;
	int aIndex, cbIndex;
	aIndex = cbIndex = 0;

	int i = 0;

	while (i < N) {
		if (CB[cbIndex].first > A[aIndex]) {
			if (N - i < CB[cbIndex].second) {
				sum += CB[cbIndex].first * (N - i);
				break;
			} else {
				sum += CB[cbIndex].first * CB[cbIndex].second;
				i += CB[cbIndex].second;
			}
			cbIndex++;
		} else {
			sum += A[aIndex];
			i++;
			aIndex++;
		}
	}

	cout << sum << endl;

	return 0;
}


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

from collections import Counter
C=Counter(A)
ANS=0
for i in C.values():
    ANS+=i*(i-1)//2

for a in A:
    k=C[a]

    print(ANS-(k*(k-1)//2)+((k-1)*(k-2)//2))

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
  return a*b/gcd(a, b);
}

PII sub(PII a, PII b) {
  PII tmp;
  if(a.second == b.second) {
    tmp.first = a.first - b.first;
    tmp.second = a.second;
  } else if(a.second < b.second) {
    tmp.first = a.first*(b.second/a.second) - b.first;
    tmp.second = b.second;
  } else {
    tmp.first = -b.first*(a.second/b.second) + a.first;
    tmp.second = a.second;
  }
  int t = gcd(tmp.first, tmp.second);
  tmp.first /= t; tmp.second /= t;
  return tmp;
}

PII add(PII a, PII b) {
  PII tmp;
  if(a.second == b.second) {
    tmp.first = a.first + b.first;
    tmp.second = a.second;
  } else if(a.second < b.second) {
    tmp.first = a.first*(b.second/a.second) + b.first;
    tmp.second = b.second;
  } else {
    tmp.first = b.first*(a.second/b.second) + a.first;
    tmp.second = a.second;
  }
  int t = gcd(tmp.first, tmp.second);
  tmp.first /= t; tmp.second /= t;
  return tmp;
}

signed main(void)
{
  while(true) {
    string s;
    cin >> s;
    if(s == "#") break;
    pair<int, int> a, b;
    bool fir = true;
    int cnt = 0;
    for(int i=s.size(); i>=0; --i) {
      if(s[i] == 'n') {
        if(fir) a = {0, 1}, fir = false;
        else {
          // -90/2^n
          int g = gcd(90, pow(2, cnt));
          PII s = {90/g, pow(2, cnt)/g};
          a = sub(a, s);
        }
        //cout << a.first << " " << a.second << endl;
        cnt++;
      }
      if(s[i] == 'w') {
        if(fir) a = {90, 1}, fir = false;
        else {
          int g = gcd(90, pow(2, cnt));
          PII s = {90/g, pow(2, cnt)/g};
          a = add(a, s);
        }
        //cout << a.first << " " << a.second << endl;
        cnt++;
      }
    }
    if(a.second == 1) cout << a.first << endl;
    else if(a.first == 0) cout << 0 << endl;
    else cout << a.first << "/" << a.second << endl;
  }

  return 0;
}

Measured memory_bytes: 3316
while True:
	h, w = map(int, raw_input().split())
	if (h == 0) and (w == 0):
		break
	for i in xrange(h):
		line = ""
		for j in xrange(w):
			if ((i%2+j%2)%2 == 0):
				line += "#"
			else:
				line += "."
		print line
	print 

Measured memory_bytes: 4212
#include<cstdio>

int main()
{
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    if(N==1){
        if(A==B)
            printf("1\n");
        else
            printf("0\n");
    }
    else{
        if(A>B)
            printf("0\n");
        else
            printf("%lld\n",(long long )(N-2)*(B-A)+1);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char a[100005];
     scanf("%s", a);
     int n = strlen(a);
     int b = 0, c = 0;
     for(int i = 0; i < n; ++i)
     {
         if(a[i] == '0')
             b++;
         else if(a[i] == '1')
             c++;
     }
     printf("%d\n", min(b, c)*2);
     return 0;
 }

Measured memory_bytes: 384
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  int t,a;
  cin >> t >>a;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  int num=1000000000;
  int num2;
  rep(i,n){
    if(num >abs(a*1000-(t*1000-h.at(i)*6))){
      num = abs(a*1000-(t*1000-h.at(i)*6));
      num2 = i;
    }
  }
  cout << num2+1 <<endl;
}

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

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()

const long long MXN = 2e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;

using namespace std;

int n, k, x, cnt[MXN], ans;

int main(){
    ios;
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> x;
        cnt[x]++;
    }sort(cnt + 1, cnt + 200001);
    reverse(cnt + 1, cnt + 200001);
    for(int i = 1; i <= k; i++){
        ans += cnt[i];
    }cout << n - ans;
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

g = [[] for _ in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

l = [0]*n

for _ in range(q):
    p, x = map(int, input().split())
    l[p-1] += x

visited = [False]*n
visited[0] = True

q = [0]

while q:
    v = q.pop()
    for w in g[v]:
        if not visited[w]:
            visited[w] = True
            l[w] += l[v]
            q.append(w)

print(*l)


Measured memory_bytes: 92876
#include<stdio.h>

int main(){
	int i,j,ans=0;
	int n,v[50],c[50];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&v[i]);
	for(i=0;i<n;i++)scanf("%d",&c[i]);
	for(i=0;i<n;i++){
		if(v[i]>c[i])ans+=(v[i]-c[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int H, W;
vector<string> F;
vector<vector<int>> cnt;
queue<pair<int, int>> que;

void bfs(){
    while(!que.empty()){
        pair<int, int> now = que.front();
        que.pop();
        for(int i = 0; i < 4; i++){
            pair<int, int> next;
            next = make_pair(now.first + dy[i], now.second + dx[i]);
            if(next.first < 0 || H <= next.first)continue;
            if(next.second < 0 || W <= next.second)continue;
            if(F[next.first][next.second] == '#')continue;
            cnt[next.first][next.second] = cnt[now.first][now.second] + 1;
            F[next.first][next.second] = '#';
            que.push(next);
        }
    }
    return;
}

int main(){
    cin >> H >> W;
    F.resize(H);
    cnt.assign(H, vector<int>(W, 0));
    
    for(int i = 0; i < H; i++){
        cin >> F[i];
        for(int j = 0; j < W; j++){
            if(F[i][j] == '#')que.push(make_pair(i, j));
        }
    }
    
    bfs();
    
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            ans = max(ans, cnt[i][j]);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13456
wa = {}
wa["AC"] = 0
wa["WA"] = 0
wa["TLE"] = 0
wa["RE"] = 0

for _ in range(int(input())):
  st = input()
  wa[st] += 1
  
print("AC x ",wa["AC"])
print("WA x ",wa["WA"])
print("TLE x ",wa["TLE"])
print("RE x ",wa["RE"])

    

Measured memory_bytes: 9192