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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 5005;
const ll inf = 2e9 + 9;

struct tpt
{
    int h, p;
};

inline bool operator<(const tpt &a, const tpt &b)
{
    return a.h + a.p < b.h + b.p;
}

int dp[maxn][maxn];
tpt p[maxn];
int n;

int main()
{
    scanf("%d", &n);
    for (int i =0 ; i < n; i++)
    {
        scanf("%d%d", &p[i].h, &p[i].p);
    }
    sort(p, p + n);
    dp[0][0] = 0;
    for (int j = 1; j <= n; j++) dp[0][j] = inf;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= n; j++) dp[i + 1][j] = dp[i][j];
        for (int j = 0; j <= i; j++) if (dp[i][j] <= p[i].h)
        {
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[i].p);
        }
    }
    for (int i = n; i >= 0; i--) if (dp[n][i] < inf)
    {
        cout << i << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 98176
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		String s = rl();
		
		if (s.charAt(s.length()-1) == 's') {
			s += "e";
		}
		
		out.println(s + "s");
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static String rl() throws IOException {
		return f.readLine();
	}

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static long nlg(StringTokenizer st) {
		return Long.parseLong(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(rl());
	}

	static long nlg() throws IOException {
		return Long.parseLong(rl());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(rl());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


Measured memory_bytes: 36660
#include <iostream>
#include <string>
using namespace std;
int main(){
  
  string s; cin >> s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
  cout << "Yes" << endl;
  }
  else {cout << "No" << endl;}
 
    return 0;
}


Measured memory_bytes: 3572
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,k = readInts()
    if a >= k:
        print(k)
    else:
        if a + b >= k:
            print(a)
        else:
            print(a - (k - (a + b)))
if __name__ == '__main__':
  main()


Measured memory_bytes: 10992
"""
75数の条件
約数の個数は各素因数の個数a1,a2,a3,...について
(a1+1)(a2+1)...(an+1)
75=3*5*5
->素因数の個数が2個, 4個, 4個になるような組み合わせ
(2,4,4)
(14,4)
(2,24)
(74)

求め方
1〜Nについて、素因数の数をdictに収めていく
->そのうち、4個以上あるものの組み合わせと2個以上あるものの組み合わせでカウントする
"""
import copy
N=int(input())
sosu=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
soinsu=dict()
for n in range(2,N+1):
  if n in sosu:
    soinsu[n]=1
  else:
    x = copy.deepcopy(n)
    i = 0
    while i<len(sosu):
      if x % sosu[i]==0:
        soinsu[sosu[i]]+=1
        x = x//sosu[i]
      else:
        i += 1

ans = 0
cnt=[0,0,0,0,0]
tit=[2,4,14,24,74]
for _,v in soinsu.items():
  for i in range(5):
    cnt[i] += 1 if v >= tit[i] else 0

# (2,4,4)
ans+= cnt[1]*(cnt[1]-1)//2*(cnt[0]-2)
# (14,4)
ans+= cnt[2]*(cnt[1]-1)
# (2,24)
ans+= cnt[3]*(cnt[0]-1)
# (74)
ans+= cnt[4]
print(ans)

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k; cin>>k;
    string s;cin>>s;
    if(s.size()<=k)cout<<s;
    else cout<<s.substr(0,k)+"...";
    return 0;
}

Measured memory_bytes: 3644
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    w = input()
    c = collections.Counter(w)
    for i in c:
        if c[i] % 2 == 1:
            print("No")
            exit()
    print("Yes")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int n;
int s[100001];

bool binsearch(int v) {
  int l = -1,r = n,mid = (-1+n) / 2;
  while(r-l > 1) {
	if(s[mid] == v) return true;
	else if(s[mid] < v) l = mid;
	else r = mid;
	mid = (r+l) / 2;
  }
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i,n) cin >> s[i];

  int c,search_num,ans = 0;
  cin >> c;
  rep(i,c) {
	cin >> search_num;
	if(binsearch(search_num)) ans += 1;
  }
  cout << ans << endl;
}




