akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		StringBuilder sb = new StringBuilder();
		for (int num : set) {
			sb.append(num + " ");
		}
		String str = sb.toString();
		str = str.substring(0, str.length() - 1);
		System.out.println(str);
	}
}



Measured memory_bytes: 76772
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
using namespace std;
inline int read(){
	#define gc getchar
	bool f=1;
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))f^=ch==gc(),ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
	#undef gc
}
const int mod=998244353;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:a-=mod;}
inline void Dec(int&a,int b){(a-=b)<0?a+=mod:a;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
const int N=1e5+5;
int n,m;
typedef pair<int,int> pii;
pii a[N];
inline bool cmp(pii a,pii b){return a.fi^b.fi?a.fi<b.fi:a.se>b.se;}
int main(){
	n=read(),m=read();
	for(ri i=1;i<=n;++i)a[i].fi=read(),a[i].se=read();
	sort(a+1,a+n+1,cmp);
	ll ans=0;
	int cur=1;
	priority_queue<int>q;
	for(ri i=m;~i;--i){
		while(cur<=n&&i+a[cur].fi<=m)q.push(a[cur].se),++cur;
		if(q.size())ans+=q.top(),q.pop();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int D; cin >> D;
  string ans;
  if (D == 25)
    ans = "Christmas";
  else if (D == 24)
    ans = "Christmas Eve";
  else if (D == 23)
    ans = "Christmas Eve Eve";
  else
    ans = "Christmas Eve Eve Eve";
  cout << ans << endl;
}


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

using namespace std;
#define pi 3.141592
int main() {
	int n, x, a[200001] = {};
	cin >> n;

	for (int i = 0; i < n-1; i++) {
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << endl;
	}
}

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

using namespace std;

typedef pair<int, int> pii;

int a[212123];
int b[212123];
int n;

int main() {
	priority_queue<pii> pq;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		pq.emplace(b[i], i);
	}
	long long ans = 0;
	while (pq.size()) {
		int x, idx;
		tie(x, idx) = pq.top();
		pq.pop();
		if (b[idx] == a[idx]) continue;
		if (b[idx] < a[idx]) goto bad;

		int l = (idx + n - 1) % n;
		int r = (idx + 1) % n;
		int s = b[l] + b[r];
		if (b[idx] <= s) goto bad;
		// check if a[idx] can be gotten to
		if ((b[idx] - a[idx]) % s == 0) {
			ans += (b[idx] - a[idx]) / s;
			b[idx] = a[idx];
			continue;
		}

		ans += b[idx] / s;
		b[idx] %= s;

		if (b[idx] < a[idx]) goto bad;
		if (b[idx] > a[idx]) pq.emplace(b[idx], idx);
	}
	cout << ans << '\n';
	return 0;

bad:
	cout << "-1\n";
	return 0;
}



Measured memory_bytes: 4724
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int base = 0;
		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; ++i) {
			b[i] = sc.nextInt();
			if (b[i] == 0)
				++base;
		}
		int Q = sc.nextInt();
		int[][] q = new int[Q][2];
		for (int i = 0; i < Q; ++i) {
			q[i][0] = sc.nextInt();
			q[i][1] = sc.nextInt();
		}
		Arrays.sort(q, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[0], o2[0]);
			}
		});
		RMQ rmq = new RMQ(n + 1);
		rmq.set(0, 0);
		int p = 0;
		for (int i = 0; i < Q; ++i) {
			while (q[i][0] - p > 1) {
				int c = b[p] == 1 ? 1 : -1;
				rmq.set(p + 1, Math.min(c + rmq.query(p), rmq.query(p + 1)));
				++p;
			}
			rmq.set(q[i][1], rmq.query(p, q[i][1] + 1));
		}
		while (n - p > 0) {
			int c = b[p] == 1 ? 1 : -1;
			rmq.set(p + 1, Math.min(c + rmq.query(p), rmq.query(p + 1)));
			++p;
		}
		System.out.println(base + rmq.query(n));
	}

	class RMQ {
		int n;
		int[] v;

		public RMQ(int n_) {
			n = 1;
			while (n < n_)
				n *= 2;
			v = new int[2 * n];
			Arrays.fill(v, Integer.MAX_VALUE / 3);
		}

		void add(int k, int val) {
			k += n;
			v[k] += val;
			while (k > 1) {
				k >>= 1;
				v[k] = Math.min(v[2 * k], v[2 * k + 1]);
			}
		}

		void set(int k, int val) {
			k += n;
			v[k] = val;
			while (k > 1) {
				k >>= 1;
				v[k] = Math.min(v[2 * k], v[2 * k + 1]);
			}
		}

		int query(int a) {
			return v[a + n];
		}

		int query(int a, int b) {
			a += n;
			b += n;
			int ret = Integer.MAX_VALUE / 3;
			while (a < b) {
				if ((a & 1) > 0) {
					ret = Math.min(ret, v[a++]);
				}
				if ((b & 1) > 0) {
					ret = Math.min(ret, v[--b]);
				}
				a >>= 1;
				b >>= 1;
			}
			return ret;
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 163196
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, K, j, x, sum = 0;
    cin >> N >> K;
    
    for(j = 0; j < N; j++){
        cin >> x;
        
        if(x <= K - x)
        sum = sum + (2 * x);
        
        else
        sum = sum + 2 * (K - x);
    }
    cout << sum << endl;
}


Measured memory_bytes: 3604
s = input()

l = 0
r = len(s)-1
ans = 0

while l < r:
    if s[l] != s[r]:
        if s[l] == "x":
            ans += 1
            l += 1
        elif s[r] == "x":
            ans += 1
            r -= 1
        else:
            print(-1)
            exit()
    else:
        l += 1
        r -= 1

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int n;
int a[20],x[20][20],y[20][20];

int func(int x)
{
	int res=0;
	while(x) {
		res+=x%2;
		x/=2;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		for(j=1;j<=a[i];j++)
			cin>>x[i][j]>>y[i][j];
	}
	int ans=0;
	for(int state=(1<<n)-1;state>-1;state--)
	{
		for(i=1;i<=n;i++)
			if((state>>(i-1)) & 1)
			{
				for(j=1;j<=a[i];j++)
					if(( (state>>(x[i][j]-1)) & 1) != y[i][j])
						break;
				if(j!=a[i]+1) break;
			}
		if(i==n+1) ans=max(ans,func(state));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s=str(input())
ans=0
rang=len(s)-1
for i in range(2**rang):
  l=[]
  for j in range(rang):
    if i>>j&1:
      l.append(j)
  if len(l)==0:
    ans+=int(s)
  elif len(l)==1:
    ans+=(int(s[0:l[0]+1])+int(s[l[0]+1:]))
  else: 
    for k in range(len(l)):
      if k==0:
        ans+=int(s[0:l[k]+1])
      elif k==len(l)-1:
        ans+=(int(s[l[k-1]+1:l[k]+1])+int(s[l[k]+1:]))
      else:
        ans+=int(s[l[k-1]+1:l[k]+1])   
print(ans)   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%mod;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

 ll int sum(ll int n) 
 { 
    ll int s; 
  
    /* Single line that calculates sum */
    for (s = 0; n > 0; s += n % 10, n /= 10); 
  
    return s; 
 } 

ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 
 
 int main() {
  ios;
  int n;
  cin>>n;
  int p=0;
  while(n--)
  {
      int l,r;
      cin>>l>>r;
      if(l==r)
      {
          p++;
      }
      else
      {
          p=0;
      }
      if(p==3)
      {
          cout<<"Yes"<<endl;
          return 0;
      }
  }
      cout<<"No"<<endl;
  }


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(void) {
    int N, M, a, b;

    cin >> N >> M;

    vector<int> na(N);

    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        na.at(a - 1) += 1;
        na.at(b - 1) += 1;
    }

    for (int i = 0; i < na.size(); i++) {
        cout << na.at(i) << endl;
    }

    return 0;
}


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

int main()
{
	int q; cin >> q;
for(;q--;){
	ll a, b;
	cin >> a >> b;
	ll kake = a * b - 1;
	ll root = max(0ll, ll(sqrt(kake))-2);
	while((root+1)*(root+1) <= kake) ++root;
	ll ans = root * 2 - 1;
	if(root * (root+1) > kake) --ans;
	if(a == b) ++ans;
	cout << ans << endl;
}
	return 0;
}


Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts arr[gets.chomp.to_i-1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int P=998244353;
int n;
struct pos{
	int x,y;
}ps[1007];
int ep=0,f[1007],sz[1007];
int gf(int x){while(x!=f[x])x=f[x]=x[f][f];return x;}
struct edge{
	int a,b;
	int v;
	bool operator<(const edge&e)const{return v<e.v;}
	void cal(){
		int x=gf(a),y=gf(b);
		if(x!=y)f[x]=y,sz[y]+=sz[x];
	}
}es[207*207];
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int pw[1007],ans;
int main(){
cin >> n;
	pw[0]=1;
	for(int i=1;i<=n;++i)pw[i]=pw[i-1]*2%P;
	ans=(pw[n]-n-1)%P;
	for(int i=0;i<n;++i)scanf("%d%d",&ps[i].x,&ps[i].y);
	for(int i=0;i<n;++i){
		for(int j=0;j<i;++j){
			int x=ps[i].x-ps[j].x,y=ps[i].y-ps[j].y;
			int g=gcd(x,y);
			x/=g,y/=g;
			if(!x)y=1;
			if(!y)x=1;
			if(x<0)x=-x,y=-y;
			es[ep++]=(edge){i,j,x*30000+y};
		}
	}
	std::sort(es,es+ep);
	for(int i=0,j=0;i<ep;i=j){
		for(int a=0;a<n;++a)sz[f[a]=a]=1;
		for(;j<ep&&es[i].v==es[j].v;es[j++].cal());
		for(int a=0;a<n;++a)if(f[a]==a&&sz[a]>1)ans=(ans-pw[sz[a]]+sz[a]+1)%P;
	}
	cout << (ans % P + P ) % P;
	return 0;
}

Measured memory_bytes: 512
#include<assert.h>　　　　//设定插入点
#include <ctype.h>                //字符处理　　　　
#include <errno.h>　　　　 //定义错误码
#include <float.h>　　　　 //浮点数处理
#include<limits.h>　　　　//定义各种数据类型最值常量
#include<locale.h>　　　　//定义本地化函数
#include <math.h>　　　　　//定义数学函数
#include <stdio.h>　　　　//定义输入／输出函数
#include<stdlib.h>　　　　//定义杂项函数及内存分配函数
#include <string.h>　　　　//字符串处理
#include<time.h>　　　　　//定义关于时间的函数
#include <wchar.h>　　　　//宽字符处理及输入／输出
#include <wctype.h>　　　　//宽字符分类
#include <algorithm>　　　 //STL通用算法
#include <bitset>　　　　　//STL位集容器
#include <cctype>                //字符处理
#include <cerrno>　　　　 //定义错误码
#include <clocale>　　　　//定义本地化函数
#include <cmath>　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <cstdio>　　　　//定义输入／输出函数
#include <cstdlib>　　　　//定义杂项函数及内存分配函数
#include <cstring>　　　　//字符串处理
#include <ctime>　　　　　//定义关于时间的函数
#include <deque>　　　　　 //STL双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream>　　　//文件输入／输出
#include <functional>　　　//STL定义运算函数（代替运算符）
#include <limits>　　　　//定义各种数据类型最值常量
#include <list>　　　　　　//STL线性列表容器
#include <map>　　　　　　 //STL 映射容器
#include <iomanip>　　　//参数化输入／输出
#include <ios>　　　　　　//基本输入／输出支持
#include<iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream>　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　//基于字符串的流
#include <stack>　　　　　 //STL堆栈容器　　　　
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　//底层输入／输出支持
#include <string>　　　　　//字符串类
#include <utility>　　　　 //STL通用模板类
#include <vector>　　　　　//STL动态数组容器
#include <cwchar>　　　　//宽字符处理及输入／输出
#include <cwctype>　　　　//宽字符分类
#include <complex.h>　　//复数处理
#include <fenv.h>　　　　//浮点环境
#include <inttypes.h>　　//整数格式转换
#include <stdbool.h>　　 //布尔环境
#include <stdint.h>　　　//整型环境
#include <tgmath.h>　　　//通用类型数学宏
#define re register
#define ll long long
using namespace std;
#define sqr(x) ((x)*(x))
#define ull unsigned long long
#define mp make_pair
#define ld long double
#define fi first
#define se second
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
    ll x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
    }
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
string a,b;
int main() 
{
    getline(cin,a);
    b=a;
    reverse(a.begin(),a.end());
    for ( re int i=0;i<a.length();i++ ) 
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) return printf("Yes\n"),0;
    else printf("No\n"),0;
    return 0;
}
        

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

#define ll long long

int main(){
    string a, b;
    cin>>a>>b;
    vector< vector< int > > dp(a.length() + 1, vector< int >(b.length() + 1, 0));
    
    for(int i = 1; i <= (int)a.length(); i++){
        for(int j = 1; j <= (int)b.length(); j++){
            if(a[i-1] == b[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    
    //backtrack
    string ans = "";
    int i = (int)a.length();
    int j = (int)b.length();
    
    while(i != 0 && j != 0){
        if(a[i-1] == b[j-1]){
            ans.push_back(a[i-1]);
            i--;
            j--;
            continue;
        }
        if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
    //cout<<dp[a.length()][b.length()];
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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




int main(){
  float T,X;
  cin >> T >> X;
  cout << T / X << endl;
}


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

const int N = 1000 * 100 * 2;

long long a[N], b[N], tmp1, tmp2, n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) 
			tmp1 += a[i] - b[i];
		else
			tmp2 += (b[i] - a[i]) / 2;
	}
	if (tmp2 < tmp1 )
		return cout << "No", 0;
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    a = A[i]
    b = B[i]
    c = C[i]
    if a==b and b==c:
        pass
    elif a==b or b==c or c==a:
        ans += 1
    else:
        ans += 2
        
print(ans)


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

template< typename T >
struct BinaryIndexedTree {
	vector< T > data;

	BinaryIndexedTree(int sz) {
		data.assign(++sz, 0);
	}

	T sum(int k) {
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += data[k];
		return (ret);
	}

	void add(int k, T x) {
		for(++k; k < data.size(); k += k & -k) data[k] += x;
	}
};

signed main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> a(N, 0);
	for(ll i=0; i<N; i++) scanf("%lld", &a[i]);
	if(N==1){
		printf("%lld\n", a[0]);
		return 0;
	}

	ll left = 0;
	ll right = 1e9+1;
	auto isOK = [&](ll val) -> bool {
		vector<ll> b(N,0);
		for(ll i=0; i<N; i++) b[i] = (a[i]<val ? -1 : 1);
		vector<ll> rui(N+1, 0);
		for(ll i=0; i<N; i++) rui[i+1] = rui[i] + b[i];
		for(ll i=0; i<N+1; i++) rui[i] += N;

		BinaryIndexedTree<ll> bit(2*N+1);
		ll tentosu=0;
		for(ll i=0; i<N+1; i++) {
			tentosu += i - bit.sum(rui[i]);
			bit.add(rui[i], 1);
		}
		ll t = N*(N+1)/2 - tentosu;
		return t >= N*(N+1)/2/2;
	};

	while(right - left > 1) {
		ll mid = left + (right - left) / 2;
		if(isOK(mid)) left = mid;
		else right = mid;
	}

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


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

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

long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long cDiv1 = (a - 1) / c;
  long long cDiv2 = b / c;
  long long dDiv1 = (a - 1) / d;
  long long dDiv2 = b / d;

  long long g = lcm(c, d);
  long long lDiv1 = (a - 1) / g;
  long long lDiv2 = b / g;

  long long divCount = (cDiv2 - cDiv1) + (dDiv2 - dDiv1) - (lDiv2 - lDiv1);
  long long ans = (b - a + 1) - divCount;
  cout << ans << endl;
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int[] l = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				int y1 = l[0], m1 = l[1], d1 = l[2], y2 = l[3], m2 = l[4], d2 = l[5];
				if (l.Sum() < 0)
					break;
				var ts = new DateTime(y2, m2, d2) - new DateTime(y1, m1, d1);
				Console.WriteLine(ts.TotalDays);
			}
		}
	}
}

Measured memory_bytes: 6056
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a==b  && b== c) ||(a!=b && b!=c && a!=c)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

