akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        x_u: [(f64, String); n],
    }
    let ans = x_u.iter().fold(0.0, |sum, &(ref x, ref u)| {
        if u == "JPY" {
            sum + x
        } else {
            sum + x * 380000.0
        }
    });
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;

struct money {
	int ten;
	int go;
	int hya;
	int gohya;

};

int main(void)
{
	vector <money> ans;
	money moti, oturi, anser;

	int nedan;
	int i, j;
	int temp1, temp2, temp3, temp4;
	int sum;
	int cnt = 0;



	while (1) {
		cin >> nedan;
		if (nedan == 0) {
			break;
		}

		cin >> moti.ten >> moti.go >> moti.hya >> moti.gohya;


		sum = moti.ten * 10 + moti.go * 50 + moti.hya * 100 + moti.gohya * 500; //?????????

		sum = sum - nedan;

		oturi.gohya = sum / 500; //500yen
		sum = sum - oturi.gohya * 500;

		oturi.hya = sum / 100; //100yen
		sum = sum - oturi.hya * 100;

		oturi.go = sum / 50;
		sum = sum - oturi.go * 50;

		oturi.ten = sum / 10;
		sum = sum - oturi.ten * 10; //sum = 0

		anser.gohya = 0;
		anser.hya = 0;
		anser.go = 0;
		anser.ten = 0;

		
		if (moti.gohya >= oturi.gohya) {
			anser.gohya = moti.gohya - oturi.gohya;
		}

		
		if (moti.hya >= oturi.hya) {
			anser.hya = moti.hya - oturi.hya;
		}

		if (moti.go >= oturi.go) {
			anser.go = moti.go - oturi.go;
		}

		if (moti.ten >= oturi.ten) {
			anser.ten = moti.ten - oturi.ten;
		}


		ans.push_back(anser);

		cnt++;
	}


	for (i = 0; i < cnt; i++) {
		if (ans[i].ten != 0) {
			cout << 10 << " " << ans[i].ten << endl;
		}

		if (ans[i].go != 0) {
			cout << 50 << " " << ans[i].go << endl;
		}

		if (ans[i].hya != 0) {
			cout << 100 << " " << ans[i].hya << endl;
		}

		if (ans[i].gohya != 0) {
			cout << 500 << " " << ans[i].gohya << endl;
		}

		if (i != cnt - 1) {
			cout << endl;
		}
	}


	return (0);
}

Measured memory_bytes: 3192
n=int(input())
x=[]
y=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)
sm=0
for i in range(n):
  for j in range(n):
    sm+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
print(sm/n)

Measured memory_bytes: 62292
// abc136d.cpp : Gathering Children
#include <bits/stdc++.h>
using namespace std;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)

int main(){
  string S; cin>>S;
  int n = S.length();
  vector<int> ans(n), divpoint, group;

  bool high_low = false; // low
  up(i,0,n,1){
    if(!high_low && S[i]=='R'){ // ↑
      divpoint.push_back(i); // グループの切れ目
      high_low = true; // hi
    }
    else if(high_low && S[i]=='L'){ // ↓
      group.push_back(i); // グループの集合場所（L側）
      high_low = false; // low
    }
  }
  divpoint.push_back(n);

  up(i,0,group.size(),1){
    int gp = group[i], dp = divpoint[i];
    int a = divpoint[i+1] - dp;
    int o = (a%2 && dp%2)? a/2+1: a/2;
    int R, L; if(gp%2){R=a-o; L=o;} else{R=o; L=a-o;}
    ans[gp-1] = R; ans[gp] = L;
  }

  //ot(ans[0]); up(i,1,n,1) cout<<" "<<ans[i]; ot("\n");
  up(i,0,n,1){ot(ans[i]);ot("\n");}

}

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

int main(void) {
    int k,a,b;
    scanf("%d %d %d\n",&k,&a,&b);
    for(int i=a;i<=b;i++) {
        if (i%k==0) {
            printf("OK");
            return 0;
        }
    }
    printf("NG");
}

