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

int main() {

	int n, num, prevnum, total;
	cin >> n;
	vector<int> contiguous;
	cin >> prevnum;
	for(int i = 1; i < n; i++){
		cin >> num;
		if(prevnum + 1 == num){
			contiguous.push_back(prevnum);
		}
		prevnum = num;
	}
	for(int i = 0; i < n; i++){
		cin >> num;
		total += num;
	}
	sort(contiguous.begin(), contiguous.end());
	reverse(contiguous.begin(), contiguous.end());
	for(int i = 0; i < n - 1; i++){
		cin >> num;
		if(contiguous.empty()){
			break;
		} else if(i + 1 == contiguous[contiguous.size() - 1]){
			contiguous.pop_back();
			total += num;
		}
	}
	cout << total;

}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        m: i64,
    }

    let f = |x| if x == 1 { 1 } else { std::cmp::max(0, x - 2) };
    println!("{}", f(n) * f(m));
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))

seki = 1

for a_i in A:
        seki *= a_i
'''
count = 0

while seki % 2 == 0:
        seki = seki // 2
        count += 1
'''

count = 0

for a_i in A:
        while a_i % 2 == 0:
                a_i = a_i // 2
                count += 1
print(count)

Measured memory_bytes: 4148
while True:
    n = int(input())
    if n == 0:break
    c = {}
    for _ in range(n):
        a,b = input().split()
        c[a] = b
    m = int(input())
    ans = ''
    for _ in range(m):
        a = input()[0]
        ans+=c[a] if a in c else a
    print(ans)

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        ans += min(x, K - x) * 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
  int a,b,c;
  double S,L,h;
  scanf("%d %d %d",&a,&b,&c);
  
  S = a * b * sin(M_PI * c / 180)/2;
  L = a+b+sqrt(a*a+b*b-2*a*b*cos((double)c/180*M_PI));
  h = S * 2 / a;

  printf("%lf\n",S);
  printf("%lf\n",L);
  printf("%lf\n",h);
  return 0;

}



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

int main() {
  int n;
  double ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    ans+=(1.0/double(x));

  }
  double ans2=1.0/double(ans);
  cout<<ans2<<endl;
  
}

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

ll C[55][55];
void CombTable(int N){
	for (int i = 0; i <= N; i++){
		for (int j = 0; j <= i; j++){
			if ((j == 0) || (j == i)){
				C[i][j] = 1;
			} else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	vector<double> v(N + 1, 0);
	for (int i = 1; i <= N; i++){
		cin >> v[i];
	}

	sort(v.begin(), v.end(), greater<double>());
	double sum = 0;
	for (int i = 0; i < A; i++){
		sum += v[i];
	}
	double average = sum/A;

	ll n = 0, k = 0;
	for (int i = 0; i < N; i++){
		if (v[i] == v[A - 1]){
			n++;
			if (i < A) k++;
		}
	}

	CombTable(N);
	ll cnt = 0;
	if (k == A){
		for (k = A; k <= B; k++){
			cnt += C[n][k];
		}
	} else {
		cnt += C[n][k];
	}

	cout.precision(20);
	cout << fixed << average << endl;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
# 2019-11-11 18:30:26(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k, *h = (int(x) for x in sys.stdin.read().split())
    h.sort()
    min_diff = h[-1] - h[0] # default value
    for i in range(n - k + 1):
        diff = h[i+k-1] - h[i]
        min_diff = min(min_diff, diff)
    print(min_diff)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14092
import sys
import fractions

N, M = map(int, input().split())
a = list(map(int, sys.stdin.readline().split()))

a_max = max(a)

smallest_X = 0

lcm_N = a[0]

for i in range(1, N):
    lcm_N = lcm_N * a[i] // fractions.gcd(lcm_N, a[i])


for X in range(int(a_max * 0.5), min(lcm_N + 1, M + 1), a_max):
    flag = True
    for j in range(N):
        if (X - a[j] * 0.5) % a[j] != 0:
            flag = False
            break
    if flag:
        smallest_X = X
        break

if smallest_X == 0:
    print(0)
    
else:
    print(int((M - smallest_X) / lcm_N) + 1)

Measured memory_bytes: 16240
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  int n,count=0;
  while (cin>>n,n|n!=0){
    count++;
    int x[n];
    int y[n];
    for (int i=0;i<n;i++){
      cin>>x[i]>>y[i];
    }
    double area=0;
    for(int i=0;i<n;i++){
      area=area+(x[i]-x[(i+1)%n])*(y[i]+y[(i+1)%n]);
    }
    area=abs((double)(0.5*area));
    cout<<count<<" "<<fixed<<setprecision(1)<<area<<endl;
  }
}

Measured memory_bytes: 1240
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), k = in.nextInt();
		int a[] = new int[n];
		for ( int i = 0; i < n; i++ ) {
			a[i] = in.nextInt();
		}
		in.close();

		char dp[] = new char[k + 1];
		Arrays.fill(dp, 's');
		for ( int di = 0; di <= k; di++ ) {
			if ( dp[di] == 'f' ) continue;

			for ( int ai = 0; ai < n; ai++ ) {
				if ( di + a[ai] > k ) break;
				else dp[di + a[ai]] = 'f';
			}
		}

		if ( dp[k] == 'f' ) {
			System.out.println("First");
		} else {
			System.out.println("Second");
		}
	}
}