Measured memory_bytes: 3492
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        List<Integer[]> edgeList = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            edgeList.add(new Integer[] { a, b });
        }
        sc.close();

        // 主処理
        Map<Integer, HashSet<Integer>> graph = createGraph(n, edgeList, false);
        int start = 1;
        int target = n;
        int distance = getDistance(n + 1, graph, start, target);

        boolean judge = distance != 0 && distance <= 2;
        String result = judge ? "POSSIBLE" : "IMPOSSIBLE";

        // 出力
        System.out.println(result);
    }

    // グラフを作成
    public static Map<Integer, HashSet<Integer>> createGraph(int nodeSize, List<Integer[]> edgeList,
            boolean isDirected) {
        Map<Integer, HashSet<Integer>> graph = new HashMap<>();
        for (int i = 1; i <= nodeSize; i++) {
            graph.put(i, new HashSet<>());
        }
        if (isDirected) {
            for (Integer[] edge : edgeList) {
                graph.get(edge[0]).add(edge[1]);
            }
        } else {
            for (Integer[] edge : edgeList) {
                graph.get(edge[0]).add(edge[1]);
                graph.get(edge[1]).add(edge[0]);
            }
        }
        return graph;
    }

    // 最短距離を求める
    public static int getDistance(int nodeSize, Map<Integer, HashSet<Integer>> graph, int start, int target) {
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(start);

        int[] distance = new int[nodeSize];
        distance[start]++;

        int dist = 0;
        while (!deque.isEmpty()) {
            int point = deque.poll();
            if (point == target) {
                dist = distance[point] - 1;
                break;
            }
            for (int nextPoint : graph.get(point)) {
                if (distance[nextPoint] == 0) {
                    deque.add(nextPoint);
                    distance[nextPoint] = distance[point] + 1;
                }
            }
        }

        return dist;
    }
}


Measured memory_bytes: 132784
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

vector<int> adj[100005];
vector<int> memo(100005, -1);

int dfs(int u)
{
    if(memo[u]!=-1)
        return memo[u];
    int ans=0;
    for(auto it:adj[u])
        ans=max(ans, 1+dfs(it));
    return memo[u]=ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin>>n>>m;
    while(m--)
    {
        int u, v;
        cin>>u>>v;
        u--, v--;
        adj[u].pb(v);
    }
    int ans=0;
    for(int i=0; i<n; i++)
        ans=max(ans, dfs(i));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
int main(){
	int a,x[10000],Max=-1000000,min=1000000;
	long long int sum=0;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",&x[i]);
		sum = sum + x[i];
		if(Max<x[i]){
			Max = x[i];
		}
		if(min>x[i]){
			min = x[i];
		}
	}
	printf("%d %d %lld\n",min,Max,sum);
	return 0;
}

Measured memory_bytes: 2748
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans1 = a[n-1];
    int r = ans1/2;
    int ans2 = INF;
    rep(i,n-1){
        if(abs(a[i]-r) <= abs(ans2-r)) ans2 = a[i];
    }
	cout << ans1 << " " << ans2 << endl;
}



Measured memory_bytes: 640
import Data.Array.IO
import Data.Vector.Unboxed (Vector, (!), fromList)
import Control.Monad

type Memo = IOUArray (Int, Int) Int