Measured memory_bytes: 3828
// insert_sort
#include <iostream>
using namespace std;

void insertionSort(int A[],int N);
void printList(int A[],int N);

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  insertionSort(A,N);
  return 0;
}

void insertionSort(int A[],int N)
{
  for(int i=0;i<N;i++) {
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    printList(A,N);
    }
}


void printList(int A[],int N) {
  for(int i = 0; i < N-1; i++) cout << A[i] << " ";
  cout << A[N-1] << endl;
}

Measured memory_bytes: 3044
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <vector>
using namespace std;


long long sum(vector<int>& A, int start, int end) {
  long long ans = 0;
  for (int i = start; i <= end; i++) ans += A[i];
  return ans;
}


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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  long long prev, cur;
  prev = sum(A, 0, K-1);
  for (int i = K; i < N; i++) {
    cur = prev - A.at(i-K) + A.at(i);
    if (cur > prev) cout << "Yes" << endl;
    else cout << "No" << endl;
    prev = cur;
  }

  return 0;
}


Measured memory_bytes: 4060
n,m = map(int,input().split())
dp = [0]*(n+1)
ary = [int(input()) for _ in range(m)]
dp[0] = 1
for i in ary:
    dp[i] = -1
    if dp[i-1] == -1 and dp[i] == -1:print(0);exit()
for i in range(1,n+1):
    if dp[i] == -1:continue
    elif dp[i-1] == -1:dp[i] = dp[i-2]
    elif dp[i-2] == -1:dp[i] = dp[i-1]
    elif i > 1: dp[i] = dp[i-1]+dp[i-2]
    else: dp[i] = dp[i-1]
print(dp[n]%(10**9+7))

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll N, A, B;

