akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, k;
    cin >> n >> k;
    set<int> st;
    for(int i = 0; i < k; i++){
        int x;
        cin >> x;
        for(int i = 0; i < x; i++){
            int y;
            cin >> y;
            st.insert(y);
        }
    }
    cout << n - st.size() << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

const ll INF = 1LL << 60;

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

  ll g = gcd(m, n);
  ll N = n/g;
  ll M = m/g;
  
  bool ok = true;
  for (ll i = 0; i < g; i++) {
    if(s[i*N] != t[i*M]) ok = false;
  }

  std::cout << (ok ? lcm(n,m) : -1) << '\n';
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
string s1, s2, s3;
cin >> s1 >> s2 >> s3;

char S1 = s1.at(0);
char S2 = s2.at(0);
char S3 = s3.at(0);

S1 += 'A' - 'a';
S2 += 'A' - 'a';
S3 += 'A' - 'a';

cout << S1 << S2 << S3 << endl;

}


Measured memory_bytes: 256
g[1263][99],a,h,p;main(m,S){for(;scanf(S="%d%d%d\n",g,&m,&a)*a;printf(S+4,a)){for(memset(g,0,5e5);m--;g[h][p]=1)scanf(S,&h,&p,g);for(h=1e3;--h;)a+=g[h][a]?1:g[h][a-1]?-1:0;}}