Measured memory_bytes: 21972
N = int(input()) 
ans = 'No' 
cnt = 0 
for _ in range(N): 
    x, y = map(int, input().split()) 
    if x == y: 
        cnt += 1 
        if cnt == 3: 
            ans = 'Yes' 
    else:
        cnt = 0
print(ans)

Measured memory_bytes: 9180
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	const int P = 2019;
	string s;
	cin >> s;
	int N = s.size();

	LL ret = 0;
	LL a = 0, b = 1;
	vector<int> count(P + 1, 0);
	count[0] = 1;
	REP(i, N){
		a += (s[N - 1 - i] - '0') * b;
		a %= P;
		b *= 10;
		b %= P;
		ret += count[a]++;
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,a,b;
    cin>>x;
    a = x/500;
    ll y1 = (x-a*500)/5;
    a = a*1000;

    ll ans1=y1*5+a;
    cout<<ans1<<endl;
    return 0;
}




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

int main() {
  int N ;
  cin >> N ;
  if ( (N/1000 == (N/100-N/1000*10)) && (N/1000 ==(N/10-N/100*10)) ){
    cout << "Yes" << endl;
  }
  else if(( (N/10-N/100*10) == (N/100-N/1000*10)) && ((N-N/10*10) ==(N/10-N/100*10))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new(); 
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_string()
    };

    let all_sec: i32 = s.parse().unwrap();
    let hour = all_sec / 3600;
    let min = (all_sec - hour * 3600) / 60;
    let sec = (all_sec - hour * 3600) - (min * 60);
    println!("{}:{}:{}", hour, min, sec);
}


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


int main()
{
	vector<char> S = {};
	for (int i = 0; i < 3; i++)
	{
		char bufS;
		cin >> bufS;
		S.push_back(bufS);
	}
	char Z, O, T;
	Z = S[0];
	O = S[1];
	T = S[2];
	if (Z == O && O == T)
		cout << "No";
	else
		cout << "Yes";
	
	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <stack>
#include <string.h>

using namespace std;

int main() {
	// your code goes here
	int ans = 0;
	stack <int> s;
	char r[10];

	int a, b;
	while(scanf("%s", r) != EOF){
		if( strcmp(r, "+") == 0 ){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a + b);
		}else if( strcmp(r, "-") ==0 ){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b - a);
		}else if( strcmp(r, "*") == 0 ){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a * b);
		}else{
			s.push( atoi(r) );
		}
	}
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 3232
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
    l, r = map(int, input().split())
    ans += r-l+1
print(ans)


Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
typedef long long ll;
typedef double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX=3000;
ld coins[MAX];
ld mem[MAX][MAX/2];
int n;

ld dp(int i,int sellos){
	if(sellos<0)return 0.0;
	if(i==n)return 1.0;
	ld &ans=mem[i][sellos];
	if(ans > -0.5) return ans;
	ans = coins[i]*dp(i+1,sellos)+(1.0-coins[i])*dp(i+1,sellos-1);
	return ans;
}
int main() {

  ios::sync_with_stdio(0), cin.tie(0);
  cin>>n;
  for(int i=0;i<=n;i++){
  	for(int j=0;j<=n;j++){
  		mem[i][j]=-1.0;
  	}
  }
  forn(i,n){
  	cin>>coins[i];
  }
  ld ans = dp(0, (n+1)/2-1);
  cout<<fixed<<setprecision(10)<< ans << endl;
  return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int cnt[3] = {};
    for(int i=0; i<3; i++)
    {
    	if(S[i]=='a') cnt[0]++;
    	else if(S[i]=='b') cnt[1]++;
    	else cnt[2]++;
    }

    if(cnt[0] == 1 && cnt[1] == 1) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ten5 100005

int num[ten5];
int num2[ten5];
int isPrime[ten5];

int main(void)
{
    int n,i,j;
    int l,r,sum;
    cin>>n;
    isPrime[0]=isPrime[1]=num2[0]=num2[1]=0;
    for(i=2;i<ten5-4;i++)
    {
        isPrime[i]=1;
        for(j=2;j*j<=i;j++)
            if(i%j==0)
                isPrime[i]=0;
    }
    for(i=2;i<ten5-4;i++)
    {
        if(isPrime[i]&isPrime[(i+1)/2]==1)
            num2[i]=num2[i-1]+1;
        else
            num2[i]=num2[i-1];
    }
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        cout<<num2[r]-num2[l-1]<<endl;
    }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>> vec(n,vector<int>(m));
    vector<int> cost(n);
    for(int i=0;i<n;++i)
    {
        cin>>cost[i];
        for(int j=0;j<m;++j)
        {
            cin>>vec[i][j];
        }
    }
    int min=INT_MAX;
    for(int i=0;i<pow(2,n+1);++i)
    {
        vector<int> vec1(m,0);
        int c=0;
        for(int j=0;j<n;++j)
        {
            int temp=i&(1<<j);
            if(temp)
            {
                for(int k=0;k<m;++k)
                {
                    vec1[k]+=vec[j][k];
                }
                c+=cost[j];
            }
        }
        int flag=0;
        for(int i=0;i<m;++i)
        {
            if(vec1[i]<x)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            if(c<min)
            {
                min=c;
            }
        }
    }
    if(min==INT_MAX)
    cout<<-1<<"\n";
    else
    cout<<min<<"\n";
    

}