bool enough(vector<ll> H, ll t) {
    ll a = A - B;
    ll k = 0;
    REP(i, N) {
        H[i] -= t * B;
        if (H[i] > 0) {
            k += H[i] / a + ((H[i] % a) > 0);
        }
    }
    if (k <= t) return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> A >> B;
    vector<ll> H(N);
    ll high = 0;
    REP(i, N) {
        cin >> H[i];
        high = max(H[i], high);
    }
    ll low = 1;
    while (low < high) {
        int mid = (low + high) / 2;
        if (enough(H, mid)) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    cout << high << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int min_cost(int *arr,int n)
{
  int *dp = new int[n+1];
  for(int i=0;i<=n;i++)
  {
      dp[i]=0;
  }
  dp[2]=abs(arr[1]-arr[0]);
  for(int i=3;i<=n;i++)
  {
    dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
  }
  return dp[n];
}
int main()
{
  int n;
  cin>>n;
  int * arr = new int[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  cout<<min_cost(arr,n)<<endl;
  delete [] arr;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

ll dp[5005][5005][2][2];

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

  int N,A,B;
  cin>>N>>A>>B;

  if(A>B) swap(A,B);

  dp[0][0][1][0]=1;
  for(int i=0;i<N;i++) for(int j=0;j<B;j++){
    rep(k,2) rep(m,2){
      if(dp[i][j][k][m]==0) continue;

      ll pre=dp[i][j][k][m];
      if(k==1&&i+A<=N){
        if(j+A<B) add(dp[i+A][j+A][0][1],pre);
        add(dp[i+A][0][0][0],MOD-pre);
      }

      for(int ne=0;ne<2;ne++){
        int nj=j,nk=ne,nm=m;
        if(ne==1||(m==1&&ne==0)) nj=j+1;
        if(ne==0&&m==0) nj=0;
        if(ne==1&&m==1) nm=0;
        add(dp[i+1][nj][nk][nm],pre);
      }
    }
  }

  ll ans=1;
  rep(k,N) mul(ans,2);
  rep(j,B) rep(k,2) rep(m,2) add(ans,MOD-dp[N][j][k][m]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 413848
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int h[] = new int[N];
        int max = 0;
        for(int i=0; i<N; i++) {
            h[i] = sc.nextInt();
            if(max<h[i]) max=h[i];
        }
        int cnt=0;
        while(max>0) {
            boolean flg = false;
            for(int i=0; i<N; i++) {
                if(flg) {
                    if(h[i] >= max) {
                        h[i]--;
                    } else {
                        flg = false;
                        cnt++;
                    }
                } else {
                    if(h[i] >= max) {
                        flg = true;
                        h[i]--;
                    } else {
                        // NOP
                    }
                }
            }
            if(flg) cnt++;
            max--;
        }
        System.out.println(String.format("%d", cnt));
    }
}


Measured memory_bytes: 23636
#include <stdio.h>

 typedef struct Card {char suit; int value;} CARD;

void printStructArray(CARD var[], int num) {
  int i;
  for (i = 0; i < num; i++) {
      if (i > 0) printf(" ");
      printf("%c%d", var[i].suit, var[i].value);
  }
  printf("\n");
}

void bubbleSort(CARD var[], int num) {
  int i, j;
  CARD tmp;

  for (i = 0; i < num; i++) {
    for (j = num -1; j > i; j--) {
        if (var[j].value < var[j - 1].value) {
            tmp = var[j];
            var[j] = var[j - 1];
            var[j - 1] = tmp;
        }
    }
  }
}

void selectionSort(CARD var[], int num) {
  int i, j, iMin;
  CARD tmp;
  for (i = 0; i < num; i++) {
    iMin = i;
    for (j = i; j < num; j++) {
      if (var[iMin].value > var[j].value) {
        iMin = j;
      }
    }
    tmp = var[i];
    var[i] = var[iMin];
    var[iMin] = tmp;
  }
}

int isStable(CARD var1[], CARD var2[], int num) {
  for (int i = 0; i < num; i++) {
    if (var1[i].suit != var2[i].suit) {
      return -1;
    } 
  }
  return 0;
}

int main(void) {
  int i, num;
  scanf("%d", &num);
  CARD varBubble[num];
  CARD varSelection[num];
  getchar();
  for (i = 0; i < num; i++) {
    scanf("%c%d", &varBubble[i].suit, &varBubble[i].value);
    varSelection[i] = varBubble[i];
    getchar();
  }
  
  bubbleSort(varBubble, num);
  printStructArray(varBubble, num);
  printf("Stable\n");
  
  selectionSort(varSelection, num);
  printStructArray(varSelection, num);
  if (isStable(varBubble, varSelection, num) < 0) {
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }

  return 0;
}


Measured memory_bytes: 2052
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
from math import gcd
from itertools import permutations as prm,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)

t=1
	

while t>0:
	t-=1
	n=fi()
	c=0
	for i in range(n):
		x,y=mi()
		if x==y:
			c+=1
		else:
			c=0
		if c==3:
			print("Yes")
			exit(0)
	print("No")					








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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for (auto& e : m) cin >> e;
    sort(begin(m), end(m));
    cout << n + (x - accumulate(begin(m), end(m), 0)) / m[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};
int m, n;

bool check(int ci, int cj) { return ci >= 0 && cj >= 0 && ci < m && cj < n; }

int main() {
    cin >> m >> n;
    string s[m];
    for (int i = 0; i < m; i++) cin >> s[i];
    int ans = 0;
    while (true) {
        int ret = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (s[i][j] == '.') {
                    pii alp[50];
                    for (int k = 0; k < 50; k++) alp[k] = pii(-1, -1);
                    for (int k = 0; k < 4; k++) {
                        int ci = i, cj = j;
                        while (check(ci, cj) && s[ci][cj] == '.') {
                            ci += di[k];
                            cj += dj[k];
                        }
                        if (check(ci, cj)) {
                            int c = s[ci][cj] - 'A';
                            if (alp[c].first != -1) {
                                pii cur = alp[c];
                                s[ci][cj] = '.';
                                s[cur.first][cur.second] = '.';
                                ret += 2;
                            } else {
                                alp[c] = pii(ci, cj);
                            }
                        }
                    }
                }
            }
        }
        if (ret == 0) break;
        ans += ret;
    }
    cout << ans << endl;
    return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) {
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stack>
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <climits>
using namespace std;

int main()
{
	int n, q;
	while (cin >> n >> q) {
		if (n == 0)break;
		map<string,pair< int,int> > his;
		string str[1009];
		int b,c;
		string a;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			(his[a]).first = c - b + 1; str[i] = a; (his[a]).second = c;
		}
		for (int i = 0; i < q; i++) {
			cin >> b; c = INT_MAX -100; int k;
			for (int j = 0; j < n;j++){
				if ((his[str[j]]).first <= b &&(b<=his[str[j]].second)&& (k = b - (his[str[j]]).first)+1 < c) {
					c = k; a = str[j];
				}
			}if (c == INT_MAX -100)cout << "Unknown" << endl;
			else
			cout << a <<" "<< c+1 << endl;
		}
	}
    return 0;
}

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