bool solve(vector<int> v){
	int dm = 0;
	for(int i=0; i<(int)v.size(); i++){
		if(i*10 <= dm) dm = max(dm, 10*i + v[i]);
	}
	return 10*(v.size() - 1) <= dm;
}

int main(){
	int n;
	cin >> n;
	vector<int> v, u;
	for(int i=0; i<n; i++){
		int tmp; cin >> tmp;
		v.push_back(tmp);
	}
	u = v;
	reverse(v.begin(), v.end());
	
	cout << (solve(v)&&solve(u)?"yes":"no") << endl;
	
	return 0;
}


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

int main(){
    int N, A[100000], B[100000], C[100000], DP[3][100001];
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i] >> B[i] >> C[i];
    DP[0][0] = 0;
    DP[1][0] = 0;
    DP[2][0] = 0;
    for(int i=0;i<N;i++) {
        for(int k=0;k<3;k++) {
            if(k==0) {
                DP[k][i+1] = max(DP[1][i], DP[2][i]) + A[i];
            }
            else if(k==1) {
                DP[k][i+1] = max(DP[0][i], DP[2][i]) + B[i];
            }
            else {
                DP[k][i+1] = max(DP[0][i], DP[1][i]) + C[i];
            }
        }
    }
    int maxvalue = max(DP[0][N], DP[1][N]);
    maxvalue = max(maxvalue, DP[2][N]);
    cout << maxvalue << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        int duplicate = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                duplicate++;
            } else {
                map.put(s, 1);
            }
        }
        System.out.println(n-duplicate);
    }
}


