akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			if (m == 0)
				break;
			n = scanner.nextInt();
			int s = scanner.nextInt();
			int[][][] map = new int[s][n][m];
			for (int i = 0; i < s; i++) {
				int x = scanner.nextInt() - 1;
				int y = scanner.nextInt() - 1;
				map[i] = dfs(x, y);
			}
			int v = scanner.nextInt();
			int max = 0;
			while (v-- > 0) {
				int c = 0;
				int x = scanner.nextInt() - 1;
				int y = scanner.nextInt() - 1;
				int[][] r = dfs(x, y);
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++) {
						boolean flag = true;
						for (int k = 0; k < s; k++) {
							if (map[k][i][j] <= r[i][j]) {
								flag = false;
								break;
							}
						}
						if (flag)
							c++;
					}
				}
				max = Math.max(max, c);

			}
			System.out.println(max);
		}
	}

	private int[][] dfs(int x, int y) {
		int[][] tmp = new int[n][m];
		Deque<Point> deque = new ArrayDeque<Main.Point>();
		deque.offer(new Point(y, x));
		boolean[][] b = new boolean[n][m];
		b[y][x] = true;
		int step = 1;
		while (!deque.isEmpty()) {
			int size = deque.size();
			for (int i = 0; i < size; i++) {
				Point point = deque.poll();
				if (point.y % 2 == 0) {
					slove(deque, point, move, b, tmp, step);
				} else {
					slove(deque, point, move2, b, tmp, step);
				}
			}
			step++;
		}
		return tmp;
	}

	private void slove(Deque<Point> deque, Point point, int[][] move,
			boolean[][] b, int[][] tmp, int step) {
		for (int[] a : move) {
			int dy = point.y + a[0];
			int dx = point.x + a[1];
			if (0 <= dy && dy < n && 0 <= dx && dx < m && !b[dy][dx]) {
				b[dy][dx] = true;
				tmp[dy][dx] = step;
				deque.offer(new Point(dy, dx));
			}
		}
	}

	class Point {
		int y;
		int x;

		public Point(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

	}

	int[][] move = { { -1, -1 }, { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, -1 },
			{ 1, 0 } };
	int[][] move2 = { { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, 0 },
			{ 1, 1 } };

	int m;
	int n;
}

Measured memory_bytes: 23472
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 
int main() {
  int x, y;
  cin >> x >> y;
  if ((x+y)%3) {
    cout << 0 << endl;
    return 0;
  }
  int n = (x+y)/3;
  x -= n; y -= n;
  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  combination c(x+y);
  mint ans = c(x+y,x);
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 13784
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());
    }

}

Measured memory_bytes: 78644
import math
import itertools
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def main():
    K=int(input())
    #l=[i for i in range(1,K+1)]
    ans=0
    dp=[[[None for i in range(201)] for j in range(201)] for k in range(201)]

    for i in range(1,K+1):
        for j in range(1,K+1):
            for k in range(1,K+1):
                p=sorted([i,j,k])
                if dp[p[0]][p[1]][p[2]] == None:
                    tmp=gcd(i,j,k)
                    dp[p[0]][p[1]][p[2]] = tmp
                    ans+=tmp
                else:
                    ans+= dp[p[0]][p[1]][p[2]]
    print(ans)
    
if __name__ == '__main__':
    main()   

Measured memory_bytes: 157884
//
//  ALDS12A_BubbleSort.cpp
//  CppAlgorithmSet
//
//  Created by 蒋春恺 on 2018/12/19.
//  Copyright © 2018 蒋春恺. All rights reserved.
//

#include <iostream>

using namespace std;

template <class T>
void printArray(T Array, int size)
{
    for (int i = 0; i < size; i++) {
        cout << Array[i];
        if (i != size - 1) cout << " ";
    }
    cout << endl;
}

void swap(int & a, int & b)
{
    int tmp = a;
    a = b;
    b = tmp;
}

void bubbleSort(int A[], int N)
{
    int count = 0;
    bool flag = true;
    
    while (flag) {
        flag = false;
        for (int j = N - 1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                count++;
                swap(A[j], A[j-1]);
                flag = true;
            }
        }
    }
    
    printArray(A, N);
    cout << count << endl;
}

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