typedef long long ll;
using namespace std;

ll N,X;
ll x[200005];
ll sum[200005];

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

	cin >> N >> X;

	ll ans = LLONG_MAX;

	for (ll i = 1;i <= N;i++){
		cin >> x[i];
		sum[i] = sum[i-1]+x[i];	
	}

	for (ll i = 1;i <= N;i++){
		ll cost = (i+N)*X;
		ll now = N;
		bool flag = false;
		for (ll j = 0;j < N/i;j++){
			if(j == 0){
				cost += (sum[now]-sum[now - i]) * 5;
				now -= i;
			}else{
				ll a = sum[now] - sum[now-i];
				ll b = 5+2*(j-1);
				if(LLONG_MAX/a< b) flag = true;
				else if(LLONG_MAX-cost < a*b)flag = true;
				cost += a * b;
				now -= i;
			}
		}
		if(sum[now] != 0 && LLONG_MAX/sum[now] < 5+2*(N/i - 1)) flag = true;
		else if(LLONG_MAX-cost < sum[now] * 5+2*(N/i - 1)) flag = true;
		cost += sum[now] * (5+2*(N/i - 1));
		if(!flag)ans = min(cost,ans);
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
signed main()
{
	Very_fast;
	ll a,b,x,y;
	cin>>a>>b>>x>>y;
	cout<<max(max(a*x,a*y),max(b*x,b*y));
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

typedef long long ll;

map<ll, ll> prime_factorization(ll n) {
  map<ll,ll> res;
  ll tmp = n;
  for (ll i=2; i*i<=n; i++) {
    while(tmp!=0 && tmp%i == 0) {
      res[i]++;
      tmp /= i;
    }
  }
  if (tmp!=1) res[tmp]++;
  return res;
}

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

int main() {
  ll a,b;
  ll ans = 1;
  cin >> a >> b;
  ll GCD = gcd(a,b);

  map<ll,ll> pf = prime_factorization(GCD);
  for (auto p : pf) {
    if (p.second > 0) ans++;
  }

  cout << ans << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll X, A[105];

int main(){
  cin >> N >> X;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);

  for (int i = 0; i < N; i++){
    if (X < A[i]){
      cout << i << endl;
      return 0;
    }
    X -= A[i];
  }
  if (X == 0) cout << N << endl;
  else cout << N -1 << endl;

  return 0;
}


Measured memory_bytes: 3568
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		
		out.close();
	}
	
	static class TaskC
	{
		void solve(int TestCase, InputReader in, PrintWriter out)
		{
			long n = in.nextLong();
			n--;
			
			out.println(n * (n + 1) / 2);
		}
	}
	
	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			
			return tokenizer.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
		
		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 22868
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String ans = "Christmas";
		int n = ni();
		for (int i = 25; i > n; i--) {
			ans += " Eve";
		}
		out(ans);

	}

	/*
	 * 以下メソッド集
	 */

	public static int[] kousokusoinnsuubunkaihairetsu(int a) {
		int[] d = new int[a];
		for (int i = 0; i < a; i++) {
			d[i] = i;
		}
		for (int i = 2; i * i < a; i++) {
			for (int j = i * i; j < a; j += i) {
				if (d[j] == j)
					d[j] = i;
			}

		}

		return d;
	}

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int w;
	int d;

	XY(int h, int w, int d) {
		this.h = h;
		this.w = w;
		this.d = d;
	}
}