Measured memory_bytes: 76820
n=int(input())
s1=input()
s2=input()

ans=1
i=0
b=0
while i<n:
    if s1[i]==s2[i]:
        if b==0:
            ans*=3
        elif b==1:
            ans*=2
        else:
            ans*=1
        b=1
        i+=1
    else:
        if b==0:
            ans*=6
        elif b==1:
            ans*=2
        else:
            ans*=3
        b=2
        i+=2
    ans=ans%(10**9+7)
print(ans)
            
    
    







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

using namespace std;

bool checkPrime(int num)
{
	if (num <= 3) return true;
	if(num % 2 == 0) return false;
	int max = sqrt(num);
	for (int i = 3; i <= max; i += 2)
	{
		if(num % i == 0) return false;
	}
	return true;
}

int main()
{
	int n, num;
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		if(checkPrime(num)) count++;
	}
	cout << count << endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    ll ans1=1;
    if(k<=a-2||b-a<=2) ans1 += k;//交換できない時と、交換しても割に合わない時
    else{
        k -= a-1;
        ans1 += (a-1)+(k/2)*(b-a);
        ans1+=(k%2);
    } 
    cout << ans1 << endl;
    return 0;
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m;
  cin>>n>>m;
  vector<P> v(n),w(m);
  rep(i,n){
    cin>>v[i].F>>v[i].S;
  }
  rep(i,m){
    cin>>w[i].F>>w[i].S;
  }

  rep(i,n){
    //cout<<i<<endl;
    int res=INF,it=-1;
    rep(j,m){
      //cout<<i<<' '<<j<<endl;
      int sum=abs(v[i].F-w[j].F)+abs(v[i].S-w[j].S);
      //cout<<sum<<endl;
      if(res>sum){
        res=sum;
        it=j;
      }
    }

    cout<<it+1<<endl;
  }



}

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



