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

int main(){
  int x,y;
  cin >> x >> y;
  bool a=false;
  if(x==4 || x==6 || x==9){
    if(y==6 || y==9 || y==11){
      a=true;
    }
  }
  else if(x==1 || x==3 || x==5 || x==7 || x==10){
    if(y==3 || y==5 || y==7 || y==8 || y==10){
      a=true;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, y;
    cin >> n >> y;
    for(int i=0; i<=n; i++) {
        for(int j=0; i+j<=n; j++) {
            int sen = n - i - j;
            if (10000*i + 5000*j + 1000*sen == y) {
                cout << i << " " << j << " " << sen << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = K; i < N; ++i) {
    if (A[i - K] < A[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }    
  return 0;
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
int k[100005];
int a[100005];
int main(){
  int m,n,b,c=0,w=0;
  string s;
  cin>>m>>b>>n;
  if(m>b){
    c=m;
    w=b;
  }
  else{
    c=b;
    w=m;
  }
  if(n%c==0) cout<<n/c<<"\n";
  else cout<<n/c+1<<"\n";
  return(0);
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, x = list(map(int,_in[0].split(' ')))
    a_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    a_arr.sort()
    for i in range(N):
        if sum(a_arr[:i+1]) > x:
            cnt = i
            break
        elif sum(a_arr[:i+1]) == x:
            cnt = i+1
            break
    else:
        cnt = N-1
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    bool a=true;
    string s;
    cin>>s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])a=false;
    string ans=a?"Good":"Bad";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int t = sc.nextInt();
		
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		int count = 0;
		int maxDif = 0;
		int max = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (max < a[i]) {
				max = a[i];
			} else {
				if (maxDif < max - a[i]) {
					maxDif = max - a[i];
					count = 1;
				} else if (maxDif == max - a[i]) {
					count++;
				}
			}
		}
		
		out.println(count);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
}

Measured memory_bytes: 9652
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if (ch == 'A')return 1;
    else if(ch == 'C')return 2;
    else if(ch == 'G')return 3;
    else if(ch == 'T')return 4;
    else return 0;
}

long long getkey(char str[]){
    long long sum = 0, p = 1,i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M - 1));}

int find(char str[]){
    long long key, i, h;
    key = getkey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        }else if(strlen(H[h]) == 0){
            return 0;
        }
    }
    
    return 0;
    
}

int insert(char str[]){
    long long key, i, h;
    key = getkey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key))% M;
        if (strcmp(H[h], str) == 0 ){
            return 1;
        }else if(strlen(H[h]) == 0 ){
            strcpy(H[h], str);
            return 0;
        }
    }
}