class NE {

	int n;
	int e;

	NE(int n, int e) {
		this.n = n;
		this.e = e;
	}
}

Measured memory_bytes: 38180
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<string>
#define x first
#define y second

using namespace std;
const int N = 100050;
string s = "ACL";
int n, m, p[N];
bool st[N];
int find(int x)
{
	return x == p[x] ? x : p[x] = find(p[x]);
}
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) p[i] = i;
	for(int i = 0; i < m; ++i)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a = find(a), b = find(b);
		if(a != b)
			p[a] = b;
	}
	for(int i = 1; i <= n; ++i)
		st[find(i)] = true;
	int ans = 0;
	for(int i = 1; i <= n; ++i) ans += st[i];
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 4192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
 
int n, m;
ll d[1123];
int a[2123], b[2123], c[2123];
bool loop[1123];

int main() {
	cin >> n >> m;
	REP(i, m) {
		scanf("%d %d %d", a + i, b + i, c + i);
		a[i]--; b[i]--;
	}
	
	fill(d, d + n, -INF);
	d[0] = 0;
	
	REP(i, n - 1) {
		REP(j, m) {
			if (d[a[j]] == -INF) continue;
			chmax(d[b[j]], d[a[j]] + c[j]);
		}
	}
	
	REP(i, n) {
		REP(j, m) {
			if (d[a[j]] == -INF) continue;
			loop[b[j]] |= loop[a[j]];
			if (chmax(d[b[j]], d[a[j]] + c[j])) loop[b[j]] = true;
		}
	}
	
	if (loop[n - 1]) puts("inf");
	else cout << d[n - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
#define MAX_N 1e6+1
int n,a,b;
using ll = long long;
vector<int> h(MAX_N,0);
/*
t回で全滅できるか？
それぞれceil((hi-B*T)/(a-b))の総和
*/
bool enough(ll t){
    ll total = 0;
    rep(i,n){
        if(ceil((h[i]-b*t)/(a-b)) >= 0){
           total += ceil((double)(h[i]-b*t)/(a-b));
        }
    }
    //cout << "total(" << t <<") |" <<"total:"<<total << endl;
    if(t >= total) return true;//足りる
    else return false;
}

int main(){
    cin >> n >> a >> b;

    rep(i,n) cin >> h[i];
    ll lb = 0;//下限
    ll ub = 1e9;//上限
    for(int i = 0; i < 100; i++){
        int mid = ceil( (lb+ub)/2);
        if(enough(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 4096
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	int n, k[15], sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
	}
	sort(k, k + n);
	for (int i = 0; i < n - 1; ++i) {
		sum += k[i];
	}
	if (sum > k[n - 1]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

typedef long long LL;

int main()
{
	vector<LL> A;
	int N;
	cin >> N;
	LL l;
	for (int i = 0; i < N; i++)
	{
		cin >> l;
		A.push_back(l);
	}
	sort(A.begin(), A.end());
	LL max1 = -1;
	LL max2 = -1;
	l = -1;
	for (int i = A.size() - 1; i >= 0; i--)
	{
		if (l != A[i]) l = A[i];
		else
		{
			if (max1 == -1)
			{
				max1 = l;
				l = -1;
			}
			else
			{
				if (max2 == -1)
				{
					max2 = l;
					l = -1;
					break;
				}
			}
		}
	}
	if (max2 != -1)
	{
		cout << (max1 * max2) << endl;
	}
	else
	{
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  int d[100];
  int a[100][100] = {0};
  int count[100] = {0};

  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) {
      cin >> a[i][j];
      count[a[i][j] - 1]++;
    }
  }
  int res = 0;
  rep(i, n) {
    if (count[i] == 0) res++;
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[110];
    rep(i, N) cin >> a[i];
    set<int> st;
    int free = 0;
    rep(i, N) {
        if(a[i] < 3200) st.insert(a[i]/400);
        else free++;
    }
    cout << max(1, (int)st.size()) << " " << st.size() + free << endl;

    return 0;
}


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}

using namespace std;

int main() 
{	
	fast;
	ll n,k; cin>>n>>k;
	ll ans = 0;
	for(ll i = k; i <= n+1; i++)
	{
		ll t = (i)*(i-1) / 2;
		ll tt = n*i - t;
		ans += (tt - t + 1 + MOD) % MOD; 
	}
	cout << ans % MOD << endl;
	return 0;
}

Measured memory_bytes: 3656
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        cout << a[n - i - 1];
        if(i != n - 1) {
            cout << " ";
        }
    }
    cout << endl;
}



Measured memory_bytes: 3080
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }

    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    if (A*B%2==1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
  string s,t;
  in(s>>t);
  int N = sz(s);
  int M = sz(t);
  vl ss(N);
  vl tt(M);
  rep(i,N) ss[i]=s[i]-96;
  rep(i,M) tt[i]=t[i]-96;
  sort(all(ss));
  sort(all(tt));
  reverse(all(tt));
 bool f = false;
  if(N>=M){
  rep(i,M){
   if(ss[i]<tt[i]){
    f = true;
     break;
   }
  }
  }
  else {
    
    rep(i,N){
   if(ss[i]<tt[i]){
    f = true;
     break;
   }
  }
    if(!f){
     bool d = true;
      rep(i,N){
      if(ss[i]!=tt[i]) d=false;
      }
      if(d) f = true;
    }
  }
  if(f) out("Yes");
  else out("No");
}

Measured memory_bytes: 256
score_dic = {}

for i in range(int(input())):
    s = input()
    if s not in score_dic:
        score_dic[s] = 1
    else:
        score_dic[s] += 1

for i in range(int(input())):
    t = input()
    if t not in score_dic:
        score_dic[t] = -1
    else:
        score_dic[t] -= 1

max_value = max(score_dic.values())
if max_value < 0:
    print(0)
else:
    print(max_value)


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

int main(){
	int ans = 0;
	long long int d = 1;
	long long int a[100000];
	int n;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> a[i];
		if(a[i]==0){
			ans += 1;
		}
		d *= a[i];
	}
	if(ans == 0){
	if(d>1000000000000000000 or d <= 0){
		cout << -1;
	}
	else{
		cout << d;
	}
}
else{
	cout << 0;
}
	return 0;
}

Measured memory_bytes: 4432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

def f():
    n,x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    mi = a.index(min(a))
    a = a[mi:] + a[:mi]
    r = sum(a)
    for t in range(n-1):
        for i in range(n-1,0,-1):
            a[i] = min(a[i],a[i-1])
        tr = ((t+1)*x) + sum(a)
        if r > tr:
            r = tr
        else:
            break
    return r

print(f())


Measured memory_bytes: 6188
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    for( int i = 1; i <= 9; ++i ) {
        for( int j = 1; j <= 9; ++j ) {
            if( i * j == n ) {
                cout << "Yes" << endl;
                return 0;

            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
int lst[100005], to[200005], pre[200005], app[100005][25], tot, ans;
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u];
	lst[u] = tot++;
}
void dfs(int u, int fa = -1)
{
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] != fa)
		{
			dfs(to[i], u);
			for (int j = 0; j < 20; j++)
				app[u][j] += app[to[i]][j];
		}
	}
	int res = 0;
	for (int i = 19; i >= 0; i--)
	{
		if (app[u][i] > 1)
		{
			res = i + 1;
			break;
		}
	}
	while (app[u][res])
		res++;
	for (int j = 0; j < res; j++)
		app[u][j] = 0;
	app[u][res]++;
	if (res > ans)
		ans = res;
}
int main()
{
	// freopen("AGC009-D.in", "r", stdin);
	memset(lst, -1, sizeof(lst));
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge(--u, --v);
		add_edge(v, u);
	}
	dfs(0);
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  a += b + c;
  if(a >= 22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int n;
int a[MAX_N];

ll ans;

ll cost(int target) {
  ll tmp = 0;
  for (int i = 0; i < n; ++i) {
    tmp += (a[i] - target) * (a[i] - target);
  }
  return tmp;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(a[i]));
  }

  ans = INF;

  for (int target = -101; target < 101; ++target) {
    ans = min(ans, cost(target));
  }

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

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s  = sc.next();
        int ans = 0;
        for (int i = 0 ; i < s.length() - 1 ; i++) {
            String b = s.substring(i, i + 1);
            String c = s.substring(i + 1, i + 2);
            if (!b.equals(c)) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}

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

