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

typedef long long int ll;

#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)

const ll MOD = 1000000007;

using namespace std;

pair<int, int> lr[100005];
int P[100005];
bool isP[100005];

int main()
{
	int Q;
	cin >> Q;
	REP(i, Q)
	{
		cin >> lr[i].first >> lr[i].second;
	}

	//! 累積和で似た数表を作る
	int p = 0;
	REP(i, 100001)
	{
		isP[i] = true;
	}
	isP[0] = isP[1] = false;
	FOR(i, 100001, 0)
	{
		if (!isP[i])
		{
			P[i] = p;
			continue;
		}
		for (int j = 2 * i; j < 100001; j += i)
		{
			isP[j] = false;
		}
		//! 2017に似た数か判定
		if (isP[(i + 1) / 2])
		{
			++p;
		}
		P[i] = p;
	}

	REP(i, Q)
	{
		cout << P[lr[i].second] - P[lr[i].first - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
int dice[6]={1,2,4,3,5,6};

//?\\?????¢??????
void rotN(){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);
}

//???????????¢??????
void rotS(){
  //rotN(),rotN(),rotN();
  swap(dice[TOP],dice[BACK]);
  swap(dice[BACK],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[FRONT]);
}


//????????¢??????
void rotE(){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

//????????¢??????
void rotW(){
  //rotE(),rotE(),rotE();
  swap(dice[TOP],dice[RIGHT]);
  swap(dice[RIGHT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[LEFT]);
}

//???????????????????¨????????????????
void rotCW(){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}

//??????????????????????¨???????????????????
void rotCCW(){rotCW(),rotCW(),rotCW();}


int main(){
  cin>>dice[TOP]>>dice[FRONT]>>dice[RIGHT];
  cin>>dice[LEFT]>>dice[BACK]>>dice[BOTTOM];
   
  string str;
  cin>>str;
  for(int i=0;i<str.size();i++){
    if(str[i]=='N') rotN();
    if(str[i]=='S') rotS();
    if(str[i]=='E') rotE();
    if(str[i]=='W') rotW();
  }
 
  cout << dice[TOP]<<endl;
   
}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int main() {
  char a,b,c,d,e,f,g,h,i;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> f;
  cin >> g;
  cin >> h;
  cin >> i;
  
  cout << a;
  cout << e;
  cout << i;
  cout << endl;
  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
L = list(map(int, input().split()))
if N == 1:
  print(0)
else:
  x = 0
  for i in range(0,len(L)-1):
    if L[i] > L[i + 1]:
      x = x + (L[i] - L[i + 1])
      L[i + 1] = L[i + 1] + (L[i] - L[i + 1])
  print(x)
    



Measured memory_bytes: 31456
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int n;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vector<ll> a(n+1), b(n);
    rep(i,0,n+1) cin>>a[i];
    rep(i,0,n) cin>>b[i];
    ll ans=0;
    rep(i,0,n){
        if(a[i]>=b[i]){
            ans+=b[i];
        }
        else{
            ans+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i]){
                ans+=b[i];
                a[i+1]-=b[i];
            }
            else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int n, k;
    cin >> n >> k;

    double p = 0;
    for(int i=1; i <= n; i++){
        int score = i;
        int cnt = 0;
        while(score < k){
            score *= 2;
            cnt++;
        }
        p += pow(0.5, cnt)/n;
    }


    printf("%.12f", p);

    




}






//              g++ -std=c++1z

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>dy({0,-1,0,1}),dx({1,0,-1,0});

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n+n); for(auto&&i:a)cin>>i;
	for(int i=1;i<n;++i){
		a.at(i)+=a.at(i-1);
		a.at(n+n-i-1)+=a.at(n+n-i);
	}
	int ans=0;
	for(int i=0;i<n;++i){
		ans=max(ans,a.at(i)+a.at(n+i));
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3620
min_num = 10
num = 0
for i in range(5):
    a = int(input())
    if a % 10 == 0:
       num += a
    else:
        num += ((a//10) + 1) * 10
        min_num = min(min_num, a%10)


print(num+min_num-10)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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


int n, m;
bool graph[60][60];
bool visited[60];

void init(){
  for (int i = 0; i < n; i++) {
    visited[i] = false;
  }
}

void dfs(int x){
  if(visited[x]) return;
  visited[x] = true;
  for (int i = 0; i < n; i++) {
    if(graph[x][i]){
      dfs(i);
    }
  }
}


int main(){
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  int res = 0;

  for (int i = 0; i < m; i++) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    init();

    dfs(0);

    bool connect = true;
    for (int i = 0; i < n; i++) {
      if(!visited[i]) connect = false;
    }
    if(!connect) res++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

  }


  cout << res << endl;

}


Measured memory_bytes: 256
N, T = [int(i) for i in input().split()]  # 数字はなるべく早い段階でint型にしておいた方がわかりやすい

all_pattern_list = []
# 次のようにするともっとシンプルにall_pattern_list = [[c1, t1], [c2, t2], ... , [cN, tN]] という2次元リストを作れる
for i in range(N):
    all_pattern_list.append([int(j) for j in input().split()])  # もしタプルにしたい場合はtuple([int(j) for j in input().split()])とすればOK

INF = 1001
ans = INF  # 解が見つからなかった場合を判定できるようにコストが取り得ない大きな値を初期値に設定しておく
# どうせ最悪全部見ることになるのでソートしなくてもOK
for c, t in all_pattern_list:  # アンパックを使うとわかりやすい変数名を使える
    if t <= T:
        ans = min(ans, c)  # 暫定最小コストより小さい場合は最小コストを更新

if ans == INF:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 9196
n = input()
a = 0
b = 2
for s in n:
  v = int(s)
  a_ = min(a + v, b + v)
  b_ = min(a + 10 - v + 1, b + 10 - v + 1 - 2)
  a = a_
  b = b_
  
print(min(a, b))

Measured memory_bytes: 5492
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// n円(支払う額)
        int a = sc.nextInt();// 1円の枚数a枚

        int leftCoin = n % 500;
        if (leftCoin <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
  int d,i,ans;
  while(scanf("%d",&d)!=EOF){
    ans=0;
    for(i=d;i<=600-d;i+=d)
      ans+=i*i*d;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void)
{
  unsigned long int n;
  unsigned long int i;

  scanf("%d", &n);

  if(0<n && n<=20){
    unsigned long int ans=n;
    for(i=n-1; i>0; i--){
      ans=ans*i;
    }

    printf("%ld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()

int main() {
	int d, n, t, sum=0;
	cin >> d >> n;
	rep(i, n) {
		cin >> t;
		sum += t;
	}

	if (sum > d) {
		std::cout << "-1" << '\n';
	} else {
		std::cout << d-sum << '\n';
	}
}


Measured memory_bytes: 3592
#include <iostream>

int main() 
{
    size_t n, n_blue, n_red;
    std::cin >> n >> n_blue >> n_red;
    const size_t iter = n / (n_blue + n_red);
    const size_t rem = n % (n_blue + n_red);
    std::cout << iter * n_blue + std::min(rem, n_blue) << std::endl;
    return 0;
}


Measured memory_bytes: 384
/*
      author : nishi5451
      created: 11.08.2020 19:46:04
*/

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


int main(){
    int m;
    cin >> m;
    cout << 48-m << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL MOD = 1000000007;

	void Solve() {
		UL N, M; cin >> N >> M;
		vector<UL> F;
		{
			for (UL i = 2; i * i <= M; i++) {
				if (M % i == 0) F.push_back(0);
				while (M % i == 0) {
					M /= i; F.back()++;
				}
			}
			if (M != 1) F.push_back(1);
		}
		UL Z = N + 100;
		vector<ULL> f(Z + 1); f[0] = 1;
		for (UL i = 1; i <= Z; i++) f[i] = f[i - 1] * i % MOD;
		vector<ULL> I(Z + 1); I[1] = 1;
		for (UL i = 2; i <= Z; i++) I[i] = MOD - MOD / i * I[MOD % i] % MOD;
		vector<ULL> If(Z + 1); If[0] = 1;
		for (UL i = 1; i <= Z; i++) If[i] = If[i - 1] * I[i] % MOD;
		ULL ans = 1;
		for (UL p : F) {
			ULL tmp = f[N + p - 1] * If[p] % MOD * If[N - 1] % MOD;
			ans = ans * tmp % MOD;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 2560
#include <stdio.h>

 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
 }


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

class Dsu
{
public:
    vector<int> par, size;
    int distinct_sets_count;

public:
    Dsu(int n)
    {
        distinct_sets_count = n;
        par.resize(n);
        for(int i = 0; i < n; i++)
            par[i] = i;
        size.resize(n, 1);
    }

    int root(int x)
    {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void connect(int a, int b)
    {
        a = root(a), b = root(b);
        if(a == b) return;
        if(size[a] < size[b])
            swap(a, b);
        size[a] += size[b];
        par[b] = a;
        distinct_sets_count--;
    }

    int set_count()
    {
        return distinct_sets_count;
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n, m;
    cin >> n >> m;
    Dsu dsu(n);
    rep(i,0,m)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        dsu.connect(x, y);
    }
    int ans = 0;
    rep(i,0,n)
        ans = max(ans, dsu.size[dsu.root(i)]);
    cout << ans;
}


Measured memory_bytes: 4780
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
const int INF=1061109567;
int n;
struct Node
{
	int l,r;
}a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,l;
		scanf("%d%d",&x,&l);
		a[i].l=x-l,a[i].r=x+l;
	}
	sort(a+1,a+n+1,[=](const Node &a,const Node &b){return a.l==b.l?a.r<b.r:a.l>b.l;});
	int ans=0,now=INF+INF;
	for(int i=1;i<=n;i++)
		if(a[i].r<=now) ans++,now=min(now,a[i].l);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  vi Prime;
  vi A(100000);
  Prime.push_back(2);
  for(int i=3;i<100000;i+=2){
    bool flag=1;
    A[i]=A[i-2];
    rep(j,0,Prime.size()){
      if(i%Prime[j]==0){
        flag=0;
        break;
      }
    }
    if(flag){
      Prime.push_back(i);
      if(binary_search(ALL(Prime),(i+1)/2))
        A[i]++;
      }
  }
  int Q; cin>>Q;
  rep(i,0,Q){
    int l,r; cin>>l>>r;
    int ans=A[r]-A[max(1LL,l-2)];
    cout<<ans<<endl;
  }
  }



Measured memory_bytes: 1664
//
//AtCoder Beginner Contest 081
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    REP(i,s.size()){
        ans += s[i]-'0';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int h, w, n, x, y, z=1, ans;
    vector<int> v[200001];
    cin >> h >> w >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        v[y].push_back(x);
    }
    ans = h;
    for(int i=1;i<=w;i++){
        sort(v[i].begin(), v[i].end());
    }
    
    for(int i=1;i<=w;i++){
        for(int j=0;j<v[i].size();j++){
            if(v[i][j]>z){
                ans = min(ans, v[i][j]-1);
            }
        }
        if(i==w)break;
        z++;
        for(int j=0;j<v[i+1].size();j++){
            if(v[i+1][j]==z)z++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8704
package main

import (
	"fmt"
	"sort"
)

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

func main() {
	var a [3]int
	fmt.Scan(&a[0], &a[1], &a[2])
	b := a[:]
	sort.Ints(b)

	fmt.Println(abs(b[0]-b[1]) + abs(b[1]-b[2]))
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
#define N 4000 + 5
#define Mod 924844033
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
int n, k, ans, tot, last, f[N], fac[N], a[N], dp[N][N][2];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){ return (a += b) >= Mod ? a - Mod : a;}
int Dec(int a, int b){ return (a -= b) < 0 ? a + Mod : a;}
int Mul(int a, int b){ return 1ll * a * b % Mod;}
int main(){
    n = read(), k = read(), f[0] = fac[0] = 1;
    rep(i, 1, 2 * n) fac[i] = Mul(fac[i - 1], i);
    rep(i, 1, k){
        for(int j = i; j <= n; j += k) a[++tot] = j;
        for(int j = i; j <= n; j += k) a[++tot] = j;
    }
    dp[1][1][1] = dp[1][0][0] = 1;
    rep(i, 2, 2 * n) rep(j, 0, n){
        dp[i][j][0] = Inc(dp[i - 1][j][0], dp[i - 1][j][1]);
        if(a[i + 1] - a[i] == k && j >= 1) dp[i][j][1] = dp[i - 1][j - 1][0];
    }
    rep(i, 0, n){
        if(i & 1) ans = Dec(ans, Mul(dp[2 * n][i][0], fac[n - i]));
        else ans = Inc(ans, Mul(dp[2 * n][i][0], fac[n - i]));
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 124544
#include <iostream>
//#include <math.h>
//#include <string>


using namespace std;

int main(void){
    int K, N, tot=0;
    cin >> K >> N;
    int A[N+1]={}, max=0;

    for (int i = 1; i < N+1; i++)
    {
        cin >> A[i];
    }
    for (int i = 1; i < N+1; i++)
    {
        if(i!=1){
            tot += A[i]-A[i-1];
            if(A[i]-A[i-1]>max){
                max = A[i]-A[i-1];
            }
        }else{
            tot += K-(A[N]-A[1]);
            max = K-(A[N]-A[1]);
        }
    }
    

    tot -= max;

    cout << tot << endl;
    
    return 0;
}

Measured memory_bytes: 1024
def f_modularness():
    K, Q = [int(i) for i in input().split()]
    D = [int(i) for i in input().split()]
    Queries = [[int(i) for i in input().split()] for j in range(Q)]

    def divceil(a, b):
        return (a + b - 1) // b

    ans = []
    for n, x, m in Queries:
        last, eq = x, 0  # 末項、D_i % m == 0 となる D_i の数
        for i,d in enumerate(D):
            num = divceil(n - 1 - i, K)  # D_i を足すことは何回起きるか？
            last += (d % m) * num
            if d % m == 0:
                eq += num
        ans.append((n - 1) - (last // m - x // m) - eq)
    return '\n'.join(map(str, ans))

print(f_modularness())


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

using namespace std;


template< typename T >
struct edge
{
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

template< typename G >
struct LowLink
{
  const G &g;
  vector< int > used, ord, low, parent;

  LowLink(const G &g) : g(g), used(g.size()), ord(g.size()), low(g.size()), parent(g.size(), -1) {}

  void dfs(int idx, int &k, int par = -1)
  {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];

    for(auto &to : g[idx]) {
      if(!used[to]) {
        dfs(to, k, idx);
        low[idx] = min(low[idx], low[to]);
        parent[to] = idx;
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
  }

  void dfs()
  {
    int k = 0;
    dfs(0, k);
  }
};

template< typename G >
struct ArticulationPoints : LowLink< G >
{
  using LL = LowLink< G >;

  ArticulationPoints(const G &g) : LL(g) {}

  vector< int > build()
  {
    LL::dfs();
    vector< int > vs;
    int sum = 0;
    for(int i = LL::g.size() - 1; i >= 1; i--) {
      if(LL::parent[i] == 0) ++sum;
      else if(LL::ord[LL::parent[i]] <= LL::low[i]) {
        vs.emplace_back(LL::parent[i]);
      }
    }
    if(sum > 1) vs.push_back(0);
    sort(begin(vs), end(vs));
    vs.erase(unique(begin(vs), end(vs)), end(vs));
    return (vs);
  }
};

int main()
{
  int V, E;
  cin >> V >> E;
  UnWeightedGraph g(V);
  while(E--) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ArticulationPoints< UnWeightedGraph > ap(g);
  for(auto &k : ap.build()) cout << k << endl;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<long> A;
	for(int i=0;i<N;i++){
		long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), greater<long>());
	long ans = 0;
	for(int i=1;i<N;i++){
		if(i % 2 == 1) ans += A[(i - 1) / 2];
		else ans += A[i / 2];
	}
	cout << ans << endl;
}


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

int main() {
	string s; cin >> s;
	int ans = s.size();
	for (int i = 0; i < 2; i++) {
		int cnt = 0;
		for (int j = 0; j < s.size(); j++) {
			if ((j % 2 == 0) ^ (s[j] == i + '0'))cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < n; i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){
    //パラメータ入力
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int m=1000005;
    vector<int> cnt(m); //1～10^6に対して約数が存在するかチェックしていくカウント用ベクタを定義
    for(int x:a){ //aの各要素に対してループ
        if(cnt[x] != 0){
            cnt[x] = 2; //すでに1になっていたら2として約数が存在することを分かるようにして次のxに
            continue;
        }
        for(int i=x; i<m; i+=x) cnt[i]++; //cnt[x]==0なら各倍数に対して+1していく
    }
    int ans=0;
    for(int x:a){
        if(cnt[x]==1) ans++; //cnt=1(=約数が自分以外存在しなかった)の数をカウント
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7904
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, T, Ans, A[1000001];
int main() {
	cin >> N >> K ;
	for(int i = 1; i <= N; i ++ ) 
		scanf("%d", &A[i]);
	sort(A+1, A+N+1);
	for(int i = N; i >= 1; i -- ) 
		if(T+A[i] >= K) Ans = 0; else Ans++, T += A[i];
	cout << Ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s;
	for(;cin>>s,s!="#";){
		int m[2]={0,0},n[2];
		for(int i=1;i<s.size();i++){
			if((s[i]-'1')%3>(s[i-1]-'1')%3){
				n[0]=min(m[0]+1,m[1]);
				n[1]=1<<30;
			}else if((s[i]-'1')%3<(s[i-1]-'1')%3){
				n[0]=1<<30;
				n[1]=min(m[0],m[1]+1);
			}else{
				n[0]=m[1];
				n[1]=m[0];
			}
			m[0]=n[0],m[1]=n[1];
		}
		cout<<min(m[0],m[1])<<endl;
	}
}

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

int fr[26];

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

    int ans=0;
    for(int i=1;i<(n-1);i++)
    {
        int q[3];
        q[0]=a[i],q[1]=a[i-1],q[2]=a[i+1];
        sort(q,q+3);
        if(q[1]==a[i])
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

from decimal import Decimal
a,b = input().split()
a = int(a)
b = float(b)
b = round(100*b)
print(a*b//100)


Measured memory_bytes: 9900
#include <iostream>
using namespace std;
int main()
{
	int n, x, buffer, now = 0, ans = 1;
	cin >> n >> x;
	for (int i = 0; i<n; i++)
	{
		cin >> buffer;
		if (now + buffer <= x)
		{
			ans++;
		}
        now += buffer;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(n);
  vector<int> q(n);
  iota(a.begin(), a.end(), 1);
  for (int i = 0; i < n; i++)
    cin >> p[i];
  for (int i = 0; i < n; i++)
    cin >> q[i];
  int cur = 1;
  int x, y;
  do{
     if (p == a)
       x = cur;
     if (q == a)
       y = cur;
     cur++;  
  }while(next_permutation(a.begin(), a.end()));
  cout << abs(x - y) << '\n'; 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>

using ll = long long;
using namespace std;
#define modmod 1000000007

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)


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

    char now = S[0];
    int count = 0;

    for(int i = 1; i < S.length(); i++){
        if(now != S[i]){
            count++;
            now = S[i];
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, m, k;
int f[N], sz[N], cnt[N];
int find(int x) 
{
	if(x==f[x]) return x;
	return find(f[x]);
}
void merge(int x, int y)
{
	int fx = find(x), fy = find(y);
	if(fx!=fy)
	{
		if(sz[fx]>sz[fy]) swap(fx, fy);
		f[fx] = fy;
		sz[fy] += sz[fx];
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++) sz[i] = cnt[i] = 1, f[i] = i;
	for(int i=1; i<=m; i++)
	{
		int u, v;
		cin >> u >> v;
		merge(u, v);
		cnt[u]++; cnt[v]++;
	}
	for(int i=1; i<=k; i++)
	{
		int u, v;
		cin >> u >> v;
		int fx = find(u), fy = find(v);
		if(fx==fy) cnt[u]++, cnt[v]++;
	}
	for(int i=1; i<=n; i++) cout << max(0, sz[find(i)]-cnt[i]) << " \n"[i==n];
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define all(arr) arr.begin(), arr.end() 
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;
int n;
string s;

int main(){
	IOS
	cin >> n >> s;
	string a, b;
	for(int i=0;i<n/2;i++){
		a+=s[i];
	}
	for(int i=n/2;i<n;i++){
		b+=s[i];
	}
	if(a==b){
		cout << "Yes" << '\n';
	}	
	else{
		cout << "No" << '\n';
	}
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n), b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n%2==0) {
        int v = n/2;
        int ans = (b[v]+b[v-1])-(a[v]+a[v-1])+1;
        cout << ans << '\n';
    }
    else {
        int ans = b[n/2]-a[n/2]+1;
        cout << ans << '\n';
    }


    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();

    set<string> sset;
    rep(i, n){
        int vmin = min(6, n-i+1);
        reps(len, 1, vmin){
            sset.insert(s.substr(i, len));
            // cout << s.substr(i, len) << endl;
        }
    }

    set<string>::iterator itr = sset.begin();
    
    rep(i, k-1){
        itr++;
    }

    cout << *itr << endl;

    return 0;
}

Measured memory_bytes: 1664
N=int(input())
X= list(map(int,input().split()))
Y=sorted(X,reverse=True) 
#print(X)
large = Y[N//2-1]
small = Y[N//2]

for i in range(N):
  if X[i]>=large:
    print(small)
  else:
    print(large)

#Y=[]
#for i in range(N):
#  Y.append((i,X[i]))
#print(Y)

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

using namespace std;

int main(){
    int n,i,j;
    long k;
    j=0;

    cin >> n >> k;
    int a[2][n+1];
    int b[n+1];
    a[0][0]=1;
    b[0]=1;
    for (i = 1;i<=n;i++){
        cin >> a[0][i];
        a[1][i]=0;
    }
    //a[1][1]=0;
    a[1][0]=0;
    b[0]=1;

    for(j=0;j<=k && a[1][b[j]]==0;j++){
        b[j+1]=a[0][b[j]];
        a[1][b[j]]=j;
    }

    if(j>k)cout << b[k] << endl;
    else cout << b[a[1][b[j]] + (k-j)%(j-a[1][b[j]])] << endl;



    return 0;
}


Measured memory_bytes: 5740
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll>l(n+1,0);
    vector<ll>r(n+1,0);
    for(int i=1;i<n;i++){
        l[i]=l[i-1];
        if(s[i-1]=='#'){
            l[i]++;
        }
    }
    for(int i=n-1;i>=0;i--){
        r[i]=r[i+1];
        if(s[i+1]=='.'){
            r[i]++;
        }
    }
    ll ans = INF;
    rep(i,n){
        chmin(ans,l[i]+r[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6808
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;
    if(p==1)
        cout << 1 << endl;
        else{
        
            ll ans = 1, yj = sqrt(p);
            if(n==1)
                ans = p;
            else{
                for (ll i = 2; i <= yj;i++){
                ll tmp = pow(i, n);
                if(tmp<=p&&p%tmp==0){
                    ans = max(ans, i);
                }
                }
            }
            cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 256
#ABC060 A - Shiritori
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c = map(str, input().split())
if a[-1]==b[0] and b[-1]==c[0]:
    print('YES')
else:
    print('NO')


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

int main() {
    int x;
    cin >> x;
    int n = 0;
    while (n * (n+1) < 2 * x) {
        ++n;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
int h,w,s,t,m,min,ans;
int main(){
    while(1){
        scanf("%d%d", &h, &w);
        if(h==0&&w==0) break;
        min=h*h+w*w;
        ans=150*150;
        for(int i=1;i<=150;i++)
            for(int j=i+1;j<=150;j++){
                m = i*i+j*j;
                if(min<=m&&m<ans&&(i!=h||j!=w)){
                    if(min==m&&i<h)continue;
                    ans=m;
                    s=i;
                    t=j;
                }
            }
        printf("%d %d\n",s,t);
    }
    return 0;
}



Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
int f[N+1][N+1];

int main(){
	string x, y;
	cin >> x;
	cin >> y;
	
	int n = x.length(), m = y.length();
	for(int i = 0; i <= n; i++){
	    for(int j = 0; j <= m; j++){
	        if(i == 0 || j == 0) f[i][j] = 0;
	        else if(x[i-1] == y[j-1]) f[i][j] = f[i-1][j-1] + 1;
	        else f[i][j] = max(f[i-1][j], f[i][j-1]);
	    }
	}
	string s;
	int i = n, j = m;
	while(i > 0 && j > 0){
	   if(x[i-1] == y[j-1]){
	            s += x[i-1];
	            i -= 1;
	            j -= 1;
	        }
	        else if(f[i-1][j] > f[i][j-1]) i -= 1;
	        else j -= 1;
	}
	reverse(s.begin(),s.end());
	cout << s;
}

Measured memory_bytes: 38800
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int MaxN = 1e5 + 5;
int a[MaxN] , dp[MaxN], n;
int main(){
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i++)scanf("%d",&a[i]);
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3 ; i <= n ;i++){
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();


		int max = 0;
		for (int i = 0; i < S.length(); i++) {
			int cnt = 0;
			char c = S.charAt(i);
			if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
				cnt = 1;
				for (int j = i+1; j < S.length(); j++) {
					char c2 = S.charAt(j);
					if (c2 == 'A' || c2 == 'C' || c2 == 'G' || c2 == 'T') {
						cnt++;
						continue;
					} else {
						i = j;
						break;
					}
				}
			}
			max  = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23380
A,B,K = map(int, input().split())

if K<A+1:
    st1 = (str(A-K))
    st2 = str(B)
    result = [st1, st2]
    print(' '.join(result))
elif K<A+B:
    st1 = (str(0))
    st2 = str(A+B-K)
    result = [st1, st2]
    print(' '.join(result))
else:
    st1 = (str(0))
    st2 = str(0)
    result = [st1, st2]
    print(' '.join(result))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

vector<vector<edge>> g;

vector<bool> see;


int main() {

	ll A, B, C;
	cin >> A >> B >> C;
	if (A == B) { cout << C; }
	if (A == C) { cout << B; }
	if (C == B) { cout << A; }

	system("PAUSE");

	

}


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

/**
 * Flick Input
 */
public class Main {

	static final char[] cs = {'w', '_', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r'};
	static final char[] vs = new char['U' + 1];

	static {
		vs['T'] = 'a';
		vs['L'] = 'i';
		vs['U'] = 'u';
		vs['R'] = 'e';
		vs['D'] = 'o';
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		String ans = "";
		
		line = br.readLine();

		for (int i = 0; i < line.length(); i += 2) {
			char c, v;
			c = cs[line.charAt(i) - '0'];
			v = vs[line.charAt(i + 1)];

			ans += c;
			ans += v;

		}

		ans = ans.replace("_", "");
		ans = ans.replace("wu", "nn");

		System.out.println(ans);

	}
}

Measured memory_bytes: 28636
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
s="abcdefghijklmnopqrstuvwxyz"
ans=""
while(n>0):
    n-=1
    ans+=s[n%26]
    n//=26
print(ans[::-1])    

Measured memory_bytes: 65400
N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

S = sum(As)

for i in range(len(As)-1):
    S -= As[i]
    tmp = As[i] * S
    result += tmp
    result %= MOD

print(result)



Measured memory_bytes: 31576
#abc066d
mod=10**9+7
fact=[1]*(10**5+2)
for n in range(1,10**5+2):
 fact[n]=n*fact[n-1]%mod

def com(n,k,m):
 return fact[n]*pow(fact[k],m-2,m)*pow(fact[n-k],m-2,m)%m

N=int(raw_input())
A=map(int,raw_input().split())
c=[-1]*N
for i in range(N+1):
 if c[A[i]-1]!=-1:
  break
 c[A[i]-1]=i
j=c[A[i]-1]
i=N-i
for k in range(1,N+2):
 res=com(N+1,k,mod)
 if k-1<=i+j:
  res-=com(i+j,k-1,mod)
 print res%mod


Measured memory_bytes: 16296
def Comb(i, j, memo):
    if i == j:
        return 1
    elif j == 1:
        return i
    try:
        return memo[(i, j)]
    except KeyError:
        ans = Comb(i-1, j-1, memo) + Comb(i-1, j, memo)
        memo[(i,j)] = ans
        return ans

N, A, B = map(int, input().split())
V = [int(i) for i in input().split()]
V.sort(reverse = True)
av = 0
for i in range(A):
    av += V[i]
av = round(av/A, 6)

memo = {}
if V[0] == V[A-1]:
    lim = min(V.count(V[0]), B)
    ans = 0
    for j in range(A, lim+1):
        ans += Comb(V.count(V[0]), j, memo)
else:
    ans = Comb(V.count(V[A-1]), V[:A].count(V[A-1]), memo)

print(av)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
int a,b,c=0,d,e;
while(c==0){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
for(d=0;d<a;d++){
for(e=0;e<b;e++){
printf("#");
}
printf("\n");
}
printf("\n");
}
}
return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
//const int mod = 1000000007;
int main(void){
    int h,w,k;cin>>h>>w>>k;
    char c[h][w];
    int sum=0;
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        if(c[i][j]=='#')sum++;
    }
    int res=0;
    for(int tmp1=0;tmp1<(1<<h);tmp1++){
        for(int tmp2=0;tmp2<(1<<w);tmp2++){
            int now=0;
            rep(i,h){
                if(!(tmp1&(1<<i)))continue;
                rep(j,w){
                    if(c[i][j]=='#'){
                        now++;
                        if(tmp2&(1<<j))now--;
                    }
                }
            }
            rep(j,w){
                if(!(tmp2&(1<<j)))continue;
                rep(i,h){
                    if(c[i][j]=='#')now++;
                }
            }
            if(now==sum-k)res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll wsum = 0;
  rep(i, n) wsum += a[i];
  vector<ll> w(n);
  w[0] = wsum;
  for(int i = 1; i < n; i += 2) {
    w[0] -= 2 * a[i];
  }
  rep(i, n - 1) w[i + 1] = 2 * a[i] - w[i];
  rep(i, n) {
    printf("%lld%c", w[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int x=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            x++;
            break;
        }
    }
    if(x!=0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    long long N, K; cin >> N >> K;
    long long res = 0;
    long long x = N / K;
    res += x * x * x;
    if (K%2==0) {
        long long y = (N+K/2)/K;
        res += y * y * y;
    }
    cout << res << endl;
}


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

int main() {
  int N;
  cin >> N;
  int a = N;
  int b = 0;
  while(true){
    b += a % 10;
    if (a >= 10) {
      a /= 10;
    }else {
      break;
    }
  }
  if (N % b == 0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Aizu Vol-2 0239: Calorie Counting
// 2017.8.7

#include <stdio.h>

#define MAX 1000
int s[MAX + 2], p[MAX + 2], q[MAX + 2], r[MAX + 2], N;

int main()
{
	int P, Q, R, C;
	int i, f, c;

	while (1) {
		scanf("%d", &N);
		if (N == 0) break;
		for (i = 0; i < N; i++) scanf("%d%d%d%d", s+i, p+i, q+i, r+i);
		scanf("%d%d%d%d", &P, &Q, &R, &C);
		for (f = i = 0; i < N; i++) {
			c = (p[i]+r[i]) * 4 + q[i] * 9;
			if (p[i] > P || q[i] > Q || r[i] > R || c > C) ;
			else printf("%d\n", s[i]), f = 1;
		}
		if (!f) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main() {

	int N,K;

	scanf("%d %d",&N,&K);

	int* table = new int[N];
	bool* henshin_sareru = new bool[N];
	bool* rule_3_apply = new bool[N];

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
		henshin_sareru[i] = false;
		rule_3_apply[i] = false;
	}

	int* min_count = new int[N];

	for(int i = 0; i < N; i++)min_count[i] = BIG_NUM;

	for(int i = N-1; i >= 0; i--){
		if(table[i] > 0){

			henshin_sareru[table[i]-1] = true;

			if(henshin_sareru[i] == false){

				int count = 0,loc = table[i]-1;

				while(count < K-1){

					if(min_count[loc] <= count)break;

					min_count[loc] = count;

					rule_3_apply[loc] = true;
					henshin_sareru[loc] = true;

					if(table[loc] == 0)break;

					loc = table[loc]-1;
					count++;
				}
			}
		}
	}

	int ans = 0;

	for(int i = 0; i < N; i++){
		if(table[i] == 0 || henshin_sareru[i] == false || rule_3_apply[i] == true)ans++;
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

bool isprime(int x){
  if(x==2)
    return true;

  if(x<2 || x%2==0)
    return false;

  int i=3;
  while(i<=sqrt(x)){
     if(x%i==0)
       return false;
     i+=2;
  }
  return true;

}

int main(){
  int n,v,s=0;

  scanf("%d\n",&n);

  for(int i=0;i<n;i++){
  scanf("%d\n",&v);
    if(isprime(v))
      s++;
  }
  printf("%d\n",s);
}


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

int main()
{
	int q,t,f;
	char c;
	string s1,s2;
	cin>>s1>>q;
	while(q--)
	{
		cin>>t;
    	if(t==1)
    		swap(s1,s2);
		else
		{
			cin>>f>>c;
      		if(f==1)
        		s2.push_back(c);
			else
        		s1.push_back(c);
    	}
	}
	reverse(s2.begin(),s2.end());
	cout<<s2+s1;
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N, M;
    cin >> N >> M;
    ll p[100000] = {};
    string S[100000] = {};
    rep(i,M) {
        cin >> p[i];
        cin >> S[i];
    }
    ll WA[100000] = {};
    bool isAC[100000] = {};
    rep(i,100000) isAC[i] = false;
    rep(i,M) {
        if(isAC[p[i]-1] == false && S[i] == "AC") {
            isAC[p[i]-1] = true;
        } else if (isAC[p[i]-1] == false && S[i] == "WA") {
            WA[p[i]-1]++;
        }
    }
    ll ans = 0;
    ll pen = 0;
    rep(i,N) {
        if(isAC[i]) {
            ans++;
            pen += WA[i];
        }
    }
    cout << ans << " " << pen << endl;
    return 0;
}

Measured memory_bytes: 7424