akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> p(a), q(b), r(c);

    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    priority_queue<ll, vector<ll>, greater<ll>> rr;
    priority_queue<ll, vector<ll>, greater<ll>> gg;


    rep(i, min(a,x)){
        rr.push(p[i]);
    }

    rep(i, min(b,y)){
        gg.push(q[i]);
    }

    sort(all(r), greater<ll>());

    rep(i, c){
        if(rr.top() > r[i] && gg.top() > r[i]) break;
        if(rr.top() < gg.top()){
            rr.pop();
            rr.push(r[i]);
        } else {
            gg.pop();
            gg.push(r[i]);
        }
    }

    ll ans = 0;
    while(!rr.empty()){
        ans += rr.top();
        rr.pop();
    }
    while(!gg.empty()){
        ans += gg.top();
        gg.pop();
    }

    cout << ans << endl;




}

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

int main(){
    int N, X;  cin >> N >> X;
    int now = 0;
    int ans = 1;
    for(int i=0; i<N; i++){
        int L;  cin >> L;
        now += L;
        if(now <= X){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main() {
  val N = readInt()
  val XY = (1..N).map { readInts() }
  val xPlusYMax = XY.map { (x, y) -> x + y }.max()!!
  val xPlusYMin = XY.map { (x, y) -> x + y }.min()!!
  val xMinusYMax = XY.map { (x, y) -> x - y }.max()!!
  val xMinusYMin = XY.map { (x, y) -> x - y }.min()!!
  println(Math.max(xPlusYMax - xPlusYMin, xMinusYMax - xMinusYMin))
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 81788
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e3+10,mxm=4e5+10,modl=1e9+7;
int nm,n,m,p,t,ans,sum;
int a[mxn],b[mxn],h[mxn];
//string s[mxn];
//bool in[mxn][mxn];
//int tr[][2]={{0,-1},{-1,0},{0,+1}};
//struct pos{
//    int x,y;
//    bool operator < (const pos b)const{
//        return h[x][y]>h[b.x][b.y];
//    }
//};
bool cmp(string a,string b){
    return a+b<b+a;
}
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    cin>>nm;
    string s,s1,s2;char c;
    while(cin>>s){
//        priority_queue<int,vector<int>,greater<int>>q;
        if(s.size()&1) {cout<<"No"; return 0;}
        F(i,0,s.size()){
            if(s[i]!='h'||s[i+1]!='i'){cout<<"No"; return 0;}
            i++;
        }
        cout<<"Yes";
    }
    return 0;
}


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

using namespace std;

int main()
{
	int h, w;
	string s[100];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < h; i++) {
		cout << s[i] << endl << s[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 256
import statistics
N = int(input())
A = list(map(int, input().split()))
B = []

for i in range(len(A)):
    B.append(A[i] - (i+1))

b = statistics.median(B)

ans = 0
for i in range(len(B)):
    ans += abs(B[i] - b)

print(int(ans))


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



namespace CSharpSample01
{

    struct Match
    {
        public int v;
        public int m;
    }

    class Program
    {

        const int MIN = -1000000009;

        static string Solve(int N, int M, Match[] match)
        {
            //dp[i] ;= i本のマッチ棒で作れる最大桁
            int[] dp = new int[N + 1];
            dp[0] = 0;

            //dpを求める
            for(int i = 1; i <= N; i++)
            {
                int max_digi = MIN;
                for(int j = 0; j < M; j++)
                {
                    if(i - match[j].m >= 0 && max_digi < dp[i - match[j].m] + 1)
                    {
                        max_digi = dp[i - match[j].m] + 1;
                    }
                }
                dp[i] = max_digi;
            }

            //Console.WriteLine($"d[N]:{dp[N]}");

            //dpをもとにansを求める
            string ans = "";

            int digi = dp[N];
            int match_num = N;
            while (digi != 0)
            {
                for(int j = 0; j < M; j++)
                {
                    if(match_num - match[j].m >= 0 && dp[match_num] == dp[match_num - match[j].m] + 1)
                    {
                        ans = ans + match[j].v.ToString();
                        match_num -= match[j].m;
                        break;
                    }
                }

                digi--;
            }

            return ans;
        }
        
              
        static void Main(string[] args)
        {
            //N, K, Aの入力
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            //table[i] := 数字iに必要なマッチの本数
            int[] table = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

            //使えるマッチの数字と必要な本数
            Match[] match = new Match[a.Length];
            for(int i = 0; i < a.Length; i++)
            {
                match[i] = new Match() { v = a[i], m = table[a[i]] };
            }

            match = match.OrderByDescending(x => x.v).ToArray();

            Console.WriteLine(Solve(N, M, match));
        }
    }
}

Measured memory_bytes: 27220
// https://atcoder.jp/contests/abc086/tasks/arc089_a
#include <iostream>
#include <cmath>

using namespace std;

int x = 0, y = 0, t = 0,
    px = 0, py = 0, pt = 0;
bool fault = false;

void move()
{
  int dt = t - pt,
      dx = abs(x - px),
      dy = abs(y - py);

  if (dt % 2 == (dx + dy) % 2 && dx + dy <= dt)
  {
    pt = t;
    px = x;
    py = y;
  }
  else
  {
    fault = true;
  }
  return;
}

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

  int n;
  cin >> n;
  for (size_t i = 0; i < n; i++)
  {
    cin >> t >> x >> y;
    if (!fault)
      move();
  }

  string result = !fault ? "Yes" : "No";
  cout << result << "\n";

  return 0;
}


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

int main() {  
  ll n;
  cin >> n;

  bool ans = true;
  ll a;
  for (ll i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      ans = false;
    }
  }

  if (ans) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N, K; cin >> N >> K;

    bitset<205> mk; mk.reset();
    FOR(i, 1, K+1) {
        int d; cin >> d;

        FOR(i, 1, d+1) {
            int x; cin >> x;

            mk[x] = true;
        }
    }

    cout << min(N, N-(int)mk.count()) << "\n";

}


Measured memory_bytes: 3656
X,Y,A,B,C=list(map(int,input().split()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
kouho=p[:X]+q[:Y]
kouho.sort()
for i in range(min(C,X+Y)):
    kouho[i]=max(kouho[i],r[i])
print(sum(kouho))




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

int main() {
	int n; cin >> n;
    double aux = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        aux += (1.0 / double(a));
    }
    printf("%.6f\n", 1.0 / aux);
	return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vector<bool> vis(n,false);
	vi arr(n);
	for(int &i:arr)cin>>i;
	int cnt=0;
	REP(i,0,n-1) {
		if(vis[i])continue;
		vis[i]=true;
		if(arr[arr[i]-1]==i+1){vis[arr[i]-1]=1;cnt++;}
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(y==0)return x;
    return gcd(y,x%y);
}
ll LCM(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(void)
{
    int c[3][3];
    rep(i,0,3){
        rep(j,0,3){
            cin>>c[i][j];
        }
    }
    int a[3],b[3];
    a[0]=0;
    rep(i,0,3){
        b[i]=c[0][i]-a[0];
    }
    rep(i,1,3){
        a[i]=c[i][0]-b[0];
    }

    rep(i,0,3){
        rep(j,0,3){
            if(c[i][j] != a[i]+b[j]){ 
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    int maxa=-10e09;
    int minv=a[0];
    
        for(int i=1;i<n;i++){
            maxa=max(maxa,a[i]-minv);
            minv=min(minv,a[i]);
    }
    
    cout <<maxa <<endl;

    return 0;
}



Measured memory_bytes: 3896
// abc115_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 30)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];

    sort(ALL(H));

    ll ans = INF;
    REP(i, N-K+1){
        ans = min(ans, H[i+K-1] - H[i]);
    }
    print(ans);


    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
inline ll sums(ll a){
	if (a == 0){
		return 0;
	}
	return a*(a+1)/2 % MOD;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin>>n>>k;
	ll ans = 0;
	for (ll i = k; i <= n+1; i++) {
		ans += sums(n) - sums(n-i) - sums(i-1)+1;
		// cout<<sums(n) - sums(n-i) - sums(i-1)+1<<'\n';
		ans %= MOD;
	}
	if (ans < 0){
		ans+=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(){
        int m,d,ans;
        while(1){
        scanf("%d %d",&m,&d);
        if(m == 0 && d == 0){
                break;
        }
        if(m ==1){
                ans = d;
        }else if(m == 2){
                ans = d + 31;
        }else if(m == 3){
                ans = d + 60;
        }else if(m == 4){
                ans = d + 91;
        }else if(m == 5){
                ans = d + 121;
        }else if(m == 6){
                ans = d + 152;
        }else if(m == 7){
                ans = d + 182;
        }else if(m == 8){
                ans = d + 213;
        }else if(m == 9){
                ans = d + 244;
        }else if(m == 10){
                ans = d + 274;
        }else if(m == 11){
                ans = d + 305;
        }else if(m == 12){
                ans = d + 335;
        }
        switch (ans % 7){
        case 0 :
                printf("Wednesday\n");
                break;
        case 1 :
                printf("Thursday\n");
                break;
        case 2 :
                printf("Friday\n");
                break;
        case 3 :
                printf("Saturday\n");
                break;
        case 4 :
                printf("Sunday\n");
                break;
        case 5 :
                printf("Monday\n");
                break;
        case 6 :
                printf("Tuesday\n");
                break;
        }
        }
return 0;
}

Measured memory_bytes: 580
package main

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

func main() {
	scan_init()
	X := scanInt()
		pailist := primeFactorizate(360)
		targetlist := primeFactorizate(X)
		// fmt.Println(pailist,targetlist)
		count := 1
		// fmt.Println(pailist,targetlist)
		for key,val := range pailist {
			if _,ok := targetlist[key]; ok {
				// fmt.Println(key,val, "ari",tar)
				count *= pow(key,val-targetlist[key],key)
			} else {
				// fmt.Println(key,val, "nasi")
				count *= pow(key,val,key)
			}
		}
	fmt.Println(count)
}
func pow(n int, number int,sum int) int {
	if number <= 0 {
		return 1
	}
	if number > 1 {
		return pow(n, number-1, sum*n)
	} else {
		return sum
	}
}
var sc = bufio.NewScanner(os.Stdin)
func scan_init () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}
func primeFactorizate (number int ) map[int]int{
	var N int
	N = number
	var memo map[int]int
	memo = map[int]int{}
	// fmt.Println(N)
	for i:=2; i * i <= N; i++ {
		if N % i == 0{
			target := i
			check := true
			for check {
				check = false
				for j, value := range memo {
					if target%j == 0 {
						target = target / j
						memo [j] = value + 1
						check = true
						break
					}
				}
			}
			if target != 1 {
				// fmt.Println(target)
				memo[target] = 1
			}
			N = N/i
		}
	}
	target := N
	check := true
	for check {
		check = false
		// fmt.Println(memo,target)
		for j, value := range memo {
			// fmt.Println(j,value,target)
			if target%j == 0 {
				target = target / j
				memo [j] = value + 1
				check = true
				break
			}
		}
	}
	if target != 1 {
		// fmt.Println("check",target)
		memo[target] = 1
	}
	return memo
}


Measured memory_bytes: 1780
#include <iostream>
#include <array>
#include <functional>
#include <utility>
#include <regex>

int main()
{
    int64_t N, M, X;
    std::cin >> N >> M >> X;
    std::vector<int64_t> C;
    std::vector<std::vector<int64_t>> A(N);

    for (int64_t n = 0; n < N; ++n)
    {
        int64_t c;
        std::cin >> c;
        C.emplace_back(c);
        std::vector<int64_t> v;
        for (int64_t m = 0; m < M; ++m)
        {
            int64_t a;
            std::cin >> a;
            v.emplace_back(a);
        }
        A[n] = std::move(v);
    }
    int64_t v = std::numeric_limits<int64_t>::max();
    for (int64_t i = 1; i <= (1 << N) - 1; ++i)
    {
        std::vector<int64_t> S(A[0].size());
        int64_t c = 0;
        for (int64_t j = 0; j < N; ++j)
        {
            if ((i >> j) & 1) {
                for (int64_t t = 0; t < M; ++t)
                {
                    S[t] += A[j][t];
                }
                c += C[j];
            }
        }
        bool ng = false;
        for (int64_t t = 0; t < M; ++t)
        {
            if (S[t] < X) {
                ng = true;
                break;
            }
        }
        if (!ng) {
            v = std::min(v, c);
        }
    }

    std::cout << (v == std::numeric_limits<int64_t>::max() ? -1 : v) << std::endl;

    return 0;
}



Measured memory_bytes: 3592
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
const int mod=1e9+7;
int n,ans;
char c[maxn];
int cnt[26];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%s",&n,c);
	rep(i,n)cnt[c[i]-'a']++;
	ans=1;
	rep(i,26)ans=1LL*ans*(cnt[i]+1)%mod;
	printf("%lld\n",(ans+mod-1)%mod);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int N = 2e5 + 10;
 
#define FILENAME ""
 
int n;
int m;

vi vin[N], vot[N];
int dp[N]; 
set<int> s;

int f (int x) {
	s.erase (x);
	if (sz (vot[x]) == 0) re 0;
	if (dp[x] != -1) re dp[x];
	for (int y : vot[x]) {
		dp[x] = max (f(y) + 1, dp[x]);
	}
	re dp[x];
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//  freopen(FILENAME ".in", "r", stdin);
//  freopen(FILENAME ".out", "w", stdout);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		vin[y].pb (x);
		vot[x].pb (y);
	}
	for (int i = 0; i < n; i++) {
		s.insert (i);
		dp[i] = -1;
	}
	while (!s.empty ()) {
		int x = *s.begin();
		f (x);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans = max (ans, dp[i]);
	cout << ans;
    re 0;
}

Measured memory_bytes: 23040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    ll ans = 0;
    for (int bit = 0; bit < (1 << (n - 1)); bit++)
    {
        ll tmp = 0;
        for (int i = 0; i < n; i++)
        {
            tmp = 10 * tmp + (S[i] - '0');
            if (bit & (1 << i))
            {
                ans += tmp;
                tmp = 0;
            }
        }
        ans += tmp;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  import fractions
  input = sys.stdin.readline
  n=int(input())
  a=list(map(int,input().split()))
  ans=a[0]
  for i in range(n):
    ans=fractions.gcd(a[i],ans)
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 16244
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
  b=[str(v) for k,v in enumerate(a) if k%2==0]
  c=[str(v) for k,v in enumerate(a) if k%2==1][::-1]
  print(" ".join(c+b))
else:
  b=[str(v) for k,v in enumerate(a) if k%2==0][::-1]
  c=[str(v) for k,v in enumerate(a) if k%2==1]
  print(" ".join(b+c))

Measured memory_bytes: 33476
# 2020/04/26
# AtCoder Beginner Contest 164 - C

# Input
n = int(input())
s = dict()

# Calc

for i in range(n):
    ins = input()
    if s.get(ins) == None:
        s[ins] = 1
    else:
        s[ins] = s[ins] + 1
ans = len(s)
# Output
print(ans)


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

int main() {
  int n;
  cin >> n;
  if(n%2 == 1) n++;
  cout << n/2-1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if(n < 10) {
			System.out.println(r+(100 * (10-n)));
		}else {
			System.out.println(r);
		}
	}
}

Measured memory_bytes: 23380
#include <stdio.h>

int a[200001], b[500000];

int main()
{
  int n;
  int l = 249999, r = 250000;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(int i = 0; i < n; i++){
    if(i % 2 != 0){
      b[l--] = a[i];
    }else{
      b[r++] = a[i];
    }
  }
  if(n % 2 == 0){
    for(int i = l + 1; i < r; i++){
      printf("%d ", b[i]);
    }
  }else{
    for(int i = r - 1; i > l; i--){
      printf("%d ", b[i]);
    }
  }
  return 0;
}


Measured memory_bytes: 3712
# coding: utf-8
# Your code here!
S=list(input())
S=list(map(int,S))
count=0

for i in range(len(S)-1):
    if S[i]^S[i+1]==0:
        S[i+1]=S[i+1]^1
        count+=1

print(min(count,len(S)-count))


Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	vector<int> dp(N);
	dp.at(1) = abs(v.at(1) - v.at(0));

	for (int i = 2; i < N; i++) {
		dp.at(i) = dp.at(i - 1) + abs((v.at(i) - v.at(i - 1)));

		for (int j = 2; j <= K; j++) {
			if (i < j) continue;
			dp.at(i) = min(dp.at(i), dp.at(i - j) + abs((v.at(i) - v.at(i - j))));
		}
	}

	//for (int i = 0; i < N; i++) cout << dp.at(i) << endl;

	cout << dp.at(N - 1) << endl;
}

Measured memory_bytes: 4052
S = input()

n = len(S)
result = [0] * n
start = 0
c = 'R'
for i in range(1, n):
    if S[i] != c:
        if c == 'R':
            result[i - 1] += (i - start) // 2 + (i - start) % 2
            result[i] += (i - start) // 2
            c = 'L'
        else:
            result[start] += (i - start) // 2 + (i - start) % 2
            result[start - 1] += (i - start) // 2
            c = 'R'
        start = i
result[start] += (n - start) // 2 + (n - start) % 2
result[start - 1] += (n - start) // 2
print(*result)


Measured memory_bytes: 6400
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <algorithm>
using namespace std;

int N;
int a[110];

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

    int ans = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    for (int j = 0; j < N; ++j) {
        if(a[j] == a[j+1]) {
            ans++;
            a[j+1] = 101;
        }
    }

    cout << ans;
    return 0;
}

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

int table[80][80];
bool dp[80][80][15000]={};

int main(){
  int H, W;
  cin >> H >> W;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> table[i][j];
    }
  }
  int m=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int b; cin >> b;
      table[i][j]=abs(table[i][j]-b);
      m=max(m, table[i][j]);
    }
  }
  dp[0][0][table[0][0]]=true;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      for(int k=0; k<=(H+W)*m; k++){
        if(dp[i][j][k]){
          if(j<W-1){
            dp[i][j+1][k+table[i][j+1]]=true;
            dp[i][j+1][abs(k-table[i][j+1])]=true;
          }
          if(i<H-1){
            dp[i+1][j][k+table[i+1][j]]=true;
            dp[i+1][j][abs(k-table[i+1][j])]=true;
          }
        }
      }
    }
  }
  for(int k=0; k<=(H+W)*m; k++){
    if(dp[H-1][W-1][k]){
      cout << k << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 92800
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

vector<int> G[N];
int in[N];
int rt = -1;
int a[N];
LL DFS(int u, int fa) {
	if(in[u] == 1) return a[u];
	LL sum = 0, maxn = 0; 
	for(int v : G[u]) {
		if(v == fa) continue;
		LL t = DFS(v, u);
		if(t < 0) return -1;
		sum += t;
		maxn = max(maxn, t);
	}
	if(a[u] > sum) return -1;
	LL dis = sum - a[u];
	if(dis > min(sum - maxn, sum / 2)) return -1;
	return a[u] - dis;
}
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	for(int i = 1; i < n; i ++) {
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
		in[u] ++, in[v] ++;
		if(rt == -1) {
			if(in[u] > 1) rt = u;
			if(in[v] > 1) rt = v;
		}
	}
	if(rt == -1) {
		if(a[1] == a[2]) puts("YES");
		else puts("NO");
		return 0;
	}
	if(DFS(rt, rt) == 0) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 14336
while gets
  n = $_.to_i
  break if n == 0
  m = Array.new(n).map{ gets.split.map(&:to_i) }
  a = Array.new
  n.times { |i| a << m[i].min }
  mt = m.transpose
  b = Array.new
  n.times { |i| b << mt[i].max }
  puts (a & b).empty? ? 0 : a & b
end

Measured memory_bytes: 8552
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int p = 0;
  for(int i = 0; s.size() > i; i++){
    if(s.at(i) == 'p') p++;
  }
  
  cout << s.size() / 2 - p << endl;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	dp[0] = 1000;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			a = (dp[j] / A[j]) * A[i] + dp[j] % A[j];
			dp[i] = max(dp[i-1], a);
		}
	
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
string k;
int d,len;
int a[100005];
ll dp[100005][105];
ll DFS(int pos,int v,bool lim){
	if(pos==len+1){
		return dp[pos][v]=(v==0);
	}
	if(!lim&&dp[pos][v]!=-1){
		return dp[pos][v];
	}
	int Lim=lim?a[pos]:9;
	ll res=0;
	for(int i=0;i<=Lim;++i){
		res+=DFS(pos+1,(v+i)%d,lim&&(i==Lim));
		if(res>=mod){
			res-=mod;
		}
	}
	if(!lim){
		dp[pos][v]=res;
	}
	return res;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>k>>d;
	len=k.size();
	k=' '+k;
	for(int i=1;i<=len;++i){
		a[i]=k[i]-'0';
	}
	cout<<(DFS(1,0,1)-1+mod)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 83072
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int t;
	int h;
	
	t = 0;
	h = 0;
	
	while (scanf ("%d,%d,%d", &a, &b, &c) != EOF){
		if (a * a + b * b == c * c){
			t++;
		}
		else if (a == b){
			h++;
		}
	}
	
	printf ("%d\n", t);
	printf ("%d\n", h);
	
	return (0);
}

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

ll V[3005][3005];
ll dp[3005][3005][4];

int main() {
    ll R, C, K; cin >> R >> C >> K;
    rep(i, K){
        ll r, c, v; cin >> r >> c >> v;
        r--; c--;
        V[r][c] = v;
    }

    rep(i, R){
        rep(j, C){
            for (int k = 3; k > 0; k--){
                dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1] + V[i][j]);
            }
            rep(k, 4){
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
            }
        }
    }

    ll ma = 0;
    rep(k, 4){
        ma = max(ma, dp[R-1][C-1][k]);
    }
    cout << ma << endl;
    
    return 0;
}

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

int main()
{
  long long X, K, D;
  
  cin >> X >> K >> D;
  
  if (K <= abs (X) / D)
  {
    cout << abs(X) - (K * D);
  }
  else
  {
    K = K - (abs(X) / D);
    
    //cout << K << endl;
    
    if ( K % 2 == 0 ) cout << abs(X) % D;
    
    else cout << abs(abs(X) % D - D);
    
  }
  

}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
ll dp[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    dp[0] = 1;
    for (int i = 3 ; i <= n ; i++){
        for (int j = 3 ; j <= n ; j++){
            if (i - j < 0) continue;
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3648
N,MA,MB = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

INF = 10**9
dp = [[INF for j in range(401)] for i in range(401)]
dp[0][0] = 0
maxa = maxb = 0
for a,b,c in src:
    for ai in range(maxa,-1,-1):
        for bi in range(maxb,-1,-1):
            dp[ai+a][bi+b] = min(dp[ai+a][bi+b], dp[ai][bi] + c)
    maxa += a
    maxb += b

ans = INF
for i in range(1,401):
    if MA*i > 400 or MB*i > 400: break
    ans = min(ans, dp[MA*i][MB*i])
print(-1 if ans == INF else ans)

Measured memory_bytes: 4852
#include <algorithm>
#include <iostream>
#define N 100
#define M 16
#define BIT (1<<16)
using namespace std;
typedef long long ll;
typedef struct data{
  int m,l,s[M],e[M],bit;
} dat;

int main(){
  int n;
  ll ans,dp[BIT];
  dat d[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++){
      cin>>d[i].m>>d[i].l;
      d[i].bit=0;
      for(int j=0;j<d[i].m;j++){
	cin>>d[i].s[j]>>d[i].e[j];
	for(int k=d[i].s[j]-6;k<d[i].e[j]-6;k++) d[i].bit=d[i].bit|(1<<k);
      }      
    }
    for(int i=0;i<BIT;i++) dp[i]=-1;
    dp[0]=ans=0;
    for(int i=0;i<BIT;i++){
      if(dp[i]==-1) continue;
      for(int j=0;j<n;j++)
	if((i&d[j].bit)==0){
	  dp[i|d[j].bit]=max(dp[i|d[j].bit],dp[i]+d[j].l);
	  ans=max(ans,dp[i|d[j].bit]);
	}
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

n, k = map(int, input().split())
parr = list(map(int, input().split()))
carr = list(map(int, input().split()))
scores = []

for i in range(n):
  cur = i
  # 1ループで通るノードの数とスコア
  roop_num = 0
  roop_score = 0
  while True:
    cur = parr[cur] - 1
    roop_num += 1
    roop_score += carr[cur]
    if cur == i:
      break
  tmp_max = -10**9
  # ループしたときにスコアが減るとき
  # kが1ループの回数より小さいとき
  if roop_score <= 0:
    score = 0
    max_iter = roop_num
  elif k <= roop_num:
    score = 0
    max_iter = k
  else:
    # ループする回数
    num = k // roop_num - 1
    score = roop_score*num
    max_iter = k - roop_num*num
  cur = i
  for _ in range(max_iter):
      cur = parr[cur] - 1
      score += carr[cur]
      if score > tmp_max:
        tmp_max = score
  scores += [tmp_max]

print(max(scores))

Measured memory_bytes: 92432
#include<stdio.h>
int main()
{
    int A,B,C,res;
    while(scanf("%d %d %d",&A,&B,&C)!=EOF)
    {
        res=A-B;
        if(res>=C)
            printf("0\n");
        else
            printf("%d\n",C-res);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
  int n,sum=0;
  cin>>n;
  vector<int> b(n-1);
  for(auto& x:b){
    cin>>x;
  }
  sum+=b[0];
  for(int i=1;i<n-1;i++){
    sum+=min(b[i],b[i-1]);
  }
  sum+=b[n-2];
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int a,b,c;
	while(1){
		cin >> a >> b;
		if(!a) break;
		int dp[17][17] = {};
		for(int i = 1;i < 17;i++) for(int j = 1;j < 17;j++) dp[i][j] = INF;
		cin >> c;
		for(int i = 0;i < c;i++){
			int d,e;
			cin >> d >> e;
			dp[d][e] = 0;
		}
		for(int i = 1;i <= a;i++){
			for(int j = 1;j <= b;j++){
				if(i == 1 && j == 1) dp[i][j] = 1;
				else if(dp[i][j]) dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
		}
		cout << dp[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_N 100

int n,time,head,tail;
int *queue;
int *dist;
int *color;
int **matrix;

void enqueue(int);
int dequeue(void);
void bfs(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  queue = malloc(MAX_N * sizeof(int));
  color = malloc(n * sizeof(int));
  dist = malloc(n * sizeof(int));

  matrix = malloc(n * sizeof(int *));
  for(i = 0 ; i < n ; i++){
    matrix[i] = malloc(n * sizeof(int));
 }
 for(i = 0 ; i < n ; i++){
   dist[i] = -1;
 }
 for(i = 0 ; i < n ; i++){
   for(j = 0 ; j < n ; j++){
     matrix[i][j] = 0;
   }
 }

 for(i = 0 ; i < n ; i++){
    scanf("%d",&u); u--;
    scanf("%d",&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      matrix[u][v] = 1;
    }
  }

  bfs();
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i+1,dist[i]);
  }

  for(i = 0 ; i < n ; i++){
    free(matrix[i]);
  }
  free(matrix);
  free(queue);
  free(dist);
  free(color);
  return 0;
}

void bfs(){
  int u,i;

  head = tail = 0;
  color[0] = GRAY;
  dist[0] = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i = 0 ; i < n ; i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
        color[i] = GRAY;
        dist[i] = dist[u] + 1;
        enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int q){
  queue[tail] = q;
  if(++tail == MAX_N+1) tail = 0;
}

int dequeue(){
  int v = queue[head];
  if(++head == MAX_N+1) head = 0;
  return v;
}

Measured memory_bytes: 636
#include<iostream>

using namespace std;

int main(){

    int n, k;
    char src;

    cin >> n;

    char s[n];

    cin >> s >> k;

    src = s[k - 1];

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

        if(src != s[i]){

            s[i] = '*';
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#!/bin/bash
read N K;

#export A # takahashi HP
#export B # takahashi attack
export numCheck=""

while true;
do
        read line1

        if [ -z "$line1" ]; then
                break
        fi

        read line2
        As=`echo ${line2} | sed "y/ /,/" `
        numCheck=${numCheck}${As}","
done

safe=`echo "$numCheck" | sed "s/,$//" |  tr "," "\n" | sort | uniq | wc -l`

echo $(( $N - $safe ))

Measured memory_bytes: 7776
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;


ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b != 0){
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll mod){
  ll x,y;
  extgcd(a,mod,x,y);
  return (mod + x%mod) % mod;
}

 
ll pow_mod(ll x, ll p, ll mod){
  ll res = 1;
  while(p){
    if(p&1) (res *= x) %= mod;
    (x *= x) %= mod;
    p >>= 1;
  }
  return res;
}

vl fact, inv_fact;

ll solve(ll a, ll b, ll c, ll n) {
  ll na = a * mod_inverse(a+b, MOD) % MOD;
  ll nb = b * mod_inverse(a+b, MOD) % MOD;

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ll tmp = pow_mod(na, i, MOD);
    tmp %= MOD;
    tmp *= pow_mod(nb, n, MOD);
    tmp %= MOD;

    ll comb = fact[i+n-1] * inv_fact[i] % MOD * inv_fact[n-1] % MOD;
    tmp *= comb;
    tmp %= MOD;

    tmp *= 100 * i + 100 * n;
    tmp %= MOD;
    tmp *= mod_inverse(100 - c, MOD);
    tmp %= MOD;

    ans += tmp;
    ans %= MOD;
  }
  return ans;
}
  
int main(){
  ll n, a, b, c;
  cin >> n >> a >> b >> c;

  fact = vl(2*n+1, 1);
  inv_fact = vl(2*n+1, 1);
  for (ll i = 1; i <= 2*n; ++i) {
    fact[i] = (i * fact[i-1]) % MOD;
    inv_fact[i] = mod_inverse(fact[i], MOD);
  }

  ll ans = solve(a, b, c, n) + solve(b, a, c, n);
  cout << ans % MOD << endl;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double H,W,x,y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << " ";
    if(2*x==W && 2*y==H){
        cout << 1 << endl;
        return 0;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
/**
* Copyright(c)
* All rights reserved.
* Author : Universal
* Description : sample
*/
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define eps 1.0E-8
using namespace std;
typedef long long ll;
const int MAXN =1e5+5;

int x[MAXN];
bool cmp(int a,int b){
    return a>b;
}
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    sort(x,x+n,cmp);
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += x[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c<22){
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y>>z;
if((z-y)%2==0)std::cout << (z-y)/2 << '\n';
else std::cout << min(min(z-1,x-y),min((y+z-1)/2,(2*x+1-z-y)/2)) << '\n';
}


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

string lis() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    int dp[n + 1][m + 1];

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 or j == 0)
                dp[i][j] = 0;
            else if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
    }

    string ans = "";

    int i = n, j = m;
    while (i > 0 and j > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans += s[i - 1];
            i--;
            j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1]) {
            i--;
        }
        else j--;
    }
    reverse(ans.begin(), ans.end());
    return ans;

}

int main()
{
    cout << lis();
    return 0;
}


Measured memory_bytes: 35456
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            a, b, c = L[i], L[j], L[k]
            if a == b or b == c or c == a:
                continue
            elif a + b > c and b + c > a and c + a > b:
                ans += 1
print(ans)

Measured memory_bytes: 9188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll h,n; cin>>h>>n;
    vector<ll>dp(h+1,INF);
    dp[0]=0;
    rep(i,n){
        ll a,b; cin>>a>>b;
        rep(j,h+1){
            int idx=min(j+a,h);
            dp[idx]=min(dp[idx],dp[j]+b);
        }

    }
    cout<<dp[h]<<endl;
}











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

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

	int a = N / 100;
	int ans = a + a * 10 + a * 100;
	int otan = ans + 111;
	
	if(ans >= N) cout << ans << endl;
	else if(ans < N) cout << otan << endl;
}

Measured memory_bytes: 256
#ABC105-B
n = int(input())
divisor_list = []
ans = 0
for i in range(1,n+1):
    divisor_list = []
    #odd,even判定
    if(i % 2 != 0):
        #約数をdivisor_listに追加していく
        for j in range(1,i+1):
            if (i % j == 0):
                divisor_list.append(j)
            if(len(divisor_list) == 8):
                ans += 1
print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python
num_of_pro = raw_input()
problems = raw_input()
num_of_drinks = raw_input()
drinks_lines = []
count = 0 
while count < int(num_of_drinks):
	count += 1
	each_line = raw_input()
	drinks_lines.append(each_line)
for each_line in drinks_lines:
	problem_num = [int(each_num) for each_num in problems.split()]
	problem_num[int(each_line.split()[0]) -1] = int(each_line.split()[1])
	print sum(problem_num)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define tt long t;cin>>t;while(t--)
#define tez ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define plli pair<lli,lli>
#define vlli vector<lli>
#define vplli vector<plli>
#define pqlli priority_queue <lli>
#define pqplli priority_queue <plli>
#define mplli map<lli,lli>
#define all(v) v.begin(),v.end()
#define alll(s) s.begin(),s.end(),s.begin(), ::tolower
#define allu(s) s.begin(),s.end(),s.begin(), ::toupper

#define mod 1000000007
#define ff first
#define ss second
#define fori(i,a,b)    for(int i=a;i<b;i++)
#define ford(i,a,b)    for(int i=a;i>=b;i--)
#define br cout<<endl
#define sz(v) (long)v.size()
#define YS cout<<"YES"<<endl
#define ys cout<<"yes"<<endl
#define Ys cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define no cout<<"no"<<endl
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define bs binary_search
#define mp make_pair
#define llmn LLONG_MIN
#define llmx  LLONG_MAX
#define stp setprecision
#define fxd fixed
#define tu (char)toupper
#define tl (char)tolower
#define coutv(v) for(lli index=0;index<v.size();index++) {cout<<v[index]<<" ";} br;

using namespace std;

/*
lli count01(string s,char ch){
  lli mx=0,c=0;
  if(ch=='0'){

   fori(i,0,sz(s)){
     if(s[i]=='0'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

   }

  }
  else{

    fori(i,0,sz(s)){
     if(s[i]=='1'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

    }

  }
return mx;

}*/
/*
vector<lli> prime(lli n){
  bool a[n+1];
  memset(a,true,sizeof(a));
  for(lli i=2;i*i<=n;i++){
    if(a[i]){
      for(lli j=i*i;j<=n;j+=i)
      {  a[j]=false;}
    }
  }
  vector<lli>v;
  for(lli i=2;i<=n;i++){
    if(a[i]){
      v.pb(i);
    }
  }
  return v;
}

*/
void solve(){
    lli n=0,m;
    string s,ss;
    vlli v,vv;
    for(lli i=0;i<n;i++){

    }
    char ch;
    cin>>ch;
    if(isupper(ch)){
        cout<<'A';br;
    }else{
        cout<<'a';br;
    }



}

int main(){
tez
    solve();
return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    
    
    if (a<1200) {
      System.out.println("ABC");
    } else if (a<2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }
  }
}


Measured memory_bytes: 21716