Measured memory_bytes: 0
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int A, B;
    cin >> A >> B;
    if(A<B){
        REP(i,0,B){
            cout << A;
        }
    }else{
        REP(i,0,A){
            cout << B;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
# 20-08-12 再トライ
from math import degrees, atan2

a, b, x = [int(x) for x in input().split()]
if x <= a ** 2 * b / 2:
    ans = degrees(atan2(a * b ** 2, 2 * x))
else:
    ans = degrees(atan2(2 * a ** 2 * b - 2 * x, a ** 3))

print(ans)

Measured memory_bytes: 9372
# -*- coding: utf-8 -*-

n = int(input())
nums = list(map(int, input().split()))
x = 10 ** 9 + 7

ans = 0

sums = [0] * (n - 1)

for j in range(n - 1):
    if j == 0:
        sums[0] = nums[0] % x
    else:
        sums[j] = (sums[j - 1] + nums[j]) % x

for i in range(1, len(nums)):
    ans += sums[i - 1] * nums[i]
    ans = ans % x

print(ans)


Measured memory_bytes: 31564
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[60][60][2600];  // dp[i+1][j][k] : x[i]までからj枚選んで合計kにする方法の数
 
int main() {
    ll n, a;
    cin >> n >> a;

    vl x(n);
    rep(i, n) {
        cin >> x[i];
    }

    dp[0][0][0] = 1;
    rep(i, n) {
        exrep(j, 0, n) {
            exrep(k, 0, 2500) {
                // x[i]を選ばないとき
                dp[i+1][j][k] += dp[i][j][k];
                // x[i]を選ぶとき
                dp[i+1][j+1][k + x[i]] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    exrep(j, 0, n) {
        ans += dp[n][j][a*j];
    }

    ans--;

    out(ans);
    re0;
}

Measured memory_bytes: 62464
#include <stdio.h>

int main(void){
    int N;
    int A[200000];
    int i;
    long int sum;
    int tmp;

    scanf("%d", &N);
    for (i=0;i<N;++i) {
        scanf("%d", &A[i]);
    }

    sum=0;
    tmp = A[0];
    for (i=1;i<N;++i) {
        if ( tmp > A[i]) {
            sum += tmp - A[i];
        } else {
            tmp = A[i];
        }
    }
    printf("%ld\n", sum);
}

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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

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

        int a, b, c;
        cin >> a >> b >> c;

        bool ok = (100 * a + 10 * b + c) % 4 == 0;
        cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/agc017/tasks/agc017_a
fn main() {
    let (n, p) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let an = read::<usize>();

    let mut flg = true;
    for i in 0..an.len() { if an[i] % 2 != 0 { flg = false; }}
    let ans = if flg {
        if p == 1 { 0 }
        else { 2u64.pow(n as u32) }
    } else { 2u64.pow((n - 1) as u32) };
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#define INF 0x3f3f3f3f
#define MAXN 200005
#define lson (idx << 1)
#define rson (idx << 1 | 1)

using namespace std;
typedef long long ll;

struct Node {
  int l, r, hi, lazy = 0;
};

struct SegTree {
  Node s[MAXN << 2];
  void calc(int idx) { s[idx].hi = max(s[lson].hi, s[rson].hi); }

  void pushdown(int idx) {
    if (s[idx].lazy) {
      for (int i = lson; i <= rson; ++i) {
        if (s[i].hi > s[idx].lazy) {
          s[i].hi = s[idx].lazy;
          s[i].lazy = s[idx].lazy;
        }
      }
    }
    s[idx].lazy = 0;
  }

  void build(int idx, int l, int r, vector<int> &a) {
    s[idx].l = l, s[idx].r = r;
    if (l == r) {
      s[idx].hi = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(lson, l, mid, a);
    build(rson, mid + 1, r, a);
    calc(idx);
  }

  void update(int idx, int l, int r, int x) {
    if (s[idx].hi <= x)
      return;
    if (s[idx].l >= l && s[idx].r <= r) {
      s[idx].hi = x;
      s[idx].lazy = x;
      return;
    }
    pushdown(idx);
    int mid = (s[idx].l + s[idx].r) >> 1;
    if (l <= mid)
      update(lson, l, r, x);
    if (mid + 1 <= r)
      update(rson, l, r, x);
    calc(idx);
  }

  int query(int idx, int l, int r) {
    if (s[idx].l >= l && s[idx].r <= r)
      return s[idx].hi;
    pushdown(idx);
    int ans = 0;
    int mid = (s[idx].l + s[idx].r) >> 1;
    if (l <= mid)
      ans = max(ans, query(lson, l, r));
    if (mid + 1 <= r)
      ans = max(ans, query(rson, l, r));
    return ans;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> col(n + 1, n), row(n + 1, n);
  col[n] = 1, row[n] = 1;
  SegTree C, R;
  C.build(1, 1, n, col);
  R.build(1, 1, n, row);
  ll ans = (ll)(n - 2) * (n - 2);
  for (int i = 0; i < q; ++i) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      int hi = C.query(1, x, x);
      ans -= hi - 2;
      R.update(1, 1, hi, x);
    } else {
      int hi = R.query(1, x, x);
      ans -= hi - 2;
      C.update(1, 1, hi, x);
    }
  }
  cout << ans;
}

Measured memory_bytes: 29828
using System;
public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        string ans = "";
        while(N != 0)
        {
            if(N % 2 != 0)
            {
                ans = "1" + ans;
                N--;
            }
            else
            {
                ans = "0" + ans;
            }
            N /= -2;
        }
        if(ans == "") //N = 0のとき
        {
            ans = "0";
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int a,b;
	cin>>a>>b;
	if (a<9 && b<9)  cout<<"Yay!";
	else  cout<<":(";
	re 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] field = new char[h][];
		int blackCount = 0;
		int[][] costs = new int[h][w];
		for (int i = 0; i < h; i++) {
		    field[i] = sc.next().toCharArray();
		    Arrays.fill(costs[i], Integer.MAX_VALUE);
		    for (int j = 0; j < w; j++) {
		        if (field[i][j] == '#') {
		            blackCount++;
		        }
		    }
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(0, 0, 0));
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.h][p.w] <= p.value) {
		        continue;
		    }
		    costs[p.h][p.w] = p.value;
		    if (p.h > 0 && field[p.h - 1][p.w] != '#') {
		        queue.add(new Path(p.h - 1, p.w, p.value + 1));
		    }
		    if (p.h < h - 1 && field[p.h + 1][p.w] != '#') {
		        queue.add(new Path(p.h + 1, p.w, p.value + 1));
		    }
		    if (p.w > 0 && field[p.h][p.w - 1] != '#') {
		        queue.add(new Path(p.h, p.w - 1, p.value + 1));
		    }
		    if (p.w < w - 1 && field[p.h][p.w + 1] != '#') {
		        queue.add(new Path(p.h, p.w + 1, p.value + 1));
		    }
		}
		if (costs[h - 1][w - 1] == Integer.MAX_VALUE) {
		    System.out.println(-1);
		} else {
		    System.out.println(h * w - blackCount - costs[h - 1][w - 1] - 1);
		}
    }
    
    static class Path implements Comparable<Path> {
        int h;
        int w;
        int value;
        
        public Path(int h, int w, int value) {
            this.h = h;
            this.w = w;
            this.value = value;
        }
        
        public int compareTo(Path another) {
            return value - another.value;
        }
    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
const ll N=200005, inf=hell;
inline ll add(ll x,ll y){x+=y;return x%hell;}
ll tr[4*N];
ll combine(ll x,ll y){return max(x,y);}
void update(ll node,ll l,ll r,ll idx,ll val){
	if(l==r){
		tr[node]=val;
		return;
	}
	ll mid=(l+r)/2;
	if(l<=idx and idx<=mid)update(node<<1,l,mid,idx,val);
	else
		update(node<<1|1,mid+1,r,idx,val);
	tr[node]=combine(tr[node<<1],tr[node<<1|1]);
}
ll query(ll node,ll l, ll r,ll a,ll b){
	if(l>r || b<l || r<a)return -inf;
	if(a<=l and r<=b)return tr[node];
	ll mid=(l+r)/2;
	return combine(query(node<<1,l,mid,a,b),query(node<<1|1,mid+1,r,a,b));
}
void solve(){
	ll n;
	cin>>n;
	while(n){
		if(n%10==7){
			cout<<"Yes";return;
		}
		n/=10;
	}
	cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
	int siz;
	vector<int> rank, par;
public:
	UnionFind(){}
	UnionFind(int n):siz(n), rank(n, 1), par(n, 0) {
		iota(par.begin(), par.end(), 0);
	}
	int find(int x) {
		return (x == par[x] ? x : par[x] = find(par[x]));
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]) swap(x, y);
		rank[x] += rank[y];
		par[y] = x;
	}
};

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

	int n, l, k;
	cin >> n >> k >> l;
	UnionFind a(n + 1), b(n + 1);
	for(int i = 0; i < k; i++) {
		int x, y;
		cin >> x >> y;
		a.unite(x, y);
	}
	for(int i = 0; i < l; i++) {
		int x, y;
		cin >> x >> y;
		b.unite(x, y);
	}
	map<pair<int, int>, int> mp;
	for(int i = 1; i <= n; i++) {
		mp[make_pair(a.find(i), b.find(i))]++;
	}
	for(int i = 1; i <= n; i++) {
		if(i > 1) cout << " ";
		cout << mp[make_pair(a.find(i), b.find(i))];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
 
 
//#########################################
 
int main() {
 
int n=D(),m=D();
char a[n][n];
char b[m][m];
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
   cin>>a[i][j];
 
   }
 
}
for(int i=0;i<m;i++){
   for(int j=0;j<m;j++){
cin>>b[i][j];
   }
 
}
 
 
 
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
int cnt=0;
 
     for(int ii=0;ii<m;ii++){
       for(int jj=0;jj<m;jj++){
 
       if(b[ii][jj]==a[i+ii][j+jj]){
       cnt++;
 
       }
 
       }
 
 
 
 
 
     }
     if(cnt==(m*m)){
     cout<<"Yes";
     return 0;
     }
 
 
 
   }
 
}
cout<<"No";
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int a[10];
	for(int i = 1 ; i <= 3 ; i++) scanf("%d",&a[i]);
	sort(a + 1 , a + 1 + 3);
	if(a[1] != a[2]) printf("%d\n",a[1]);
	else printf("%d\n",a[3]);
}

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