Measured memory_bytes: 3124
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String k = s.next();
		
		int flag=0;
		for(int i=0;i<k.length();i++) {
			if(i%2!=0) {
				if(k.charAt(i)!='L' && k.charAt(i)!='U' && k.charAt(i)!='D') {
					flag=1;
					break;
				}
			}
			else {
				if(k.charAt(i)!='R' && k.charAt(i)!='U' && k.charAt(i)!='D') {
					flag=1;
					break;
				}
			}
		}
		if(flag==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 3e3+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
char ans[111];

void DFS(int cur,int mx){
//    printf("cur = %d\n",cur);
    if(cur==N){
        ans[N]='\0';
        printf("%s\n",ans);
        return;
    }
    for(int i=0;i<=cur;i++){
        ans[cur]='a'+i;
        DFS(cur+1,max(mx,i));
        if(i>mx) break;
    }
}

void work(){
    scanf("%d",&N);
    DFS(0,0);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

const int MAX = 1000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}



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

    int n, m; cin >> n >> m;
    vector<int> s[m];
    vector<int> p(m);

    for(int i=0; i<m; ++i){
        int k; cin >> k;
        for(int j=0; j<k; ++j){
            int ss; cin >> ss;
            --ss;
            s[i].push_back(ss);
        }
    }

    for(int i=0; i<m; ++i) cin >> p[i];

    int ans = 0;
    for(int bit=0; bit<1<<n; ++bit){
        bool all_ok = true;
        for(int i=0; i<m; ++i){
            int cnt = 0;
            for(int j=0; j<s[i].size(); ++j) if(bit&1<<s[i][j]) ++cnt;
            if(cnt%2 != p[i]) { all_ok = false; break; }
        }
        if(all_ok) ++ans;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import re

x = raw_input()

num = list(x)

for i in range(len(x)):
        tmp = len(x) - i
        if (tmp % 2 == 0):
                first = x[0:tmp/2]
                second = x[tmp/2:-i]
                if (first == second):
                        print tmp
                        exit(0)


Measured memory_bytes: 2696
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD


def fs(n):
    f = Counter()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        error_print(i)
        if i > n:
            break
        while n % i == 0:
            f[i] += 1
            n /= i
    if n != 1:
        f[n] = 1
    return f


mod = 10**9 + 7


def mod_mul(a, b):
    return ((a % mod) * (b % mod)) % mod


def mod_power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return mod_power(x, y/2)**2 % mod
    else:
        return mod_power(x, y/2)**2 * x % mod


def mod_div(a, b):
    return mod_mul(a, mod_power(b, mod-2))


def P(n):
    ans = 1
    for i in range(2, n+1):
        ans = mod_mul(ans, i)

    return ans


@mt
def slv(N, M):
    f = fs(M)
    ans = 1
    error_print(f)
    C = Combination(10**6, mod)

    for k in f:
        ans = mod_mul(ans, C(N+f[k]-1, f[k]) % mod)
    return ans


def main():
    N, M = read_int_n()
    print(slv(N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 145664
from collections import defaultdict


def check(ai, ratemax, d):
    if 3199 < ai:
        ratemax += 1
    else:
        d[ai // 400] += 1
    return ratemax


def main():
    N, *a = map(int, open(0).read().split())
    d = defaultdict(lambda: 0)
    ratemax = 0
    for ai in a:
        ratemax = check(ai, ratemax, d)
    print(len(d) if len(d) else 1, len(d) + ratemax)
    return


main()


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

int main() {
    int a, b;
    char c;
    while (1) {
        cin >> a >> c >> b;
        if (c == '?') break;

        if (c == '+') cout << a + b << endl;
        else if (c == '-') cout << a - b << endl;
        else if (c == '*') cout << a * b << endl;
        else if (c == '/') cout << a / b << endl;
    }
    
    return 0;
}


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


using namespace std;
typedef long long ll;
int N = 2005 ,mod = 1000000007;

int c[2005][2005];
int main() {
	
	//cout << "hell0" << endl;
   	int n , k;
   	
   	c[0][0] = 1;
   	for(int i = 1 ; i < 2005 ; i++){
   		for(int j = 0 ; j <= i ;j++)
   		{
   			if(j == i or j == 0) 
   				c[i][j] = 1;
   			else 
   				c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
   			c[i][j] %= mod;
   		}
   	}
   //	cout << "yep" << endl;
/*   	for(int i = 1 ; i < 10 ; i++){
   		for(int j = 0 ; j <= i ;j++){
   			cout << c[i][j] << " ";
   		}
   		cout << endl;
   	}*/
   	cin >> n >> k;
   	int red = n - k , blue = k , ans = 0;
   	for(int i = 1 ; i <= blue; i++){
   		ans = (1LL * c[red + 1][i] * c[blue - 1][i - 1]) % mod;
   		cout << ans << endl;
   	}
   //	cout << "end" << endl;
   	return 0;
} 

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r;
	cin>>r;
	if(r<1200){
		cout<<"ABC"<<endl;
		return 0;
	}
	if(r>=1200 && r<2800){
		cout<<"ARC"<<endl;
		return 0;
	}
	if(r>=2800){
		cout<<"AGC"<<endl;
		return 0;
	}
}



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

int main() {
	// your code goes here
	double N;
	
	while(cin >> N && N>=0){
		string s;
		for(int i=0;i<8;i++){
			if(N>=pow(2,7-i)){
				N-=pow(2,7-i);
				s+='1';
			}
			else
				s+='0';
		}
		s+='.';
		for(int i=1;i<=4;i++){
			if(N>=pow(2,-i)){
				N-=pow(2,-i);
				s+='1';
			}
			else
				s+='0';
		}
		if(N==0)
		cout << s << endl;
		else
		cout << "NA" << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  
  string S;
  
  cin >> S ;
  
  int count=0;
  
  for(int i=0;i<S.length();i++){
    if(S[i]=='o'){
      count++;
    }
  }
  
  if(15-S.length()+count<8){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A[10];

bool dfs(int n, int a, int b)
{
	if (n == 10)
	{
		return true;
	}

	if (a < A[n])
	{
		if (dfs(n + 1, A[n], b) == true) { return true; }
	}
	
	if (b < A[n])
	{
		if (dfs(n + 1, a, A[n]) == true) { return true; }
	}

	return false;
}

int main()
{
	const int DATASETS = 1000;

	int N;

	bool check[DATASETS];

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> A[j];
		}

		check[i] = dfs(0, 0, 0);
	}

	for (int i = 0; i < N; i++)
	{
		cout << (check[i] ? "YES" : "NO") << endl;
	}

	return 0;
}

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

using namespace std;

int f(long a, long b) {
	int n = 0;
	for (; a > b; n++)
		a /= 4;
	return n;
}
long a[222222], b[222222], p[222222], x[222222], c[222222];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%ld", a + i);
	for (int k = 0; k < 2; k++) {
		for (int i = 1; i < n; i++) {
			long y = a[i - 1] < a[i] ? -f(a[i] + 1, 4 * a[i - 1]) : f(a[i - 1], a[i]);
			p[i] = max(0l, p[i - 1] + y);
		}
		stack<int> s;
		for (int i = n; i--;) {
			while (!s.empty()) {
				if (p[s.top()] < p[i])
					break;
				s.pop();
			}
			x[i] = s.empty() ? n : s.top();
			s.push(i);
		}
		for (int i = 1; i < n; i++)
			b[0] += p[i];
		long d = b[0];
		for (int i = 1; i < n; i++) {
			b[i] = d -= p[i - 1];
			for (int j = i; j < n; j = x[j])
				b[i] -= p[j] * (x[j] - j);
		}
		if (!k) {
			copy(b, b + n, c);
			b[0] = p[0] = 0;
			for (int i = 0; i < n / 2; i++)
				swap(a[i], a[n - i - 1]);
		}
	}
	long m = 1e18;
	for (int i = 0; i < n; i++)
		m = min(m, 2 * (c[i] + b[n - i]) + i);
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 8576
s=input()
f=1
i=0
if len(s)%2!=0:
    print("No")
    exit()
while i<len(s):
    if s[i]=="h" and s[i+1]=="i":
        i+=2
    else:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")

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

const int maxn=1e6+7;
int main(){
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int ans=0;
    while(1){
        if(a[0]==a[1]&&a[1]==a[2]) {
            cout<<ans<<endl;
            break;
        }
        ans++;
        if(a[2]-a[0]>=2) a[0]+=2;
        else a[0]++,a[1]++;
        sort(a,a+3);
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class CSnack
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine(Lcm(a, b));
            Console.ReadLine();
        }


        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}

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

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

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

	int n;
	cin >> n;
	map<int,int> cnt;
	REP(i, n) {
		int x;
		cin >> x;
		++cnt[x];
	}
	int result = 0;
	for (auto& item : cnt) {
		if (item.second < item.first) {
			result += item.second;
		} else {
			result += item.second - item.first;
		}
	}
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 4736
i = 0
m = Array.new(100, 0)
n = Array.new
x = Array.new
while n[i-1] != 0 || x[i-1] != 0
	n[i], x[i] = gets.split.map(&:to_i)
	i += 1
end
for o in 0..i-2
	for j in 1..n[o]-2
		for k in j+1..n[o]-1
			for l in k+1..n[o]
				m[o] += 1 if j + k + l == x[o]
			end
		end
	end
	puts m[o]
end

Measured memory_bytes: 8880
#include<stdio.h>
int main(){
  int n,i,cnt=0,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&t);
    if(t!=i+1)cnt++;
  }
  if(cnt<3){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}

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

int main(){
  string S;
  cin >> S;

  long long sum = 0;

  for (int i = 0; i < S.size(); i++){
    sum += S.at(i) - '0';
  }

  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3764
str = gets.chomp
arr = str.split("")
map = {}
arr.each { |a|
  if map.has_key?(a) then map[a] = map[a] + 1 else map[a] = 1 end
}
flag = true
map.each { |k, v|
  if v % 2 != 0 then flag = false end
}
 
if flag then puts "Yes" else puts "No" end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int w;
    cin >> w;
    
    int n = 0;
    while (n < s.length()) {
        cout << s[n];
        n += w;
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] vals = line.split(" ");
        int n = Integer.parseInt(vals[0]);
        int m = Integer.parseInt(vals[1]);
        ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            adj.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            line = in.readLine();
            vals = line.split(" ");
            int s = Integer.parseInt(vals[0]);
            int t = Integer.parseInt(vals[1]);
            adj.get(s).add(t);
            adj.get(t).add(s);
        }
        ArrayList<HashSet<Integer>> connectedComponents = buildComponents(adj, n);
        line = in.readLine();
        int q = Integer.parseInt(line);
        for (int i = 0; i < q; i++) {
            line = in.readLine();
            vals = line.split(" ");
            int s = Integer.parseInt(vals[0]);
            int t = Integer.parseInt(vals[1]);
            System.out.println(isReachable(connectedComponents, s, t) ? "yes" : "no");
        }
    }

    private static boolean isReachable(ArrayList<HashSet<Integer>> connectedComponents, int s, int t) {
        for (HashSet<Integer> component : connectedComponents) {
            boolean containsS = component.contains(s);
            boolean containsT = component.contains(t);
            if (containsS && containsT) {
                return true;
            } else if (containsS) {
                return false;
            } else if (containsT) {
                return false;
            }
        }
        return false;
    }

    private static ArrayList<HashSet<Integer>> buildComponents(ArrayList<ArrayList<Integer>> adj, int n) {
        ArrayList<HashSet<Integer>> connectedComponents = new ArrayList<>();
        HashSet<Integer> explored = new HashSet<>();
        for (int i = 0; i < n; i++) {
            if (!explored.contains(i)) {
                HashSet<Integer> connected = new HashSet<>();
                Queue<Integer> toDo = new LinkedList<>();
                toDo.offer(i);
                while (!toDo.isEmpty()) {
                    int next = toDo.poll();
                    explored.add(next);
                    connected.add(next);
                    ArrayList<Integer> neighbors = adj.get(next);
                    for (int neighbor : neighbors) {
                        if (!explored.contains(neighbor)) toDo.offer(neighbor);
                    }
                }
                connectedComponents.add(connected);
            }
        }
        return connectedComponents;
    }
}



Measured memory_bytes: 185928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

bool flag[9];
int cnt;

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

    rep(i, N) {
	int a;
	cin >> a;

	if (a < 3200) {
	    flag[a / 400] = true;
	} else {
	    cnt++;
	}
    }

    int base = 0;

    rep(i, 8) {
	base += flag[i];
    }

    cout << max(1LL, base) << ' ' << base + cnt << endl;

    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc116/tasks/abc116_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
int N,K;
int t[112345];
LL d[112345];
int o[112345];
int used[112345];
int main(){
    cin>>N>>K;
    for(int i:range(N)){
        cin>>t[i]>>d[i];
        t[i]--;
    }
    iota(o,o+N,0);
    sort(o,o+N,[&](int l,int r){return d[l]<d[r];});
    reverse(o,o+N);
    LL use = 0;
    LL sum = 0;
    stack<LL> x;
    for(int _i:range(K)){
        int i=o[_i];
        if(used[t[i]])x.push(d[i]);
        else {
            used[t[i]]=1;
            use++;
        }
        sum+=d[i];
    }
    LL ret=use*use+sum;
    for(int _i:range(K,N)){
        if(x.empty())break;
        int i=o[_i];
        if(used[t[i]])continue;
        used[t[i]]=1;
        use++;
        sum+=d[i];
        sum-=x.top();
        x.pop();
        chmax(ret,use*use+sum);
    }
    cout<<ret<<endl;
    return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void)
{	
	int n;
	cin >> n;
	if (n % 10 == 3)print("bon");
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)print("pon");
	else print("hon");
}

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

int main(void){
    char day[10];
    
    scanf("%s",day);
    
    if (strcmp(day,"SUN")==0) {
        printf("7\n");
    } else if (strcmp(day,"MON")==0) {
        printf("6\n");
    } else if (strcmp(day,"TUE")==0) {
        printf("5\n");
    } else if (strcmp(day,"WED")==0) {
        printf("4\n");
    } else if (strcmp(day,"THU")==0) {
        printf("3\n");
    } else if (strcmp(day,"FRI")==0) {
        printf("2\n");
    } else if (strcmp(day,"SAT")==0) {
        printf("1\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (min(a,b)<c && c<max(a,b)){
        cout << "Yes" <<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    X = readline().rstrip().decode('utf-8')
    nx = int(X, 2)

    ans = [0] * N

    oc = X.count('1')

    if oc - 1 != 0:
        mx = nx % (oc - 1)
        f = True
    else:
        f = False

    px = nx % (oc + 1)

    for i in range(N):

        if X[i] == '0':
            a = (px + pow(2, N - i - 1, oc + 1)) % (oc + 1)
        elif f:
            a = (mx - pow(2, N - i - 1, oc - 1)) % (oc - 1)
        else:
            ans[i] = 0
            continue

        count = 1
        while a:
            a = a % bin(a).count('1')
            count += 1

        ans[i] = count

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    int direction = 1;
    string s;
    int q;
    cin >> s >> q;

    list<char> l;
    for (char c : s) l.push_back(c);

    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) direction *= -1;
        else {
            int f;
            char c;
            cin >> f >> c;

            if (direction == -1) {
                if (f == 1) f = 2;
                else f = 1;
            }

            if (f == 1) {
                l.push_front(c);
            } else {
                l.push_back(c);
            }
        }
    }

    string ans = "";
    for (char c: l) {
        ans += c;
    }

    if (direction == -1) {
        reverse(ans.begin(), ans.end());
    }

    cout << ans << endl;


}


Measured memory_bytes: 10500
#include <bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b)-1; i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

const int INF = 1e9 + 7;
///----------------------------------------------
int main() {

    //freopen ( "xx.in" , "r" , stdin );

    ///read
    int n; cin>>n;
    ll nowt,nowa; cin>>nowt>>nowa;
    rep(i,1,n) {
        ll t,a; cin>>t>>a;
        ll tmpt=(nowt-1)/t+1;
        ll tmpa=(nowa-1)/a+1;
        ll tmp=max(tmpt,tmpa);
        nowt=t*tmp;
        nowa=a*tmp;
    }

    ///print
    cout << nowt+nowa;



}


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

int main()
{
	int x;
	cin>>x;
	
	for(int i=0; i<=x/100; i++)
		for(int j=0; j<=x/101; j++)
			for(int k=0; k<=x/102; k++)
				for(int l=0; l<=x/103; l++)
					for(int m=0; m<=x/104; m++)
						for(int n=0; n<=x/105; n++)
							{
								if((100*i+101*j+102*k+103*l+104*m+105*n)==x)
								{
									cout<<1<<endl;
									return 0; 
								} 
							}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
l = int(input())
n = len(bin(l)) - 3
tmp = 2 ** n
print(n + 1, 2 * n + bin(l)[3:].count('1'))
for i in range(n):
    print(i+1, i+2, 0)
    print(i+1, i+2, 2 ** i)
    if l & (1<<i):
        print(i+1, n+1, tmp)
        tmp += 2 ** i



Measured memory_bytes: 3060
/*
Write a program which reads an integer n (n &#8804; 999999) and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, 7.
 */

#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

 /* 
http://community.appliplanet.co.jp/community/beginner

[|Cg]
+nªfÅÈ¢ÈçÌ½ûªmæè¬³¢àÌÅèØêéÍ¸B
+\ßQÌ{ðO·éB
+ªå«­ÈéÈçÎGXgeXÌâ¿ðÂ©¤©ÀÍbool[]ðg¤B
 */
void solve(int n) {
	bool prime[n+1];
	for (int i=0; i<n+1; i++)
		prime[i] = true;
	prime[0] = false; prime[1] = false;
	int m = (int)sqrt(n);					// nÌ½ûª
	
	for (int i=2; i<=m; i++) {
		if(prime[i]) {
			for (int k=i*i; k<=n; k += i)
				prime[k] = false;
		}
	}
	
	int count = 0;
	for (int i=0; i<n+1; i++) {
		if (prime[i]) count++;
	}
	
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		solve(n);
	}
	return 0;
}

Measured memory_bytes: 1844
#include<stdio.h>
char a[8][8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"},c;
int b[9][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};

int d(int x)
{
	int i,r=0;
	for(i=0;i<3;i++)
		r+=(b[8][i]-b[x][i])*(b[8][i]-b[x][i]);
	return r;
}

int main()
{
	int i,r;
	for(;~scanf("%c%2x%2x%2x\n",&c,&b[8][0],&b[8][1],&b[8][2]),c!='0';puts(a[r]))
	{
		for(i=r=0;i<8;i++)
			if(d(r)>d(i))
				r=i;
	}
	return 0;
}

Measured memory_bytes: 592
# Author: cr4zjh0bp
# Created: Sun Mar 22 23:25:40 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

s = ns()
c = Counter(s)
print("yes" if len(s) == len(c) else "no")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
string s;
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>n;
 cin>>s;
 for(int i=0; i<s.size(); i++)
 {
  if(s[i]=='I') x++;
  else x--;
  if(x>y) y=x;
 }
 cout<<y;
 return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = (S)

cnt = 0
for i,s in enumerate(S):
    if cnt < 0:
        ans = ['('] + ans
        cnt = 0
    if s == '(':
        cnt += 1
    else:
        cnt -= 1
if cnt> 0:
    ans = ans + [')'] * cnt
elif cnt < 0:
    ans = ['('] * (-cnt) + ans
print(''.join(ans))


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

int main(){
    int i, j;
    int n, q;
    
    scanf("%d %d", &n, &q);
    
    char *str = malloc(sizeof(char)*n + 2);
    
    scanf("%s", str);

    int l, r;
    int *map = calloc(n, sizeof(int));
    int *ans = malloc(sizeof(int) * q);

    if(str[0] == 'A' && str[1] == 'C'){
        map[0] = 0;
        map[1] = 1;
    } else {
        map[0] = 0;
        map[1] = 0;
    }    
    for(i=1; i<n-1; i++){
        if(str[i] == 'A' && str[i+1] == 'C'){
            map[i+1] = map[i] + 1;
        } else {
            map[i+1] = map[i];
        }
    }
    
    for(i=0; i<q; i++){
        scanf("%d %d", &l, &r);
        ans[i] = map[r-1] - map[l-1];
    }
    
    for(i=0; i<q; i++){
        printf("%d\n", ans[i]);
    }
    
    free(str);
    free(map);
    free(ans);
        
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#define ll long long
using namespace std;
int main () {
    ll N, M, ans=0;
    cin >> N >> M;
    for (int i=0;i<=N;i++){
        if (M==0){
            ans+=N*N;
            break;
        }
        int a=0;
        if (i-M>0){
            a=(N / i)*(i - M);
            if (N%i>=M)
                a+=N%i-(M-1);
        }
        ans+=a;
    }
    cout << "\n" << ans;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let s: String = read();
  let d: Vec<&str> = s.split('/').collect();
  let y: i16 = d[0].parse().unwrap();
  let m: i16 = d[1].parse().unwrap();
  
  println!("{}",
    if (y == 2019 && m >= 5) || y > 2019 { "TBD" }
    else { "Heisei" }
  );
}

Measured memory_bytes: 4352
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
count=0
for i in range(N):#N人の勇者目線で考える。
  count +=min(A[i],B[i])#一個目の町でモンスターを倒す。
  if A[i]>=B[i]:
    B[i]=0
  else:
    B[i] -= A[i]#二個目の町で倒せるモンスターの数
  count +=min(A[i+1],B[i])#二個目の町で倒せるモンスターの数
  if A[i+1]<=B[i]:
    A[i+1]=0
  else:
    A[i+1] -=B[i]
print(count)

Measured memory_bytes: 18436
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c = map(int, input().split())
if b-a == c-b:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 38640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

int main() {
    long N;
    cin >> N;
    map<long, long> c = factorization(N);

    long res = 0;
    for (auto const & e: c) {
        long i = e.second;
        long j = 1;
        while (i >= j) {
            i -= j;
            j++;
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
int mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);

int dp[1<<22][25];
ll allmask;
ll recursion(ll &n,ll mask,vector<vector<int>> &vec,ll level){
  if(level>=n){
    if(mask==allmask) return 1;
    return 0;
  }
  if(dp[mask][level]!=-1) return dp[mask][level];
  ll val=0;
  for(int i=0;i<n;i++){
    if(vec[i][level]==1 && (mask & (1<<i))==0){
      val=(val%mod+recursion(n,mask | (1<<i),vec,level+1)%mod)%mod;
    }
  }
  dp[mask][level]=val;
  return dp[mask][level];
} 
signed main()
{
  //------------ SEE BELOW ARTICLE---------------
 // https://codeforces.com/blog/entry/64250?#comment-484569
  //input_from_file;
  ll n;cin>>n;
  vector<vector<int>> vec(n,vector<int> (n,0));
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)  cin>>vec[i][j];
  }
  allmask=(1<<n)-1;
  memset(dp, -1 , sizeof dp);
  cout<<recursion(n,0,vec,0);
  return 0;
}


Measured memory_bytes: 409856
#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<long long> > xsel(1 << N, std::vector<long long>(N));
	std::vector<std::vector<long long> > ysel(1 << N, std::vector<long long>(N));
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], (long long)std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], (long long)std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] *= P[j];
			ysel[i][j] *= P[j];
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += std::min({ xsel[j][k], ysel[i - j][k] });
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 13016
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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
# a〜z --- END ---

