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

int main(){
 
   int A,B,C;
   cin >>A>>B>>C;
  
   if(A+B==10 && C==7) cout<<"YES"<<endl;
   else if(B+C==10 && A==7 ) cout<<"YES"<<endl;
   else if(C+A==10 && B==7 ) cout<<"YES"<<endl;
   else cout <<"NO"<<endl;
  
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define pr(x)      printf("%d ",x)
#define scl(x)     scanf("%lld",&x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P

char b(bool x)
{
    return x?'#':'.';
}
bool q(string&s1,string&s2)
{
    cout<<s1<<endl<<s2<<endl;
    fflush(stdout);
    string ans;
    cin>>ans;
    if(ans=="end")
        exit(0);
    return ans=="T";
}
int main()
{
    int n ;
    cin >> n;
    string s1 = "",s2 = "";
    lop(i,4)
    {
        s1=b(i&1);
        s2=b(i&2);
        if(q(s1,s2))
        {
            break;
        }
    }
    while (1) {
    bool ok = 0;
    lop(i, 4) {
      string q1 = s1 + b(i & 1);
      string q2 = s2 + b(i & 2);
      if (q(q1, q2)) {
        ok = 1;
        s1 = q1;
        s2 = q2;
        break;
      }
    }
    if (!ok) break;
  }
  while (1) {
    bool ok = 0;
    lop(i, 4) {
      string q1 = b(i & 1) + s1;
      string q2 = b(i & 2) + s2;
      if (q(q1, q2)) {
        ok = 1;
        s1 = q1;
        s2 = q2;
        break;
      }
    }
    if (!ok) break;
  }

    r0;
}


/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


Measured memory_bytes: 724
#include<stdio.h>
int main(void){
int n,a[100],A;
scanf("%d",&n);
for(A=0;A<n;A++)scanf("%d",&a[A]);
for(A=n-1;A>=0;A--){
printf("%d",a[A]);
if(A==0)printf("\n");
else printf(" ");
}
return 0;
}


Measured memory_bytes: 1960
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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

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

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  while (1) {
    C -= B;
    if (C <= 0) break;
    A -= D;
    if (A <= 0) break;
  }

  if (C <= 0) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }

  return 0;
}


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

//Cheating on ICPC
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			Arrays.sort(a);
			int p = 0;
			int s = 0;
			for(int i=0;i<n;i++){
				s+=a[i];
				p+=s;
			}
			System.out.println(p);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main (){

	int arr[1000000];
	int N=1000000;

		for(int i = 0; i < N; i++){
			arr[i] = 1;
		}
		for(int i = 2; i < sqrt(N); i++){
			if(arr[i]){
				for(int j = 0; i * (j + 2) < N; j++){
					arr[i *(j + 2)] = 0;
				}
			}
		}
	
	while(1){
		int n,a=0;
		cin >> n;
		if(n==0)
			break;

		
		for(int i = 2; i <n; i++){
			if(arr[i]&&arr[n-i]&&i<=n-i)
				a++;
		}

		cout << a << endl;
	}
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll n,a[100010];
  ll four=0,two=0,other=0;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    if(a[i]%4==0&&a[i]>2){
      four++;
    }else if(a[i]%2==0){
      two++;
    }
  }

  if(four+two/2>=n/2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 4416
def main():
    N, M = (int(i) for i in input().split())
    S = []
    for _ in range(M):
        k, *s = (int(i)-1 for i in input().split())
        S.append(set(s))
    P = [int(i) for i in input().split()]
    ans = 0
    for bit in range(1 << N):
        on = set()
        for i in range(N):
            if bit & (1 << i):
                on.add(i)
        if all(len(S[i] & on) % 2 == P[i] for i in range(M)):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43740
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, tmp;
    cin >> A >> B;
    if (A > B)
    {
        tmp = A - B;
    }
    else
    {
        tmp = B - A;
    }
    if (tmp % 2 == 0)
    {
        if (A > B)
        {
            cout << A - tmp / 2 << endl;
        }
        else
        {
            cout << B - tmp / 2 << endl;
        }
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
const ll MOD = 1e9+7;

inline ll pow(ll x, ll p) {
	ll ans = 1;
	while(p > 0) {
		if(p&1) ans = (ans*x) % MOD;
		p >>= 1;
		x = (x*x) % MOD;
	}
	return ans;
}
inline ll inv(ll x) { return pow(x, MOD-2); }
vl fac;
inline ll C(int k, int n) {
	return (fac[n] * inv((fac[n-k]*fac[k]) % MOD)) % MOD; 
}
inline void mul(ll &a, const ll &b) {
	a = (a*b) % MOD;
}

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

	int N, M;
	cin >> N >> M;
	fac.resize(M+1);
	fac[0] = 1;
	ll ans = 0;
	for(int i = 1; i <= M; ++i) fac[i] = (i*fac[i-1]) % MOD;
	for(int i = 0; i <= N; ++i) { // i: number of equality position
		ll add = C(i, N); // choose equality positions
		mul(add, C(i, M)); // choose values of equality
		mul(add, fac[i]); // choose order of values
		mul(add, C(N-i, M-i)); // choose remaining values of A
		mul(add, fac[N-i]); // choose their order
		mul(add, C(N-i, M-i)); // choose remaining values of B
		mul(add, fac[N-i]); // choose their order
		if(i&1) ans = (ans+MOD-add) % MOD;
		else ans = (ans+add) % MOD;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1005;
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;
	ll ans=(1+n-1)*(n-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
X,N=map(int, input().split())
ans=0
flag=0

if N!=0:
	P=sorted(list(map(int, input().split())))
	pabs=[]
	
	for p in P:
		pabs.append(abs(X-p))
	pabs.sort()
	
	if 0 in pabs:
		for i in range(1,max(pabs)+1):
			if i in pabs:
				
				if pabs.count(i)==1:
					if X-i not in P:
						ans=X-i
						flag=1
						break
					else:
						ans=X+i
						flag=1
						break
					
				else:
					continue
				
			else:
				ans=X-i
				flag=1
				break
		
		print(X-max(pabs)-1 if flag==0 else ans)
										
	else:
		print(X)
		
else:
	print(X)

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b < 10){
        a *= 10;
    }else if(b<100){
        a *= 100;
    }else{
        a *= 1000;
    }
    int c = a + b;
    if(sqrt(c)- (int)sqrt(c) == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}



Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,n=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      if (a+b == 0) break;
		}catch(Exception e){
      break;
    }

    for (i = 0; i < a; i++){
      for (n = 0; n < b; n++){
        if (i%2 == 0) {
          if (n%2 == 0) {
            System.out.print("#");
          }else{
            System.out.print(".");
          }
        }else{
          if (n%2 == 0) {
            System.out.print(".");
          }else{
            System.out.print("#");
          }
          
        }
      }
      System.out.print("\n");
    }
    System.out.print("\n");

  }
	}
}