int main(){
    int n;
    
    while(cin >> n,n){
        int cnt = 0;
        if(n == 6174){
            cout << cnt << endl;
            continue;
        }
        while(true){
            cnt++;
            int d[4],m=10,NA=0;
            for(int i = 0 ; i < 4 ; i++){
                d[i] = n % m;
                n /= 10;
                if(i&&d[i]==d[i-1]) NA++;
            }
            if(NA == 3){
                cout << "NA" << endl;
                break;
            }
            sort(d,d+4);
            int L=d[3]*1000+d[2]*100+d[1]*10+d[0];
            int S=d[0]*1000+d[1]*100+d[2]*10+d[3];
            if(L-S==6174){
                cout << cnt << endl;
                break;
            }
            else n = L-S;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1180
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i % 2 == 0:
                print('#', end="") if j % 2 == 0 else print('.', end="")
            else:
                print('.', end="") if j % 2 == 0 else print('#', end="")
        print()
    print()


Measured memory_bytes: 7008
using System;
using System.Numerics;

namespace AtCoder.Problems
{
    public class ProblemE
    {
        public static void Main(string[] args)
        {
            var s = new SolveE();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] {' '};

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveE
    {
        public void Solve()
        {
            var cin = new ProblemE.Scanner();
            var n = cin.NextInt();
            var k = cin.NextInt();

            var result = GetAnswer(n, k);
            Console.WriteLine(result);
        }

        public long GetAnswer(int n, int k)
        {
            const int mod = 1000000007;
            var d = new long[k + 1];
            for (int i = 1; i < d.Length; i++)
            {
                d[i] = (long)BigInteger.ModPow(k / i, n, mod);
            }

            for (int i = k; i > 0; i--)
            {
                for (int j = 2 * i; j <= k; j += i)
                {
                    d[i] -= d[j];
                    d[i] = (d[i] + mod) % mod;
                }
            }
            var ans = 0L;
            for (int i = 1; i < d.Length; i++)
            {
                ans += d[i] * i;
                ans %= mod;
            }
            return ans;
        }
    }
}


Measured memory_bytes: 28328
/* kadai6_2
   nabe9393 */
 
#include<stdio.h>
#include<string.h>
 
int main(void){
  int len_word;
  //NULL文字入れて101字以内
  char str[101];
  //入力
  scanf("%s",str);
  //文字の長さを計算
  len_word = strlen(str);
  //一文字目と最後の文字と文字列の長さから２引いたものを書いて終了
  printf("%c%d%c\n",str[0],len_word-2,str[len_word-1]);
  return 0;
}

Measured memory_bytes: 128