Measured memory_bytes: 4088
import copy

n = int(input())
p = list(map(int, input().split()))
q = copy.copy(p)
q.sort()
c = 0

for i in range(n):
    if p[i] != q[i]:
        c = c + 1

if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

void DFS(int R, vector< vector<int> > &G, vector<int> &S, vector<int> &par) {
	S[R] =1;
	ALL_THE(G[R],it) if(S[*it] == 0) {
		DFS(*it,G,S,par);
		par[*it] =R;
		S[R] +=S[*it];
	}
}

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x =pw(a,e/2,mod);
	x =(x*x)%mod;
	if(e%2) x =(x*a)%mod;
	return x;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< vector<int> > G(N);
	for(int i =0; i < N-1; i++) {
		int x,y;
		cin >> x >> y;
		G[--x].push_back(--y);
		G[y].push_back(x);
	}

	vector<int> S(N,0), par(N,0);
	DFS(0,G,S,par);
	int c =0;
	for(int i =0; i < N; i++) {
		bool isc =(S[i] >= N-S[i]);
		ALL_THE(G[i],it) if(*it != par[i] && S[*it] > N-S[*it]) isc =false;
		if(isc) c =i;
	}
	for(int i =0; i < N; i++) S[i] =0;
	par[c] =c;
	DFS(c,G,S,par);
	vector<int> A;
	ALL_THE(G[c],it) A.push_back(S[*it]);
	A.push_back(1);
	int M =A.size();

	cat mod =1000000007;
	vector<cat> fac(10000,1), inv(10000,1);
	for(int i =1; i < 10000; i++) fac[i] =(i*fac[i-1])%mod;
	for(int i =1; i < 10000; i++) inv[i] =pw(fac[i],mod-2,mod);
	vector< vector<cat> > cnt(M+1,vector<cat>(N+1,0));
	cnt[0][0] =1;
	for(int i =0; i < M; i++) for(int k =0; k <= A[i]; k++) {
		cat C =(fac[A[i]]*inv[k])%mod*inv[A[i]-k]%mod;
		C =C*fac[A[i]]%mod*inv[A[i]-k]%mod;
		for(int j =0; j <= N-k; j++)
			cnt[i+1][j+k] =(cnt[i+1][j+k]+cnt[i][j]*C)%mod;
	}
	
	cat ans =0;
	for(int i =N; i >= 0; i--) {
		if((N-i)%2) ans =(ans-fac[i]*cnt[M][N-i])%mod;
		else ans =(ans+fac[i]*cnt[M][N-i])%mod;
	}
	for(int i =N-1; i >= 0; i--) {
		if((N-1-i)%2) ans =(ans-fac[i]*cnt[M-1][N-1-i])%mod;
		else ans =(ans+fac[i]*cnt[M-1][N-1-i])%mod;
	}
	ans %=mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 196352
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m

    read*, n,m
    if (n==1 .and. m==1) call ans(1_8)
    if (n==1) call ans(m-2)
    if (m==1) call ans(n-2)
    call ans((n-2)*(m-2))
contains
    subroutine ans(num)
        integer(int64)::num
        print'(i0)',num
        stop
    end subroutine
end program name

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt(); 	
      
       System.out.println((Math.max(A*B,Math.max(A+B,A-B))));
      }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T>