public class Main {
    void run() {
        String s = read();
        int p = s.indexOf("iwi");
        char[] left = s.substring(0, p).toCharArray();
        char[] right = s.substring(p + 3).toCharArray();
//        sysout.println("left " + new String(left));
//        sysout.println("right " + new String(right));
        int ans = 0;
        for (int i = 0; i < 1 << left.length; i++) {
            for (int j = 0; j < 1 << right.length; j++) {
                if (Integer.bitCount(i) != Integer.bitCount(j)) {
                    continue;
                }
                StringBuilder L = new StringBuilder();
                for (int k = 0; k < left.length; k++) {
                    if (((i >> k) & 1) != 0) {
                        L.append(left[k]);
                    }
                }
                StringBuilder R = new StringBuilder();
                for (int k = 0; k < right.length; k++) {
                    if (((j >> k) & 1) != 0) {
                        R.append(right[k]);
                    }
                }
//                sysout.println(L.toString() + " " + R.toString());
                int len = L.length();
                boolean f = true;
                for (int k = 0; k < len; k++) {
                    if (L.charAt(k) == '(' && R.charAt(len - 1 - k) != ')') f = false;
                    if (L.charAt(k) == ')' && R.charAt(len - 1 - k) != '(') f = false;
                    if (L.charAt(k) == '[' && R.charAt(len - 1 - k) != ']') f = false;
                    if (L.charAt(k) == ']' && R.charAt(len - 1 - k) != '[') f = false;
                    if (L.charAt(k) == '{' && R.charAt(len - 1 - k) != '}') f = false;
                    if (L.charAt(k) == '}' && R.charAt(len - 1 - k) != '{') f = false;
                }
                if (f) ans = Math.max(ans, 3 + 2 * len);
            }
        }
        sysout.println(ans);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 18440
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

var memo [][2]int
var f [][2]int

func rec(p, flg, n int, a []int) int {
	if f[p][flg] == 1 {
		return memo[p][flg]
	}
	if p == n-1 {
		return a[p]
	}
	x0 := a[p] + rec(p+1, 0, n, a)
	a[p+1] = -a[p+1]
	x1 := -a[p] + rec(p+1, 1, n, a)
	a[p+1] = -a[p+1]

	memo[p][flg] = max(x0, x1)
	f[p][flg] = 1
	return max(x0, x1)
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	memo = make([][2]int, N)
	f = make([][2]int, N)

	out(rec(0, 0, N, a))
}


Measured memory_bytes: 22912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main {
	
	public static void main(String[] args) throws IOException {
	
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		String input;
		int primes = 0;
		int[] n = new int[1000000];
		for (int i = 2; i < n.length; ++i) {
			
			if (isPrime(i))
				++primes;
			
			n[i] = primes;
		}
		
		while ((input = bf.readLine()) != null) {

			try {
				int num = Integer.parseUnsignedInt(input);
				System.out.print(n[num] + "\n");
			} catch (NumberFormatException nfe) {
				break;
			}
		}
	}
	
	
	private static boolean isPrime(int i) {
	
		for (int div = 2; div <= Math.sqrt(i); div += 1) {
			if (i % div == 0)
				return false;
		}
		return true;
	}
}

Measured memory_bytes: 28824
#include <cstdio>
#define N 100010
int n,a[N],f[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int op=-1;
	for(int i=1;i<=n;++i){
		if(op==0 && a[i]==a[i-1]) f[i]=f[i-1],op=0;
		else if((op==0 || op==1) && a[i]>=a[i-1]) f[i]=f[i-1],op=1;
		else if((op==0 || op==2) && a[i]<=a[i-1]) f[i]=f[i-1],op=2;
		else{
			f[i]=f[i-1]+1;
			op=0;
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])

# print(ruiseki)
answer = 0
for i in range(0, len(sum01), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)

print(answer)

Measured memory_bytes: 8604
n = gets.to_i
pt = Array.new(n).map{Array.new(2,0)}
for i in 0..(n-1)
  pt[i][0] = i
end
for i in 1..(n*(n-1)/2)
  a,b,c,d = gets.split.map(&:to_i)
  if c > d
    pt[a-1][1] += 3
  elsif c < d
    pt[b-1][1] += 3
  else
    pt[a-1][1] += 1
    pt[b-1][1] += 1
  end
end
pt.sort!{|a,b| b[1]<=>a[1]}
ans = Array.new(0)
for i in 0..(n-1)
  if i > 0 && pt[i-1][1] == pt[i][1]
    ans[pt[i][0]] = ans[pt[i-1][0]]
  else
    ans[pt[i][0]] = i+1
  end
end
for i in 0..(n-1)
  puts ans[i]
end


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

int main() {
  char a;
  cin >> a;
  if (a < 91){
    cout << "A" << endl;;
  }else {
    cout << "a" << endl;;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    int L, R;
    cin >> L >> R;
    int cnt = 2019;
    for(long long i = L; i < R; i++) {
        for(long long j = i+1; j <= R; j++) {
            cnt = min((int)(i*j%2019), cnt);
            if(!cnt) {
              cout << 0 << endl;
              return 0;
            };
        }
    }
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b=0,c=0;
  cin >> a;
  vector<int> rank(a),pts(a);
  for (int i=0;i<a;i++){
    cin >> rank[i] >> pts[i];
    if (rank[i]>b){
      b=rank[i];
      c=pts[i];
    }
  }
  for(;c>0;c--){
      b++;
  }
  cout << b << endl;
}

Measured memory_bytes: 1024
N,X,Y=map(int,input().split())
X-=1
Y-=1
ans=[0 for i in range(0,N)]

for i in range(0,N-1):
    for j in range(i+1,N):
        distance=0
        if X>=j:
            distance=j-i
        elif Y>=j>=X and X>=i:
            distance=min(j-i,X+Y+1-i-j)
        elif j>=Y and X>=i:
            distance=X-i+j-Y+1
        elif Y>=i>=X:
            distance=min(j-i,i-X+1+abs(Y-j))
        else:
            distance=j-i
        ans[distance]+=1

for i in range(0,N):
    if i!=0:
        print(ans[i])

Measured memory_bytes: 49244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	int p[2] = { 0 };
	REP(i, n)
	{
		string s[2];
		cin >> s[0] >> s[1];
		if (s[0] == s[1])
		{
			p[0] += 1; p[1] += 1;
		}
		else if (s[0] > s[1])
		{
			p[0] += 3;
		}
		else
		{
			p[1] += 3;
		}
	}

	cout << p[0] << " " << p[1] << endl;
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int sum = 100*a, sugar = 0;
	rep(32, i) rep(32, j) rep(124, k) rep(124, l) {
		int tsum = i*a*100 + j*b*100 + c*k + d*l;
		int tsugar = c*k + d*l;
		if (tsum > f || (i*a + j*b) * e < tsugar) continue;
		if (tsugar * sum > sugar * tsum) {
			sugar = tsugar;
			sum = tsum;
		}
	}
	cout << sum << ' ' << sugar << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, c, d, tmp, m, h, w, x, y, sum, k, q;
char a, b;

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

  cin >> a >> b;
  if (a < b)
    Cout("<");
  else if (a == b)
    Cout("=");
  else
    Cout(">");
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m= map(int,input().split())
graph = [[]for _ in range(n)]
deg = [0 for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    graph[x-1] += [y-1]
    graph[y-1] += [x-1]
    deg[x-1] += 1
    deg[y-1] += 1
q = deque([i for i in range(n) if deg[i] == 1])# 無向グラフのシンクは 1
seen = [False for _ in range(n)]

while q:
    v = q.popleft()
    seen[v] = True
    for i in graph[v]:
        deg[i] -= 1
        if deg[i] == 1:
            q.append(i)
if all(i for i in seen):print(n-1);exit()
print(seen.count(True))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int MAXN = 100000;
int N, a, b, colors = 0;
vector<vector<int>> Tree(MAXN);
vector<pair<int, int>> vp;
map<pair<int, int>, int> Edge; // a, b, color

void dfs(int cur, int from, int colorUsed)
{
  int col = 1;
  for (int nxt = 0; nxt < Tree.at(cur).size(); nxt++)
  {
    if (Tree.at(cur).at(nxt) == from)
      continue;
    while (col <= colors)
    {
      if (col == colorUsed)
      {
        col++;
      }
      else
      {
        Edge[make_pair(cur, Tree.at(cur).at(nxt))] = col;
        Edge[make_pair(Tree.at(cur).at(nxt), cur)] = col;
        dfs(Tree.at(cur).at(nxt), cur, col);
        col++;
        break;
      }
    }
  }
}

int main()
{
  cin >> N;
  for (int i = 0; i < N - 1; i++)
  {
    cin >> a >> b;
    a--;
    b--;
    Tree.at(a).push_back(b);
    Tree.at(b).push_back(a);
    vp.push_back(make_pair(a, b));
    Edge[make_pair(a, b)] = -1;
    Edge[make_pair(b, a)] = -1;
  }
  for (int i = 0; i < N; i++)
  {
    if (colors < Tree.at(i).size())
      colors = Tree.at(i).size();
  }
  dfs(0, -1, -1);
  cout << colors << endl;
  for (int i = 0; i < vp.size(); i++)
  {
    cout << Edge.at(vp.at(i)) << endl;
  }
}


Measured memory_bytes: 20472
#define _[301][301]
N,M,i,j,t,r,C _,D _;char S _;main(v){for(scanf("%d%d ",&N,&M);i=j=++t<M;r+=v)for(;j>N?j=i++<N:1;++j)i-1||gets(S+j),v=D[i][j]=fmin(D[i-1][j],D[i][j-1])+(C[i][j]=C[i-1][j-1]+(S[i][t-1]==S[j][t]));printf("%d\n",r);}

Measured memory_bytes: 1024
N = int(input())
# 1<=N<=10 abcdefghij
L = "abcdefghijk"[:N+1]

def dfs(s,mx):
    M = L.index(mx)
    if len(s) == N:
        print(s)
    else:
        for i in range(M+1):
            if L[i] == mx:
                dfs(s + L[i],L[M+1])
            else:
                dfs(s + L[i],mx)

dfs("",'a')

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    ll N,M; cin >> N >> M;
    vector<ll> S(N), T(M);
    REP(i,N) cin >> S[i]; REP(i,M) cin >> T[i];

    mint dp[N+1][M+1]; REP(i,N+1)REP(j,M+1) dp[i][j] = 0;
    mint sum[N+1][M+1]; REP(i,N+1)REP(j,M+1) sum[i][j] = 0;
    mint ans;
    REP(i,N)REP(j,M){
        if(S[i] == T[j]){
            dp[i+1][j+1] = sum[i][j] + 1;
        }
        else{
            dp[i+1][j+1] = 0;
        }
        sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + dp[i+1][j+1];
    }
    cout << sum[N][M].x+1 << endl;
    return 0;
}

Measured memory_bytes: 62848
import sys
sys.setrecursionlimit(10**6)

def main(n):
	a = list(map(int, input().split()))
	ans = 10**8
	for i in range(-100, 101, 1):
		temp = 0
		for j in a:
			temp += (i-j)**2
		if ans > temp:
			ans = temp
	print(ans)

main(int(input()))

Measured memory_bytes: 3060
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>
 
using namespace std;
 
/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, p; cin>>a>>p;
	cout<<(p + (a*3))/2;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, q;
  cin >> k >> q;
  vector<int> d(k);
  rep(i, k) cin >> d[i];
  rep(query, q) {
    int n, x, m;
    cin >> n >> x >> m;
    vector<int> dm(k);
    rep(i, k) dm[i] = d[i]%m;
    int res = n-1;
    ll a = x%m;
    rep(i, k) {
      ll num = (n-1)/k+((n-1)%k > i);
      a += num*dm[i];
      if (!dm[i])
        res -= num;
    }
    res -= a/m;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 384
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut c: Vec<usize> = Vec::new();
    let mut s: Vec<usize> = Vec::new();
    let mut f: Vec<usize> = Vec::new();
    for _ in 0..(n - 1) {
        c.push(iterator.next().unwrap().parse().unwrap());
        s.push(iterator.next().unwrap().parse().unwrap());
        f.push(iterator.next().unwrap().parse().unwrap());
    }

    let mut result = String::new();
    for i in 0..n {
        let mut current: usize = i;
        let mut t: usize = 0;
        while current < n - 1 {
            if t < s[current] {
                t = s[current];
            } else if t % f[current] != 0 {
                t += f[current] - t % f[current];
            }
            t += c[current];
            current += 1;
        }
        result.push_str(&format!("{}\n", t));
    }
    return result.trim().to_string();
}


Measured memory_bytes: 4352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x, y = readline().decode().split()
# x = int(x.lower(), 16)
# y = int(y.lower(), 16)
if x < y:
    print('<')
elif x == y:
    print('=')
else:
    print('>')


Measured memory_bytes: 2940
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >> getLine >>= print . length . filter ( == "ABC" ) . map ( take 3 ) . tails

Measured memory_bytes: 380
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DEF_ELM_MAX 20001
char pStr[DEF_ELM_MAX];

typedef struct _PAIR {
	int indx;
	int diff;
} PAIR;

int S1[DEF_ELM_MAX];
PAIR S2[DEF_ELM_MAX];

int s1_top = 0;

int s1_pop()
{
	return S1[--s1_top];
}

void s1_push(int x)
{
	S1[s1_top++] = x;
}

int s2_top = 0;

PAIR s2_Top()
{
	return S2[s2_top-1];
}

PAIR s2_pop()
{
	return S2[--s2_top];
}

void s2_push(int indx, int diff)
{
	PAIR x;
	x.indx = indx;
	x.diff = diff;

	S2[s2_top++] = x;
}

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	int j;
	int i;
	int sum;
	int a;
	char c;

//
	scanf("%s", pStr);

	sum = 0;
	i = 0;
	while ( (c = pStr[i]) != 0 ) {
		if ( c == '\\' ) {
			s1_push(i);
		} else if ( s1_top > 0 && c == '/') {
			j = s1_pop();
			a = i - j;
			sum += a;
			while ( s2_top > 0 && s2_Top().indx > j) {
				a += s2_pop().diff;
			}
			s2_push(j, a);
		}
		i++;
	}

	printf("%d\n", sum);
	printf("%d", s2_top);
	for ( i = 0 ; i < s2_top; i++ ) {
		printf(" ");
		printf("%d", S2[i].diff);	
	}
	printf("\n");	

	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxN = 1000010;
int n, m;
int Q[100];
char s[maxN];

ll cal(int k)
{
    ll res = 0;
    ll numD = 0, numM = 0, numC = 0;
    ll work = 0;
    int l = 0, r = k - 1;
    for (int i = 0; i < k; i++)
    {
        if (s[i] == 'D')
        {
            numD++;
        }
        if (s[i] == 'M')
        {
            work += numD;
            numM++;
        }
        if (s[i] == 'C')
        {
            res += work;
            numC++;
        }
    }
    while (r < n - 1)
    {
        if (s[l] == 'D')
        {
            numD--;
            work -= numM;
        }
        if (s[l] == 'M')
        {
            numM--;
        }
        if (s[l] == 'C')
        {
            numC--;
        }
        l++;
        r++;
        if (s[r] == 'D')
        {
            numD++;
        }
        if (s[r] == 'M')
        {
            work += numD;
            numM++;
        }
        if (s[r] == 'C')
        {
            numC++;
            res += work;
        }
    }
    return res;
}
int main()
{
    scanf("%d", &n);
    scanf("%s", s);
    scanf("%d", &m);
    for (int i = 0; i < m; i++)
        scanf("%d", &Q[i]);
    for (int i = 0; i < m; i++)
        printf("%lld\n", cal(Q[i]));
    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> G;
  for (int i = 2; i <= N; i++) {
    G.push_back(make_pair(1, i));
  }
  int d = (N - 1) * (N - 2) / 2;
  int res = d - K;
  if (res < 0) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 2; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (res == 0) goto loop;
      res--;
      G.push_back(make_pair(i, j));
    }
  }
  loop:
  cout << G.size() << "\n";
  for (int i = 0; i < G.size(); i++) {
    cout << G[i].first << " " << G[i].second << "\n";
  }
  return 0;
}

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

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    if(n%3==0 || m%3==0)cout<<0;
    else
    {
        long long mi=1e15;
        long long a,b,c;
        a=(n/3)*m+(n%3==2?m:0);
        b=(n/3)*m+m;
        c=(n/3)*m;
        mi=min(mi,max(a,max(b,c))-min(a,min(b,c)));
        a=(m/3)*n+(m%3==2?n:0);
        b=(m/3)*n+n;
        c=(m/3)*n;
        mi=min(mi,max(a,max(b,c))-min(a,min(b,c)));
        for(int i=0; i<=n; i++)
        {
            a=i*m;
            b=n-i;
            c=m-(m/2);
            c*=b;
            b*=m/2;
            mi=min(mi,max(a,max(b,c))-min(a,min(b,c)));
        }
        for(int i=0; i<=m; i++)
        {
            a=i*n;
            b=m-i;
            c=n-(n/2);
            c*=b;
            b*=n/2;
            mi=min(mi,max(a,max(b,c))-min(a,min(b,c)));
        }
        cout<<mi;
    }
    return 0;
}


Measured memory_bytes: 256
r,c = map(int, input().split())
a = []
for i in range(r):
    a.append(list(map(int, input().split())))
for i in range(r+1):
    if i != r:
        for j in range(c+1):
            if j != c:
                print(f'{a[i][j]} ', end='')
            else:
                print(sum(a[i]))
    else:
        for j in range(c+1):
            if j != c:
                print(f'{sum([b[j] for b in a])} ', end='')
            else:
                print(sum(map(sum, a)))


Measured memory_bytes: 6240
from sys import stdin

input = stdin.readline
lines = stdin.readlines

N = int(input())

txy = ((map(int, line.split())) for line in lines())


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        dt = t - pt - abs(x - px) - abs(y - py)
        # 余った時間が奇数 戻れない
        if dt < 0 or dt % 2 == 1:
            break

