akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    int N, M;
    int s[5];
    int c[5];
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> s[i] >> c[i];
    }

    int ans = -1;
    if (N == 1) {
        for (int i = 0; i <= 9; i++) {
            bool is_clear = true;
            for (int j = 0; j < M; j++) {
                if (c[j] != i) is_clear = false;
            }
            if (is_clear) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
        return 0;
    }
    else if (N == 2) {
        int number[2];
        for (int i = 10; i <= 99; i++) {
            number[0] = i / 10;
            number[1] = i % 10;
            bool is_clear = true;
            for (int j = 0; j < M; j++) {
                if (c[j] != number[s[j] - 1]) is_clear = false;
            }
            if (is_clear) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
    else if (N == 3) {
        int number[3];
        for (int i = 100; i <= 999; i++) {
            number[0] = i / 100;
            number[1] = (i / 10) % 10;
            number[2] = i % 10;
            bool is_clear = true;
            for (int j = 0; j < M; j++) {
                if (c[j] != number[s[j] - 1]) is_clear = false;
            }
            if (is_clear) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	double x = 0, y = 0, a, b, agl = 90, rad = 3.14159265358998 / 180;

	while(1){
		scanf("%lf,%lf", &a, &b);
		if(a == 0 && b == 0)    break;

		x += a * cos(rad * agl);
		y += a * sin(rad * agl);

		agl -= b;
	}

	cout << int(x) << endl << int(y) << endl;

	return 0;
}

Measured memory_bytes: 1236
n = int(input())
l, r = 0, n-1
print(0, flush=True)
l_s = input()
if l_s == "Vacant":
  exit()
print(n-1, flush=True)
l_t = input()
if l_t == "Vacant":
  exit()
while True:
  mid = (l+r)//2
  print(mid, flush=True)
  t = input()
  if t == "Vacant":
    exit()
  if ((mid-l)%2 and l_s==t) or ((mid-l)%2==0 and l_s!=t):
    r = mid
  else:
    l = mid
    l_s = t

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    VL a(x), b(y), c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    sort(rall(a));
    sort(rall(b));
    sort(rall(c));

    VL sum;
    rep(i, x){
        rep(j, y){
            sum.push_back(a[i] + b[j]);
        }
    }
    sort(rall(sum));
    VL ans;
    rep(i, min(k, (int)sum.size())){
        rep(j, min(k, (int)c.size())){
            ans.push_back(sum[i] + c[j]);
        }
    }

    sort(rall(ans));
    rep(i,k) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 44124
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int a[n] , b[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin>>b[j];
    }
    int h = 0;
    for(int i = 0 ; i<n ; i++){
        if(a[i] > b[i]){
            h += a[i] - b[i];
            a[i] = b[i];
        }
    }
    for(int i = 0 ; i<n ; i++){
        if(a[i] < b[i] && h > 0){
            int r = (b[i] - a[i]) / 2;
            a[i] += 2 * min(h , r);
            h -= min(h , r);
        }
    }
    if(h > 0){
        cout<<"No"<<endl;
    }else cout<<"Yes"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> cnt(n + 1, 1);
	for (int i = 2; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			++cnt[j];
		}
	}
	long long answer = 0;
	for (int i = 1; i <= n; i++) {
		answer += 1ll * i * cnt[i];
	}
	std::cout << answer << '\n';
}

Measured memory_bytes: 42324
import java.util.*; 
import java.io.*;

//the answer must be bountry * bountry
public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        long a = nextInt();
        long b = nextInt();
        long c = nextInt();
        long d = nextInt();

        long ans = Long.MIN_VALUE;
        ans = Math.max(a*c,ans);
        ans = Math.max(a*d,ans);
        ans = Math.max(b*c,ans);
        ans = Math.max(b*d,ans);

        System.out.println(ans);
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}


Measured memory_bytes: 32800
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        while(true) {
            a = sc.nextInt();
            b = sc.nextInt();
            if (a==0 && b==0) break;
            if (a<=b) {
                System.out.println(a+" "+b);
            } else {
                System.out.println(b+" "+a);
            }
        }
    }
}