int main(){
    
    int i, n, h;
    char str[L], com[9];
    for (i = 0;i < M; i++) {
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s",com, str);
        
        if(com[0] == 'i'){
            insert(str);
        }else {
            if(find(str) == 1){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 14916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int s[3005][2];

int main(){
	LL n,a;
	int i,j,k;
	cin>>n;
	for(i=0,a=1;n>a;i++,a*=3);
	cout<<i<<endl;
}



Measured memory_bytes: 3116
def gcd(a,b):
  if not a or not b:
    return 0
  else:
    while b:
      a,b = b,a%b
    return a

num = int(input())
nums = [int(s) for s in input().split()]

l = nums[0]
r = nums[-1]
left = []
right = []
for i in range(num-1):
  l,r = gcd(l,nums[i]), gcd(r,nums[-i-1])
  left.append(l)
  right.append(r)
answer = [left[-1],right[-1]]
for i in range(len(left)-1):
  answer.append(gcd(left[i],right[-i-2]))
print(max(answer))

Measured memory_bytes: 14052
#include <iostream>
#include <unordered_map>
#include <string>

using namespace std;

int main()
{
    unsigned int cmd_num;
    cin >> cmd_num;
    string cmd;
    string gene;
    unordered_map<string, int> u_map;
    for (int i = 0; i < cmd_num; ++i) {
        cin >> cmd;
        if (cmd == "insert")
        {
            cin >> gene;
            u_map.insert({gene, 1});
        }
        else {
            cin >> gene;
            if (u_map.find(gene) == u_map.end()) {
                cout << "no" << endl;
            }
            else {
                cout << "yes" << endl;
            }
        }
    }
}



Measured memory_bytes: 36276
import java.util.*
import kotlin.math.*

fun main() {
    val (x, y) = readIntList()

    var ans = Int.MAX_VALUE
    if (y >= -x) {
        ans = min(ans, y - -x + 1)
    }
    if (-y >= x) {
        ans = min(ans, -y - x + 1)
    }
    if (y >= x) {
        ans = min(ans, y - x)
    }
    if (-y >= -x) {
        ans = min(ans, -y - -x + 2)
    }
    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36340
import math
a,b,h,m=map(int,input().split())
anga=h*math.pi/6+m*math.pi/360
angb=m*math.pi/30
ax=a*math.cos(anga)
ay=a*math.sin(anga)
bx=b*math.cos(angb)
by=b*math.sin(angb)
#print(math.degrees(anga),ax,ay,bx,by)
l=((ax-bx)**2+(ay-by)**2)**0.5
print(l)

Measured memory_bytes: 9572
#include<iostream>
#include<vector>
#include<cstdlib>
#include<string>
#include<cmath>
using namespace std;

struct Dice{
  int num[6];
};

int main(){
    vector<int> number(6);
    Dice d1;
    for(int i=0; i<6; i++){
        cin>>d1.num[i];
    }
    cin.ignore();
    int a;
    cin>>a;
    int top[a]={0};
    int front[a]={0};
    int q1[a],q2[a];
    for(int i=0; i<a; i++){
        cin>>q1[i]>>q2[i];
        for(int j=0; j<6; j++){
            if(q1[i]==d1.num[j]) top[i]=j+1;
            if(q2[i]==d1.num[j]) front[i]=j+1;
        }
    }

    int r[3][4]={{1,2,6,5} , {1,3,6,4} , {2,3,5,4}};
    for(int i=0; i<a; i++){
        int dtop=1;
        int n=5,e=3,s=2,w=4;
        if(top[i]==3){
            w=dtop;
            dtop=e;
            e=7-w;
        }else if(top[i]==4){
            e=dtop;
            dtop=w;
            w=7-e;
        }else{
            for(int j=0;j<4; j++){
                if(r[0][j]==top[i]) break;
                n=dtop;
                dtop=s;
                s=7-n;
            }
        }

        int rnum=0;
        for(int j=0; j<3; j++){
            for(int k=0; k<4; k++){
                if(r[j][k]==top[i]) break;
                if(k==3) rnum=j;
            }
        }

        for(int j=0; j<4; j++){
            if(front[i]==s) break;
            int tmp=n;
            n=w;
            w=s;
            s=e;
            e=tmp;
        }

        cout<<d1.num[e-1]<<endl;

    }
    return 0;
}


Measured memory_bytes: 3076
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    ll r;
    cin >> r;
    double pi = 3.1415926535;
    cout << (double)2*pi*r;
    
    return 0;
}


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

int main(){
    char a, b;
    cin >> a >> b;

    if(a < b){
        for(int i = 0; i < b - '0'; i++){
            cout << a;
        }
    }
    else{
        for(int i = 0; i < a - '0'; i++){
            cout << b;
        }
    }
    cout << endl;
    return 0;
}

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


unsigned ll ans=0;

ll int gcd(ll x,ll y){
   return y ? gcd( y , x%y ) : x;
}

ll lcm(ll x , ll y ){/*gcdの呼び出し忘れない*/
    return x*y / gcd( x , y ) ;
}


int main(){
    unsigned ll a,b,c,d,ans;    cin >> a >> b >> c >> d;

    unsigned ll lcma = lcm(c,d),ansa,ansb;

    ansa = a-1 - (a-1)/c - (a-1)/d + (a-1)/lcma;
    ansb = b   - b/c - b/d + b/lcma;

    cout << ansb - ansa << endl;
}

Measured memory_bytes: 384
#define _ 2<<17
A[_];long P[_],M=1e9+7,F[_],I[_]={1},X;i,j,k,t;c(a,b)int*a,*b;{t=*a-*b?:a[1]-b[1];}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<_;)I[X]=p(s=F[X]=X*s%M,M-2);for(;~scanf("%d",A+i);)i++-1||gets(P);for(qsort(A,i/2,8,c);j<i;P[j]=X,j+=2)for(X=f(s=A[k=j]-=1,t=A[j+1]-=1);(k-=2)>=0;)X=t<A[k+1]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M;printf("%d",X);}

Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int n,m,buf;
	vector < vector <int> >  A;
	vector <int> b, c;

	cin >> n >> m;

	A.resize(n);

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> buf;
			A[i].push_back(buf);
		}
	}

	for (int i = 0; i < m; i++){
		cin >> buf;
		b.push_back(buf);
	}

	for (int i = 0; i < n; i++){
		buf = 0;
		for (int j = 0; j < m; j++){
			buf += A[i][j] * b[j];
		}		
		c.push_back(buf);
		cout << c[i] << endl;
	}



	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> G[N];
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> distF(N);
    queue<ll> qF;
    vector<bool> isVisitedF(N, false);
    distF[0] = 0;
    qF.push(0);
    while(!qF.empty())
    {
        ll p = qF.front();
        qF.pop();
        if (!isVisitedF[p])
        {
            isVisitedF[p] = true;
            REPV(it, G[p])
            {
                qF.push(*it);
                if (!isVisitedF[*it])
                {
                    distF[*it] = distF[p] + 1;
                }
            }
        }
    }

    vector<ll> distS(N);
    queue<ll> qS;
    vector<bool> isVisitedS(N, false);
    distS[N - 1] = 0;
    qS.push(N - 1);
    while(!qS.empty())
    {
        ll p = qS.front();
        qS.pop();
        if (!isVisitedS[p])
        {
            isVisitedS[p] = true;
            REPV(it, G[p])
            {
                qS.push(*it);
                if (!isVisitedS[*it])
                {
                    distS[*it] = distS[p] + 1;
                }
            }
        }
    }

    ll countF = 0, countS = 0;
    REP(i, N)
    {
        if (distF[i] <= distS[i]) 
        {
            countF++;
        }
        else
        {
            countS++;
        }  
    }

    string ans = countF > countS ? "Fennec" : "Snuke";
    cout << ans << endl;
}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int main(){
  int s, n, m;
  cin >> s;
  n = s / 100;
  m = s % 100;
  if (1 <= n && n <= 12 && 1 <= m && m <= 12)
    cout << "AMBIGUOUS" << endl;
  else if ((n == 0 || 13 <= n) &&  1 <= m && m <= 12)
    cout << "YYMM" << endl;
  else if (1 <= n && n <= 12 && (m == 0 || 13 <= m))
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

sub gcd {
    my ($a, $b) = @_;
    return ($b == 0) ? $a : gcd($b, $a % $b);
}

my $k = <STDIN>;
my $sum = 0;

my @first = ();
for my $i (1..$k) {
    my $second = [];
    push @first, $second;
}

for my $a (1..$k) {
    for my $b (1..$k) {
        my $temp = ($first[$a][$b]) ? $first[$a][$b] : gcd($a, $b);
        $first[$a][$b] = $temp;
        $first[$b][$a] = $temp;
        for my $c (1..$k) {
            my $temp2 = ($first[$temp][$c]) ? $first[$temp][$c] : gcd($temp, $c);
            $first[$temp][$c] = $temp2;
            $first[$c][$temp] = $temp2;
            $sum += $temp2;
        }
    }
}

print $sum;


Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;

int par[100100];
int rrank[100100];
void init(int n){
for (int i=0;i<n;i++){
par[i]=i;
rrank[i]=0;
}}
int find(int x){
if (par[x]==x) return x;
else return par[x]=find(par[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if (x==y) return;
if (rrank[x]<rrank[y]) par[x]=y;
else {par[y]=x;
if (rrank[x]==rrank[y]) rrank[x]++;}}
bool same(int x,int y){
return find(x)==find(y);}

int main() {
   int n,m;
   cin >> n >> m;
   vector<int> a(n+1);
   rep(i,n) cin >> a.at(i+1);
   init(n+1);
   int f,g;
   rep(i,m){
       cin >> f >> g;
       unite(f,g);
   }
   int ans=0;
   for (int i=1;i<n+1;i++){
       if (same(a.at(i),i)) ans++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
    char s[11],t[12];
    scanf("%s %s",s,t);
    int i;
    int count=0;
    for(i=0;s[i]!='\0';++i){
        if(s[i]!=t[i]){
            count=1;
            break;
        }
    }
    if(count==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	a = n * (n - 1)/2;
	b = m * (m - 1) / 2;
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    s, t = rsa()
    a, b = ria()
    u = rs()
    if s == u: a -= 1
    if t == u: b -= 1
    print("{0} {1}".format(a,b))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12488
#include <cstdio>
#include <algorithm>
#include <iostream>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
#define min(q,w) ((q)>(w)?(w):(q))
#define max(q,w) ((q)<(w)?(w):(q))
using namespace std;
typedef long long LL;
const int N=200500,mo=1e9+7;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int a[N];
LL g[N];
LL f[N],sum[N];
int main()
{
	int q,w,mx=0;
	read(n);
	fo(i,1,n)read(a[i]),mx=max(mx,a[i]);
	sum[0]=f[0]=1;ans=1;
	a[0]=-1;
	fo(i,1,n)
	{
		if(a[i]!=a[i-1])f[i]=g[a[i]];
		sum[i]=(sum[i-1]+f[i])%mo;
		ans=(ans+f[i])%mo;
		if(a[i]!=a[i-1])g[a[i]]=(g[a[i]]+sum[i-1])%mo;
	}
	printf("%lld\n",ans);
	return 0;
}

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


// dp[k][i] := 長さkの列で、積がN以下で、末尾がiの数列の数
long long dp[102][100000];
long long N, K;
long long mod = 1e9 + 7;

int main(){
    cin >> N >> K;
    for(int i = 1; i * i <= N; i++){
        dp[1][i] = 1;
        dp[2][i] = N / i;
    }

    for(int k = 3; k <= K + 1; k++){
        long long dp_base = 0;
        for(int i = 1; i * i <= N; i++){
            dp_base += dp[k - 1][i];
        }

        long long dp_prev_sum[100000] = {};
        for(int i = 1; i * i <= N; i++){
            dp_prev_sum[i] = dp_prev_sum[i - 1] + dp[k - 2][i];
            dp_prev_sum[i] %= mod;
        }

        long long ura_dp[100000] = {};
        long long ura_dp_sum = 0;
        int i = 1;
        for(; (i + 1) * (i + 1) <= N; i++){
            ura_dp[i] = (N / i - N / (i + 1)) * dp_prev_sum[i] % mod;
            ura_dp_sum += ura_dp[i];
            ura_dp_sum %= mod;
        }
        ura_dp[i] = (N / i - i) * dp_prev_sum[i] % mod;
        ura_dp_sum += ura_dp[i];
        ura_dp_sum %= mod;

        dp[k][1] = dp_base + ura_dp_sum;
        dp[k][1] %= mod;

        for(int i = 2; i * i <= N; i++){
            dp[k][i] = dp[k][i - 1] + (mod - ura_dp[i - 1]);
            dp[k][i] %= mod;
        }
        
    }

    cout << dp[K+1][1] << endl;

}


Measured memory_bytes: 78592
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    L = [list(map(int, input().split())) for i in range(Q)]
    Ac = Counter(A)
    ans = 0
    for k, v in Ac.items():
        ans += int(k)*v

    for b,c in L:
        ans -= b*Ac[b]
        ans += c*Ac[b]
        Ac[c] += Ac[b]
        Ac[b] = 0
        print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 40168
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 305;
struct { int v, next; ll w; } e[MAXN * MAXN];
int head[MAXN], cnt_edge;
inline void add_edge(int u, int v, ll w) {
    e[cnt_edge] = { v, head[u], w };
    head[u] = cnt_edge++;
}
int n;
struct Item {
    ll val;
    int u, v;
    bool operator < (const Item &item) const {
        return val < item.val;
    }
};
ll dis[MAXN];
bool inque[MAXN];
void spfa(int s) {
    queue<int> que;
    dis[s] = 0;
    inque[s] = true;
    que.push(s);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        inque[u] = false;
        for(int i = head[u]; i != -1; i = e[i].next) {
            if(dis[e[i].v] > dis[u] + e[i].w) {
                dis[e[i].v] = dis[u] + e[i].w;
                if(!inque[e[i].v]) {
                    inque[e[i].v] = true;
                    que.push(e[i].v);
                }
            }
        }
    }
}
Item item[MAXN * MAXN];
int cnt_item;
int main() {
    memset(head, 0xff, sizeof(head));
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) {
        ll val; scanf("%lld", &val);
        if(i < j) {
            item[cnt_item++] = (Item){val, i, j};
        }
    }
    sort(item, item + cnt_item);
    ll ans = 0;
    for(int i = 0; i < cnt_item; i++) {
        memset(dis, 0x3f, sizeof(dis));
        spfa(item[i].u);
        if(dis[item[i].v] < item[i].val) {
            printf("-1\n");
            return 0;
        }
        else if(dis[item[i].v] > item[i].val) {
            add_edge(item[i].u, item[i].v, item[i].val);
            add_edge(item[i].v, item[i].u, item[i].val);
            ans += item[i].val;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

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

    cout << "square1001" << endl;
}



Measured memory_bytes: 3104
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll r, g, b, n; cin >> r >> g >> b >> n;
    ll ans = 0;
    REP(i, 3001) REP(j, 3001) {
        ll rm = n - (r * i + g * j);
        if (rm >= 0 && rm % b == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> sa(m);
    rep(i,m) cin >> x[i];
    SORT(x);
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0;i < m-1;i++){
        sa[i] = x[i+1] - x[i];
    }
    SORT(sa);
    int ans = 0;
    for(int i = 0;i <= m-n;i++)ans += sa[i];
    cout << ans << endl;

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://abc117.contest.atcoder.jp/tasks/abc117_c


Measured memory_bytes: 1792
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

typedef long long ll;
typedef boost::multiprecision::uint128_t uint128_t;

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

    uint128_t ans = (uint128_t(1) << 90);
    for(int k=1;k<=n;++k) {
        uint128_t tmp_ans = x * ll(k+n);
        tmp_ans += 5LL * a[k-1];
        for(int i=1;i<(n+k-1)/k;++i) {
            tmp_ans += ll(2*i+3) * (a[min(n-1,k*(i+1)-1)] - a[min(n-1, k*i-1)]);
        }
        ans = min(tmp_ans, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 5e3 + 5;
bool f[N][N], g[N][N];
int a[N];
int main()
{
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
   scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int ans = n;
  for (int i = 1; i <= n; ++i)
  {
    if (a[i] >= k)
    {
      n = i - 1;
      ans = n;
      break;
    }
  } 
 
  for (int i = 0; i <= n + 1; ++i)
    f[i][0] = g[i][0] = true;
 
  for (int j = 1; j < k; ++j)
  {
    for (int i = 1; i <= n; ++i)
    {
      f[i][j] = f[i - 1][j];
      if (j >= a[i])
        f[i][j] |= f[i - 1][j - a[i]];
    }
 
    for (int i = n; i >= 1; --i)
    {
      g[i][j] = g[i + 1][j];
      if (j >= a[i])
        g[i][j] |= g[i + 1][j - a[i]];
    }
  }
 
  //O(nk)
  for (int i = 1; i <= n; ++i)
  {
    int l = k - 1, x = 0;
    while (l >= 0 and !f[i - 1][l])
      --l;
 
    x = max(x, l);
    for (int r = 1; r < k; ++r)//O(2k) 
    {
      if (!g[i + 1][r])
        continue;
 
      while (l >= 0 and l + r >= k and f[i - 1][l])//r递增 l+r>=k 则l肯定要减小 
        --l;
      x = max(x, l + r);
    }
    if (x >= k - a[i])
    --ans; 
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 49152
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n, W;
	cin >> n >> W;
	vi w(n), v(n);
	f_v2I(w, v, n);
	vvi dp(n + 1, vi(W + 1,0));
	f(i, 0, n) {
		f(j, 0, W+1) {
			if (w[i]<=j) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 80256
import numpy as np

n, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((n + 1, W + 1), dtype=np.int)


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


# # 遅い
# for i in range(n):
#     for sum_w in range(W + 1):
#         if sum_w >= wv[i, 0]:
#             dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w - wv[i, 0]] + wv[i, 1])
#         dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w])

for i in range(0, n):
    w, v = wv[i, :]
    dp[i + 1, w:] = np.maximum(dp[i, w:], dp[i, :-w] + v)
    dp[i + 1, :] = np.maximum(dp[i + 1, :], dp[i, :])

print(int(dp[n , W]))


Measured memory_bytes: 92276
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,A,B; cin >> N >> A >> B;
    int ans=0;
    rep(i,N){
        string S=to_string(i+1);
        int cnt=0;
        rep(j,SZ(S)){
            cnt+=S[j]-'0';
        }
        if(cnt>=A && cnt<=B) {
            ans+=i+1;
        }
    }
    cout << ans << endl;
}

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

Hlen = len(H)


Hsyugou = set(H)
Hhennkann = list(Hsyugou)
Hhennkannlen = len(Hhennkann)




if Hlen ==Hhennkannlen:
    print("YES")

else:
    print("NO")

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> v((n+1)/2, 2);
    if(n%2==1) --v[0];
    long long ans=1;
    for(int i=0; i<n; ++i){
        int a; cin >> a;
        if(a%2==n%2 || !v[a/2]){
            ans=0;
            break;
        }
        --v[a/2];
    }
    for(int i=0; i<n/2; ++i){
        ans=ans*2%(1000*1000*1000+7);
    }
    cout << ans << endl;
    return 0;
}


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

int gcd(int a, int b){
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    else return gcd(b, a%b);
}

int main(){
    ll N, M;  cin >> N >> M;
    string S, T;  cin >> S >> T;
    ll L = N/gcd(N,M)*M;
    map<ll, char> X;
    for(ll i=0; i<N; i++){
        X[i*(L/N)+1] = S[i];
    }

    bool ans = true;
    for(ll i=0; i<M; i++){
        if(X.find(i*(L/M)+1) == X.end()) continue;
        else if(X[i*(L/M)+1] == T[i]) continue;
        else{
            ans = false;
            break;
        }
    }

    if(ans) cout << L << endl;
    else cout << -1 << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);

    for(int i=0;i<N;i++) 
        cin >> A[i];
    
    long long max=0;
    long long submax=0;
    int maxind;
    if(A[0] <= A[1]) {
        max = A[1];
        submax = A[0];
        maxind = 1;
    } else {
        max = A[0];
        submax = A[1];
        maxind = 0;
    }

    for(int i=2;i<N;i++){
        if(A[i] > max){
            submax = max;
            max = A[i];
            maxind = i;
        } else if(A[i] > submax){
            submax = A[i];
        }
    }
    for(int i=0;i<N;i++) {
       if(A[i] == max) cout <<  submax << endl;
       else cout << max << endl;
    }
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

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

Measured memory_bytes: 3604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

}

class Magatro
{
    private int R,G;
    private void Scan()
    {
        var sc=new Scanner();
        R=sc.NextInt();
        G=sc.NextInt();
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(G*2-R);
    }

    static public void Main(string[]args)
    {
        new Magatro().Solve();
    }
}

Measured memory_bytes: 13140
from collections import Counter

N, M = map(int, input().split())

def parent(par, i):
    depth = 0
    while par[i] != i:
        i = par[i]
        depth +=1
    return i, depth

def union(par, a, b):
    pa, da = parent(par, a)
    pb, db = parent(par, b)
    if da < db:
        par[pa] = par[pb]
    else:
        par[pb] = par[pa]

par = [i for i in range(N)]

for _ in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    union(par, a,b)

c = Counter()
for i in range(N):
    c.update([parent(par, i)[0]])

print(c.most_common(1)[0][1])


Measured memory_bytes: 100188
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def main():
    n,c = map(int,input().split())
    time = [[0] * c for _ in range(10 ** 5 + 1)]

    for _ in range(n):
        s,t,c1 = map(int,input().split())
        c1 -= 1
        time[s][c1] += 1
        time[t][c1] -= 1
    
    for i in range(10 ** 5):
        for j in range(c):
            if time[i][j] == 0 and time[i + 1][j] == 1:
                time[i][j] = 1
                time[i + 1][j] = 0

    ans = sum(time[0])
    tmp = ans
    for i in range(1,10 ** 5 + 1):
        tmp += sum(time[i])
        ans = max(ans, tmp)
    
    print(ans)
if __name__=='__main__':
    main()



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

int main() {
    int n; cin >> n;
    int half = 0, ans = 0, h = 0;
    for (int i = 0; i < n; i++) {
        cin >> h;
        ans += h;
        half = max(half, h);
    }
    cout << ans - (half / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,b;
	int t,b1,i;
	bool f;
	cin>>a>>b;
	b1=b;t=0;
	while(b1>0){
		t++;b1=b1/10;
	}
	for(i=1;i<=t;i++) a=a*10;
	a=a+b;f=false;
	for(i=1;i<=a/4;i++)
		if(i*i==a) {cout<<"Yes";f=true;}
	if(f==false)  cout<<"No";
	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;

int main(){

    int  N,M,sum=0;
    cin >> N >> M ;
    double A[N],X;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    X = (double)sum/(4*M);
    
    sort(A,A+N);
    
    if(A[N-M]>=X)cout << "Yes";
    else cout << "No";
	return 0;
}



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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, q);
    vi table(n+1, 0);
    string st;
    cin >> st;
    

    int state = 0;
    rep(i, st.size()) {
        if (st[i] == 'A') {
            state = 1;
        } else if (state == 1 && st[i] == 'C') {
            table[i+1] = 1;
            state = 0;
        } else {
            state = 0;
        }
    }

    Rep(i, table.size()) {
        table[i] += table[i-1];
    }

//    rep(i, table.size()) cout << table[i] << " "; cout << endl;

    while (q--) {
        int2(a, b);
        int yui = 0;
        if (a > 1 && st[a-1] == 'C' && st[a-2] == 'A') yui = 1;
        cout << table[b] - table[a-1] - yui << endl;
    }



    return 0;
}


Measured memory_bytes: 1872
package main

import (
	"fmt"
)

func sumDigit(n int) int {
	var sum int
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	var n, a, b, count int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		if num := sumDigit(i); num >= a && num <= b {
			count += i
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+5;
using namespace std;

ll t,n,m,k;
int maxn=0,sum=0,minn;
int a[N]={0};
int main(){
    scanf("%lld%lld",&n,&m);
    n%=m;
    printf("%lld\n",min(n,abs(n-m)));
    return 0;
}

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

using namespace std;

int main() {
  string S; cin >> S;
  for(int i = 0; i < (int)S.size() - 1; i++) {
    if(S[i] == S[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), t = (int)Math.sqrt(N);
		System.out.println(t*t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35868
#include <iostream>

int main() {
  int a, b, c, d, e, k;
  std::cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k) {
    std::cout << "Yay!\n";
  } else {
    std::cout << ":(\n";
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = intArray[0];
            int M = intArray[1];
            int A = N * (N - 1) / 2;
            int B = M * (M - 1) / 2;
            Console.WriteLine(A + B);
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28244
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
connection=[[] for i in range(h*w)]
start=[]

for i in range(h):
  for j in range(w):
    if i!=0:
      connection[i*w+j].append((i-1)*w+j)
    if i!=h-1:
      connection[i*w+j].append((i+1)*w+j)
    if j!=0:
      connection[i*w+j].append(i*w+j-1)
    if j!=w-1:
      connection[i*w+j].append(i*w+j+1)
    if l[i][j]=='#':
      start.append(i*w+j)
n=h*w

def bfs(l):
  distance=[-1]*n
  next=set()
  next2=set()
  visited=[-1]*n
  visitct=0
  for i in range(len(l)):
    distance[l[i]]=0
    for j in range(len(connection[l[i]])):
      next.add(connection[l[i]][j])
    visited[l[i]]=1
    visitct=+1
  next=list(next)
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

print(max(bfs(start)))

Measured memory_bytes: 368156
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define P pair<int, int>
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

static const ll mod = 1000000007LL;

const int MAX = 10000;
ll fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

  if(s<=2){
    cout << 0 << endl;
    return 0;
  }

  COMinit();

  int num = s / 3;
  ll ans = 0;
  reps(i, num){
    ans = (ans + com(s - 2 * i - 1, i-1)) % mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int a[maxn];
int cmp(const int a,const int b){
    return a>b;
}
int n,m,v,p;
int b[maxn];
bool judge(int mid){
    //printf("hello %lld\n",mid);
    if(mid<=p)return true;
    if(a[mid]+m<a[p])return false;
    if(v<=p-1&&a[mid]+m>=a[p])return true;
    for(int i=1;i<=n;i++)b[i]=a[i];
    int temp=0;
    for(int i=1;i<=p-1;i++){
        b[i]+=m;
        temp+=m;
    }
    //给开头的p-1个元素加值
    int inx=n,cnt=v-p+1;
    //给后面的元素加值
    while(inx>mid&&cnt>1){
        temp+=m;
        inx--;
        cnt--;
        b[inx]+=m;
    }
    temp+=m;
    int now=a[mid]+m;
    int res=m*v-temp;
    //中间还能被填多少
    for(int i=p;i<mid;i++){
        int add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
    }
    return now>=b[p]&&res<=0;
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    int low=1,high=n;
    int ans=0;
    while(low<=high){
        int mid=(low+high)>>1;
        if(judge(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792