        pt = t
        px = x
        py = y
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()


Measured memory_bytes: 10276
n = int(input())
ls = [0]*4
for i in range(n):
  s = input()
  if s=="AC":
    ls[0]+=1
  elif s=="WA":
    ls[1]+=1
  if s=="TLE":
    ls[2]+=1
  if s=="RE":
    ls[3]+=1
print("AC x {}".format(ls[0]))
print("WA x {}".format(ls[1]))
print("TLE x {}".format(ls[2]))
print("RE x {}".format(ls[3]))

Measured memory_bytes: 9236
N, M = map(int, input().split())
H = list(map(int, input().split()))

adj = {i:[] for i in range(N)}
for _ in range(M):
	A, B = map(int, input().split())
	adj[A-1].append(H[B-1])
	adj[B-1].append(H[A-1])

cnt = 0
for v in range(N):
	if not adj[v]:
		cnt += 1
		continue
	if H[v] > max(adj[v]):
		cnt += 1

print(cnt)

Measured memory_bytes: 31612
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

void main()
{
    auto N = readln.chomp.to!int;
    if (N < 3 || popcnt(N) == 1) {
        writeln("No");
        return;
    }
    writeln("Yes");
    writefln("%d %d", 1, 2);
    writefln("%d %d", 2, 3);
    writefln("%d %d", 3, N+1);
    writefln("%d %d", N+1, N+2);
    writefln("%d %d", N+2, N+3);
    for (int i = 4; i+1 <= N; i += 2) {
        writefln("%d %d", N+1, i);
        writefln("%d %d", i, i+1);
        writefln("%d %d", N+1, N+i+1);
        writefln("%d %d", N+i+1, N+i);
    }
    if (N%2 == 0) {
        foreach (i; 2..N) {
            if ((N^i^1) < N && (N^i^1) != i) {
                writefln("%d %d", (i != 2 && i%2 == 0) ? i : N+i, N);
                writefln("%d %d", ((N^i^1)%2 == 0) ? N^i^1 : N+(N^i^1), 2*N);
                break;
            }
        }
    }
}

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,N,M,R,Q,X,Y,Z;
string s,t;

signed main()
{
	IOS();
	cin>>N>>M;
	vector<int>a(N);
	for(int i = 0;i < N;i++){
		cin>>a[i];
	}
	vector<pair<int,int>>v(M);
	for(int i = 0;i < M;i++){
		cin>>v[i].se>>v[i].fi;
	}
	sort(all(v));
	reverse(all(v));
	vector<int>ma;
	int flg = 1;
	for(auto e:v){
		rep(i,0,e.se){
			ma.push_back(e.fi);
			if(ma.size()==N){flg = 0;break;}
		}
		if(flg == 0)break;
	}
	while(ma.size()<N)ma.push_back(0);
	sort(all(a));
	int ans = 0;
	rep(i,0,N){
		ans+=max(a[i],ma[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3832
currentPlace = []
array = []
height = 0
start = 0
abs_len = 0

def get_input():
    array = []
    N = []
    while True:
        try:
            str1,str2,str3 = input().split()
            int1,int2,int3 = int(str1),int(str2),int(str3)
            if int1 == 0 and int2 == 0 and int3 == 0:
                break
            yield [int1,int2,int3]
        except EOFError:
            break

if __name__ == '__main__':
    array_total = list(get_input())
    while True:
        height = array_total[start][1]
        who = array_total[start][2]
        array = array_total[start:start+height+1]

        currentPlace = [height,who]
        del array[0]
        array.sort(key = lambda x:x[0],reverse = True)

        for i in range(len(array)):
            currentPlace[0] = int(array[i][0])
            if (int(array[i][0]) == currentPlace[0]
            and (int(array[i][1]) == currentPlace[1]
            or int(array[i][2]) == currentPlace[1])):
                if int(array[i][1]) == currentPlace[1]:
                    currentPlace[1] = int(array[i][2])
                else:
                    currentPlace[1] = int(array[i][1])

        print(currentPlace[1])

        start = start + height + 1
        abs_len = abs_len + height + 1
        del array[:]

        if abs_len + 1 > len(array_total):
            break

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

int main(){
    int N, K;
    cin >> N >> K;
    int p[N];
    for(int i=0; i<N; i++){
        cin >> p[i];
    }

    // int tmp;
    for(int i=1; i<N; i++){
        int tmp= p[i];
        for(int j=0; j<i; j++){
            if(p[i-j-1]>p[i-j]){
                tmp= p[i-j-1];
                p[i-j-1]= p[i-j];
                p[i-j]= tmp;
            }
        }
    }

    int sum=0;
    for(int i=0; i<K; i++){
        sum+= p[i];
    }
    cout << sum << endl;
    // for(int i=0; i<N; i++){
    //     cout << p[i] << endl;
    // }
    
    return 0;
}

Measured memory_bytes: 3652