Measured memory_bytes: 35776
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll>v(n);
    rep(i,n)cin >> v[i];
    sort(v.rbegin(), v.rend());
    double sum = 0;
    rep(i,a)sum += v[i];
    printf("%.10lf\n", sum/a);
    ll c[55][55] = {};
    rep(i,55)rep(j,i+1){
        if(j==0 or j==i)c[i][j] = 1;
        else c[i][j] = (c[i-1][j] + c[i-1][j-1]);
    }
    ll ans = 0;
    if(v[0] == v[a-1]){
        int cnt = (int)count(v.begin(), v.end(), v[0]);
        for(int i = a; i <= b; i++)ans += c[cnt][i];
    }else{
        int cnt = (int)count(v.begin(), v.end(), v[a-1]);
        int k = 0;
        rep(i,n)if(v[i]>v[a-1])k++;
        ans = c[cnt][a-k];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	static int ceil(int x, int y) {

		return (x + y - 1) / y;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), d = sc.nextInt(), a = sc.nextInt();
		int[] x = new int[n], h = new int[n];
		Integer[] indices = new Integer[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			h[i] = sc.nextInt();
			indices[i] = i;
		}
		Arrays.sort(indices, Comparator.comparingInt(i -> x[i]));
		TreeMap<Long, Long> map = new TreeMap();
		long sum = 0, ans = 0;
		for (int i : indices) {
			while (!map.isEmpty()) {
				long before = map.firstKey();
				if (before > x[i])
					break;
				sum += map.get(before);
				map.remove(before);

			}
			h[i] = (int) Math.max(0, h[i] - sum);
			int add = ceil(h[i], a);
			long addVal = add * 1L * a;
			sum += addVal;
			ans += add;
			long r = x[i] + 0L + 2 * d;
			map.put(r + 1, map.getOrDefault(r + 1, (long) 0) - addVal);

		}
		out.println(ans);

		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 67028
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<int> g[1<<18];
int s[1<<18];
int main()
{
	int n; cin>>n;
	for(int i=0; i<(1<<n); i++) cin>>s[i];
	//sort(s, s+(1<<n), greater<int>());
	vector<int> v;
	v.push_back(0);
	for(int i=0; i<n; i++){
		for(int j=0; j<(1<<i); j++){
			v.push_back(v[j]+(1<<i));
			g[v[j]].push_back(v[j]+(1<<i));
		}
	}
	int d[1<<18];
	for(int i=(1<<n)-1; i>=0; i--){
		d[i]=0;
		for(auto y:g[i]) d[i]=max(d[i], d[y]+1);
	}
	map<int, int> mp;
	for(int i=0; i<(1<<n); i++) mp[s[i]]++;
	priority_queue<P> que;
	que.push({d[0], 0});
	for(auto itr=mp.rbegin(); itr!=mp.rend(); itr++){
		int c=itr->second;
		if(c>que.size()){
			cout<<"No"<<endl;
			return 0;
		}
		vector<int> w;
		for(int i=0; i<c; i++){
			P p=que.top(); que.pop();
			w.push_back(p.second);
		}
		for(auto x:w){
			for(auto y:g[x]) que.push({d[y], y});
		}
	}
	/*queue<int> que;
	que.push(0);
	int t=0;
	int num[1<<18];
	while(!que.empty()){
		int x=que.front(); que.pop();
		num[x]=s[t];
		t++;
		for(auto y:g[x]){
			que.push(y);
		}
	}
	for(int i=0; i<(1<<n); i++){
		for(auto y:g[i]){
			if(num[i]<=num[y]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}*/
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 27508
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())

ls = []; rs = []
for _ in range(n):
    a,b = [int(i) for i in readline().split()]
    ls.append(a)
    rs.append(b)

ls.sort()
rs.sort()

ans = 0

if n%2 == 1:
    l = ls[n//2]
    r = rs[n//2]
    ans = r-l+1
else:
    l2 = ls[n//2-1]+ls[n//2]
    r2 = rs[n//2-1]+rs[n//2]
    ans = r2-l2+1

print(ans)

Measured memory_bytes: 25540
#include <cstdio>
using namespace std;

int main(){
	int N, r, c = 0;
	scanf("%d", &N);
	while (c++, N > 3) {
		r = N % 3;
		N /= 3;
		if (r != 0) {
			N++;
		}
	}
	printf("%d\n", c);

	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    string s; cin >> s;
    int x = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++, ans = max(ans, x);
        } else {
            x--;
        }
    } 
    cout << ans << endl;
    return 0;
}


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

/*
long long cache[100005];
long long jump(int *a, int n, int i) {
    if (i >= n) {
        return 2e9;
    }

    if (i == n-1) {
        return 0;
    }

    if (cache[i] != -1) {
        return cache[i];
    }

    long long cost1 = jump(a, n, i+1);
    long long abs1 = abs(a[i] - a[i+1]);

    long long cost2 = jump(a, n, i+2);
    long long abs2 = abs(a[i] - a[i+2]);

    long long minCost = min(cost1 + abs1, cost2 + abs2);
    cache[i] = minCost;
    return minCost;
}
*/

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

    long long dp[n];
    memset(dp, 0, sizeof(long long) * n);

    for (int i = 1; i < n; i++) {
        long long cost1 = dp[i-1];
        long long abs1 = abs(a[i] - a[i-1]);
        long long cost2 = 2e9;
        long long abs2 = 2e9;
        if (i-2 >= 0) {
            cost2 = dp[i-2];
            abs2 = abs(a[i] - a[i-2]);
        }
        dp[i] = min(cost1+ abs1, cost2 + abs2);
    }

    cout<<dp[n-1]<<endl;

    /*
    for (int i = 0; i <= n; i++) cache[i] = -1;
    cout<<jump(a, n, 0)<<endl;
    */
}


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int i,n,x,ans=0;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> x;
        if((i & 1)  &&  (x & 1))++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int N;
Graph G;

vector<int> res;

void dfs(int v, int p, int c) {
  res[v] = c;
  for (auto e : G[v]) {
    if (e.first == p) continue;
    if (e.second & 1)
      dfs(e.first, v, 1 - c);
    else
      dfs(e.first, v, c);
  }
}

int main() {
  cin >> N;
  G.assign(N, vector<Edge>());
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }
  res.assign(N, 0);
  dfs(0, -1, 1);
  for (auto v : res) cout << v << endl;

  return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <algorithm> 

using namespace std;

int main(){
  //https://qiita.com/Nasupl_r/items/35a903a4a69932c26c83
  int n;
  cin >> n;
  
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  
  std::vector<int> vec(n);
  long sumao=0;
  for (int i = 0; i < n; ++i) {
    vec[i] = a[i] + b[i];
    sumao += b[i];
  }
  
  std::sort(vec.begin(),vec.end(),std::greater<int>()); //降順ソート
  
  long sumta=0;
  for(int i=0;i<n;i++){
    if(i % 2 == 0){
      sumta += vec[i];
    }
  }
  
  cout << sumta - sumao << endl;
  return 0; 
      
  
  /*
  int ta=0;
  int ao=0;
  
  for(int i=0;i<n;i++){
    if(i % 2 == 0){
      std::vector<int>::iterator iter = std::max_element(vec.begin(), vec.end());
      int index = std::distance(vec.begin(), iter);
      ta += a[index];
      vec.erase(iter);
      a.erase(a.begin() + index);
      b.erase(b.begin() + index);
    }else{
      std::vector<int>::iterator iter = std::max_element(vec.begin(), vec.end());
      int index = std::distance(vec.begin(), iter);
      ao += b[index];
      vec.erase(iter);
      a.erase(a.begin() + index);
      b.erase(b.begin() + index);
    }
  }
  
  cout << ta - ao << endl;
  return 0;
  */
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int arr[100003];
int dp[100003];
int main()
{
    int n, k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        
        cin>>arr[i];
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=1e9;
        for(int j=1;j<=min(i-1,k);j++){
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int fla,n,a,b,c,d;
int nn,ami,ama,bmi,bma;
string s;
int dfs(int i,int ve)
{
	int fc=1;
	if(ve==0)
		fc=-1;
	if(i+fc>=n||i+fc<0)
		return i;
	if(s[i+fc]=='.')
	{
		int val=dfs(i+fc,ve);
		if(val!=-1)
			return val;
	}
	fc*=2;
	if(i+fc>=n||i+fc<0)
		return i;
	if(s[i+fc]=='.')
	{
		int val=dfs(i+fc,ve);
		if(val!=-1)
			return val;
	}
	return i;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>a>>b>>c>>d>>s;
	a--,b--,c--,d--;
	ami=ama=a;
	bmi=bma=b;
	nn=s.length();
	ami=a;
	ama=dfs(a,1);
	bmi=b;
	bma=dfs(b,1);
	// cout<<ami<<" "<<ama<<" "<<bmi<<" "<<bma<<endl;
	if(c>ama||c<ami||d>bma||d<bmi)
	{
		cout<<"No"<<endl;
		return 0;
	}
	if((a<b&&c>d)||(a>b&&c<d))
	{
		for(int i=max({0ll,ami-1,bmi-1});i<=min({c-1,d-1,n-3});i++)
		{
			if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i+2]=='.')
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 5968
#include <iostream>
#include <string>
using namespace std;
string S, T; int p, q;
int main() {
  cin >> S >> T;
  for(p = S.size()-T.size(); p >= 0; p--) {
    for(q = 0; q < T.size(); q++) {
      if(S[p+q] != '?' && S[p+q] != T[q]) break;
    }
    if(q == T.size()) break;
  }
  if(q < T.size()) {
    cout << "UNRESTORABLE";
  } else {
    S.replace(p, q, T);
    for(int i = 0; i < S.size(); i++) if(S[i] == '?') S[i] = 'a';
    cout << S;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
const long long MOD = 1e9+7;

int main(){
  int n;cin>>n;
  ll num9=1,ans=1,num1_8=1,num1_9=1,ttl=1;

  REP(i,n){
    num1_8*=8;
    num1_8%=MOD;

    num1_9*=9;
    num1_9%=MOD;

    ttl*=10;
    ttl%=MOD;
  }
  num9=num1_9-num1_8;
  num9%=MOD;
  if(num9<0) num9+=MOD;

  ans=ttl-num1_8-num9*2;
  ans%=MOD;
  while(ans<0) ans+=MOD;

  //cout<<ttl<<" "<<num1_8<<" "<<num9<<" "<<num1_9<<endl;
  cout<<ans;
}

Measured memory_bytes: 3620
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    n = get_int()
    c_list = get_string_char_list()

    count = 0
    ret = 0
    for i in range(0, n):
        if c_list[i] == "R":
            count += 1

    for i in range(0, count):
        if c_list[i] == "W":
           ret += 1

    print(ret)


if __name__ == '__main__':
    main()




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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;
char c[N];
int MEM[N];
int n, q;

void init(){

}

void solve(){
    scanf("%d %d", &n, &q);
    scanf("%s", c);
    MEM[0] = 0;
    for(int i = 1; i < n; i++){
        if(c[i] == 'C' && c[i-1] == 'A') MEM[i] = MEM[i-1]+1;
        else MEM[i] = MEM[i-1];
    }
    for(int i = 0; i < q; i++){
        int l, r;
        scanf("%d %d", &l, &r);
        --l; --r;
        int ans = MEM[r];
        if(l > 0){
            if(c[l] == 'C' && c[l-1] == 'A') ans--;
            ans -= MEM[l-1];
        }
        printf("%d\n", ans);
    }
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const double PI = 3.14159265358979323846;

int main() {
    ios::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double h_rad, m_rad;
    h_rad = 2.0 * PI * (h / 12.0 + m / 60.0 / 12.0);
    m_rad = 2.0 * PI * m / 60.0;
    double hx = a * cos(h_rad);
    double hy = a * sin(h_rad);
    double mx = b * cos(m_rad);
    double my = b * sin(m_rad);

    double ans = sqrt(pow(hx - mx, 2) + pow(hy - my, 2));
    printf("%0.12lf\n", ans);
    return 0;
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){
	
	bool all_visited=true;
	
	for(int i=0;i<N;++i){
		if(visited[i]==false)
			all_visited=false;
	}

	if(all_visited){
		return 1;
	}

	int ret=0;
	
	for(int i=0;i<N;++i){
		if(graph[v][i]==false) continue; 
		if(visited[i]) continue;

		visited[i]=true;
		ret+=dfs(i,N,visited);
		visited[i]=false;
	}

	return ret;
}

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

	for(int i=0;i<M;++i){
		int A,B;
		cin >> A >> B;
		graph[A-1][B-1]=graph[B-1][A-1]=true;
	}

	bool visited[nmax];
	for(int i=0;i<N;++i){
		visited[i]=false;
	}

	visited[0]=true;
	cout << dfs(0,N,visited) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            string S = cin.Read;
            int K = cin.ReadInt;
          
            char chk = S[K-1];
            foreach(char a in S)
            {
              if( a != chk && a != '*' )
              {
                S = S.Replace(a,'*');
              }
            }
            Console.WriteLine(S);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define vec(type) vector<type>

int main() {
    int p[3][2];
    cin >>  p[0][0] >> p[0][1] >>
            p[1][0] >> p[1][1] >>
            p[2][0] >> p[2][1];

    int c[4] = {0,0,0,0};
    for (int i = 0; i < 3; i++) {
        c[p[i][0]-1]++;
        c[p[i][1]-1]++;
    }

    int n[4] = {0,0,0,0};
    for (int i = 0; i < 4; i++) {
        n[c[i]]++;
    }

    if (n[1]==2 && n[2]==2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    string a[n];
    int ans=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]=="E869120"){
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3312
#include<bits/stdc++.h> 
using namespace std; 
typedef long  long ll;
ll MOD=1e9+7;
const ll MAX=1e5+2;
 
void solve(){
     ll n,ans=0;cin>>n;
     for(int i=2;i<1000000;i++){
         ll cnt=0;
         while(n%i==0){
             cnt++;
             n/=i;
         }
         ll x=0;
         while(1){
             ll a=((x+2)*(x+1))/2;
             if(a<=cnt)x++;
             if(a>cnt)break;
         }
        ans+=x; 
     }
     if(n>1)ans++;
     cout<<ans<<endl;
     
}
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;t=1;
    // cin>>t;
    // cin.ignore();
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;

    cin >> s;

    if ((s[0] == '9') || (s[1] == '9')) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int check(string a, int l1, int r1, int l2, int r2){
	int alphabet1[26] = {};
	int alphabet2[26] = {};
	for(int i = l1; i < r1; i++){
		alphabet1[a[i]-97]++;
	}
	for(int i = l2; i <= r2; i++){
		alphabet2[a[i]-97]++;
	}
	int counter = 0;
	for(int i = 0; i < 26; i++){
		if(alphabet1[i] && alphabet2[i])
			counter++;
	}
	return counter;
}

int main(){
	int length;
	string a;
	cin >> length >> a;
	int max = 0;
	for(int i = length-1; i >= 1; i--){
		int temp = check(a, 0, i, i, length-1);
		if(temp >= max){
			max = temp;
		}
	}
	cout << max << endl;
}

//tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir
// bcd fghijklmnopqr tu  xyz

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

using namespace std;

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
ll mod=1000000007;
string ans;
ll func1(vector<vector<pll>>&dp,string &s,string &t,int a,int b)
{
    if(a==0||b==0)
    return 0;
    if(dp[a][b].F!=-1)
    return dp[a][b].F;
    if(s[a-1]==t[b-1])
    {
        //ans.pb(s[a-1]);
        dp[a][b].S=1;
        return dp[a][b].F=1+ func1(dp,s,t,a-1,b-1);
    }
    ll x=func1(dp,s,t,a-1,b);
    ll y=func1(dp,s,t,a,b-1);
    if(x>=y)
    {
        dp[a][b].S=2;
        return dp[a][b].F=x;
    }
    dp[a][b].S=0;
    return dp[a][b].F=y;
    
    
}

int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--)
        {
          ll i,j,k,n;
          cin>>n;
          vector<long double>v(n);
          for(i=0;i<n;i++)
          cin>>v[i];
          vector<vector<ld>>dp(n,vector<ld>(n+1,0));
          dp[0][0]=1-v[0];
          dp[0][1]=v[0];
          for(i=1;i<n;i++)
          {
              dp[i][0]=dp[i-1][0]*(1-v[i]);
          }
          for(i=1;i<n;i++)
          {
              for(j=1;j<=i+1;j++)
              {
                  dp[i][j]=dp[i-1][j-1]*v[i]+dp[i-1][j]*(1-v[i]);
              }
          }
         ld k1=0;
         for(j=n/2+1;j<=n;j++)
         {
             k1+=dp[n-1][j];
         }
         cout.precision(17);
         cout<<fixed<<k1;
         
        }
        
    }

Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N;cin>>N;
    pair<double,double> site[N];
    rep(i,N)cin>>site[i].first>>site[i].second;
    double ans=0;
    double count=1;
    for(double i=1;i<=N;i++)count*=i;
    rep(i,N-1){
        for(ll j=i+1;j<N;j++){
            double p=abs(site[i].first-site[j].first),q=abs(site[i].second-site[j].second);
            ans+=(pow((p*p+q*q),(double)0.5));
        }
    }
    ans=ans*2/N;
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
/**
*    created: 02.08.2020 22:09:55
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int k; cin >> k;
    int x = 7 % k;
    set<int> s;
    int i = 1;
    while(!s.count(x)) {
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % k;
        i++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 50380
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

int main(){
  int k;cin >> k;
  vl lun(10);
  rep(i,9)lun[i+1]=i+1;
  rep2(i,1,k){
    for(int j=-1;j<=1;j++){
      ll t=lun[i]*10+lun[i]%10+j;
      if(lun[i]%10+j<0||lun[i]%10+j>9)continue;
      lun.push_back(t);
    }
  }
  cout << lun[k] << endl;
}

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

#define ll long long
#define ld long double
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> l(m);
  ll i;
  for(i = 0; i < m; i++)
    cin >> l[i];
  
  sort(ALL(l));
  vector<ll> s(m - 1);
  
  for(i = 0; i < m - 1; i++)
    s[i] = l[i + 1] - l[i];
  
  sort(ALL(s));
  reverse(ALL(s));
  ll minus = 0;
  if(m - 1 > n - 1){
    for(i = 0; i < n - 1; i++)
      minus += s[i];
  }
  else minus = l[m - 1] - l[0];
  cout << l[m - 1] - l[0] - minus << endl; 
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INT_MAX 10000000
#define MAX 10001

int d[MAX];
int n;
priority_queue<pair<int,int> > q;
vector<pair<int,int> > adj[MAX];
vector<int> s;

int check(int point){
    if(find(s.begin(), s.end(), point) != s.end()){
        //printf("%d in q\n",point);
        return 1;
    }
    else{
        //printf("%d not in q\n",point);
        return 0;
    }
}

void dijk(){
    q.push(make_pair(0,0));
    int new_node, v;
    while(s.size()!=n){
        // get smallest value
        pair<int,int> pa = q.top();
        new_node = pa.second;
        if(check(new_node)==0){
            s.push_back(new_node);
        }

        q.pop();

        for(int i=0;i<adj[new_node].size();++i){
            v = adj[new_node][i].first;
            if(d[new_node]+adj[new_node][i].second<d[v]){
                d[v] = d[new_node]+adj[new_node][i].second;
                q.push(make_pair(d[v]*(-1),v));
            }
        }
    }
}

int main(){
    int id, pair_n, source, dis;
    int value;
    //FILE *fp=fopen("In3.txt","r");
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d %d",&id, &pair_n);
        //cin >> id >> pair_n;
        for(int j=0;j<pair_n;++j){
            scanf("%d %d",&source, &dis);
            //cin >> source >> dis;
            adj[id].push_back(make_pair(source,dis));
        }
    }
    d[0] = 0;
    for(int i=1;i<n;++i){
        d[i] = INT_MAX;
    }
    dijk();
    for(int i=0;i<n;++i){
        printf("%d %d\n",i,d[i]);
    }

    return 0;
}



Measured memory_bytes: 7816
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &k)

	aCount := min(a, k)
	bCount := min(b, k-aCount)
	cCount := min(c, k-aCount-bCount)

	fmt.Println(aCount - cCount)
}

func min(first, second int) int {
	if first < second {
		return first
	}

	return second
}


Measured memory_bytes: 1816
#include <stdio.h>
int binarySearch(int);
int n,A[100000];

int main()
{
  int q,i,x,judge,num=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&x);
    judge=binarySearch(x);
    if(judge) num++;
  }
  
  printf("%d\n",num);

  return 0;
}

int binarySearch(int key)
{
  int left=0;
  int right=n;
  int mid;
  
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key) return 1;
    else if(key<A[mid]) right=mid;
    else left=mid+1;
  }

  return 0;
}

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

class PaizaSample
{
   
    static void Main()
    {

        string input;
        while ((input = Console.ReadLine()) != null)
        {
            if (input.Length % 2 != 0)
            {
                Console.WriteLine("NA");
                continue;
            }

            char[] ar = {'.', '?', '!', ' '};

            bool flag = true;
            string output = "";
            for (int i = 0; i < input.Length; i += 2)
            {
                int col = int.Parse(input[i].ToString());
                int row = int.Parse(input[i+1].ToString());
               
                if (row > 0 && col > 0 && row <= 5 && col <= 6)
                {
                    if (col == 6 && row >= 2)
                    {
                        output += ar[row - 2];
                    }
                    else
                    {
                        char c = (char)(97 + (col - 1) * 5 + (row - 1));
                        output += c.ToString();
                    }
                }
                else
                {
                    Console.WriteLine("NA");
                    flag = false;
                    break;
                }
            }

            if (flag)
            {
                Console.WriteLine(output);
            }
        }
        

       // Console.ReadKey();

    }
}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k; //入力値
  int num = 1; //掲示板表示値
  cin >> n >> k;
  
  for(int i = 0; i < n; i++)
  {
  	if(num > k){
      num += k;
    }
    else{
      num *= 2;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long d=max({a,b,c}),e=min({a,b,c});
    long long f=a+b+c-d-e;
    if(d%2==1&&e%2==1&&f%2==1){
        cout<<e*f<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
using namespace std;
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}

int main()
{
  int A[200000],N=IN(),K=IN(),l,m=0,r,accum=1,sign=1;long x,y;
  rep(i,N)A[i]=IN(),m+=A[i]<0?1:0;
  sort(A,A+N);
  if(K&1)accum=A[N-1],sign=(A[N-1]<0?-1:1),N--,K--;
  l=0,r=N-1;
  while(K)
  {
    x=1l*A[l]*A[l+1],y=1l*A[r]*A[r-1];
    if(x*sign>y*sign)x%=MOD,accum=1l*accum*x%MOD,l+=2;
    else y%=MOD,accum=1l*accum*y%MOD,r-=2;
    K-=2;
  }
  return printf("%ld\n",(1l*accum%MOD+MOD)%MOD),0;
}


Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
int n,a[55],b[55],check=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++)
		if(b[i]!=a[i]) check++;
	if(!check||check==2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
typedef long long ll;

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

    if(x==3 || x==5 || x==7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  vector<double> a(n);
  rep(i,n) cin>>a[i];
  
  rep(i,n) a[i] = 1/a[i];
  
  double s;
  rep(i,n) s += a[i];
    
  double ans = 1/s;
  printf("%.10f\n",ans);
  return 0;
  
}

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

int main()
{
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a + n);
  cout << a[n - 1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 3648
def solve():
    N = int(input())
    # ord("a") Unicode コードポイントを返す
    codepoint = ord("a")
 
    # たどるグラフの深さ
    i = 1
    # 標準形文字列とその次の辞書順
    ans = [["a", 1]]
    # 一つづつ潜る
    while i < N:
        # 次の深さをtmpとする
        tmp = []
        # 各ノード
        for w, j in ans:
            # 辞書順で追加していく
            for k in range(j+1):
                if k != j:
                    tmp.append([w + chr(codepoint+k), j])
                # 辞書順のインクリメント
                else:
                    tmp.append([w + chr(codepoint+k), j+1])
        ans = tmp
        i += 1
 
    [print(a[0]) for a in ans]
 
    # Solve
if __name__ == "__main__":
    solve()

Measured memory_bytes: 80604
/* Card Game */
#include <stdio.h>
#include <string.h>

int main()
{
    char tcard[101], hcard[101];
    int n, i, j, tp=0, hp=0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s %s", &tcard, &hcard);
        if('A' <= tcard[i] && tcard[i] <= 'Z'){
             tcard[i] = tcard[i] + 32;
        }
        if('A' <= hcard[i] && hcard[i] <= 'Z'){
             hcard[i] = hcard[i] + 32;
        }
        for(j=0;;j++){
            if(tcard[j] > hcard[j]){
                tp += 3;
                break;
                }
            else if(tcard[j] < hcard[j]){
                hp += 3;
                break;
            }
            else if(tcard[j] == hcard[j]){
                if(tcard[j] == '\0' && hcard[j] != '\0'){
                hp += 3;
                break;
                }
                else if(hcard[j] == '\0' && tcard[j] != '\0'){
                    hp += 3;
                    break;
                }
                else if(hcard[j] == '\0' && tcard[j] == '\0'){
                    tp += 1;
                    hp += 1;
                    break;
                }
            }
        }
    }
    printf("%d %d\n", tp, hp);
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll n;
    cin >> n;
    ll res = 1;
    for (ll i=1; i<=n; ++i) {
        res *= i;
        res %= MOD;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a,b,c,d;cin >> a >> b >> c >> d;
    chmin(b,a+a);chmin(c,b+b);
    chmin(d,c+c);
    ll n;cin >> n;
    if(n==1)cout << c <<endl;
    else{
        cout << n/2*d+n%2*c <<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
        int l[]=new int[n];
        int d[]=new int[n+1];
        d[0]=0;
        int ans=1;
        for(int i=0; i<n; i++){
            l[i]=sc.nextInt();
            d[i+1]=d[i]+l[i];
            if(d[i+1]<=x)
                ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
package main

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

// Scane Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine() // cyclic
	p := nextLine()

	slen := len(s)
	plen := len(p)

	// sの開始位置をシーク
	for i := 0; i < len(s); i++ {
		short := (slen - i) - plen

		mihon := ""
		if short > 0 {
			mihon = s[i : i+plen]
		} else {
			mihon = s[i:slen] + s[:-1*short]
		}

		if p == mihon {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}



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

using namespace std;


using ll = long long;

const int MX = 200 * 1000 + 7;

int cnt[MX];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cnt[i % k]++;
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        if ((i + i) % k == 0) {
            ll x = cnt[i];
            ans += x * x * x;
        }
    }
    cout << ans << "\n";
}




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

int main(){
  long long int n,k,i,wa=0;
  cin>>n>>k;
  long long int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<n-k;i++){
    wa+=a[i];
  }
  cout<<wa;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
numgcd = [0]*(K+1)
sumgcd = 0
mod = 10**9+7
for i in range(1, K+1)[::-1]:
    numgcd[i] = pow(K//i, N, mod)
    count = 2
    while count*i <= K:
        numgcd[i] -= numgcd[count*i]
        count += 1
    sumgcd += numgcd[i]*i
print(sumgcd%mod)

Measured memory_bytes: 11168
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
	int value;
    struct node* prev,* next;
}Node;
Node* head;
void Init()
{
    head=(Node*)malloc(sizeof(Node));
    head->next=head;
    head->prev=head;
}

Node* FindNode(int x)
{
	Node*temp=head->next;
	while(temp!=head&&temp->value!=x)
        temp=temp->next;
    return temp;
}
void Insert(int x)
{
	Node*temp=(Node*)malloc(sizeof(Node));
    temp->value=x;
    head->next->prev=temp;
    temp->next=head->next;
    head->next=temp;
    temp->prev=head;
}

void Delete(Node*temp)
{
	if(temp==head)
        return ;
	temp->next->prev=temp->prev;
	temp->prev->next=temp->next;
    free(temp);
}

void DeleteFirst()
{
    Delete(head->next);
}
void DeleteLast()
{
	Delete(head->prev);
}
void PrintList()
{
    Node*temp=head->next;
    int flag=0;
    while(1)
    {
        if(temp==head)
            break;
        else
        {
            if(flag++>0)
                printf(" ");
            printf("%d",temp->value);
            temp=temp->next;
        }
    }
    printf("\n");
}
int main()
{
	int n;
	int i;
	scanf("%d",&n);
	char str[12];
	int x;
	Init();
    /*
	while(n--)
	{
		scanf("%s%d",str,&x);
		if(str[0]=='i'){Insert(x);}
		else if(str[0]=='d'&&str[6]=='F')DeleteFirst();
		else if(str[0]=='d'&&str[6]=='L')DeleteLast();
		else if(str[0]=='d'){Delete(FindNode(x));}
	}
    */

	for(i = 0; i < n; i++) {
        scanf("%s %d", str, &x);
        if (str[0] == 'i') {
            Insert(x);
        }
        else if(str[0] == 'd') {
            if(str[6] == 'F')
                DeleteFirst();
            else if(str[6] == 'L')
                DeleteLast();
            else
                //DeleteValue(x);
                Delete(FindNode(x));
        }
    }
    /*
    Node* temp=head->next;
    while(temp->next!=head)
    {
        printf("%d ",temp->value);
        temp=temp->next;
    }
    printf("%d\n",temp->value);
    */
    PrintList();
	return 0;
}

Measured memory_bytes: 33820