int main() {
	
	string ans = "No";
	int a,b,c,k; cin >> a >> b >> c >> k;
	
	rep(i,k){
			int j = k - i;
			int A = a;
			int B = b;
			int C = c;
			rep(k1,i) B *= 2;
			rep(k2,j) C *= 2;
			if((A < B) && (B < C)){
				ans = "Yes";
				//cout << A << B << C << endl;
			}

	}
	
	
	
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
  	cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  int answer = 1;
  for (int i=0; i<N-1; i++) {
  	if(d.at(i) < d.at(i+1)) {
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a.at(i);
    }
    ll SUM = 0;
    for(ll i=0;i<n;i++){
        SUM+=a.at(i);
    }
    for(ll i=1;i<=n-2;i+=2){
        SUM-=2*a.at(i);
    }
    vector<ll>ans(n);
    ans.at(0)=SUM;
    cout<<ans.at(0)<<" ";
    for(ll i=1;i<n-1;i++){
        ans.at(i)=a.at(i-1)*2-ans.at(i-1);
        cout<<ans.at(i)<<" ";
    }
    ans.at(n-1)=a.at(n-2)*2-ans.at(n-2);
    cout<<ans.at(n-1)<<endl;

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b, k;
    cin >>a >> b >> k;

    if (a<=k)
    {
	k-=a;
	a = 0;
    }
    else
    {
	ll tmp = a;
	a-=k;
	k=(k<tmp)?0:k-tmp;
    }

    //cout << a << ' ' << b << ' ' << k << endl;

    if (b<k)
	b = 0;
    else	
	b -= k;
	
    cout << a << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 256
k = int(input())
ans = -1
seq = [0]

seq.append(7%k)
for i in range(2,k+1):
  seq.append((seq[i-1]*10+7)%k)

for j in range(1,k+1):
  if seq[j] == 0:
    ans = j
    break

print(ans)


Measured memory_bytes: 141036
def make_mat(grid, H, W):
    res = [[0] * W for _ in range(H)]
    for h in range(H):
        cnt = 0
        for w in range(W):
            if (grid[h]>>w)&1 == 1:
                for i in range(cnt):
                    res[h][w - 1 - i] = cnt
                cnt = 0
            else:
                cnt += 1
        if (grid[h]>>w)&1 == 0:
            for i in range(cnt):
                res[h][w - i] = cnt
    return res

def max2(x,y):
    return x if x > y else y


import sys
input = sys.stdin.readline

H, W = map(int, input().split())


grid = []
grid_t = [0]*W
for h in range(H):
    temp = 0
    for w, s in enumerate(input().rstrip()):
        if s=="#":
            temp += 1<<w
            grid_t[w] += 1<<h
    grid.append(temp)

A = make_mat(grid, H, W)
B = make_mat(grid_t, W, H)

res = 0
for h in range(H):
    for w in range(W):
        res = max2(A[h][w] + B[w][h], res)

print(res-1)

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

int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int N = a[n-1];
    int K = a[0];
    for (int i = 0; i < n-1; i++)
    {
        if(min(K, N - K) < min(a[i], N - a[i])) K = a[i];
    }

    cout << N << " " << K << endl;
    return 0;
}

Measured memory_bytes: 640
import operator

X, N = map(int, input().split())

p = list(map(int, input().split()))

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)