struct RangeCount{
  struct BIT{
    vector<T> dat;
    BIT(){}
    BIT(int n){dat.assign(++n,0);}
    T sum(int k){
      T res=0;
      for(;k;k-=k&-k) res+=dat[k];
      return res;
    }
    void add(int k,T v){
      for(++k;k<(int)dat.size();k+=k&-k) dat[k]+=v;
    }    
  };
  int n;
  vector<vector<int> > val;
  vector<BIT> dat;
  RangeCount(){}
  RangeCount(int n_){
    n=1;
    while(n<n_) n<<=1;
    val.assign(n<<1,vector<int>());
    dat.reserve(n<<1);    
  }
  void preupdate(int a,int x){
    a+=n;
    while(a){
      val[a].emplace_back(x);
      a>>=1;
    }
  }
  void build(){    
    for(int i=0;i<n*2;i++){
      auto &v=val[i];
      sort(v.begin(),v.end());
      v.erase(unique(v.begin(),v.end()),v.end());
      dat.emplace_back(v.size());
    }
  }
  void update(int a,int x,int z){
    a+=n;
    while(a){
      auto &v=val[a];
      int k=lower_bound(v.begin(),v.end(),x)-v.begin();
      dat[a].add(k,z);
      a>>=1;
    }    
  }
  T calc(int k,int x,int y){
    auto &v=val[k];
    int p=lower_bound(v.begin(),v.end(),x)-v.begin();
    int q=lower_bound(v.begin(),v.end(),y)-v.begin();
    return dat[k].sum(q)-dat[k].sum(p);
  }
  // [a, b) * [x, y)
  T query(int a,int b,int x,int y){
    T res=0;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
      if(l&1) res+=calc(l++,x,y);
      if(r&1) res+=calc(--r,x,y); 
    }
    return res;
  }
};
//END CUT HERE

//INSERT ABOVE HERE
signed YUKI_743(){  
  int n,m;
  scanf("%d %d",&n,&m);
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]);

  RangeCount<int> seg(m);
  
  for(int i=0;i<n;i++){
    if(a[i]>b[i]) swap(a[i],b[i]);
    seg.preupdate(a[i],b[i]);
  }

  seg.build();
  
  long long ans=0;
  for(int i=0;i<n;i++){
    ans+=seg.query(0,a[i],a[i],b[i]);
    ans+=seg.query(a[i],b[i],b[i],m);
    seg.update(a[i],b[i],1);
  }

  printf("%lld\n",ans);
  return 0;
}

signed ABC106_D(){
  int n,m,q;
  scanf("%d %d %d",&n,&m,&q);
  vector<int> x(m),y(m);
  for(int i=0;i<m;i++) scanf("%d %d",&x[i],&y[i]);
  
  RangeCount<int> seg(n+1);
  for(int i=0;i<m;i++) seg.preupdate(x[i],y[i]);
  seg.build();
  for(int i=0;i<m;i++) seg.update(x[i],y[i],1);
  
  for(int i=0;i<q;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",seg.query(a,b+1,a,b+1));    
  }
  return 0;
}

//END CUT HERE
signed main(){
  ABC106_D();
  return 0;
}


Measured memory_bytes: 13032
N = int(input())
ans = 0

def num_divisors(n):
  d = 0
  for j in range(1,n+1):
    if n%j == 0:
      d+=1
  return d

for i in range(1,N+1):
  if i%2 != 0 and num_divisors(i)==8:
    ans+=1      
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	map<string, int> m;
  	m["SUN"] = 7;
  	m["MON"] = 6;
  	m["TUE"] = 5;
  	m["WED"] = 4;
    m["THU"] = 3;
  	m["FRI"] = 2;
  	m["SAT"] = 1;
  	string temp;
  	cin >> temp;
  	cout << m[temp];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e5;
int N;
ll K,a[MAX_N];
ll psm[MAX_N+1];
ll yse[MAX_N+1];
int bit[MAX_N+2];
void add(int x){
	while(x<=N+1){
		bit[x]++;
		x+=x&(-x);
	}
}
int query(int x){
	int ret=0;
	while(x){
		ret+=bit[x];
		x-=x&(-x);
	}
	return ret;
}
int main(){
	cin>>N>>K;
	psm[0]=0;
	REP(i,N){
		cin>>a[i];
		psm[i+1]=psm[i]+a[i];
	}
	REP(i,N+1){
		yse[i]=psm[i]-i*K;
	}
	{
		vector<ll> x;
		REP(i,N+1){
			x.push_back(yse[i]);
		}
		sort(x.begin(),x.end());
		x.erase(unique(x.begin(),x.end()),x.end());
		REP(i,N+1){
			yse[i]=lower_bound(x.begin(),x.end(),yse[i])-x.begin();
		}
	}
	ll ans=0;
	for(int i=N;i>=0;i--){
		ans+=(N-i)-query(yse[i]);
		add(yse[i]+1);
	}
	cout<<ans<<endl;
	return 0;
}

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

int up(const void *a, const void *b){
  return *(long long *)a - *(long long *)b;
}