n=I()

def dfs(x,s):
  if len(s)==n:
    print(s)
    return

  for i in range(x+1):
    _s=s+l[i]
    dfs(max(x,i+1),_s)

def main():
  dfs(0,'')

main()
# print(main())


Measured memory_bytes: 6484
n=int(input())
a = list(map(int,input().split()))[:n]
a.sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)
# other
# print(sum(a[::2]) - sum(a[1::2]))


Measured memory_bytes: 2940
using System;

namespace ABC173
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int n = int.Parse(Console.ReadLine());
            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;
            for(int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (s == "AC")
                    ac++;
                else if (s == "WA")
                    wa++;
                else if (s == "TLE")
                    tle++;
                else
                    re++;
            }
            Console.WriteLine("AC x {0}", ac);
            Console.WriteLine("WA x {0}", wa);
            Console.WriteLine("TLE x {0}", tle);
            Console.WriteLine("RE x {0}", re);
        }
    }
}


Measured memory_bytes: 30684
//ABC137C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	vector<long long int> a(n+1);
	vector<long long int> b(n);
	for(int i=0;i<n+1;i++){
		cin >> a.at(i);
	}
	for(int i=0;i<n;i++){
		cin >> b.at(i);
	}
	long long int sigma = 0;
	for(int i=0;i<n;i++){
		if(a.at(i)+a.at(i+1) <= b.at(i)){
			sigma += a.at(i)+a.at(i+1);
			a.at(i+1) = 0;
		}else if(a.at(i) < b.at(i)){
			sigma += b.at(i);
			a.at(i+1) -= b.at(i)-a.at(i);
		}else{
			sigma += b.at(i);
		}
	}
	cout << sigma << endl;
	return 0;
}

Measured memory_bytes: 1792