Measured memory_bytes: 35372
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  K = readint()[1]

  d = 0
  for a in 1:K, b in 1:K, c in 1:K
    d += gcd(gcd(a,b),c)
  end
  println(d)
end

main()

Measured memory_bytes: 214916
import Control.Applicative
import Data.String
import Data.Char
toInt :: (String -> Int)
toInt x = read x :: Int

main = do
    c <- getLine
    
    if read c == 1
        then
             putStrLn "Hello World"
        else do
            a <- getLine
            b <- getLine
            putStrLn (show (read a + (read b)))



Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    string s = inp1;

    // 最初はグーじゃないといけない

    int ans = 0;

    int g_num = 0;
    int pa_num = 0;

    for (auto c : s) {
        if (g_num == pa_num) {
            ++g_num;
            if (c == 'p') --ans;
            continue;
        }

        ++pa_num;
        if (c == 'g') ++ans;
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
int main(){
	int n;
	cin>>n;
	int arr[105]={0}, ans =0 ;
	int ln[n-1];
	for(int i=0; i<n-1; i++){
		cin>>ln[i];
		if(i==0){
			arr[i]=ln[i];
			arr[i+1]=ln[i];
		}
		else{
			if(ln[i]>arr[i]){
				arr[i+1]=ln[i];
			}
			else{
				arr[i]=ln[i];
				arr[i+1]=ln[i];
			} 
		}
	}
	for(int i=0; i<n; i++)ans+=arr[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n, ma, mb = map(int,input().split())
a = [0] * (n + 1)
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    a[i], b[i], c[i] = map(int,input().split())

#iまでの薬品で、aがj(g),bがk(g)となるときの最小コスト
dp = [[[10 ** 15 for i in range(n + 1)] for j in range(401)] \
    for k in range(401)]

dp[0][0][0] = 0

for i in range(1, n + 1):
    for j in range(401):
        for k in range(401):
            if j < a[i] or k < b[i]:
                dp[k][j][i] = dp[k][j][i - 1]
            else:
                dp[k][j][i] = min(dp[k][j][i - 1], \
                    dp[k - b[i]][j - a[i]][i - 1] + c[i])

i = 1
ans = 10 ** 15
while True:
    if i * ma > 400 or i * mb > 400:
        break
    ans = min(ans, dp[i * mb][i * ma][n])
    i += 1

if ans == 10 ** 15:
    ans = -1

print(ans)

Measured memory_bytes: 115164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
ll mul(ll a, ll b){return (a*b)%MOD;}
int N;
string S;
int cnt[8];
int mp(char x){
    if (x=='R') return 0;
    else if (x=='G') return 1;
    else return 2;
}

ll ans=1;
int main(void){
    cin >> N >> S;
    for(int i=0;i<8;i++){
        cnt[i] = 0;
    }
    cnt[0] = N;
    for(int i=0;i<S.size();i++){
        int c = mp(S[i]);
        int cand=-1;
        for(int j=0;j<7;j++){
            if (cnt[j]==0) continue;
            if (((1<<c)^j)>j){ // complements
                cand = j;
            }
        }
        assert(cand!=-1);
        ans = mul(ans, cnt[cand]);
        cnt[cand]--;
        cnt[cand^(1<<c)]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	string a,b;cin>>a>>b;
	if(a.size()>b.size()){
		cout<<"GREATER"<<endl;
	}else if(a.size()<b.size()){
		cout<<"LESS"<<endl;
	}else{
		if(a>b){
			cout<<"GREATER"<<endl;
		}else if(a<b){
			cout<<"LESS"<<endl;
		}else{
			cout<<"EQUAL"<<endl;
		}
	}
    return 0;
}

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

int main(){
  int n, s = 0; scanf("%d", &n);
  map<int, int> m;
  rep(i, n){
    int a; scanf("%d", &a);
    m[a] += 1;
  }
  for(auto p: m) if(p.second & 1) ++s;
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 4864
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type QueueItem struct {
	key, value int
}

type Queue struct {
	body []QueueItem
}

func (q Queue) isPrior(i, j int) bool {
	if q.body[i].key > q.body[j].key {
		return true
	}
	if q.body[i].key == q.body[j].key {
		return q.body[i].value < q.body[i].value
	}
	return false
}

func (q Queue) swap(i, j int) {
	q.body[i], q.body[j] = q.body[j], q.body[i]
}

func NewQueue() *Queue {
	return &Queue{[]QueueItem{}}
}

func (q *Queue) Push(item QueueItem) {
	index := len(q.body)
	q.body = append(q.body, item)
	for index > 0 {
		parentIndex := ((index + 1) >> 1) - 1
		if q.isPrior(index, parentIndex) {
			q.swap(index, parentIndex)
			index = parentIndex
		} else {
			break
		}
	}
}

func (q *Queue) Pop() QueueItem {
	result := q.body[0]
	size := len(q.body)
	q.body[0] = q.body[size-1]
	size--
	q.body = q.body[:size]
	for index := 0; ; {
		child := ((index + 1) << 1) - 1
		if child >= size {
			break
		}
		rIndex := child + 1
		if rIndex < size && q.isPrior(rIndex, child) {
			child = rIndex
		}
		if q.isPrior(index, child) {
			break
		}
		q.swap(index, child)
		index = child
	}
	return result
}

func (q *Queue) Size() int {
	return len(q.body)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()

	dateMap := make(map[int][]int)
	for i := 0; i < n; i++ {
		date, salary := nextInt(), nextInt()
		dateMap[date] = append(dateMap[date], salary)
	}
	//fmt.Printf("%v\n", dateMap)

	total := 0
	q := NewQueue()
	for d := m - 1; d >= 0; d-- {
		if salaries, ok := dateMap[m-d]; ok {
			for _, v := range salaries {
				q.Push(QueueItem{v, m - d})
			}
		}
		//fmt.Printf("%v\n", q)
		if q.Size() > 0 {
			total += q.Pop().key
		}
	}

	fmt.Printf("%d\n", total)
}


Measured memory_bytes: 11264
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,f=0,mini=INF;
    double sum=0,maxi=0;
    string str,sub;
    ll h,w;
    ll m,k;
    cin>>str>>sub;
    char tmp;
            rep(j,100){

    rep(i,100){
        if(i<str.length()-1&&str[i]>str[i+1]){
            tmp=str[i];
            str[i]=str[i+1];
            str[i+1]=tmp;
        }
        if(i<sub.length()-1&&sub[i]<sub[i+1]){
            tmp=sub[i];
            sub[i]=sub[i+1];
            sub[i+1]=tmp;
        }
        }
    }
    //cout<<str<<endl<<sub<<endl;
    if(str<sub) Yes;
    else No;
    return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=3e5+5;
const int mod=998244353;
int n,sum,inv2,A[N],p[N],g[N];

namespace _ {	
	inline int mul(int x,int y) {return 1ll*x*y%mod;}
	inline int dec(int x,int y) {x-=y;if(x<0) x+=mod;return x;}
	inline int add(int x,int y) {x+=y;if(x>=mod) x-=mod;return x;}
	inline int modpow(int x,int y,int res=1) {
		for(;y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
		return res;
	}
	template <typename _Tp> inline void IN(_Tp&x) {
		char ch;bool flag=0;x=0;
		while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
		while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
		if(flag) x=-x;
	}
}using namespace _;

inline void FWT(int*f,short inv) {
	for(int p=2;p<=n;p<<=1)
		for(int len=p>>1,k=0;k<n;k+=p)
			for(int l=k;l<k+len;++l) {
				int X=f[l],Y=f[l+len],tmp=inv^1?inv2:1;
				f[l]=mul(tmp,add(X,Y)),f[l+len]=mul(tmp,dec(X,Y));
			}
}

int main() {
	IN(n),n=1<<n,inv2=modpow(2,mod-2);
	for(int i=0;i<n;++i) IN(A[i]),sum=add(sum,A[i]);
	sum=modpow(sum,mod-2);
	for(int i=0;i<n;++i) p[i]=mul(A[i],sum),g[i]=mod-1;
	g[0]=dec(n,1),p[0]=dec(p[0],1),FWT(g,1),FWT(p,1);
	for(int i=0;i<n;++i) g[i]=mul(g[i],modpow(p[i],mod-2));
	FWT(g,-1);
	for(int i=0;i<n;++i) printf("%d\n",dec(g[i],g[0]));
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    REP(i,n){
        cout << 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

N=int(input())

string = str(N)
ans = 0

for i in range(len(string)):
    ans += int(string[i])

if ans%9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 76152
n = int(input())
d = [[0]*9 for _ in range(9)]
ans = 0

for num in range(1, n+1):
    s = str(num)
    x, y = int(s[0]), int(s[-1])
    if x != 0 and y != 0:
        d[x-1][y-1] += 1

for i in range(9):
    k = -1
    for j in range(9):
        if i == j:
            ans += pow(d[i][j], 2)
            k = 1
        elif k == 1:
            ans += 2*d[i][j]*d[j][i]

print(ans)

Measured memory_bytes: 9104
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
const ll N = 1000000000;

#define M_PI 3.14159265358979323846264338327950288

void solve() {
    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.size() <= k) {
        cout << s;
    } else {
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "...";
    }
}

int main(){
    int t;
    t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
s = input()[::-1]
t = input()[::-1]
sl, tl = len(s), len(t)
for i in range(sl - tl + 1):
    for j in range(tl):
        if s[i + j] != "?" and s[i + j] != t[j]:
            break
    else:
        print((s[:i] + t + s[i + tl:]).replace("?", "a")[::-1])
        break
else:
    print("UNRESTORABLE")


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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
string s,t;
int lcs[3030][3030];
stack<char> h;


ll fill(int ptr1, int ptr2)
{
	if (ptr1 == 0 || ptr2 == 0)
		return 0;
	if (lcs[ptr1][ptr2] != -1)
		return lcs[ptr1][ptr2];

	if (s[ptr1 - 1] == t[ptr2 - 1])
	{
		lcs[ptr1][ptr2] = 1 + fill(ptr1 - 1,ptr2 - 1);
		return lcs[ptr1][ptr2];
	}
	lcs[ptr1][ptr2] = max(fill(ptr1 - 1, ptr2), fill(ptr1, ptr2 - 1));
	return lcs[ptr1][ptr2];
}

void retrive(int ptr1, int ptr2)
{
	int i = ptr1;
	int j = ptr2;

	while(i > 0 && j > 0)
	{
		if (s[i - 1] == t[j - 1])
		{
			h.push(s[i - 1]);
			i--;
			j--;
		}
		else
		{
			if (lcs[i][j - 1] > lcs[i - 1][j])
				j--;
			else
				i--;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(lcs,-1,sizeof(lcs));
	cin >> s;
	cin >> t;
	int n = s.length();
	int m = t.length();
	fill(n,m);
	retrive(n,m);
	while(!h.empty())
	{
		char c = h.top();
		h.pop();
		cout << c;
	}
	cout << " " << endl;
	return 0;
}

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

int main() {
    //
    int num;
    string str;
    long long cnt = 0;
    long long all = 0;

    cin >> num >> str;
    vector<int> r;
    vector<int> g;
    vector<int> b;

    for (int i = 0; i < num; i++) {
        if (str.at(i) == 'R')
            r.push_back(i);
        else if (str.at(i) == 'G')
            g.push_back(i);
        else if (str.at(i) == 'B')
            b.push_back(i);
    }

    all = r.size() * g.size() * b.size();
    for (int i = 0; i < num; i++) {
        for (int j = i+1; j < num; j++) {
            long long k = j * 2 - i;

            if (k >= num || str.at(i) == str.at(j)) continue;
            if (str.at(k) == str.at(i) || str.at(k) == str.at(j)) continue;
            all--;
            /*
            for (int k = 0; k < b.size(); k++) {
                if (g.at(j) - r.at(i) == b.at(k) - g.at(j)) continue;
                if (b.at(k) - g.at(j) == r.at(i) - b.at(k)) continue;
                if (r.at(i) - b.at(k) == g.at(j) - r.at(i)) continue;
                cnt++;
            }
            */
        }
    }

    cout << all;
    //
}


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

typedef struct {
	char t;
	int pt[10];
	int win;
	int lose;
} GAME;

int main()
{
	GAME game[10];
	int n;

	while (scanf("%d", &n), n){
		for (int i = 0; i < n; i++){
			game[i].win = game[i].lose = 0;
			cin >> game[i].t;
			for (int j = 0; j < n - 1; j++){
				cin >> game[i].pt[j];
				if (game[i].pt[j] == 0){
					game[i].win++;
				}
				else if (game[i].pt[j] == 1){
					game[i].lose++;
				}
			}
		}

		for (int i = 0; i < n; i++){
			for (int j = n - 1; j > i; j--){
				if (game[j].win > game[j - 1].win){
					swap(game[j], game[j - 1]);
				}
				else if (game[j].win == game[j - 1].win && game[j].lose < game[j - 1].lose){
					swap(game[j], game[j - 1]);
				}
			}
		}

		for (int i = 0; i < n; i++){
			cout << game[i].t << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 1236
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; 

const int maxn = 50+5;
int M, T, P, R;
struct Pm
{
    int num;
    int ac;
    int time;
};
Pm mem[maxn];
int List[maxn][15];

bool Input()
{
    cin >> M >> T >> P >> R;
    if(!M && !T && !P && !R) return false;

    int Time, Num, Pro, J;

    for(int i = 1; i <= T; i++) mem[i].num = i;

    for(int i = 1; i <= R; i++)
    {
        cin >> Time >> Num >> Pro >> J;
        if(!J)
        {
            mem[Num].ac++;
            mem[Num].time += Time+List[Num][Pro]*20;
        }
        else
        {
            List[Num][Pro]++;
        }
    }

    return true;
}

bool cmp (const Pm & a, const Pm & b)
{
    return   a.ac > b.ac ||
            (a.ac == b.ac && a.time < b.time) ||
            (a.ac == b.ac && a.time == b.time && a.num > b.num);
}

void Print()
{
    for(int i = 1; i < T; i++)
    {
        if(mem[i].ac == mem[i+1].ac && mem[i].time == mem[i+1].time) printf("%d=", mem[i].num);
        else printf("%d,", mem[i].num);
    }
    printf("%d\n", mem[T].num);
}

int main()
{
    while(1)
    {
        memset(mem, 0, sizeof(mem));
        memset(List, 0, sizeof(List));
        if(!Input()) break;
        sort(mem+1,mem+T+1, cmp);
        Print();
    }
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  mat dp(n+1,vec(4));
  dp[n][3]=1;
  for(ll i=n-1;i>-1;i--) {
    for(ll j=3;j>-1;j--) {
      ll m=1;
      if(s[i]=='?') m=3;
      (dp[i][j]=m*dp[i+1][j])%=mod;
      if(s[i]=='?'||(j==0&&s[i]=='A')||(j==1&&s[i]=='B')||(j==2&&s[i]=='C')) m=1;
      else m=0;
      if(j!=3) {
        (dp[i][j]+=m*dp[i+1][j+1])%=mod;
      }
    }
  }
  cout << dp[0][0] << endl;
}

Measured memory_bytes: 7424
class Heap
  attr_accessor :heap, :size

  def initialize
    @heap = []
    @size = 0
  end

  def add(n)
    i = size
    while i > 0
      parent_index = (i - 1) / 2
      break if n < heap[parent_index]

      heap[i] = heap[parent_index]
      i = parent_index
    end
    heap[i] = n
    @size += 1
  end

  def pop
    return if size <= 0
    max = heap[0]
    @size -= 1
    n = heap[size]
    i = 0
    while i * 2 + 1 < size
      child_index1 = i * 2 + 1
      child_index2 = i * 2 + 2
      if child_index2 < size && heap[child_index2] >= heap[child_index1]
        child_index1 = child_index2
      end
      break if heap[child_index1] < n

      heap[i] = heap[child_index1]
      i = child_index1
    end
    heap[i] = n
    max
  end
end

heap = Heap.new

n, m = gets.chomp.split.map(&:to_i)
gets.chomp.split.map(&:to_i).each do |a|
  heap.add(a)
end

m.times do
  heap.add(heap.pop / 2)
end

p heap.heap.inject(:+)


Measured memory_bytes: 10580
#include <iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]!=s[i+1]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n - 1) / 111 * 111 + 111;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n-1];
    int ans = 0;
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) {
        cin >> b[i];
        ans += b[i];
    }
    rep(i,n-1){
        cin >> c[i];
    }
    for(int i = 1; i < n; i++){
       if(a[i]-a[i-1] == 1) ans += c[a[i-1]]; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

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

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

int main(void){
  int num;
  string bef,now;
  while(cin>>num,num){
    int cnt = 0;
    cin>>bef;num--;
    rep(i,num){
      cin>>now;
      if(now[0]!=bef[0] && now[1]==bef[1]){
	//cout<<"now "<<now<<"bef "<<bef<<endl;
	cnt++;
      }
      //cout<<now<<endl;
      bef=now;
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 1204
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

if b < a:
    print(0)
    exit()

if n == 1:
    if a==b:
        print(1)
    else:
        print(0)
    exit()

if n == 2:
    print(1)
    exit()

print( (n-2)*b - (n-2)*a + 1  )

Measured memory_bytes: 38384
void main() {
  problem();
}

void problem() {
  auto X = scan!int;
  auto Y = scan!int;

  string solve() {
    foreach(a; 0..51) {
      foreach(b; 0..26) {
        if (a + b == X && 2*a + 4*b == Y) return "Yes";
      }
    }

    return "No";
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2700
def training_camp(N: int) -> int:
    MOD = 10 ** 9 + 7
    ret = 1
    for n in range(N):
        ret = (ret * (n + 1)) % MOD
    return ret


if __name__ == "__main__":
    N = int(input())
    ans = training_camp(N)
    print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define re register
#define ui unsigned int
#define ull unsigned long long
const double pi=3.14159265358979323846264338327950;
const int maxn=(1<<20)+1;
struct com
{
	double a,b;
	inline com operator +(const com&A){return(com){a+A.a,b+A.b};}
	inline void operator +=(const com&A){a+=A.a,b+=A.b;}
	inline com operator -(const com&A){return(com){a-A.a,b-A.b};}
	inline com operator *(const com&A){return(com){a*A.a-b*A.b,a*A.b+b*A.a};}
	inline com operator *(re const double &o) {return (com){a*o,b*o};}
	inline com operator /(const int&A){return(com){a/A,b/A};}
	inline com operator !(){return(com){a,-b};}
	inline bool operator !=(const com&A){return a!=A.a||b!=A.b;}
};
com w[maxn],T1[maxn],xx1[maxn],xx2[maxn];
int getlen(re int n){re int x=1;for(n--;n;n>>=1,x<<=1);return x;}
ui x1[maxn];
ull x2[maxn];
bool cp[maxn<<1];
void init(re int len)
{
	cp[1]=1;
	for(re int i=2;i<len;i++)
	{
		cp[i]=(cp[i>>1]&(!(i&1)))||(cp[i>>2]&((i>>1)&1));
	}
}
void fft(com*a,re int len)
{
	re ui i1=0;
	re com x1,x2,x3;
	for(re ui i=0,j=0;i<len;i++)
	{
		if(i<j)std::swap(a[i],a[j]);
		for(ui k=len>>1;;k>>=1)if((j^=k)>=k)break;
	}w[0]=(com){1,0};
	if(len>=2)
	{
		for(re ui i=0;i<len;i+=2)if(cp[(len+i)>>1])x1=a[i+1],a[i+1]=a[i]-x1,a[i]+=x1;
	}
	if(len>=4)
	for(re ui i=0;i<len;i+=4)
		if(cp[(len+i)>>2])
		{
			x1=a[i+2];
			x2=a[i+3];
			x3=(com){-x1.b+x2.b,-x2.a+x1.a};x1+=x2;
			a[i+2]=a[i]-x1;a[i]+=x1;
			a[i+3]=a[i+1]-x3;a[i+1]+=x3;
		}
	w[1]=(com){0,1};w[2]=(com){-1,0};
	for(re ui i=8,i2=3;i<=len;i<<=1,i2++)
	{
		i1=i>>2;
		com s=(com){cos(pi/i1/2),sin(pi/i1/2)};
		for(re ui j=3*i1-2;j>0;j-=2)
			w[j]=w[j>>1];
		for(re ui j=1;j<3*i1;j+=2)
			w[j]=s*w[j-1];
		for(re ui j=0;j<len;j+=i)
		if(cp[(len+j)>>i2]){re com*aa=a+j,*aaa=aa+i1,*bb=aaa+i1,*cc=bb+i1;
			for(re int k=0;k<i1;k++)
			{
				x1=w[k]*bb[k];
				x2=w[k*3]*cc[k];
				x3=(com){-x1.b+x2.b,-x2.a+x1.a};
				cc[k]=aaa[k]-x3;
				aaa[k]+=x3;
				x1+=x2;
				bb[k]=aa[k]-x1;
				aa[k]+=x1;
			}
		}
	}
}
void DFT(ui *a,com *R1,int n,int len) {
	for(re int i=0;i<n+1>>1;++i) R1[i]=(com){(double)a[i<<1],(double)a[i<<1|1]};
	fft(R1,len);
}
void DFTMul(com *R1,com *S1,int len) {
	for(re int i=0;i<len;++i) {
		re int j=len-1&len-i;
		com tmp=(i&len>>1)?(com){1,0}-w[i^len>>1]:w[i]+(com){1,0};
		T1[j]=R1[i]*S1[i]-(R1[i]-!R1[j])*(S1[i]-!S1[j])*tmp*0.25;
	}
}
void IDFT(ull *__ans,int r,int len) {
	fft(T1,len);
	for(re int i=0;i<r;++i) __ans[i]=(i&1)?(ull)(T1[i>>1].b/len+0.5):(ull)(T1[i>>1].a/len+0.5);
}
const ui P=200003,g1=5;
ui a1[200100];
int main()
{
	re ui len=getlen(P);init(len);
	re int n,x;
	scanf("%d",&n);
	re ull ans=0;
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		ans-=(ull)x*x%P;
		if(x==0)continue;
		a1[x]++;
	}
	re ui gg=1;
	for(re ui i=0;i<P-1;i++)
	{
		x1[i]=a1[gg];
		gg=(ull)gg*g1%P;
	}
	DFT(x1,xx1,P,len);
	DFTMul(xx1,xx1,len);
	IDFT(x2,len<<1,len);
	gg=1;
	for(re ui i=0;i<=2*P;i++)
	{
		ans+=(ull)gg*x2[i],gg=(ull)gg*g1%P;
	}
	printf("%llu\n",ans/2);
}

Measured memory_bytes: 21128
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

ull m = (ull) 1e9+7;
ull dp[(ull)2e5];

ull pow(ull b, ull e){
  if(e==0) return 1;
  ull p = 1;
  if( e % 2 == 1 ){
    p = b % m;
    e--;
  }
  ull t = pow(b, e/2);
  p *= (t*t)%m;
  p %= m;
  return p;
}

ull fac(ull n){
  if( dp[n] != 0 ) return dp[n];
  if( n == 0 ) return 1;
  ull f = ((n%m)*fac(n-1)) % m;
  dp[n] = f;
  return f;
}

ull bc(ull n, ull k){
  ull nf = fac(n);
  ull kf = fac(k);
  ull nkf = fac(n-k);

  ull kfi = pow(kf, m-2);
  ull nkfi = pow(nkf, m-2);

  ull coef = (((nf * kfi)%m)*nkfi)%m;
  return coef;
}

int main(){
  dp[(ull)2e5] = {0};
  ull h, w, a, b;

  cin >> h >> w >> a >> b;

  ull limit = min(h-a, w-b);

  ull sum=0;
  for(int i=1; i<=limit; i++){
    ull t1 = bc(h+b-a-1, h-a-i);
    ull t2 = bc(w+a-b-1, w-b-i);
    ull pr = (t1*t2)%m;
    sum += pr;
    sum %= m;
  }


  cout << sum << endl;
  return 0;
}


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

int main() {
int h,w;
cin >> h >> w;
vector<vector<char>> a(h,vector<char>(w));

rep(i,h)rep(j,w) cin >> a.at(i).at(j);


rep(i,2*h)rep(j,w){
  cout <<a.at((i+2)/2-1).at(j);
  if(j == w-1) cout << endl;
}

}


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

int main() {
  int n, k;
  long long S = 0;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0;i < n;i++) cin >> h[i];
  sort(h.begin(), h.end());
  for(int i = 0;i < (n - k);i++) S += h[i];
  cout << S << endl;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll lg=31;
const ll N=1e5+5;
const ll INF=3e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define f first
#define s second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repp(i, a, b) for(int i = a; i > (b); --i)
#define sz(x) (int)(x).size()
#define pb push_back
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main() {
	FASTIO;
	int n;
	cin >> n;
	ll count = 0;
	for (int a = 1; a < n; a++) {
	    count += ((n - 1) / a);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3624
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_C&lang=jp
*/
#include<iostream>
#include<string>
using namespace std;
#define NIL -1
#define REP(l,r) for(int i=(l);i<(r);i++)
#define P(r) cout<<" "<<r

struct Node{int p,l,r;};
Node Tree[25];
int n;

void make_tree(){
  int left,right,k;
  REP(0,n){
    cin>>k>>left>>right;
    Tree[k].l=left; Tree[k].r=right;//子設定
    if(left!=NIL)Tree[left].p=k;
    if(right!=NIL)Tree[right].p=k; //親設定
  }
}
//Perorder
void Pre(int r){
  if(r!=NIL){
    P(r);
    Pre(Tree[r].l);
    Pre(Tree[r].r);
  }
}
//Inoder
void In(int r){
  int L=Tree[r].l;
  int R=Tree[r].r;
  if(r==NIL)return;
  In(L);
  P(r);
  In(R);
}
//Postorder
void Post(int r){
  int L=Tree[r].l;
  int R=Tree[r].r;
  if(r==NIL)return;
  Post(L);
  Post(R);
  P(r);
}
int main(){
  int r;
  cin>>n;
  //初期化
  REP(0,25) Tree[i].p=Tree[i].l=Tree[i].r=NIL;
  make_tree();
  REP(0,n){
    if(Tree[i].p==-1) r=i;
  }
  cout<<"Preorder"<<"\n";
  Pre(r); cout<<"\n";
  cout<<"Inorder"<<"\n";
  In(r); cout<<"\n";
  cout<<"Postorder"<<"\n";
  Post(r); cout<<"\n";
}



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

long long n, x;

long long gcd(long long a, long long b)
{
	return !b ? a : gcd(b, a % b);
}

inline void init()
{
	scanf("%lld%lld", &n, &x);
}

inline void work()
{
	printf("%lld\n", 3 * (n - gcd(n, x) ) );
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

unsigned long long calc(int num, bool prev)
{
	if (num <= 1)
	{
		if (prev)
		{
			return 1;
		}
		return 2;
	}

	if(prev)
	{
		return calc(num - 1, false);
	}
	else
	{
		return calc(num - 1, true) + calc(num - 1, false);
	}
}

int main()
{
	unsigned long long dp[102][8];

	int H, W, K;
	cin >> H >> W >> K;
	for (auto i = 0; i < W; ++i)
	{
		dp[1][i] = 0;
	}
	dp[1][0] = 1;

	vector<unsigned long long> count(8);
	for (auto i = 1; i < 8; ++i)
	{
		count[i] = calc(i, false);
	}
	count[0] = 1;

	unsigned long long mod = 1000000007;
	for (auto i = 2; i <= H + 1; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			auto sum = 0ull;
			if (j > 0)
			{
				auto temp = 1ull;
				auto num = j - 2;
				if (num >= 0)
				{
					temp *= count[num];
				}
				num = W - j - 2;
				if (num >= 0)
				{
					temp *= count[num];
				}
				sum = (((dp[i - 1][j - 1] * temp) % mod) + sum) % mod;
			}
			{
				auto temp = 1ull;
				auto num = j - 1;
				if (num >= 0)
				{
					temp *= count[num];
				}
				num = W - j - 2;
				if (num >= 0)
				{
					temp *= count[num];
				}
				sum = (((dp[i - 1][j] * temp) % mod) + sum) % mod;
			}
			if (j < W - 1)
			{
				auto temp = 1ull;
				auto num = j - 1;
				if (num >= 0)
				{
					temp *= count[num];
				}
				num = W - j - 3;
				if (num >= 0)
				{
					temp *= count[num];
				}
				sum = (((dp[i - 1][j + 1] * temp) % mod) + sum) % mod;
			}

			dp[i][j] = sum;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
#define ll long long
#define ld long double
ll ctoi(const char c){if('0'<=c&&c<='9') return (c-'0');return -1;}
#define ALL(x) begin(x),end(x)
  
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> l(m),r(m);
  rep(i,m) cin >> l[i] >> r[i];
  sort(ALL(l));
  sort(ALL(r));
  if(r[0]-l[m-1]+1>0) cout << r[0]-l[m-1]+1 << endl;
  else cout << "0" << endl;
}

Measured memory_bytes: 4856
using System;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[]x, string[]y)
        {
            bool g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static string Check(string[]x, string[]y)
        {
            if (Eql(x, y)) return "Yes";
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b } :
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return "Yes";
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return "Yes";
                    }
                }
            }
            return "No";
        }

        static void Main()
        {
            var s = Console.ReadLine().Split(' ');
            var t = Console.ReadLine().Split(' ');
            Console.WriteLine(Check(s, t));
        }
    }
}

Measured memory_bytes: 8932
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;


int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    For(i, K, n) puts(a[i-K] < a[i] ? "Yes" : "No");
}

Measured memory_bytes: 4436
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

main(){
  int f,ans=0;
  string s;
  while(cin >> s){
    f=0;
    int sl=s.size();
    for(int i=0;i<sl/2+1;i++){
      if(s[i]!=s[sl-i-1]){
	f=1;
      }
    }
    if(f!=1){
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else
		return gcd(b, a % b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a>=13)
        cout << b << endl;
        else if(6<=a&&a<=12)
            cout << b / 2 << endl;
            else
                cout << 0 << endl;
            return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  string s;
  cin >> s;
  int res = 0, ans = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      res++;
    } else {
      ans = max(ans, res);
      res = 0;
    }
  ans = max(ans, res);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vector<map<ll,ll>> G(n);
  for(ll i=0;i<n-1;i++) {
    ll a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    G[a][b]=c;
    G[b][a]=c;
  }
  ll Q,k;
  cin >> Q >> k;
  k--;
  vec d(n,-1);
  priority_queue<pll,vector<pll>,greater<pll>> q;
  q.push({0,k});
  while(q.size()) {
    ll f=q.top().second;
    ll fd=q.top().first;
    q.pop();
    if(d[f]>-1) continue;
    d[f]=fd;
    for(auto p:G[f]) {
      ll t=p.first;
      ll td=fd+p.second;
      q.push({td,t});
    }
  }
  while(Q--) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    cout << d[x]+d[y] << endl;
  }
}

Measured memory_bytes: 20976