akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

c = 1
m = a[0]

s = 1 # 0:- 1:_ 2:+

for i in a:
    if m == i:
        continue
    elif m > i:
        if s == 2:
            s = 1
            c += 1
        else:
            s = 0
    else:
        if s == 0:
            s = 1
            c += 1
        else:
            s = 2
    m = i

print(c)

Measured memory_bytes: 14252
#include <iostream>
#include <map>
#include <vector>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int ans=0,n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(m[x]==0)v.push_back(x);
		m[x]++;
	}
	for(i=0;i<v.size();i++)
		if(v[i]>m[v[i]])ans+=m[v[i]];
		else if(v[i]<m[v[i]])ans+=m[v[i]]-v[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdlib>
#include <memory.h>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;

const int inf = 1e6;
int n, m;

struct _edge {
    int x, i;
    _edge(int x, int i) : x(x), i(i) {}
};

int dist[1001][1001];
vector<_edge> edge[1001];
vector<_edge> redge[1001];
int ans[200000];
void dfs(int dist[], int x, int e) {
    for (_edge i : edge[x]) {
        if (dist[i.x] != m && dist[i.x] != e) {
            if (dist[i.x] != -1) {
                dist[i.x] = m;
            }
            else {
                dist[i.x] = e;
            }
            dfs(dist, i.x, e);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        edge[a].emplace_back(b, i);
        redge[b].emplace_back(a, i);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            dist[i][j] = -1;
        }

        dist[i][i] = m;
        for (_edge j : edge[i]) {
            if (dist[i][j.x] != m) {
                if (dist[i][j.x] != -1) dist[i][j.x] = m;
                else dist[i][j.x] = j.i;
                dfs(dist[i], j.x, j.i);
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (_edge e : edge[i]) {
            int j = e.x;
            int t = e.i;
            if ((dist[j][i] != -1) == (dist[i][j] != m)) {
                ans[t] = 1;
            }
        }
    }

    for (int i = 0; i < m; ++i) {
        printf(ans[i] ? "diff\n" : "same\n");
    }
    return 0;
}


Measured memory_bytes: 12032
use proconio::*;

fn calc(mut a: Vec<(u32, i32)>, item: (u32, i32)) -> Vec<(u32, i32)> {
    let mut b = a.iter().map(|a| (a.0 + item.0, a.1 + item.1)).collect::<Vec<_>>();
    let mut c = Vec::with_capacity(a.len() * 2);
    while !(a.is_empty() || b.is_empty()) {
        if a.last().unwrap().1 >= b.last().unwrap().1 {
            c.push(a.pop().unwrap());
        } else {
            c.push(b.pop().unwrap());
        }
    }
    for p in a.into_iter().chain(b.into_iter()).rev() {
        c.push(p);
    }
    c.reverse();
    for i in 1..c.len() {
        c[i].0 = std::cmp::max(c[i].0, c[i - 1].0);
    }
    c
}

#[fastout]
fn run() {
    input! {
        n: usize,
        mut item: [(u32, i32); n],
        q: usize,
        ask: [(usize, i32); q],
    }
    item.insert(0, (0, 0));
    let mut memo = vec![vec![]; n + 1];
    memo[1] = vec![(0, 0), item[1]];
    let batch = 10;
    for i in 2..=std::cmp::min(n, 1 << batch) {
        memo[i] = calc(memo[i / 2].clone(), item[i]);
    }
    for (start, width) in ask {
        let ans = if start < (1 << batch) {
            memo[start].iter().filter(|p| p.1 <= width).max().unwrap().0
        } else {
            let mut dp = vec![(0, 0)];
            let mut pos = start;
            while pos >= (1 << batch) {
                dp = calc(dp, item[pos]);
                pos /= 2;
            }
            let memo = &memo[pos];
            let mut i = 0;
            let mut j = memo.len();
            let mut ans = 0;
            while i < dp.len() && j > 0 {
                if dp[i].1 + memo[j - 1].1 <= width {
                    ans = std::cmp::max(ans, dp[i].0 + memo[j - 1].0);
                    i += 1;
                } else {
                    j -= 1;
                }
            }
            ans
        };
        println!("{}", ans);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 21532
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  D,T,S=LI()
  if T*S<D:
    return 'No'
  return 'Yes'

# main()
print(main())


Measured memory_bytes: 10780
N, W = gets.split.map(&:to_i)

goods = N.times.map { gets.split.map(&:to_i) }

dp = Hash.new(-1)
dp[0] = 0

goods.each do |w, v|
  temp = dp.dup

  temp.each do |weight, (value, cnt)|
    nw = weight + w
    next if W < nw

    val = value + v

    dp[nw] = val if dp[nw] < val
  end
end

puts dp.max_by { |w, v| v }.last


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,K;cin>>N>>K;
  long long int x=0;
  vector<long long int>H(N);
  if(N>K){
    for(long long int i=0;i<N;i++)cin>>H.at(i);
    sort(H.begin(),H.end());
    for(long long int i=0;i<N-K;i++)x+=H.at(i);
  }
  cout<<x<<endl;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

char a[10][10],x[10],y[10];
int main() {
    int n,m,k;
    cin>>n>>m>>k;
    int cnt=0;
    for(int i=0;i<n;++i) for(int j=0;j<m;++j) cin>>a[i][j];
    for(int i=0;i<n;++i) for(int j=0;j<m;++j) if(a[i][j]=='#') cnt++,x[i]++,y[j]++;
    int ans=0;
    for(int i=0;i<1<<(n+m);++i) {
        int tmp=0;
        for(int j=0;j<n;++j) if(i&(1<<j)) tmp+=x[j];
        for(int k=0;k<m;++k) if(i&(1<<k+n)) tmp+=y[k];
        for(int j=0;j<n;++j) if(i&(1<<j)) {
            for(int k=0;k<m;++k) if(i&(1<<k+n)) {
                if(a[j][k] == '#') --tmp;
            }
        }
        if(cnt - tmp == k) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

long long C(long long n, long long k) {
    long long res = 1LL;
    for (long long i = 0; i < k; i++) res = res * (n - i) / (i + 1);
    return res;
}

void solve() {
    cout << fixed << setprecision(10);
    long long N, A, B;
    cin >> N >> A >> B;
    vector<double> v(N);
    for (long long i = 0; i < N; i++) cin >> v.at(i);
    sort(v.begin(), v.end());
    double sum = 0;
    for (long long i = N - A; i < N; i++) sum += v.at(i);
    double ave = sum / A;
    cout << ave << endl;
    long long same = 0, choice = 0;
    for (long long i = 0; i < N; i++) {
        if (v.at(i) == v.at(N - A)) {
            same++;
            if (i >= N - A) choice++;
        }
    }
    long long ans = 0L;
    if (v.at(N - A) == v.at(N - 1)) {
        for (long long i = A; i <= min(same, B); i++) {
            ans += C(same, i);
        }
    } else {
        ans = C(same, choice);
    }
    cout << ans << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++) cout<<"x";
    cout<<endl;
}


Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k = 0;
	cin >> k;
	vector<lli> a(k);
	for (auto &i : a)
		cin >> i;
	lli l = 2ll, r = 2ll;
	for (int i = k - 1; i >= 0; --i)
	{
		lli t = a[i];
		l += ((t - l % t) % t); r -= (r % t);
		if (l > r)
		{
			cout << "-1" << endl; return 0;
		}
		r += (t - 1);
	}
	cout << l << " " << r << endl;
}

Measured memory_bytes: 3968
K = int(input())

lst = [i for i in range(1, 10)]

if K < 10:
    print(K)
else:
    now = 0
    K -= 9
    ans = 0
    while True:
        md = lst[now] % 10
        for i in range(10):
            if abs(md - i) <= 1:
                K -= 1
                ans = lst[now] * 10 + i
                lst.append(ans)
                if K == 0:
                    print(ans)
                    exit()
        now += 1

Measured memory_bytes: 13284
import java.util.*;

class Main{
  static int repow(int b,int p){
    System.err.println(b+"^"+p);
    int res=1;
    int a=b;
    while(p>0){
      if((p&1)==1){
        res*=a;
      }
      a*=a;
      p/=2;
    }
    System.err.println("="+res);
    return res;
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int cnt=0;
    int fr=0;
    int ba=s.length()-1;
    while(fr<ba){
      if(s.charAt(fr)==s.charAt(ba)){
        fr++;
        ba--;
      }else{
        if(s.charAt(fr)=='x'){
          fr++;
          cnt++;
        }else if(s.charAt(ba)=='x'){
          ba--;
          cnt++;
        }else{
          System.out.println(-1);
          return;
        }
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 24856
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int h, w; cin >> h >> w;

    char a[h][w];

    int cnt = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                cnt++;
            }
        }
    }

    if(cnt == h + w - 1){
        cout << "Possible";
    }
    else{
        cout << "Impossible";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, m = li()
balls = [1]*n
canex = [0]*n

canex[0] = 1

for _ in range(m):
    x, y = li_()
    balls[x] -= 1
    balls[y] += 1

    if balls[x] > 0 and canex[x]:
        canex[y] = 1

    elif balls[x] == 0 and canex[x]:
        canex[y] = 1
        canex[x] = 0

print(sum(canex))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int idx = -1;
  rep(i, 7)
  {
    if (days[i] == s)
      idx = i;
  }
  cout << 7 - idx;
  return 0;
}

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

bool comp_pair(P a, P b) {
    return a.second < b.second;
}

int main() {
    ll n;
    cin >> n;
    vector<P> a(n);
    rep(i, n) {
        ll input;
        cin >> input;
        a[i] = make_pair(i+1, input);
    }

    sort(a.begin(), a.end(), comp_pair);

    rep(i, n) {
        cout << a[i].first << " ";
    }
    cout << endl;

    return 0;
}


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

int main() {
  string b;
  cin >> b;
if(b=="A"){
cout<<"T"<<endl;
}
else if(b=="T"){
cout<<"A"<<endl;
}
else if(b=="G"){
cout<<"C"<<endl;
}
else if(b=="C"){
cout<<"G"<<endl;
}
}

Measured memory_bytes: 256
#include<string>
#include<list>
#include<iostream>

using namespace std;

int main()
{
    string str;
    list<int> data;
    list<int>::iterator it,l;
    int n,x;
    cin >> n;
    while(n--)
    {
        cin >> str;
        if(str == "insert")
        {
            cin >> x;
            data.push_front(x);
        }
        else if(str == "delete")
        {
            cin >> x;
            for(it=data.begin(),l=data.end(); it!=l; ++it)
            {
                if(*it == x)
                {
                    data.erase(it);
                    break;
                }
            }
        }
        else if(str == "deleteFirst")
            data.pop_front();
        else
            data.pop_back();
    }
    for(it=data.begin(),l=--data.end(); it!=l; ++it)
        cout << *it << " ";
    cout << *it << endl;
}


Measured memory_bytes: 34312
s1 = ''
try:
    while True:
        t = input()
        if t == '':
            break
        s1 += t
except EOFError:
    pass

n = [0] * 26
s = s1.lower()
for i in range(len(s)):
    j = ord(s[i]) - 97
    if j >= 0 and j < 26:
        n[j] += 1
for i in range(26):
    print('%s : %d' %(chr(i + 97),n[i]))


Measured memory_bytes: 5564
MOD = 1000000007

N = int(input())

S = ['A', 'C', 'G', 'T']
T = []

for i in range(4):
    for j in range(4):
        for k in range(4):
            s = S[i] + S[j] + S[k]
            T.append(s)

dp = [[0 for j in range(64)] for i in range(N)]

for j in range(64):
    sj = T[j]
    if sj == 'GAC' or sj == 'ACG' or sj == 'AGC':
        continue
    dp[2][j] = 1

for i in range(3, N):
    for j in range(64):
        sj = T[j]
        if sj == 'GAC' or sj == 'ACG' or sj == 'AGC':
            continue
        for k in range(64):
            sk = T[k]
            if sj[2] == 'C' and sk[0] == 'A' and sk[2] == 'G':
                continue
            if sj[2] == 'C' and sk[:2] == 'AG':
                continue
            if sj[:2] == sk[1:]:
                dp[i][j] += dp[i - 1][k]
                dp[i][j] %= MOD

print(sum(dp[N - 1])%MOD)

Measured memory_bytes: 41584
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		int M=sc.nextInt();
		
		int x[]=new int[M];
		for(int i=0;i<M;i++) {
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		
	
		
		int t[]=new int[M-1];
		for(int i=1;i<M;i++) {
			t[i-1]=x[i]-x[i-1];
		}
		Arrays.sort(t);
		
		int ans=0;
		for(int i=0;i<M-N;i++) {
			ans+=t[i];
		}
		if(M<=N)ans=0;
		
		p(ans);
		
	}
	
}
	


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

//constant
const long long int inf = 1<<30;
const int N = 1e5+1;
const int M = 1e5+1;

//variable
long long int x, y;
long long int ans;

//function


int main()
{
    cin>>x>>y;
    for(ans=1; ; ans++){
        x=x*2;
        if(x>y){
            break;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
long long int dp[2][100005];

long long int sol(int color, int v, int prev, vector< vector<int>>&adj){
      if(dp[color][v]!=-1)return dp[color][v];
      long long int ans1=1, ans2=1;
      int cnt=0;
      for(auto u: adj[v]){
            if(u!=prev){
                  cnt++;
                  long long int p=0;
            
                  p+=sol(0, u, v, adj);
                  //else p+=sol(1, u, v, adj);
                  p%=mod;
                  ans1*=p;
                  ans1%=mod;
            }
      }
      if(!color)
      for(auto u: adj[v]){
            if(u!=prev){
                  cnt++;
                  long long int p=0;
            
                  p+=sol(1, u, v, adj);
                  //else p+=sol(1, u, v, adj);
                  p%=mod;
                  ans2*=p;
                  ans2%=mod;
            }
      }
      if(!color)ans1+=ans2;
      ans1%=mod;
      dp[color][v]=ans1;
      if(cnt==0){
            if(color)dp[color][v]=1;
            else dp[color][v]=2;
      }
      //cout<<color<<' '<<v<<' '<<dp[color][v]<<'\n';
      return dp[color][v];
}

int main(){
      int n;
      cin>>n;
      memset(dp, -1, sizeof(dp));

      vector< vector<int>>adj(n+1);
      for(int i=0; i<n-1; i++){
            int u, v;
            cin>>u>>v;
            adj[u-1].push_back(v-1);
            adj[v-1].push_back(u-1);
      }
      long long int ans=(sol(0, 0, -1, adj))%mod;
      cout<<ans<<'\n';
}

Measured memory_bytes: 18472
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	map<char, int> m;
	for(auto &it:s)
		m[it]++;
	for(auto &it:m)
	{
		if(it.second%2)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


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

typedef long long ll;
ll dp[52][52];
ll C(int n, int r) {
	if(n < r) return 0;
	if(n == 0 || n == r || r == 0) return 1;
	if(dp[n][r] != -1) return dp[n][r];
	return dp[n][r] = C(n-1,r-1) + C(n-1,r);
}

int main() {
	memset(dp,-1,sizeof dp);
	int n, a[52], p, ev = 0, od = 0;
	cin >> n >> p;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] & 1) od++;
		else ev++;
	}
	long long ans = 0;
	if(p == 0) {
		for(int i = 0; i <= od; i += 2) {
			ans += C(od,i) * (1ll << ev);
		}
		cout << ans << endl;
	} else {
		for(int i = 1; i <= od; i += 2) {
			ans += C(od,i) * (1ll << ev);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun n aa bb ->
    let m = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0, b0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in

    let inv x y = (* 1/x in mod y *)
        let c, d = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = ((a mod m) * (b mod m)) mod m in
    let ( /@) a b = a *@ inv b m in

    let rec loop acc i j acc1 =
        let acc = acc *@ i /@ j in
        let acc1 = if j = aa then acc else acc1 in
        if j = bb then acc1, acc else
            loop acc (i - 1) (j + 1) acc1
    in
    let acc1, acc2 = loop 1 n 1 0 in
    let pow2 a =
        let rec loop acc a b =
            if a = 0 then acc else
                let acc = if a mod 2 = 1 then acc *@ b else acc in
                loop acc (a / 2) (b *@ b)
        in
        loop 1 a 2
    in
    let acc = pow2 n -@ acc1 -@ acc2 -@ 1 in
    Printf.printf "%d\n" acc
)

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

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

int main(){

    ll A, B;
    cin >> A >> B;
    ll X = gcd(A, B);
    set<ll>S;
    for(ll i = 2; i * i <= X; i++){
        while(X % i == 0){
            S.insert(i);
            X /= i;
        }
    }
    if(X != 1)S.insert(X);
    cout << S.size() + 1 << endl;

    return 0;
}


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

namespace abc177_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();
      var A = new int[M];
      var B = new int[M];

      for (int i = 0; i < M; i++)
      {
        A[i] = CIn.ReadInt() - 1;
        B[i] = CIn.ReadInt() - 1;
      }

      var uf = new UnionFind(N);

      for (int i = 0; i < M; i++)
      {
        uf.Unite(A[i], B[i]);
      }

      var ans = Enumerable.Range(0, N).Select(e => uf.GetRoot(e)).GroupBy(e => e).Max(e => e.Count());

      Console.WriteLine(ans);
    }
  }

  class UnionFind
  {
    private readonly int[] parent;
    private readonly int[] size;

    public UnionFind(int n)
    {
      parent = Enumerable.Range(0, n).ToArray();
      size = Enumerable.Repeat(1, n).ToArray();
    }

    public int GetRoot(int a)
    {
      if (parent[a] == a) return a;
      return parent[a] = GetRoot(parent[a]);
    }

    public void Unite(int a, int b)
    {
      var aRoot = GetRoot(a);
      var bRoot = GetRoot(b);

      if (aRoot == bRoot) return;

      if (size[a] >= size[b])
      {
        size[aRoot] += size[bRoot];
        parent[bRoot] = aRoot;
      }
      else
      {
        size[bRoot] += size[aRoot];
        parent[aRoot] = bRoot;
      }
    }

    public bool IsSame(int a, int b)
    {
      return GetRoot(a) == GetRoot(b);
    }

    public int GetSize(int a)
    {
      return size[GetRoot(a)];
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 51300
def function(arg):
    xyabc, pa, qb, rc = arg.split('¥n')
    X,Y,A,B,C = map(int, xyabc.split())
    oishisa_A = list(map(int, pa.split()))
    oishisa_B = list(map(int, qb.split()))
    oishisa_C = list(map(int, rc.split()))
    
    oishisa_A.sort(reverse=True)
    oishisa_A = oishisa_A[:X] # at most X
    oishisa_B.sort(reverse=True)
    oishisa_B = oishisa_B[:Y] # at most Y
    oishisa_C.sort(reverse=True)
    
    oishisa = oishisa_A + oishisa_B + oishisa_C
    oishisa.sort(reverse=True)

    results = 0
    for i in range(X+Y):
        results += oishisa[i]

    return results

if __name__ == '__main__':
    xyabc = input()
    pa = input()
    qb = input()
    rc = input()
    print(function(xyabc+'¥n'+pa+'¥n'+qb+'¥n'+rc))


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

int main(){
  const int Nplyrs= 3;
  vector<string> decks(Nplyrs);

  for(int i=0; i<Nplyrs; i++){
    cin >> decks.at(i);
  }

  char turn= 'a';
  vector<int> idxs(Nplyrs, 0);
  while(true){
    int plyr= turn- 'a';
    int  idx= idxs.at(plyr);
    if(idxs.at(plyr)==decks.at(plyr).size()){ break; }
    else{
      turn= decks.at(plyr).at(idxs.at(plyr));
      idxs.at(plyr)++;
    }
  }

  cout << (char)toupper(turn) << endl;
}

Measured memory_bytes: 256
from collections import Counter
from itertools import combinations, permutations


def factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        return res + [n]
    else:
        return res


N = int(input())
if N < 10:
    print(0)
    exit()

cnt = Counter()
for i in range(2, N + 1):
    primes = factor(i)
    cnt += Counter(primes)

ans = 0
for x, y in combinations(cnt, 2):
    if cnt[x] < 4 or cnt[y] < 4:
        continue
    for z in cnt:
        if z == x or z == y or cnt[z] < 2:
            continue
        ans += 1

for x, y in permutations(cnt, 2):
    if cnt[x] >= 14 and cnt[y] >= 4:
        ans += 1

for x, y in permutations(cnt, 2):
    if cnt[x] >= 24 and cnt[y] >= 2:
        ans += 1

for x in cnt:
    if cnt[x] >= 74:
        ans += 1

print(ans)


Measured memory_bytes: 9748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N,K;
  cin >>N >> K;
  int x[N];
  rep(i,N) cin >> x[i];
  ll ans=0;
  rep(i,N) ans+=min(abs(x[i]),abs(K-x[i]))*2LL;
  cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll h1; ll m1; ll h2; ll m2; ll k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll time = (h2-h1)*60 + m2-m1;
    cout << max(time-k, ll(0)) << endl;
    return 0;
}

Measured memory_bytes: 3632
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	
	NM = input[0].split(" ");
	N = parseInt(NM[0], 10);
	M = parseInt(NM[1], 10);
    //console.log('%d %d', N, M);

	var a = [];
	var b = [];
	for (i=1; i <= N; i++){
	  ab = input[1+i-1].split(" ");
	  a[i] = parseInt(ab[0], 10);
	  b[i] = parseInt(ab[1],10);
	  //console.log('%d %d', a[i], b[i]);
	}

	var c = [];
	var d = [];
	for (i=1; i <= M; i++){
	  cd = input[1+N+i-1].split(" ");
	  c[i] = parseInt(cd[0],10);
	  d[i] = parseInt(cd[1],10);
	  //console.log('%d %d', c[i], d[i]);
	}
	//console.log('---');
	
	for (i=1; i <= N; i++){
	  minDistance = 0;
	  minIndex = 0;
	  for (j=1; j <= M; j++){
	    //console.log('=', Math.abs( a[i]-c[j]) + Math.abs(b[i]-d[j]));
	    distance = Math.abs( a[i]-c[j]) + Math.abs(b[i]-d[j]);
	    if (j == 1){
	      minDistance = distance;
	      minIndex = j;
	    } else {
	      if (distance < minDistance){
	        minDistance = distance;
	        minIndex = j;
	      }
	    }
	  }
	  //console.log('---');
	  console.log(minIndex);
	}

	//文字列から10進数に変換するときはparseIntを使います
//	var a = parseInt(input[0], 10);
//	var b = parseInt(tmp[0], 10);
//	var c = parseInt(tmp[1], 10);
//	var s = input[2];
	//出力
//	console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 25160
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
S = sys.stdin.buffer.readline().decode().rstrip()
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

graph = [defaultdict(int) for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    graph[a][b] += 1
    if a != b:
        graph[b][a] += 1

# AB 両方と隣接する頂点のみで部分グラフを作れるか
# どっちかとしか隣接しない頂点を取り除いていく
# removed = True
# while removed:
#     removed = False
#     for v in range(N):
#         if not graph[v]:
#             continue
#         a = 0
#         b = 0
#         for u in graph[v]:
#             if S[u] == 'A':
#                 a += 1
#             else:
#                 b += 1
#         if a == 0 or b == 0:
#             for u in graph[v]:
#                 graph[u].remove(v)
#             graph[v] = []
#             removed = True
# print(graph)


a_counts = [[0, v] for v in range(N)]
b_counts = [[0, v] for v in range(N)]
for v in range(N):
    for u, cnt in graph[v].items():
        if S[u] == 'A':
            a_counts[v][0] += cnt
        else:
            b_counts[v][0] += cnt
candidates = []
for c, v in a_counts + b_counts:
    if c == 0:
        candidates.append(v)

while candidates:
    v = candidates.pop()
    if not graph[v]:
        continue
    for u, cnt in list(graph[v].items()):
        if S[v] == 'A':
            a_counts[u][0] -= cnt
            if a_counts[u][0] == 0:
                candidates.append(u)
        else:
            b_counts[u][0] -= cnt
            if b_counts[u][0] == 0:
                candidates.append(u)
        del graph[u][v]
    graph[v] = {}

# print(graph)

ok = any(graph)
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 159752
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>

#include <functional>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <numeric>
#include <random>
#include <ratio>
#include <sstream>
#include <utility>

#include <bitset>
#include <deque>
#include <queue>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <string>
#include <set>

using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int aa,bb;
	vector<int> adj[n];
	vector<int> adj2[n];
	for(int i=0;i<m;i++){
		cin>>aa>>bb;
		adj[aa-1].pb(bb-1);
		adj2[bb-1].pb(aa-1);
	}
	int dp[n];
	int ma=0;
	queue<int> x;
	int si[n];
	for(int i=0;i<n;i++){
		dp[i]=0;
		si[i]=adj2[i].size();
		if(adj2[i].size()==0){
			x.push(i);
		}
	}
	for(int i=0;i<n;i++){
		int y=x.front();
		x.pop();
		for(auto jj:adj2[y]){
			dp[y]=max(dp[y],dp[jj]+1);
		}
		for(auto jj:adj[y]){
			si[jj]-=1;
			if(si[jj]==0){
				x.push(jj);
			}
		}
		ma=max(ma,dp[y]);
	}
	cout<<ma<<endl;


	return 0;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
    vector<int> v;
    int a, b, c;
    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    if (v.size() != 2)
        cout << "No" << endl;
    else
        cout << "Yes";
}

Measured memory_bytes: 256
N = gets.to_i
M = gets.split.map(&:to_i).group_by(&:itself)
    .map{|k,v| [k,v.size]}
    .select{|k,z| z >= 2 }
    .max_by(2){|k,z| k }

if M.empty?
  puts 0
elsif M.size == 1 
  if M[0][1] >= 4
    puts M[0][0] ** 2
  else
    puts 0
  end
else
  if M[0][1] >= 4
    puts M[0][0] ** 2
  else
    puts M[0][0] * M[1][0]
  end
end


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

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<vector<int> >grid(2,vector<int>(n));
    rep(i,2)rep(j,n)cin>>grid[i][j];
    rep(i,n)grid[0][i]+=grid[0][i-1];
    grid[1][0]+=grid[0][0];
    re(i,1,n)grid[1][i]+=max(grid[0][i],grid[1][i-1]);
    cout<<grid[1][n-1];
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) (v).rbegin(), (v).rend()
#define Dump(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const lint N = (lint)1e9;

class ATriangle {
public:
	void solve(std::istream& in, std::ostream& out) {
	    lint S;
	    in>>S;
	    lint left = -1, right = N + 1;
	    while(1<right-left){
	        lint mid = (left+right) / 2;
	        if(N*mid<S) left = mid;
	        else right = mid;
	    }
	    out<<0<<' '<<0<<' '<<N*right-S<<' '<<right<<' '<<N<<' '<<1<<'\n';
	}
};


int main() {
	ATriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n,q,i,j,C=0;
  int S[100000];
  int T[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	C++;
	break;
      }
    }
  }
  printf("%d\n",C);
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int a[110][110];

void solve(){

    ll a,b,c;
    ll x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = INF;
    for(ll i=0; i<=max(x,y); i++){
        ans = min(ans, max((x-i),ll(0))*a+max((y-i),ll(0))*b+2*i*c);
    }
    cout << ans << endl;

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  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;
    cin >> N;
    
    int A[N];
    rep(i,N){
        cin >> A[i];
    }
    int count = 0;
    int i;
    vector<int> v;
    
    rep(i,N){
        v.push_back(A[i]);
    }
    
    sort(v.begin(), v.end());
    rep(i,N){
        if(A[i] != v[i]){
            count++;
        }
    }
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> iP;
#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++)

int main() {
    while (1) {
        int M, T, P, R;
        cin >> M >> T >> P >> R;
        if (M == 0) break;
        int mt[60]{}, pt[60]{}, f[60][15]{};
        REP(i, R) {
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            if (j==0) {
                pt[t]++;
                mt[t] += m + f[t][p] * 20;
            } else {
                f[t][p]++;
            }
        }
        vector<pair<iP, int> > ls;
         for (int i = 1; i <= T; i++) {
             ls.push_back({{pt[i],1000000-mt[i]},i});
        }
        sort(ls.rbegin(),ls.rend());
        cout << ls[0].second;
        for(int i=1;i<T;i++){
            if(ls[i-1].first == ls[i].first){
                cout << "=";
            }
            else cout << ",";
            cout << ls[i].second;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3024
import math, string, itertools, fractions, collections, re, array, bisect, sys, random, time, copy, functools
from heapq import heappush, heappop, heappushpop, heapify, heapreplace
input = sys.stdin.readline

N, M, S, T = [int(_) for _ in input().split()]
UVAB = [[int(_) for _ in input().split()] for _ in range(M)]
G1 = collections.defaultdict(lambda: collections.defaultdict(int))
G2 = collections.defaultdict(lambda: collections.defaultdict(int))

for u, v, a, b in UVAB:
    u -= 1
    v -= 1
    G1[u][v] = G1[v][u] = a
    G2[u][v] = G2[v][u] = b


def dijkstra(V, G, start):
    INF = float('inf')
    D = [INF for _ in range(V)]
    D[start] = 0
    H = [(0, start)]
    while H:
        du, u = heappop(H)
        if D[u] < du:
            continue
        for v, d in G[u].items():
            if D[v] > du + d:
                D[v] = du + d
                heappush(H, (D[v], v))
    return D


D1 = dijkstra(N, G1, S - 1)
D2 = dijkstra(N, G2, T - 1)

D = [10**15 - sum(_) for _ in zip(D1, D2)]
for i in range(N - 1, 0, -1):
    D[i - 1] = max(D[i - 1], D[i])
print(*D, sep='\n')


Measured memory_bytes: 127728
n = gets.to_i
a = n.times.map { gets.strip.to_i }

nxt = 1

(1..n).each do |i|
  if a[nxt-1] == 2
    puts i.to_s
    exit 0
  else
    nxt = a[nxt-1]
  end
end
puts '-1'

Measured memory_bytes: 3068
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	n = int(N // 2)
	if N % 2 == 0:
		cnt = 0
		jud = 0
		for i in range(M + 1):
			if jud == 0 and 4 * i + 2 >= N:
				jud = 1
			else:
				if jud == 0:
					print(n - i, n + 1 + i)
				else:
					print(n - i + 1, n + 1 + i)
				cnt += 1
			if cnt == M:
				break

	else:
		for i in range(M):
			print(n - i, n + 1 + i)


	


if __name__ == '__main__':
	main()

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


void solve(){
    long long n; cin >> n;
    cout << n*(n+1)/2;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
//    multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3640
lefteater::Int->[Char]->[Int]
lefteater n [] = []
lefteater n (x:xs) =n:(lefteater (if x=='W' then (n+1) else n) xs)

righteater::Int->[Char]->[Int]
righteater n [] = []
righteater n (x:xs) = n:(righteater (if x=='E' then (n+1) else n) xs)

solver::String -> Int
solver st = let st_r = reverse st in
            let left_score = lefteater 0 st in
            let right_score = reverse (righteater 0 st_r) in
            minimum (map (\(x,y)->x+y) (zip left_score right_score))

main::IO ()
main=do
  _<-getLine
  st<-getLine
  print (solver st)

Measured memory_bytes: 57852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int n[5], tmp = 0, ans = 0;
	cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4];

	for (int i = 0; i < 5; i++) {
		if (n[i] % 10 != 0) {
			tmp = max(tmp, 10 - (n[i] % 10));
		}
		ans += ceil(double(n[i]) / 10) * 10;
	}

	cout << ans - tmp << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int N;
  int ans = 0;

  cin >> N;

  for (int i = 0; i < (int)log10(N); i+=2) {
    ans += (int)(pow(10, i+1) - pow(10, i));
  }
  if ((int)log10(N) % 2 == 0) {
    ans += N - (pow(10, (int)log10(N))-1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int q(const int *a,const int *b)
{
	return *b-*a;
}
int main(void)
{
	int n,a[100],i,l=0,b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),q);
	for(i=0;i<n;i+=2)l+=a[i];
	for(i=1;i<n;i+=2)b+=a[i];
	printf("%d",l-b);
	return 0;
}

Measured memory_bytes: 128
A = gets.chomp
B = gets.chomp
C = A.to_i
D = B.to_i
lengA = A.length
lengB = B.length
if lengA > lengB
    puts 'GREATER'
elsif lengB > lengA
    puts 'LESS'
else
    if A > B 
        puts 'GREATER'
    elsif B > A 
        puts 'LESS'
    else
        puts 'EQUAL'
    end
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int ms[300001];

int main(){
	ms[0]=ms[1]=1;
	
	for(int i=2;i*i<300001;i++){
		if(ms[i]==1)continue;
		for(int j=2;j*i<300001;j++){
			if(i%7==1 || i%7==6 || j%7==1 || j%7==6)ms[i*j]=1;
		}
	}
	
	int n;
	while(cin>>n){
		if(n==1)break;
		printf("%d:",n);
		
		for(int i=2;i<=n;i++){
			if(ms[i]==0 && n%i==0 && (i%7==1 || i%7==6))printf(" %d",i);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2044
count=0
s=input()
if s[0]=="A":
  count+=1

c=0
ci=0
for i in range(2,len(s)-1):
  if s[i]=="C":
    c+=1
    ci=i
if c==1 :
  count+=1

if (s[1:ci]+s[ci+1:]).islower()==True and count==2:
  print("AC")
else:
  print("WA")
#print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int n, A, B, a[N];
int cnta, cntb, cntc;
int main(){
    cin >> n >> A >> B;
  	for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] <= A) cnta++;
      else if (a[i] <= B) cntb++;
      else cntc++;
    }
  cout << min(cnta, min(cntb, cntc)) << endl;
  return 0;
}

Measured memory_bytes: 3628
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(4):: s
    integer(int32):: i,ans

    read*, s
    ans=0
    do i=1,4
        if (s(i:i) == '+')then
            ans=ans+1
        else
            ans=ans-1
        end if
    end do

    print*, ans
end program name

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

int main() {
  int x,X;
  int sum = 0;
  cin >> x; 
  X =x;
  int i=9;
  while(i>=1){
    sum += X%10;
    X /= 10;
    i--;
  }

   if (x%sum == 0){
     cout << "Yes" << endl;
   }
    else {
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
/*****************************************************/
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define   offcin        ios::sync_with_stdio(false)
#define   DEBUG         freopen("#.txt", "r", stdin)
#define   sigma_size    26
#define   lson          l,m,v<<1
#define   rson          m+1,r,v<<1|1
#define   slch          v<<1
#define   srch          v<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   lowbit(x)     (x&-x)

const int    INF    = 0x3f3f3f3f;
const ll     INFF   = 1e18;
const double pi     = acos(-1.0);
const double inf    = 1e18;
const double eps    = 1e-9;
const ll     mod    = 1e9+7;
const int    maxmat = 10;
const ull    BASE   = 133333331;

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
inline ll bits(ll x) {
      return !x ? x : bits(x - lowbit(x)) + 1;
}
/*****************************************************/

int N, M;

struct Node {
    int x, y;
}n[55], m[55];

int dis(Node &a, Node &b) {
    return abs(a.x - b.x) + abs(a.y - b.y);
}

int main(int argc, char const *argv[]) {
    cin>>N>>M;
    for (int i = 1; i <= N; i ++)
        cin>>n[i].x>>n[i].y;
    for (int i = 1; i <= M; i ++)
        cin>>m[i].x>>m[i].y;
    for (int i = 1; i <= N; i ++) {
        int minv = INF, ind = -1;
        for (int j = 1; j <= M; j ++) {
            int d = dis(n[i], m[j]);
            if (d < minv) minv = d, ind = j;
        }
        cout<<ind<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

ll mygcd(ll A, ll B)
{
  ll a = A, b = B;
  while (a > 0 && b > 0)
  {
    b %= a;
    swap(a, b);
  }
  return b;
}

ll mylcm(ll A, ll B)
{
  ll G = mygcd(A, B);
  if (A % G == 0) return A / G * B;
  return B / G * A;
}

int main()
{
  ll A, B;
  cin >> A >> B;
  cout << mylcm(A, B) << endl;
}

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

using namespace std;
void Output(int a, bool (&b)[4][13] ) {

        char ma;

        if(a == 0 ) ma = 'S';
        else if(a == 1) ma = 'H';
        else if(a == 2) ma = 'C';
        else if(a == 3) ma = 'D';

        for(int i = 1; i <= 13; i++ )
                if(b[a][i] != true) cout << ma << ' ' <<  i << endl;

}
int main(int argc, char const *argv[]) {
        int N, num;
        char mark;
        bool Card[4][13]={false};
        //データを読み込む
        cin >> N;
        for(int i = 0; i < N; i++) {
                cin >> mark >> num;
                switch (mark) {
                case 'S': Card[0][num] = true; break;
                case 'H': Card[1][num] = true; break;
                case 'C': Card[2][num] = true; break;
                case 'D': Card[3][num] = true; break;
                }
        }
        //データを出力する。
        Output(0, Card);
        Output(1, Card);
        Output(2, Card);
        Output(3, Card);

        return 0;
}



Measured memory_bytes: 3088
from math import factorial

x,y=map(int,input().split())
if x>1:
    a = factorial(x) / factorial(2) / factorial(x - 2)
else: a=0
if y>1:
    b = factorial(y) / factorial(2) / factorial(y - 2)
else: b=0
print(int(a+b))

Measured memory_bytes: 3060