int main(void){
  long long n , m;
  scanf("%lld %lld",&n ,&m);
  
  long long a[n][2];
  for(int i = 0;i < n;i ++){
    scanf("%lld %lld",&a[i][0],&a[i][1]);
  }
  
  qsort(a,n,sizeof(long long)*2,up);
  
   long long count = 0 , j = 0 , ans = 0;
   while(count < m){
   count += a[j][1];
    if(count <= m){
      ans += a[j][0] * a[j][1];
    }
    else{
      ans += a[j][0] *(a[j][1] - (count - m));
    }
    j ++;
  }
  
  printf("%lld\n",ans);
  return 0;
 
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    n--;
    if(n%2==0){
        cout<<(n+1)*(n/2)<<endl;
    }
    else{
        cout<<(n+1)*(n/2)+(n+1)/2<<endl;
    }
}

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



int main()
{
   long i,j,k;
   long n;
   long cnt = 0;
   long left,right,mid;
   long ans = 0;
   int W,H,x,y,r;
   scanf("%d",&W);
   scanf("%d",&H);
   scanf("%d",&x);
   scanf("%d",&y);
   scanf("%d",&r);

   if(x+r <= W && 0 <= x-r && 0 <= y-r && y+r <= H)
      printf("Yes\n");
   else
      printf("No\n");


   return 0;
}

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



int main(){
 char s,t,q;
  cin >>s;
  cin >>t;
  cin >>q;

  
  if(s=='A'&&q=='A'&&t=='A'){
        cout << "No" <<endl;
      
    
  }else if(s=='B'&&q=='B'&&t=='B'){
        cout << "No" <<endl;
      
    
  }
  
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
include Math
n = gets.to_i
x = gets.split(" ").map(&:to_i)
y = gets.split(" ").map(&:to_i)

_Dxy1 = 0
_Dxy2 = 0
_Dxy3 = 0
_Dxyi = (x[0]-y[0]).abs
0.upto(n-1){|i|
  d = (x[i]-y[i]).abs
  _Dxy1 += d
  _Dxy2 += d**2
  _Dxy3 += d**3
  _Dxyi = d if (_Dxyi < d)
}

printf "%f\n", _Dxy1
printf "%f\n", sqrt(_Dxy2)
printf "%f\n", _Dxy3**(1.0/3.0)
printf "%f\n", _Dxyi

Measured memory_bytes: 8808
from fractions import gcd

def calc_lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int, input().split(' ')))

lcm = a[0]
for i in range(1, n):
    lcm = calc_lcm(lcm, a[i])

s = 0
for i in range(n):
    s += lcm // a[i]

ans = s % 1000000007
print(ans)


Measured memory_bytes: 6112
import java.util.Scanner;
public class Main {
	static long eaten;
	static long eatenPatty = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long level =  Long.parseLong(sc.next());
		eaten = Long.parseLong(sc.next());

		makeBurger(level);