main = do
  [n, a] <- map read . words <$> getLine :: IO [Int]
  x <- map read . words <$> getLine :: IO [Int]
  memo <- newArray ((0, negate (n * 50)), (n, n*50)) 0 :: IO Memo
  writeArray memo (0, 0) 1
  let y = map (flip (-) a) x
      y' = fromList (0:y) :: Vector Int
      max = maximum x
      idx = [(i, j) | i <- [1..n], j <- [negate (n * 50)..n * 50]]
  foldM (dp y' n max) memo idx
  ans <- readArray memo (n, 0)
  print $ ans - 1

dp :: Vector Int -> Int -> Int -> Memo -> (Int, Int) -> IO Memo
dp y n x memo (i, j)
  | i >= 1 && (j - (y ! i) < (negate $ n*x) || j - (y ! i) > n*x) = do
    a <- readArray memo (i-1, j)
    writeArray memo (i, j) a
    return memo
  | i >= 1 && (negate $ n*x) <= j - (y ! i) && j - (y ! i) <= n*x = do
    a <- readArray memo (i-1, j)
    b <- readArray memo (i-1, j-(y!i))
    writeArray memo (i, j) $ a + b
    return memo
  | otherwise = return memo


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

int main() {
  char a,b;
  cin>>a>>b;
  if(a-b>0){
    cout<<">"<<endl;
  }else if(b-a>0){
    cout<<"<"<<endl;
  }else if(a==b){
    cout<<"="<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
mod=10**9 + 7
#print(bin(9))
N=int(input())
A=list(map(int,input().split()))
A.sort()
#print(A)
A=[bin(i)[2:] for i in A]
#print(A)
nowdata=[0 for i in range(60)]
data=[0 for i in range(60)]

#print(A)

for i in range(N-1):
    S=A[i]

    for a in range(len(S)):
        if S[-a-1]=="1":
            nowdata[a]+=1
    S=A[i+1]
    for a in range(len(S)):
        if S[-a-1]=="0":
            data[a]+=nowdata[a]
        else:
            data[a]+=i+1-nowdata[a]
    #print(nowdata)


num=0
#print(data)
for i in range(60):
    num+=data[i]* (2**i)
    num%=mod

print(num)


Measured memory_bytes: 125908
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int b[100][100000];
int func(vector<pii>&v,int p,int i,int s)
{
	if(i<0)
	{return 0;}
	int k=v[i].S-p*v[i].F;
	if(!b[i][p])
	{
	if(k<0){b[i][p]=func(v,p,i-1,s);}
	else{
		b[i][p]=max(v[i].S-p*v[i].F+func(v,p+s,i-1,s),func(v,p,i-1,s));
	}
	}
	return b[i][p];
}
int main()
{
	//fopen();
	int k,x;
	cin>>k>>x;
	cout<<(k*500>=x?"Yes":"No");

	
}


Measured memory_bytes: 256
timequeue = Array.new
namequeue = Array.new  
N,Q = gets.split.map(&:to_i)
proc =0.to_i
N.times do
name, time = gets.split
timequeue.push(time.to_i)
namequeue.push(name.to_s)
end

while !namequeue.empty? 
	data = timequeue.shift
	name = namequeue.shift
	if data> Q
		proc += Q
		data-=Q
		timequeue.push(data)
		namequeue.push(name)
	else
		proc += data
		print(name+" ")
		puts proc
	end

end

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

const int N = 1e5 + 10;

ll a[N], b[N];
int n;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", a + i, b + i);
  }
  ll ans = 0;
  for (int i = n; i >= 1; i--) {
    a[i] = (a[i] + ans) % b[i];
    a[i] %= b[i];
    ans += (b[i] - a[i]) % b[i];
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

typedef long long ll;

int depth(int i, map<int, vector<int>> &child) {

  vector<int> &childs = child[i];

  if( childs.empty() ) { return 0; }

  // それぞれの子のトーナメントの深さをもとめる。
  vector<int> dc; // depth of childs
  for(auto c: childs) {
    dc.push_back( depth(c, child) );
  }

  // 深さが浅い人と先に対戦する。
  sort(dc.begin(), dc.end());

  int res = 0;
  int cn = dc.size();
  for(int k = 0; k < (int)dc.size(); k++) {
    res = max(res, dc[k] + cn - k);
  }

  return res;

}

 int main() {

   int N;
   cin >> N;

   // child[i] == (i に負けた人たち)
   map< int, vector<int>  > child;
   for(int i = 2; i <= N; i++ ) {
     int p;
     cin >> p;
     child[p].push_back(i);
   }

   cout << depth(1, child) << "\n";

   return 0;
 }


Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

const long long MAX_N = 100000, MAX_H = 1000000000;

int main(int argc, char const *argv[]) {
  long long N, H;
  cin >> N >> H;
  long long int a[MAX_N], b[MAX_N];
  for (long long i = 0; i < N; i++) cin >> a[i] >> b[i];

  sort(a, a+N,greater<long long int>());
  sort(b, b+N,greater<long long int>());

  long long int cnt = 0;

  for (size_t i = 0; i < N and H > 0; i++) {
    if (b[i] < a[0] or H <= 0) break;
    else {
      H -= b[i];
      cnt++;
    }
  }
  if (H > 0) cnt += (H + (a[0] - 1)) / a[0];

  cout << cnt << endl;

  return 0;
}


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

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b<=c || d<=a){
        cout << 0 << endl;
    }else if(a<=c){
        if(b<=d){
            cout << b-c << endl;
        }else{
            cout << d-c << endl;
        }
    }else{
        if(d<=b){
            cout << d-a << endl;
        }else{
            cout << b-a << endl;
        }
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	char p = 0;
	int a = 0;
	rep(i, n) {
		char c; cin >> c;
		if (c == p) continue;
		a++; p = c;
	}
	cout << a << endl;
}

int main() {

	solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f(long long l,long long r){
	l%=2019,r%=2019;
	int ans=1e9;
	int f=min(l,r),e=max(l,r);
	for(int i=l;i<=e;i++){
		for(int j=i+1;j<=e;j++){
		ans=min(ans,i*j%2019);
		}
	
	}
	return ans;
}
int main(){
 
long long l,r;
cin>>l>>r;
long long ans=1;

if((r/2019)!=(l/2019))ans=0;
else ans=f(l,r);
cout<<ans;
 
 
}

Measured memory_bytes: 256
object Main{
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt();
    val k = sc.nextInt();
    val x = sc.nextInt();
    val y = sc.nextInt();

    if(n <= k) {
      println(n * x);
    }
    else {
      println(k * x + (n - k) * y);
    }
  }
}


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

int main(void){
    int i, j, N, A[100], minj, cnt=0;
    cin >> N;
    for (i=0; i<N; i++) cin >> A[i];
    for (i=0; i<N-1; i++){
        minj = i;
        for(j=i+1; j<N; j++){
            if(A[j] < A[minj]){
                minj = j; 
            }
        }
        if(minj!=i){
            cnt++;
            swap(A[i], A[minj]);
        }

    }
    for(i=0; i<N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3092
n = int(input())
A = list(map(int, input().split()))

DP = [[0, 0] for _ in range(n + 1)]
DP[0][1] = -1e20
# print(DP)
for i in range(n):
    for j in [0, 1]:
        DP[i + 1][0] = max(DP[i][0] + A[i], DP[i][1] - A[i])
        DP[i + 1][1] = max(DP[i][0] - A[i], DP[i][1] + A[i])

print(DP[-1][0])

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

int main() {
  int N, A;
  
  cin >> N >> A;
  
  if (N%500 == 0) {
    cout << "Yes" << endl;
  }
    
  else if ( N%500 <= A ) {
    cout << "Yes" << endl;
    }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>

const int N = 100000;

std::vector<int> tree[N];

int dfs(int p, int u)
{
    int ban = 0;
    int k = 0;
    for (auto&& v : tree[u]) {
        if (v != p) {
            int ret = dfs(u, v);
            int high = 31 - (int)__builtin_clz(ban & ret);
            k = std::max(k, high);
            ban |= ret;
        }
    }
    while (ban >> k & 1) {
        k ++;
    }
    return (ban | (1 << k)) & ~((1 << k) - 1);
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("D.in", "r", stdin);
#endif
    int n;
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; ++ i) {
            tree[i].clear();
        }
        for (int i = 1; i < n; ++ i) {
            int a, b;
            scanf("%d%d", &a, &b);
            a --;
            b --;
            tree[a].push_back(b);
            tree[b].push_back(a);
        }
        auto result = dfs(-1, 0);
        printf("%d\n", 31 - __builtin_clz(result));
    }
}

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

using namespace std;

typedef long long ll;

#define MOD 998244353
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}




ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


/*const int N=200000;

ll fac[N+1];
ll inv[N+1];
ll p=998244353;

ll c(ll a, ll b,ll m)
{
  if(a<b)return 0;
  return (fac[a]*inv[b]%m)*(inv[a-b])%m;
}

void fill()
{
inv[0]=1;
fac[0]=1;

for(int i=1;i<=N;i++)
{
  fac[i]=fac[i-1]*i%p;
  inv[i]=powM(fac[i],p-2,p);
}

}
*/
//ld dp[2001][2001];

//ll dp[3001][3001];  // dp[i][j] ways to make sum i using j numbers.


int main()
{  fast

//sum of D and PD.

  string t;cin>>t;

  ll cnt=0;

  for(auto &x:t)if(x=='?')x='D';

    cout<<t<<endl;

/*for(int i=0;i<t.size();i++)
{
  cnt+=(t[i]=='D');
  if(i==t.size())continue;
  else if(t[i]=='P'&&t[i+1]=='D')cnt++;
}

cout<<cnt<<"\n";

*/
 return 0;

}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vei A(N); rep(i,N) { cin >> A[i]; A[i]--; }

    int card[100005];
    memset(card, 0, sizeof(card));

    rep(i,N) card[ A[i] ]++;
    int cnt = 0;
    rep(i,100005) {
        if(card[i] > 1) cnt += card[i] - 1;
    }
    if(cnt % 2 == 1) cnt++;
    cout << N - cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);


			//配列に入力値代入
			//別の配列に代入

			//配列に格納
			int num[] = new int[3];

			for(int i =0;i< 3;i++) {
				num[i] = sc.nextInt();
			}

			int num2[] = new int[3];

			num2[0] = num[2];
			num2[1] = num[0];
			num2[2] = num[1];

			for(int i =0;i<3;i++) {
				System.out.print(num2[i]+" ");
			}




		}
}



Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    string S;
    cin >> S;
    int N=S.size();
    rep(i,N){
        if(i==0 && S.at(i)=='?'){
            S.at(i)='D';
            continue;
        }
        
        if(S.at(i)=='?'){
            if(S.at(i-1)=='P'){
                S.at(i)='D';
            }
            else{
                S.at(i)='D';
            }
        }
    }
    

    cout << S << endl;

    
 
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL c)
{
    return c*c;
}
int main()
{
    while(cin>>n)
    {
        ma.clear();
        for(LL i=1; i<=n; i++)
        {
            LL t;
            cin>>t;
            for(LL j=2; j*j*j<=t; j++)
            {
                while(t%(j*j*j)==0)
                {
                    t/=(j*j*j);
                }
            }
            ma[t]++;
            a[i]=t;
            LL ans=1;
            for (LL j=2; j*j*j<=t; j++)
            {
                if (t%j==0)
                {
                    ans*=(t%(j*j)==0)?j:j*j;
                }
                while (t%j==0) t/=j;
            }
            if (sqr((LL)sqrt(t))==t) ans*=(LL)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        LL ans1=0;
        if(ma[1])
        {
            ans1++;
            ma[1]=0;
        }
        for(int i=1; i<=n; i++)
        {
            ans1+=max(ma[a[i]],ma[b[i]]);
            ma[a[i]]=ma[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}


Measured memory_bytes: 17664
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int k, q, d[5010];
ll csum[5010];
int main() {
	scanf("%d %d", &k, &q);
	for (int i = 0; i < k; i++)
		scanf("%d", d + i);

	for (int i = 0; i < q; i++) {
		int n, x, m;
		scanf("%d %d %d", &n, &x, &m);

		csum[0] = 0;
		for (int i = 1; i <= k; i++)
			csum[i] = csum[i - 1] + (d[i - 1] % m ? d[i - 1] % m : m);
		ll total = (x % m) + ((n - 1) / k) * csum[k] + csum[(n - 1) % k];
		printf("%d\n", (n - 1) - total / m);
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	final static int TIME=1, COST=0;
	static int TYPE;
	static int start;
	static int goal;
	static int V;
	static int E;
	static int request;
	static boolean[] already;
	static Vertex[] v;
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		while(true){
			E=cin.nextInt();
			V=cin.nextInt();
			if(E+V==0){
				return;
			}
			v = new Vertex[V+1];
			
			for(int i = 1; i <= V; i++){
				v[i]=new Vertex(i);
			}
			for(int i = 1; i <= E; i++){
				int a = cin.nextInt();
				int b = cin.nextInt();
				int c = cin.nextInt();
				int t = cin.nextInt();
				v[a].costtime[TIME][b]=t;
				v[b].costtime[TIME][a]=t;
				v[a].costtime[COST][b]=c;
				v[b].costtime[COST][a]=c;
			}
			request = cin.nextInt();
			while(request--!=0){
				already = new boolean[V+1];
				for(int i = 1; i <= V;i++){
					v[i].init();
				}
				start = cin.nextInt();
				goal = cin.nextInt();
				TYPE = cin.nextInt();
				di();
				System.out.println(v[goal].min);	
			}
		}
	}
	static void di(){
		PriorityQueue<Pair> q = new PriorityQueue<Pair>();
		q.add(new Pair(start, 0));
		while(!q.isEmpty()){
			Pair p = q.poll();
			v[p.num].min=p.value;
			already[p.num]=true;
			if(p.num==goal){
				break;
			}
			for(int i = 1; i <= V; i++){
				int val = v[p.num].costtime[TYPE][i];
				if(!already[i] && val!=-1 
						&& val+p.value < v[i].min){
					q.add(new Pair(i, val+p.value));
				}
			}
		}
	}
}
class Pair implements Comparable{
	int num;
	int value;
	Pair(int a, int b){
		num=a;
		value=b;
	}
	public int compareTo(Object o){
		Pair p = (Pair)o;
		return (this.value-p.value);
	}
}
class Vertex{
	int num;
	int min=Integer.MAX_VALUE;
	int costtime[][];
	void init(){
		min=Integer.MAX_VALUE;
	}
	Vertex(int n){
		num=n;
		costtime= new int[2][301];
		for(int i = 0; i < 2; i++){
			for(int j  =0; j < 301; j++){
				costtime[i][j]=-1;
			}
		}
		min=Integer.MAX_VALUE;
	}
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll n;cin>>n;
    vector<ll> v;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)v.push_back(i);
    }
    ll ans=0;
    rep(i,0,v.size()){
        ll u=n/v[i];
        u--;
        if(u>v[i])ans+=u;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    string s=get_str();
    int c=0;
    FOR(i,4){
        c+=(s[i]=='+'?1:-1);
    }
    print(c);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static int[] h;
	static int ans=0,l=0,n;
	static void Main(){
		string s=Console.ReadLine();
		n=int.Parse(s);
		l=s.Length;
		h=new int[l];
		fu(0,1,0);
		Console.WriteLine(ans);
	}
	static void fu(int a,int b,int c){
		if(a==l){
			if(c==7&&n>=int.Parse(String.Join("",h))){ans++;}
		}
		else{
			h[a]=3;fu(a+1,0,c|1);
			h[a]=5;fu(a+1,0,c|2);
			h[a]=7;fu(a+1,0,c|4);
			if(b==1){h[a]=0;fu(a+1,1,c);}
		}
	}
}

Measured memory_bytes: 17360
#include <iostream>
#include <cstdlib>

int main(){
    int N = 0;
    std::cin >> N;
    int plans[N][3];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> plans[i][j];
        }
    }
    bool answer = true;
    int t = plans[0][0];
    int a = plans[0][1];
    int b = plans[0][2];
    
    
    for(int i = 0; i < N; i++){
        if(i != 0){
            t = std::abs(plans[i - 1][0] - t);
            a = std::abs(plans[i - 1][1] - a);
            b = std::abs(plans[i - 1][2] - b);
        }
        int cost = a + b;
        if(!(cost <= t && (cost - t) % 2 == 0)){
            answer = false;
            break;
        }
    }
    if(answer){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }
}

Measured memory_bytes: 1408
N = int(input())
A = [int(i) for i in input().split()]

L = len(A)
total = 0
tmp = 0
mod = 10**9+7
for y in range(L):
    tmp += A[y]

for x in range(L):
    tmp -= A[x] 
    total += tmp*A[x]
print(total % mod)


Measured memory_bytes: 94312
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
 
using namespace std;
 
string toString(int n) {
    ostringstream ss;
    ss << n;
    return ss.str();
}
 
bool check(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return t == s;
}
 
int main() {
    int N;
    cin >> N;
    for(int i = 0; ; i++) {
        string s = toString(N - i);
        if(check(s)) {
            cout << s << endl;
            break;
        }
        s = toString(N + i);
        if(check(s)) {
            cout << s << endl;
            break;
        }
    }
}

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

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

// math
template <class T>
inline T sqr(T x) { return x * x; }

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

// constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

// debug
#define dump(x) cerr << #x << " = " << x << endl;
#define debug(x) cerr << #x << " = " << x << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main(int argc, char const *argv[])
{
    int x1, x2, x3, x4, y1, y2, y3, y4;
    CIN(x1);
    CIN(y1);
    CIN(x2);
    CIN(y2);
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (x2 - x1);
    y4 = y3 - (y2 - y1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
def main():
    N = int(input())
    s = ''
    l = []
    def calc3(s, N, i):
        if len(s) == N:
            l.append(s)
            return
        if len(s) > 0:
            s2 = s[:]
            z = i + 2
            for j in range(z):
                st = s[:]
                st += chr(ord('a')+j)
                if j == i + 1:
                    calc3(st[:], N, i+1)
                else:
                    calc3(st[:], N, i)
        else:
            s += 'a'
            calc3(s[:], N, i)
    calc3(s[:], N, 0)
    l = sorted(set(l))
    for i in l:
        print(i)
main()


Measured memory_bytes: 17552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    const ll d[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    ll ans = 0;
    rep(y, h) {
        rep(x, w) {
            if (s[y][x] == '#') continue;
            vector<vector<ll>> dist(h, vector<ll>(w, inf));
            queue<pair<ll, ll>> q;
            q.push(make_pair(y, x));
            dist[y][x] = 0;
            while(!q.empty()) {
                auto p = q.front(); q.pop();
                rep(i, 4) {
                    ll ny = p.first + d[i][0];
                    ll nx = p.second + d[i][1];
                    ll nd = dist[p.first][p.second] + 1;
                    if ((nx < 0) || (nx >= w) || (ny < 0) || (ny >= h)) continue;
                    if ((s[ny][nx] == '#') || (dist[ny][nx] <= nd)) continue;
                    dist[ny][nx] = nd;
                    q.push(make_pair(ny, nx));
                }
            }
            ll tmp = 0;
            rep(i, h) {
                rep(j, w) {
                    if (dist[i][j] == inf) continue;
                    tmp = max(tmp, dist[i][j]);
                }
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int a, b, c; cin >> a >> b >> c;

    int ans = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        if (a == b && b == c) {
            cout << -1 << endl;
            return 0;
        }
        
        int na = b / 2 + c / 2;
        int nb = a / 2 + c / 2;
        int nc = a / 2 + b / 2;
        a = na;
        b = nb;
        c = nc;

        ans++;

    }

    cout << ans << endl;
}

Measured memory_bytes: 3576
a,b=input().split()
a=int(a)
bb=[0,0]
c=0
for i in b:
    if(i=='.'):
        c=1
        continue
    bb[c]*=10
    bb[c]+=int(i)
res=a*bb[0] + (a*bb[1])//100
print(res)

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

int main() {
  int s;
  int cnt = 0;
  int a, b, c;
  cin >> s;
  a = s / 100;//100の位
  b = ( s - 100 * a )/ 10;//10の位
  c = ( s - 100 * a ) % 10;//1の位
  
  cout << a + b + c << endl;
}

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

using namespace std;
typedef long long int ll;
typedef tuple<int, int, int> P;

const int H = 100, W = 100;
char board[H + 2][W + 2];

int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
char dirs[] = "WNES";

int main(){
	int h, w, sx, sy, x, y, d;
	ll l;
	vector<P> v;
	map<P, ll> m;
	while(cin >> h >> w >> l, h){
		m.clear();
		v.clear();
		memset(board, 0, sizeof(board));
		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j){
				cin >> board[i + 1][j + 1];
				if(board[i + 1][j + 1] != '.' && board[i + 1][j + 1] != '#'){
					sx = j + 1;
					sy = i + 1;
				}
			}
		}
		char *ptr = find(dirs, dirs + 4, board[sy][sx]);
		d = (ptr - dirs);
		P p = make_tuple(sy, sx, d);
		for(ll k = 0;k < l;++k) {
			int nx, ny;
			tie(y, x, d) = p;
			while(board[y + dy[d]][x + dx[d]] == '#' || board[y + dy[d]][x + dx[d]] == 0){
				d = (d + 1) % 4;
			}
			nx = x + dx[d];
			ny = y + dy[d];
			p = make_tuple(ny, nx, d);
			if(m.find(p) != m.end()){
				break;
			}
			m[p] = k;
			v.emplace_back(p);
		}
		if(v.size() == l){
			tie(y, x, d) = p;
		}
		else {
			ll idx = m[p];
			ll loop = v.size() - m[p], left = l - v.size();
			tie(y, x, d) = v[idx + ((left + loop - 1) % loop)];
		}
		cout << y << " " << x << " " << dirs[d] << endl;
	}
	return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll fexp(ll n, ll p) {
	ll ans = 1;
	while (p) {
		if (p & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		p >>= 1;
	}
	return ans % MOD;
}

ll fat(ll n) {
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = (ans * i) % MOD;
	}
	return ans;
}

ll inverse(ll n) {
	return fexp(n, MOD - 2);
}

ll comb(ll n, ll k) {
	if (k < 0 || k > n) return 0;
	ll x = (inverse(fat(k)) * inverse(fat(n - k))) % MOD;
	return (fat(n) * x) % MOD;
}

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

	long long x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << "0\n";
		return 0;
	}
	ll diag = (x + y) / 3;
	long long n = (2 * y - x) / 3;
	long long m = (2 * x - y) / 3;

	cout << comb(diag, x - diag) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  //a=10000000019;
  //b=10000000019;
    ci(a>>b)
  vll A(0);
  ll g=gcd(a,b);
  ll s=sqrt(g)/1+1;
  
  for(ll i=2;i<=s;i++){
    while(g%i==0){
      A.push_back(i);
      g/=i;
    }
  }
  
  ll n=A.sz;
  ll ans=n+1;
  if(g!=1){
    ans++;
  }
  
  FOR(i,1,n){
    if(A[i-1]==A[i]){
      ans--;
    }
  }
  co(ans)
}

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

int mat[3][3];
bool res[3][3];

int main(){
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> mat[i][j];
      res[i][j] = false;
      //cout << mat[i][j] << endl;
    }
  }
  int N;
  cin >> N;
  vector<int> lst(N);
  for (int i = 0; i < N; i++) {
    cin >> lst[i];
    for (int j = 0; j < 3; j++) {
      bool flg = false;
      for (int k = 0; k < 3; k++) {
        if (lst[i] == mat[j][k]) {
          res[j][k] = true;
          //cout << j << ' ' <<  k << endl;
          flg = true;
          break;
        }
      }
      if (flg) {
        break;
      }
    }
  }
  string result;
  if (res[0][0] && res[0][1] && res[0][2]
   || res[1][0] && res[1][1] && res[1][2]
   || res[2][0] && res[2][1] && res[2][2]
   || res[0][0] && res[1][0] && res[2][0]
   || res[0][1] && res[1][1] && res[2][1]
   || res[0][2] && res[1][2] && res[2][2]
   || res[0][0] && res[1][1] && res[2][2]
   || res[0][2] && res[1][1] && res[2][0]) {
    result = "Yes";
  } else {
    result = "No";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n, k  = list(map(int, input().split()))
#n, m = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))

h.sort()
dif_min =max(h)
for i in range(n-k+1):
    dif = h[i+k-1]-h[i]
    #print(str(h[i])+" "+str(h[i+k-1]))
    if dif < dif_min:
        dif_min = dif

print(dif_min)

Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>

using namespace std;

const int kMaxN = 1e5 + 10;

int main(int argc, char const *argv[]) {
  int ans = 0;
  int n, m, p;
  vector<int> v;
  string s;

  cin >> s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <array>
int main(void){
	int x;

		for(int count=1;;count++){
		std::cin >> x;
		if (x == 0){
			break;
		}
		std::cout <<"Case "<<count<<": "<<x<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict


N,K = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
# 先頭からiビット目に1が立っている個数を数え上げる
for a in A:
    for i in range(50):
        if a & (1 << i):
            d[i] += 1
dp = [[-1 for _ in range(2)] for _ in range(51)]
dp[0][0] = 0

# 頭からi桁
for i in range(50):


    # 先頭からi番目の位置の数字
    if K & (1 << (50-i-1)):
        digit = 1
    else:
        digit = 0

    # i桁目に1を選んだ時
    use_1 = (N-d[50-i-1]) * (1 << (50-i-1))
    # i桁目に0を選んだ時
    use_0 = d[50-i-1] * (1 << (50-i-1))

    if K < (1 << (50-i-1)):
        use_1 = 0

    """
    i-1桁までがKより小さい場合、0,1どちらも選択可能
    dp[i][1] == -1 だとそれは起こりえない
    """
    if dp[i][1] != -1:
        dp[i+1][1] =  dp[i][1] + max(use_0, use_1)

    """
    i-1桁まで同じで、i桁目でKより小さくなる場合（Kのi桁目が1で0を選択）
    ここでmax(dp[i+1][1], ～)にしてあげないと、上で決めたものが上書きされてしまう
    """
    if dp[i][0] != -1:
        if digit == 1:
            dp[i+1][1] = max(dp[i+1][1], dp[i][0] + use_0)

    """
    i-1桁まで同じで、i桁目でKとまた一致する場合

    """
    if dp[i][0] != -1:
        if digit == 1:
            dp[i+1][0] = dp[i][0] + use_1
        else:
            dp[i+1][0] = dp[i][0] + use_0

print(max(dp[-1]))


Measured memory_bytes: 68696
#include<iostream>
using namespace std;
#define max 1000000

int h = 0;
int a[max];

void maxheap(int i) {
	int l = i * 2;
	int r = i * 2 + 1;
	int largest;
	if (l <= h && a[l] > a[i]) {
		largest = l;
	}
	else largest = i;
	if (r <= h && a[r] > a[largest]) largest = r;

	if (largest != i) {
		swap(a[i], a[largest]);
		maxheap(largest);
	}
}

int main()
{
	cin >> h;
	for (int i = 1; i < h + 1; i++) {
		cin >> a[i];
	}

	for (int i = h / 2; i > 0; i--) {
		maxheap(i);
	}
	
	for (int i = 1; i < h + 1; i++) {
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4944