if abs_val_dict != {}:
    print(min(abs_val_dict.items(), key=operator.itemgetter(1))[0])

Measured memory_bytes: 9096
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};

int main()
{
    int x;
    cin>>x;
    if(x>=1800 && x<=1999) cout<<1<<endl;
    else if(x>=1600 && x<=1799) cout<<2<<endl;
    else if(x>=1400 && x<=1599) cout<<3<<endl;
    else if(x>=1200 && x<=1399) cout<<4<<endl;
    else if(x>=1000 && x<=1199) cout<<5<<endl;
    else if(x>=800 && x<=999) cout<<6<<endl;
    else if(x>=600 && x<=799) cout<<7<<endl;
    else cout<<8<<endl;

}




Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PriorityQueue<Short> pq = new PriorityQueue<Short>();
		short N = Short.parseShort(st.nextToken());
		short T = Short.parseShort(st.nextToken());
		st = new StringTokenizer(br.readLine());
		short p;
		for (short i = 0; i < N; i++) {
			p = Short.parseShort(st.nextToken());
			pq.add(p);
		}
		int sum = 0;
		for (short i = 0; i < T; i++) {
			sum += pq.poll();
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 33304
import copy

S = input()

dp = [0] * 13

dp[0] = 1

mod = 10 ** 9 + 7
mul = 1
for i in range(len(S)-1, -1, -1):
    # 二次元dpの代わり
    ndp = [0] * 13
    
    if S[i] == '?':
        for k in range(10):
            for j in range(13):
                # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
                # ただし、0-9までの値をその桁が取る可能性があるので、
                #　それぞれの場合全てを加算する
                ndp[(k * mul + j) % 13] += dp[j]
                ndp[(k * mul + j) % 13] %= mod
    else:
        k = int(S[i])
        for j in range(13):
            # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
            ndp[(k * mul + j) % 13] += dp[j]
            ndp[(k * mul + j) % 13] %= mod

    mul *= 10
    mul %= 13
    dp = copy.deepcopy(ndp)

# 13で割って5で余るものを出力
print(dp[5])


Measured memory_bytes: 54232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
const int INF = 1073741823;

int f(string a){
    vector<string> strA={"1","2","3","4","5","6","7","8","9"};
    vector<int> numA={2,5,5,4,5,6,3,7,6};
    for(int i=0;i<9;i++){
        if( a==strA[i]) return numA[i];
    }
    return 0;
}

int main(){
    // dp[i] max num from i matches, loger is bigger, chk as a string
    int n,m;
    cin >> n >> m;
    vector<int> inA(m);
    for(int i=0;i<m;i++){
        int k;
        cin >>k;
        inA[i] = k;
    }
    vector<string> A(m);
    sort(inA.begin(), inA.end());
    for(int i=0;i<m;i++){
        string s;
        s = to_string(inA[i]);
        A[i] = s;
    }
    // 状態n 遷移d(m,n) 10^9 ぎりぎりOK 
    //f(x) xを作るために使うマッチの数
    // vector<string> dp(n);
    // for (int i=0;i<n;i++){
    //     dp[i] = max_str(dp[i-fabs(Aj)]+Aj | j=1~M)
    // }
    vector<int> dp(n+1,-INF);
    dp[0] = 0;
    for(int i=0;i<n+1;i++){
        for(int j=0;j<m;j++){
        if (i - f(A[j])<0) continue;
        int ne = dp[i - f(A[j])] + 1;
        dp[i] = max(dp[i],ne);
        }
        // if(i<10){
        //     cout << "dp["<<i<<"]:" << dp[i] << endl;
        // }
            
    }
    string ans= "";
    int remain = dp[n];
    int match = n;
    // for(int i=9;i>=0;i--){
    //     cout << "i:"<<i<<",f(i):"<<f(to_string(i))<<endl;
    // }
    // cout << "remain:" << remain << "match:" << match << endl;
    while(match > 0){
        for(int i=m-1;i>=0;i--){
            // cout << "i:"<<i<<",";
            if(dp[match-f(A[i])] == remain-1 & match-f(A[i])>=0){
                ans += A[i];
                match -= f(A[i]);
                remain--;
                // cout <<"i=" << i << ",remain="<<remain<< ",match="<<match<<",";
                // cout <<"ans:" << ans << endl;
                i = m;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum, sumsum = 0;
  for (int i = 1; i <= n; i++) {
    sum = 0;
    for (int j = 0; j < to_string(i).size(); j++)
      sum += to_string(i).at(j) - '0';
    if (a <= sum && sum <= b) sumsum += i;
  }
  cout << sumsum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int h, w, i, k;

  while(1){
    scanf("%d %d", &h, &w);
    if(h==0 && w==0){ break; }
    for(i=1;i<=h;i++){
      for(k=1;k<=w;k++){
        if(i%2==1){
          if(k%2==1){ printf("#"); }
          if(k%2==0){ printf("."); }
        } else {
          if(k%2==1){ printf("."); }
          if(k%2==0){ printf("#"); }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



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

void solved(){
	int n;cin>>n;
	map<string ,int >st;
	for(int i = 1; i <= n; i++){
		string s;cin>>s;
		st[s]++;
	}
	map<string,int >::iterator it = st.begin();
	int ans = 0;
	for(;it != st.end(); it++){
		ans ++;
	} 
	cout<<ans<<endl;
}
int main(){
	solved();
	return 0;
} 

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	int K;
	cin >>S >>K;
	int N=S.size();
	vector<int> A;
	A.push_back(0);
	Rep0(i, N)
		A.push_back(S.at(i)-'0');
	int NN=A.size();
	vector<vector<int>>	DPOK(NN+1, vector<int> (K+2, 0));
	vector<vector<int>>	DPUK(NN+1, vector<int> (K+2, 0));
	DPUK.at(0).at(K)=1;
	Rep1(i, NN-1) {
		Rep0(j, K+1) {
			if (0<A.at(i))
				DPUK.at(i).at(j)=DPUK.at(i-1).at(j+1); 	// ==A.at(i), K--
			else
				DPUK.at(i).at(j)=DPUK.at(i-1).at(j);	// ==0, K=K
			DPOK.at(i).at(j)=DPOK.at(i-1).at(j)		// ==0, K=K
				+DPOK.at(i-1).at(j+1)*9;		// ==1, 9, K--
			if (0<A.at(i))
				DPOK.at(i).at(j)+=DPUK.at(i-1).at(j+1)*(A.at(i)-1)	// ==1, A.at(k)-1, K--
					+DPUK.at(i-1).at(j);		// ==0, K=K
		}
	}
	int SS=DPOK.at(NN-1).at(0)+DPUK.at(NN-1).at(0);
	cout <<SS <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, N;
  cin >> K >> N;
  int count = -1;
  vector<int> vec(N,0);
  for(int i = 0;i < N;i++){
    cin >> vec.at(i);
    count++;
  }
  int max = K-vec.at(count)+vec.at(0);
  for(int i = 0;i < count ; i++){ 
      if(max <= vec.at(i+1)-vec.at(i)){
        max = vec.at(i+1)-vec.at(i);
      }
  }
  cout << K-max << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;

int power(int x,int y)
{
      if(y==0)return 1;
      int temp=power(x,y/2);
      temp=(temp*temp)%MOD;
      if(y&1)temp=(temp*x)%MOD;
      return temp;
}

map<pii,int> m;
map<pii,bool> check;
int a[200005];
int b[200005];
int ZEROS=0;

pii comp(pii p)
{
      pii ans={-p.s,p.f};
      if(ans.f<=0 && ans.s<=0){ans.f*=-1;ans.s*=-1;}
      else if(ans.f>=0 && ans.s<=0){ans.f*=-1;ans.s*=-1;}
      return ans;
}

pii normalize(pii p)
{
      int val=1;
      if(p.f==0)val=abs(p.s);
      else if(p.s==0)val=abs(p.f);
      else
      val=__gcd(abs(p.f),abs(p.s));      
      p.f/=val;p.s/=val;       

      pii ans={p.f,p.s};
      if(ans.f<=0 && ans.s<=0){ans.f*=-1;ans.s*=-1;}
      else if(ans.f>=0 && ans.s<=0){ans.f*=-1;ans.s*=-1;}

      return ans;
}

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n;
           cin>>n;
           rep(i,0,n){cin>>a[i]>>b[i];}
           int ans=0;
           rep(i,0,n)
           {
               if(a[i]==0 && b[i]==0){ZEROS++;continue;}
               pii p=normalize({a[i],b[i]});
               m[normalize({a[i],b[i]})]++;
           }
      }
      
      int ans=1;

      for(auto it:m)
      {
            if(check[it.f])continue;
            pii cur=it.f;
            pii comp1=comp(it.f);
            int cnt=it.s;
            int cnt1=m[comp1];
            check[cur]=check[comp1]=true;
            int toMul=(power(2,cnt)+power(2,cnt1)-1+MOD)%MOD;
            ans=(ans*toMul)%MOD;
      }

      ans=(ans-1+MOD)%MOD;
      ans=(ans+ZEROS)%MOD; 

      cout<<ans<<endl;

      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 56664
import sys

N = int(input())
old_t, old_x, old_y = 0, 0, 0

for n in range(N):
    t, x, y = list(map(int, input().split()))
    dist = t - old_t
    shortest = abs(x - old_x) + abs(y - old_y)
    if dist < shortest or (dist - shortest) % 2 != 0:
        print("No")
        sys.exit()
    old_t, old_x, old_y = t, x, y

print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
const int MOD=1e9+7;
long long dp[5005][5005][2];
vector<int> nei[5005];
int sz[5005];
long long po[5005];
long long tmp[5005][2];
void dfs(int v,int pa){
	sz[v]=1;
	dp[v][1][1]=1;
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(u==pa) continue;
		dfs(u,v);
		for(int j=1;j<=sz[v];j++){
			for(int k=1;k<=sz[u];k++){
				tmp[j+k][0]=(tmp[j+k][0]+(dp[v][j][1]*dp[u][k][0]+dp[v][j][0]*dp[u][k][1])%MOD)%MOD;
				tmp[j+k][1]=(tmp[j+k][1]+(dp[v][j][0]*dp[u][k][0]+dp[v][j][1]*dp[u][k][1])%MOD)%MOD;
				tmp[j][0]=(tmp[j][0]+(dp[v][j][0]*dp[u][k][0]+dp[u][k][1]*dp[v][j][1])%MOD*po[k-1]%MOD)%MOD;
				tmp[j][1]=(tmp[j][1]+(dp[v][j][0]*dp[u][k][1]+dp[u][k][0]*dp[v][j][1])%MOD*po[k-1]%MOD)%MOD;
			}
		}
		sz[v]+=sz[u];
		for(int j=1;j<=sz[v];j++){
			dp[v][j][0]=tmp[j][0];
			dp[v][j][1]=tmp[j][1];
			tmp[j][0]=tmp[j][1]=0;
		}
	}
}
int main(){
	po[1]=1;
	for(int i=3;i<=5002;i+=2) po[i]=po[i-2]*i%MOD;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x--,y--;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	dfs(0,-1);
	long long res=0;
	for(int i=1;i<=sz[0];i++){
		res+=(dp[0][i][1]-dp[0][i][0])*po[i-1];
		res%=MOD;
//		cout<<dp[0][i][1]<<","<<dp[0][i][0]<<","<<po[i-1]<<" "<<i-1<<endl;
	}
	if(res<0) res+=MOD;
	cout<<res;
} 

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int a[maxr], b[maxr];
int32_t main()
{
	GO;
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];

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

	for (int i = 1; i < n; i++)
		a[i] += a[i - 1];
	for (int i = 1; i < m; i++)
		b[i] += b[i - 1];

	int ans = 0;
	for (int i = -1; i < n; i++) {
		if (a[i] > k)
			continue;
		int value = k;
		if (i >= 0)
			value = k - a[i];
		auto itr = lower_bound(b, b + m, value) - b;
		if (itr == m) {
			ans = max(ans, m + i + 1);
		}
		else if (b[itr] > value) {
			ans = max(ans, itr + i + 1);
		}
		else {
			ans = max(ans, itr + i + 2);
		}
	}
	cout << ans << endl;
	return 0;
}

//!

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

int main(){

  int  a , b ;

  cin >> a >> b ;

  if (a > b){

 cout <<"a > b" <<"\n";

  }

  else if (a < b){

    cout <<"a < b" <<"\n";
 }

  else if (a == b){

  cout <<"a == b" <<"\n";
 }
  
  return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


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);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
signed main(){
    /*
    int n,m;
    cin>>n>>m;
 
    h.assign(n,0);
    rep(i,0,n) cin>>h[i];
 
    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
 
    seen.assign(n,-1);
 
    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }
 
    int sum=accumulate(all(seen),0);
 
    cout<<sum<<endl;*/
 
     int n; cin>>n;
    int ans=0;
    map<string,int> mp;

    rep(i,0,n){
        string si; cin>>si;
        sort(all(si));
        if(mp[si]==0){
            mp[si]+=1;
        }else{
            ans+=mp[si];
            mp[si]++;
        }
    }

    cout<<ans<<endl;
}   

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

int main(){
    int n,l,r,mid;
    char s1[10],s2[10],s3[10],x[10],f;
    strcpy(s1,"Vacant");
    strcpy(s2,"Male");
    strcpy(s3,"Female");
    cin>>n;
    cout<<"0\n"<<flush;
    cin>>x;
    if(strcmp(x,s1)==0){
        return 0;
    }
    if(strcmp(x,s2)==0){
        f=0;
    }
    else{
        f=1;
    }
    l=1;
    r=n-1;
    while(1){
        mid=(l+r)/2;
        cout<<mid<<"\n"<<flush;
        cin>>x;
        if(strcmp(x,s1)==0){
            return 0;
        }
        if(strcmp(x,s2)==0){
            if(mid%2==f){
                l=mid+1;
            }
            else{
                r=mid-1;
            }
        }
        else{
            if(mid%2==f){
                r=mid-1;
            }
            else{
                l=mid+1;
            }
        }
    }
}

Measured memory_bytes: 852
#include<stdio.h>
int main (){
	int utuhnih;
	int pecahan;
	int hasilpie;
	
	utuhnih >=0;
	pecahan <= 100;
	
	scanf("%d %d", &utuhnih, &pecahan);
	hasilpie = ((utuhnih *3) + pecahan)/ 2;
	printf("%d", hasilpie);	
	
	return 0;
}

Measured memory_bytes: 1736