		System.out.println(eatenPatty);
	}

	public static void makeBurger(long level) {
		if(level == 0) {
			if(eaten > 0) {
				eatenPatty ++;
				eaten --;
			}
		}else {
			long gapEaten = 0;
			long gapEatenPatty = 0;
			if(eaten > 0) {
				eaten --;
				long prvEaten = eaten;
				long prvEatenPatty = eatenPatty;
				makeBurger(level - 1);
				gapEaten = eaten - prvEaten;
				gapEatenPatty = eatenPatty - prvEatenPatty;
			}
			if(eaten > 0) {
				eatenPatty ++;
				eaten --;
				if(eaten + gapEaten >= 0) {
					eaten += gapEaten;
					eatenPatty += gapEatenPatty;
				}else {
					makeBurger(level - 1);
				}
			}
			if(eaten > 0) {
				eaten --;
			}
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll k;
    string s;
    cin >> k >> s;
    
    if(s.size() <= k){
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#define SIZE10 100000

typedef long long int ll;
typedef unsigned char u8;

int main(void){
    int N;
    int B[256];
    int sum;
    int i = 0;

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

    for(i = 1; i < N; i++){
        if(B[i] == B[i-1]){
            sum += B[i];
        }else if(B[i] > B[i-1] && B[i+1] >= B[i] && i != N-1){
            sum += B[i-1];
            sum += B[i];
            i++;
        }else if(B[i] > B[i-1] && B[i] > B[i+1] && i != N-1){
            sum+=B[i-1];
        }else if(B[i] < B[i-1] && B[i] > B[i+1] && i != N-1){
            sum += B[i];
        }else if(B[i] < B[i-1] && B[i] <= B[i+1] && i != N-1){
            sum += B[i]*2;
            i++; 
        }else if(i == N-1){
            sum += B[i-1];
        }
    }

    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
mod_673 = [1] * 672
for i in range(1,672):
    mod_673[i] = (mod_673[i -1] * 10) % 673

S = input()
S = S[::-1]
A = [0] * (len(S) + 1)
B = [0] * (len(S) + 1)
x = 0
Ans = [[0] * 3 for i in range(673)]
for i in range(1, len(S) + 1):
    A[i] = (A[i - 1] + int(S[i - 1]) * mod_673[(i - 1) % 672]) % 673
    B[i] = (B[i - 1] + int(S[i - 1])) % 3

for i in range(len(S) + 1):
    Ans[A[i]][B[i]] += 1

for i in range(673):
    for j in range(3):
        y = Ans[i][j]
        x += y * (y - 1) // 2

print(x)

Measured memory_bytes: 16016
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int n=in(),a=in();
	print(n*n-a);
	return 0;
}

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

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

    int l, r;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=(1<<18)+5;
pair<int,int> mx[nmax][2];
int v[nmax],ans[nmax];
int n,i,j;
bool grt(pair<int,int> unu,pair<int,int> doi)
{
    return (unu.first>=doi.first);
}
void mrg(pair<int,int> A[],pair<int,int> B[])
{
    if(grt(B[1],A[1])&&B[1].second!=A[1].second) {A[0]=A[1];A[1]=B[1];}
    if(grt(B[0],A[0])&&B[0].second!=A[1].second) A[0]=B[0];
    if(grt(B[1],A[0])&&B[1].second!=A[1].second) A[0]=B[1];
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    for(i=0;i<(1<<n);i++)
    {
        cin>>v[i];
        mx[i][1]={v[i],i};
        mx[i][0]={-1,-1};
    }
    for(i=1;i<(1<<n);i++)
    {
        for(j=0;j<n;j++)
            if(((1<<j)&i))
               mrg(mx[i],mx[i^(1<<j)]);
        ans[i]=max(ans[i-1],mx[i][0].first+mx[i][1].first);
        cout<<ans[i]<<'\n';
    }
    return 0;
}


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

string make_num(int n){
    string s=to_string(n);
    while(s.length()<6){
        s="0"+s;
    }
    return s;
}

int main(){
    int n,m;
    cin >> n >> m;
    map<P,string> mp;
    vector<P> v; 
    vector<P> original;
    rep(i,m){
        int p,y;
        cin >> p >> y;
        //mp.insert(P(p,y)," ");
        mp[P(p,y)]="";
        v.push_back(P(p,y));
        original.push_back(P(p,y));
    }
    sort(v.begin(),v.end());
    int count=0;
    int pre=0;
    for(auto x:v){
        if(x.first==pre) count++;
        else count=1;
        mp[P(x.first,x.second)]=make_num(x.first);
        mp[P(x.first,x.second)]+=make_num(count);
        pre=x.first;
    }

    for(auto x:original){
        cout << mp[x] << endl;
    }


}

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

int sumOfEachDegit(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  int N;
  cin >> N;
  int res = numeric_limits<int>::max();
  for(int A = 1; A <= N / 2; A++){
    int B = N - A;
    int sumA = sumOfEachDegit(A);
    int sumB = sumOfEachDegit(B);
    res = min(res, sumA + sumB);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN+1];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

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

int main(){
  int elaps=0,c,q;
  P u;
  scanf("%d %d",&n,&q);
  for (int i=1;i<=n;i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1; tail=n+1;

  while (head!=tail) {
    u=dequeue();
    c=min(q, u.t);
    u.t-=c;
    elaps+=c;
    if (u.t>0) enqueue(u);
    else printf("%s %d\n", u.name, elaps);
  }
  return 0;
}


Measured memory_bytes: 12752
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

LL get(LL a, LL b, LL c)
{
	if (a % 2 == 0) return 0;
	return b * c;
}

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	LL a, b, c;
	cin>>a>>b>>c;

	LL res = get(a, b, c);
	res = min(res, get(b, c, a));
	res = min(res, get(c, a, b));
	cout<<res<<endl;

}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	N, K := nextInt(), nextInt()
	A := make([]int, N)
	for i := 0; i < K; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			l := nextInt()
			A[l-1]++
		}
	}

	ans := 0
	for _, a := range A {
		if a == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
import math

n,d = map(int, input().split())
x_array = []
for i in range(n):
  x_array.append(list(map(int, input().split())))

  ans = 0
for i in range(1,n):
  for j in range(i):
    list1 = x_array[i]
    list2 = x_array[j]
    count = 0
    for k in range(len(list1)):
      count += (list1[k]-list2[k]) ** 2

    if math.sqrt(count) == int(math.sqrt(count)):
      ans += 1

print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
sum_res = sum(A)
counter = [0 for _ in range(10 ** 5 + 1)]

for a in A:
    counter[a] += 1

for _ in range(Q):
    B, C = map(int, input().split())
    sum_res += (C - B) * counter[B]
    counter[C] += counter[B]
    counter[B] = 0
    print(sum_res)


Measured memory_bytes: 20980
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int answer = 0;

		for (int i = 1; i <= N; i++) {
			if (String.valueOf(i).length() % 2 == 1) {
				answer++;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 27860
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define ARRAY_MAX 100005

int dp[ARRAY_MAX];

int dfs(int now,vector<vector<int> >& g,vector<bool>& used,vector<int>& ans){

    used[now] = true;//今いる位置をチェックする
    int path_cnt = 0;
    for(auto to : g[now]){

        if(used[to] != true){
            //まだ調べていないなら調べる
            dfs(to,g,used,ans);   
        }
        path_cnt = max(path_cnt,dp[to]+1);
    }
    //帰りがけ順で追加
    //ans.push_back(now+1);
    dp[now] = path_cnt;//nowスタートの最大経路長が求まる
    return dp[now];
}

//トポロジカルソート
int Topological_Sort(int v,int e,vector<vector<int> >& g,vector<bool>& used,vector<int>& ans){
    //頂点数、辺の個数、隣接リスト、チェック用配列、結果用配列

    int maxi_path = 0;
    for(int i = 0;i < v;++i){
        if(used[i] == true){
            //既に調べているなら見ない
            continue;
        }
        maxi_path = max(maxi_path,dfs(i,g,used,ans));//iスタートのDAG探索により経路長を求める
    }
    //reverse(ans.begin(),ans.end());
    return maxi_path;
}


int main(){

    int n,m;//頂点数、辺の個数
    cin >> n >> m;
    vector<vector<int> > g(ARRAY_MAX);//隣接リスト
    vector<bool> used(ARRAY_MAX,false);//そのノードを使用したかどうかの判定
    vector<int> ans;//トポロジカルソートの結果配列

    REP(i,m){
        int x,y;
        cin >> x >> y;
        x--;
        y--;//indexによってはいらない可能性あり
        g[x].push_back(y);
    }

    int path_cnt = Topological_Sort(n,m,g,used,ans);
    cout << path_cnt << endl;

    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];


    int tmp = 1;
    int ans = 0;
    REP(i,62){
        bool flag = true;
        int ki = 0;

        REP(j,n){
            if(A[j] %2 == 1) ki++;
            A[j] /= 2;
            if(A[j] != 0) flag = false;
        }
        int hoge = ki * (n - ki) % MOD;
        hoge *= tmp;
        hoge %= MOD;
        ans += hoge;
        ans %= MOD;


        if(flag ) break;
        tmp *= 2;
        tmp %= MOD;
    }

    cout << ans << endl;

}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    if (n % 2 == 0 || n % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    long long c = 1;
    int m = 7;
    while (m < n) {
        c++;
        m = 10 * m + 7;
    }
//    cout << m << endl;
    while (true) {
        int mod = m % n;
        if (mod == 0)
            break;
        m = 10 * mod + 7;
        c++;
//        cout << m << endl;
    }
    cout << c << endl;
    return 0;
}

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

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

    int prize = 100000 * (max((4 - x), 0) + (max(0, (4 - y))));

    if (x == 1 && y == 1)
    {
        prize += 400000;
    }

    cout << prize << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define N 200010
using namespace std;

long double ans = 0;
long double a[N], d[N];

int main() {
	int n, d1, x;
	scanf("%d%d%d", &n, &d1, &x);
	a[0] = d1; d[0] = x;
	for (int i = 0; i < n; ++i) {
		a[i + 1] = ((2.0 * (n - i) + 2) * a[i] + 5.0 * d[i]) / (2.0 * (n - i));
		d[i + 1] = (2.0 * (n - i) + 4) * d[i] / 2.0 / (n - i);
//cout << a[i] << ' ' << d[i] << endl;
		ans += (2.0 * (n - i) * a[i] + ((n - i) * (2.0 * (n - i) - 1)) * d[i]) / (2.0 * (n - i));
	}
	printf("%.15f\n", (double)ans);
}

Measured memory_bytes: 6528
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: i64 = it.next().unwrap().parse().unwrap();
    let x: i64 = it.next().unwrap().parse().unwrap();
    let d: i64 = it.next().unwrap().parse().unwrap();
    if d == 0 {
        let mut set = std::collections::BTreeSet::new();
        for i in 0..(n + 1) {
            set.insert(i * x);
        }
        println!("{}", set.len());
        return;
    }
    let (x, d) = if d > 0 {(x, d)} else {(-x, -d)};
    let mut map = std::collections::BTreeMap::<i64, Vec<(i64, i64)>>::new();
    for i in 0..(n + 1) {
        let m = x * i;
        let v = (m % d + d) % d;
        let l = i * (i - 1) / 2 * d;
        let r = (n * (n - 1) / 2 - (n - i) * (n - 1 - i) / 2) * d;
        map.entry(v).or_insert(vec![]).push((m + l, m + r));
    }
    let mut ans = 0;
    for (_, a) in map {
        let mut a = a;
        a.sort();
        a.reverse();
        let mut now = a.pop().unwrap();
        while let Some((l, r)) = a.pop() {
            if l <= now.1 {
                now.1 = std::cmp::max(now.1, r);
            } else {
                ans += (now.1 - now.0) / d + 1;
                now = (l, r);
            }
        }
        ans += (now.1 - now.0) / d + 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 37116
def main():
    n = int(input())

    ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'

    s = ''
    while n>0:
        n -= 1
        i = n % 26
        s += ascii_lowercase[i]
        n = n // 26

    out = s[::-1]
    print(out)

main()

Measured memory_bytes: 8976
#include<cstdio>
#include<iostream>
using namespace std;
int n,L,maxn,maxi;
int a[101010];
int main()
{
	scanf("%d%d",&n,&L);
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	if (n==1)
	{
		printf("Possible\n");
		return 0;
	}
	for (int i=1;i<n;++i)
		if (a[i]+a[i+1]>maxn)
			maxn=a[i]+a[i+1],maxi=i;
//	printf("%d\n",maxn);
	if (maxn>=L) 
	{
		printf("Possible\n");
		for (int i=1;i<maxi;++i)
			printf("%d\n",i);
		for (int i=n-1;i>maxi;--i)
			printf("%d\n",i);
		printf("%d\n",maxi);
	}
	else printf("Impossible\n");
	return 0;
}

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

int main() {
    int a, b;
    string op;
    cin >> a >> op >> b;

    int ans;
    if (op[0] == '+') {
        ans = a + b;
    }
    else {
        ans = a - b;
    }

    cout << ans << endl;

    return 0;
}


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

void swap(int *a,int *b){
    int tmp;
    tmp=*a;
    *a=*b;
    *b=tmp;
}
int main(){
    int n;
    cin >> n;
    vector<int> A;
    int a;
    
    for(int i=0;i<n;i++){
          cin >> a;
          A.push_back(a);
    }
    for(int i=0;i<n/2;i++){
        swap(A[i],A[n-i-1]);   
    }
    
    for(int i=0;i<n-1;i++){
        cout << A[i] << " ";
    }
    
    cout << A[n-1] <<endl;
    
    return 0;
    
}


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

int main() {
    ll n,k;
    cin >> n >> k;
    ll r = n % k;
    ll ans = min(r,k-r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll MOD = 1000000007;
char a[1005][1005];
ll dp[1005][1005];

int dx[] = {1, 0};
int dy[] = {0, 1};

int main(void) {
  int h, w;
  cin >> h >> w;
  rep (i, h) rep (j, w) cin >> a[i][j];

  dp[0][0] = 1;
  rep (i, h) rep (j, w) {
    rep (k, 2) {
      int x = j + dx[k];
      int y = i + dy[k];
      if (0 <= x && x < w && 0 <= y && y < h && a[y][x] == '.') {
        dp[y][x] += dp[i][j];
        dp[y][x] %= MOD;
      }
    }
  }

  cout << dp[h - 1][w - 1] << endl;
  return 0;
}

Measured memory_bytes: 9088
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iterator>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int N;
	cin >> N;
	int A;
	int ans = 0;
	int maxa = 2147483647;
	rep(i, N) {
		cin >> A;
		maxa = min(maxa, A);
		if (A <= maxa) { ans++; }
	}
	cout << ans;
}

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

const int N = 2e5 + 5;

int n, k, a[N];
double s[N], ans; 

int main() {
	cin>>n>>k;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		s[i] = (double) ((a[i] + 1) * a[i]) / 2.0 / a[i];
		s[i] += s[i - 1];
		if(i >= k)
		   ans = max(ans, s[i] - s[i - k]); 
   }
   printf("%.7f\n", ans);
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int a[3];
	int num;
	
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	num = a[0];
	
	if(num == a[1]){
		printf("%d\n",a[2]);
	}
	else if(num == a[2]){
		printf("%d\n",a[1]);
	}
	else if(num != a[1] && num != a[2]){
		printf("%d\n",num);
	}
	
	return (0);
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	string s; cin >> s;


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

		for (char c = 'a'; c <= 'z'; c++) {
			bool r = false;
			bool l = false;

			for (int j = 0; j < i; j++) {
				if (s[j] == c) {
					l = true;
				}

				for (int j = i; j < n; j++) {
					if (s[j] == c) {
						r = true;
					}

				}
			}
			if (r == true && l == true) {
				count++;
			}
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256