akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, K, S;

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

  cin >> N >> K >> S;
  if (S==1e9) {
    rep(i, K) cout << S << ' ';
    rep(i, N-K) cout << 1 << ' ';
  } else {
    rep(i, K) cout << S << ' ';
    rep(i, N-K) cout << S+1 << ' ';
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#define N 10000
#define Q 500
 
int main() {
     
    int i,j,n,q,count=0;
    int S[N],T[Q];
     
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",&S[i]);
    }
     
    scanf("%d",&q);
    for(i=0; i<q; i++) {
        scanf("%d",&T[i]);
        for(j=0; j<n; j++) {
            if(T[i]==S[j]) {
                count++;
                break;
            }
        }
    }
    printf("%d\n",count);
     
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;
ll n, m, s;
ll U[100], V[100], a[100], b[100], c[50], d[50];
vector<ll> edge[50];

ll ans[50][2501];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>s;
	s = min(s, 2500ll);
	for(ll i = 0; i < m; i++){
		cin>>U[i]>>V[i]>>a[i]>>b[i];
		U[i]--;
		V[i]--;
		edge[U[i]].pb(i);
		edge[V[i]].pb(i);
	}
	for(ll i = 0; i < n; i++){
		cin>>c[i]>>d[i];
	}
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j <= 2500; j++){
			ans[i][j] = 1000000000000000000;
		}
	}
	set<pair<ll, pll>> st;
	ans[0][s] = 0;
	st.insert({0, {0, s}});
	while(!st.empty()){
		auto ele = *(st.begin());
		// cout<<ele.second.second<<endl;
		ll u = ele.second.first;
		ll cur = ele.second.second;
		st.erase(st.begin());
		ll incre = d[u];
		for(ll coins = cur + c[u]; ; coins += c[u]){
			coins = min(coins, 2500ll);
			if(ans[u][coins] <= ans[u][cur] + incre){
				break;
			}
			if(st.find({ans[u][coins], {u, coins}}) != st.end()){
				st.erase({ans[u][coins], {u, coins}});
			}
			ans[u][coins] = ans[u][cur] + incre;
			st.insert({ans[u][coins], {u, coins}});
			if(coins >= 2500){
				break;
			}
			incre += d[u];
		}
		for(ll pos : edge[u]){
			ll v;
			if(U[pos] == u){
				v = V[pos];
			}
			else{
				v = U[pos];
			}
			if(cur >= a[pos] && ans[v][cur - a[pos]] > ans[u][cur] + b[pos]){
				if(st.find({ans[v][cur - a[pos]], {v, cur - a[pos]}}) != st.end()){
					st.erase({ans[v][cur - a[pos]], {v, cur - a[pos]}});
				}
				ans[v][cur - a[pos]] = ans[u][cur] + b[pos];
				st.insert({ans[v][cur - a[pos]], {v, cur - a[pos]}});
			}
		}
	}
	for(ll i = 1; i < n; i++){
		ll temp_ans = ans[i][0];
		for(int j = 1; j <= 2500; j++){
			temp_ans = min(temp_ans, ans[i][j]);
		}
		cout<<temp_ans<<endl;
	}
	return 0;
}

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

int main(){
    int A, B, *l;
    int score = 0;

    cin >> A >> B;

    for (size_t i = 0; i < 2; i++)
    {    
        l = (A > B ? &A : &B);
        score += *l;
        (*l)--;       
    }

    cout << score << endl;
    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  if (a == b && b == c && (a % 2) == 0) {
    cout << -1 << endl;
  } else {
    ll result = 0;
    while ((a % 2) != 1 && (b % 2) != 1 && (c % 2) != 1) {
      int tmpA = a;
      int tmpB = b;
      int tmpC = c;
      a = tmpB / 2 + tmpC / 2;
      b = tmpA / 2 + tmpC / 2;
      c = tmpA / 2 + tmpB / 2;
      result++;
    }
    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


while True:

    N,K,M = map(int,input().split())
    if N == 0 and K == 0 and M == 0:
        break

    table = [i for i in range(1,N+1)]

    loc = M-1

    while len(table) > 1:
        table.pop(loc)
        loc = (loc+K-1)%(len(table))

    print("%d"%table[0])



Measured memory_bytes: 14160
#include <stdio.h>
int a[200000];
int b[200000];
    
int main(void){
    int n,i,j,itest;
    scanf("%d",&n);
    //printf("n=%d\n",n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    };
    for(j=0;j<n;j++){
            itest=n-j-j-1;
            if(itest<0) i=j+j-n; else i=itest;
            b[j]=a[i];
            //printf("b[%d]=a[%d]=%d\n",j,i,a[i]);
    };
    printf("%d",b[0]);
    for(j=1;j<n;j++){
        printf(" %d",b[j]);
    };
    return 0;
};

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

#define mp make_pair
#define eb emplace_back
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(m);
  for (int i = 0; i < m; i++) cin >> a[i].x >> a[i].y;

  vector<int> cnt(n, 1);
  vector<int> u(n, 0);
  u[0] = 1;

  for (int i = 0; i < m; i++){
    u[a[i].y - 1] |= u[a[i].x - 1];
    if (cnt[a[i].x - 1] == 1) u[a[i].x - 1] = 0;
    cnt[a[i].x - 1]--;
    cnt[a[i].y - 1]++;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) ans += u[i];
  
  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


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

struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n):rank(n+1,0),parent(n+1){
        rep(i,n+1) parent[i]=i;
    }

    int find(int x){
        if (parent[x] == x) return x;
        else return parent[x] = find(parent[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x==y) return;
        else if(rank[x]<rank[y]) parent[x]=y;
        else{
            parent[y]=x;
            if (rank[x]==rank[y]){
                rank[x]+=1;
            }
        }
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        uf.unite(x,y);
    }
    set<int> s;
    rep(i,n){
        if(s.count(uf.find(i+1))==1) continue;
        s.insert(uf.find(i+1));
        //cout << uf.find(i+1) << endl;
    }

    cout << s.size() << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	rep(i,n) cin >> v[i];
	rep(i,n) cin >> c[i];
	int res = 0;
	rep(i,n){
		if(v[i] > c[i]){
			res += v[i]-c[i];
		}
	}
	cout << res << endl;
	return 0;
}



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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int K, S; cin >> K >> S;

	ll ans = 0;
	rep(x, K+1)rep(y, K+1) {
		int z = S - x - y;
		if (0 <= z && z <= K)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll ans = max({a*c,a*d,b*c,b*d});

	cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int a,b;
    in(a,b);
    if(a>b) out("a > b");
    else if(b>a) out("a < b");
    else out("a == b");
}


Measured memory_bytes: 3120
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int sz = 2e5 + 1;

int n, m;
vector<int> g[sz];
int used[sz];

void dfs(int v, int c) {
	used[v] = c;
	for (int to : g[v]) {
		if (!used[to])
			dfs(to, c);
	}
}

void solve() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int c = 1;
	for (int i = 0; i < n; i++) {
		if (!used[i])
			dfs(i, c++);
	}
	vector<int> cnt(c);
	for (int i = 0; i < n; i++)
		cnt[used[i]]++;
	int ans = 0;
	for (int i = 1; i < c; i++)
		ans = max(ans, cnt[i]);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 24708
#include <iostream>

using namespace std;

int arr[100];

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; i++)
        if (s[i] != s[i - 1]) ans++;
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N, M, C, cnt=0;
    cin >> N >> M >> C;
    vector<int> B(M);

    for(int i=0; i< M; i++){
        cin >> B[i];
    }

    for(int i=0; i< N; i++){
        vector<int> A(M);
        int sum=0;
        for(int j=0; j<M; j++){
            cin >> A[j];
        }
        for(int k=0; k<M; k++){
            sum += A[k]*B[k];
        }

        if((sum+C)>0){
            cnt++;
        }
    }
    cout << cnt;
}

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

#define MAX 2000000
#define AMAX 10000

int main(){
    unsigned short *A,*B;
    
    int C[AMAX + 1];
    int n,i,j;
    scanf("%d",&n);
    
    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    
    for(i = 0;i <= AMAX;i++){
        C[i] = 0;
    }
    
    for(i = 0;i < n;i++){
        scanf("%hu",&A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for(i = 1;i <= AMAX;i++){
        C[i] = C[i] + C[i - 1];
    }
    
    for(j = 1;j <= n;j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for(i = 1;i <= n;i++){
        if(i > 1){
            printf(" ");
        }
        printf("%d",B[i]);
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 9680
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    List<Integer> numbers = new ArrayList<Integer>();
    for (int i = 0; i < N; ++i) {
      numbers.add(scanner.nextInt());
    }

    int temp, count = 0;
    for (int i = 0; i + 1 < N; ++i) {
      for (int j = 0; j + 1 < N - i; ++j) {
        if (numbers.get(j) > numbers.get(j + 1)) {
          temp = numbers.get(j + 1);
          numbers.set(j + 1, numbers.get(j));
          numbers.set(j, temp);
          ++count;
        }
      }
    }

    if (N == 0) count = 1;

    for (int i = 0; i < N - 1; ++i) System.out.print(numbers.get(i) + " ");
    System.out.println(numbers.get(N - 1) + "\n" + count);
  }
}


Measured memory_bytes: 26528
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int min=0;
  for(int i=0;i<n;i++){
    if(a[i]==min+1)min=a[i];
  }
  if(min==0){
    printf("-1");
    return 0;
  }
  printf("%d",n-min);
  return 0;
}

Measured memory_bytes: 896
import math

n, d = map(int, input().split())
a = []
for i in range(n):
  a.append(list(map(int, input().split())))

b = 0
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(d):
      b+= (a[i][k] - a[j][k])**2
      
    b= math.sqrt(b)
    
    if b%1==0:
      ans += 1
    b = 0
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(void)
{
	LL n,a,b; scanf("%lld%lld%lld",&n,&a,&b);
	LL x=n%(a+b);
	LL res=n/(a+b)*a;
	if(x>a) res+=a;
	else res+=x;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
#Xは高々40bitぶんくらい
c = [0] * 40
#Aの各要素について、i番目のbitはいくつ立っているか
for i in range(40):
  for a in A:
    c[i] += (a >> i) & 1
#print(c)
X = 0
res = 0
for i in range(39, -1, -1):
  #i番目のbitを立てようとする。立てる時にXがKを超えないなら続ける
  #N - c[i]とc[i]の大小関係を考える
  #i番目のbitに関して、立っている値が半分より多いなら、Xでそのbitを立てるのは不利益
  #逆ならfへの貢献は大きい
  #c[i] < N - c[i]の時、立っていないものの方が多いので、Xでi番目のbitは立てておく
  #違うなら立てない
  if c[i] < N - c[i] and X + (1 << i) <= K:
    X += (1 << i)
    res += (N - c[i]) * (1 << i)
  else:
    res += (c[i]) * (1 << i)

print(res)

Measured memory_bytes: 14620
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

const int RED = 1, BLUE = -1;

int query(vector<int> &q) {
    cout << "?";
    for(int x : q) cout << " " << x + 1;
    cout << endl;
    string ans;
    cin >> ans;
    return ans == "Red" ? RED : BLUE;
}

int main() {
    int N;
    cin >> N;
    vector<int> v(N), u1(N - 1), u2(N - 1), ans(2 * N);
    int L, R;

    for (int j = 0; j < N; j++) v[j] = j;
    L = query(v);
    R = -L;

    if(N == 1) {
        cout << "! " << (L == RED ? "RB" : "BR") << endl;
        return 0;
    }

    // query logN times 
    int i = BinSearch<int>(-1, N, [&](int k) {
        for(int j = 0; j < N; j++) v[j] = j + k;
        return query(v) == R;
    });
    for(int j = 0; j < N; j++) {
        u1[j] = i + j;
        u2[j] = (i + N + j) % (2 * N);
    }
    // query 2N times
    for(int k = 0; k < 2 * N; k++) {
        for (int j = 0; j < N - 1; j++) {
            v[j] = (i <= k && k < i + N) ? u2[j] : u1[j];
        }
        v[N - 1] = k;
        ans[k] = query(v);
    }
    cout << "! ";
    for(int x : ans) cout << (x == RED ? "R" : "B");
    cout << endl;
    return 0;
}



Measured memory_bytes: 724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private final int N;
    private final int[] p;

    public Main() {
	N = Integer.parseInt(scan.next());
	p = new int[N];
	for (int i = 0; i < N; i++) {
	    p[i] = Integer.parseInt(scan.next()) - 1;
	}

	scan.close();
    }

    public final void answer() {
	boolean continuous = false;
	List<Integer> list = new ArrayList<Integer>();
	int count = 0;
	for (int i = 0; i < N; i++) {
	    if(p[i] == i) {
		if(continuous) {
		    count++;
		} else {
		    count = 1;
		    continuous = true;
		}
	    } else {
		if(continuous) {
		    list.add(count);
		    continuous = false;
		    count = 0;
		}
	    }
	}
	if(count > 0) list.add(count);

	int ans = 0;
	for(Integer n: list) {
	    ans += n/2;
	    if(n%2 != 0) ans++;
	}

	System.out.println(ans);
    }
}


Measured memory_bytes: 49056
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


signed main() {
	int a,b;
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;
	}else {
		cout<<b-a<<endl;
	}
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
$a = explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));

$avg = array_sum($a)/count($a);
$m = 1000;
foreach($a as $k=>$v) {
   $m = min(abs($v - $avg),$m);
}
foreach($a as $k=>$v) {
  if ($m == abs($v - $avg)) {
    printf("%d\n",$k);
    exit;
  }
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

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

	ll N,M;
	cin >> N >> M;
	if (M>=2*N) {
		ll ch=(M-2*N)/4;
		N+=ch;
		M-=2*ch;
	}

	cout << min(N,M/2) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

B = [0] * N

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

ans = 0

for i in range(N):
	ans += (B[i] * (B[i] - 1)) // 2

for i in range(N):
	res = ans
	res -= (B[A[i]-1] * (B[A[i]-1] - 1)) // 2
	if B[A[i]-1] >= 1:
		res += ((B[A[i]-1] - 1) * (B[A[i]-1] - 2)) // 2
	print(res)

Measured memory_bytes: 81868
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long LL;
const int maxn=20;
LL dp[maxn][maxn];
vector<int> res;
void dfs(int pos,int x,int k)
{
	if(pos==0) return ;
	res.push_back(x);
	if(k<=dp[pos-1][x-1])
	{
		dfs(pos-1,x-1,k);
	}
	else if(k<=dp[pos-1][x-1]+dp[pos-1][x])
	{
		dfs(pos-1,x,k-dp[pos-1][x-1]);
	}
	else
	{
		dfs(pos-1,x+1,k-dp[pos-1][x-1]-dp[pos-1][x]);
	} 
	
}



int main(void)
{
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=9;i++) dp[1][i]=1;
	for(int i=2;i<=18;i++)
	{
		for(int j=0;j<=9;j++)
		{
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j]+dp[i-1][j+1];
		}
	}
	int k; scanf("%d",&k);
	int p1,p2;
	for(int i=1;i<=18;i++)
	{
		bool flag=false;
		for(int j=1;j<=9;j++)
		{
			if(k<=dp[i][j])
			{
				p1=i; p2=j;
				flag=true;
				break;
			}
			k-=dp[i][j];
		}
		if(flag) break;
	}
	dfs(p1,p2,k);
	for(int v:res) printf("%d",v);
	printf("\n");
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s,t;
  cin >> s >> t;
  ll cnt=0;
  ll n=s.size();
  for(ll i=0;i<n;i++) {
    if(s[i]!=t[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3860
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;

char s[10];

int main(){
    int i;
    long long x=1;
    for(i=1;i<=11;i++,x*=10){
        printf("? %lld\n",x);fflush(stdout);
        scanf("%s",s+1);
        if(s[1]=='N')break;
    }if(i>11){
        for(i=1,x=10;i<=11;i++,x*=10){
            printf("? %lld\n",x-1);fflush(stdout);
            scanf("%s",s+1);
            if(s[1]=='Y')break;
        }printf("! %lld\n",x/10);return 0;
    }
    long long l=x-1,r=x*10-1;
    while(l+1<r){
        long long mid=(l+r)>>1;
        printf("? %lld\n",mid);
        fflush(stdout);
        scanf("%s",s+1);
        if(s[1]=='N')l=mid;
        else r=mid;
    }printf("! %lld\n",r/10);
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 680
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        int x = scanner.nextInt();
        int n = scanner.nextInt();
        List<Integer> inputList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            inputList.add(scanner.nextInt());
        }
        // N = 0 の場合
        if (n == 0) {
            System.out.println(x);
            return;
        }
        int min = 999;
        for (int i = 0; i <= 150; i++) {
            if (!inputList.contains(x - i)) {
                min = x - i;
                break;
            }
            if (!inputList.contains(x + i)) {
                min = x + i;
                break;
            }
        }
        System.out.println(min);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 32548
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    reps(j, i+1, n) {
      if(llabs(a[i]-a[j])%(n-1) == 0) {
	cout << a[i] << " " << a[j] << endl;
	return 0;
      }
    }
  }


  return 0;
}



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

using namespace std;

typedef long long LL;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 mrand(random_device{}());

#define rep(i , l , r) for (int i = (l); i < (r); ++i)

const int N = 5e5 + 5;
const int mod = 998244353;

int n , m , mx , mn;
int cm[N] , cn[N] , fac[N] , ifac[N];

template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void read(T &x) {
   T f = 1; x = 0;
   char c = getchar();
   for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
   for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
   x *= f;
}

inline void inc(int &x , int y) {
	x = x + y < mod ? x + y : x + y - mod;
}
inline void dec(int &x , int y) {
	x = x - y >= 0 ? x - y : x - y + mod;
}
inline int binom(int n , int m) {
	if (n < m) return 0;
	else return 1LL * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
inline int quickpow(int a , int n) {
	int res = 1;
	for (; n; n >>= 1 , a = 1LL * a * a % mod)
		if (n & 1) res = 1LL * res * a % mod;
	return res;
}
int main() {
   	
   	read(n); read(m); mx = max(m , n); mn = min(m , n);
   	fac[0] = 1;
   	for (int i = 1; i <= mx; ++i) fac[i] = 1LL * fac[i - 1] * i % mod;
   	ifac[mx] = quickpow(fac[mx] , mod - 2);
   	for (int i = mx - 1; i >= 0; --i) ifac[i] = 1LL * ifac[i + 1] * (i + 1) % mod;
   	cm[0] = cn[0] = 1;
   	for (int i = 1; i <= mx; ++i) cm[i] = 1LL * cm[i - 1] * (m + 1) % mod;
   	for (int i = 1; i <= mx; ++i) cn[i] = 1LL * cn[i - 1] * (n + 1) % mod;
   	int ans = 0;
   	for (int i = 0; i <= mn; ++i) {
   		int val = 1LL * binom(n , i) * binom(m , i) % mod * cm[n - i] % mod * cn[m - i] % mod * fac[i] % mod;
   		if (i & 1) dec(ans , val); else inc(ans , val);	
	}
	printf("%d\n" , ans);
    return 0;
}


Measured memory_bytes: 11524
import math

LI = lambda : list(map(int, input().split()))
N, D = LI()
X = [LI() for _ in range(N)]

count = 0

for i in range(N-1):
    for j in range(i+1, N):

        sum = 0
        for d in range(D):
            sum += (X[i][d] - X[j][d]) ** 2

        if int(math.sqrt(sum)) ** 2 == sum:
            count += 1
            
print(count)

Measured memory_bytes: 3064
# 167 A

s = input()
t = input()
cnd = True

if len(s) + 1 == len(t):   
    for i in range(len(s)):
        if s[i] != t[i]:
            cnd = False
    if cnd == True:
       print("Yes")    
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 9064
/////////////////////////////////////////
////////// ^\/^ *_* :) :-D '~' \\\\\\\\\\
/////////////////////////////////////////
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m;
pii a[100010];

int main()
{
	cin>>n>>m;
	rep(i,m) cin>>a[i].fi>>a[i].se;
	sort(a,a+m);
	int ans=1;
	int last=1e9;
	rep(i,m)
	{
		last=min(last,a[i].se);
		if(a[i].fi>=last)
		{
			ans++;
			last=a[i].se;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  vector<int> stu; 
  for(int i=1; i<=30; i++) { 
    stu.push_back(i); 
  }   
  for(int i=0; i<28; i++) { 
    int x;  
    cin >> x;  
    stu.erase(find(stu.begin(), stu.end(), x));
  }  
  for(vector<int>::iterator it=stu.begin(); it!=stu.end(); it++) {   
    cout << *it << endl;  
  } 
  return 0;
}


Measured memory_bytes: 1216
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string str;
    cin >> str;

    for (int i = 0; i < str.size() / 2; i++) {
        if (str[i] != str[str.size() - i - 1]) {
            cout << "No\n";
            return 0;
        }
    }

    for (int i = 0; i < str.size() / 4; i++) {
        if (str[i] != str[(str.size() / 2) - i - 1]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
X = INT()
ans = X//500*1000

X = X%500
ans += X//5*5

print(ans)

Measured memory_bytes: 5396
N = int(input())
a = list(map(int, input().split()))

even4, even, odd = 0, 0, 0
for i in a:
    if i % 4 == 0:
        even4 += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1

if N % 2 == 0:
    if even4 >= odd:
        print("Yes")
    else:
        print("No")
else:
    if even4 >= odd - 1:
        print("Yes")
    else:
        print("No")


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    vector<int> a(m), b(m);
    vector<int> goodornot(n,1);
    rep(i,m) {
        cin >> a[i] >> b[i];
        if (h[a[i]-1] > h[b[i]-1]) {
            goodornot[b[i]-1] = 0;
        } else if (h[a[i]-1] < h[b[i]-1]) {
            goodornot[a[i]-1] = 0;
        } else {
            goodornot[a[i]-1] = 0;
            goodornot[b[i]-1] = 0;
        }
    }

    int goodnum=0;
    goodnum = accumulate(goodornot.begin(), goodornot.end(), 0);

    cout << goodnum << endl;

    return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>
const int N=3e3+10;
int main(){
  int n;
  double dp[N][N],p,ans=0;
  scanf("%d",&n);
  for(int i=0;i<=n;i++)dp[0][i]=0;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
  	scanf("%lf",&p);
    dp[i][0]=dp[i-1][0]*(1-p);
    for(int j=1;j<=n;j++)dp[i][j]=dp[i-1][j]*(1-p)+dp[i-1][j-1]*p;
  }
  for(int i=(n>>1)+1;i<=n;i++)ans+=dp[n][i];
  printf("%.20lf\n",ans);
}

Measured memory_bytes: 70912
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int n; cin >> n;
	auto ts = vector<int>(n);
	int left = 0;
	int right = 0;
	for (int i = 0; i < n; i++) {
		cin >> ts[i];
		right += ts[i];
	}
	int min_sub = right;
	for (size_t i = 0; i < n; i++) {
		left += ts[i];
		right -= ts[i];
		min_sub = min(min_sub, abs(right - left));
	}
	cout << min_sub << endl;
}


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

int main(){
    int n,x[1000],y[1000];
    cin >> n;
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<n;i++) cin >> y[i];

    double d1,d2,d3,d4;
    for(int i=0;i<n;i++){
        d1 += fabs(x[i]-y[i]);
        d2 += fabs((x[i]-y[i])*(x[i]-y[i]));
        d3 += fabs(pow(x[i]-y[i],3));
        d4 = (d4<fabs(x[i]-y[i]))?fabs(x[i]-y[i]):d4;
        
    }
    
    printf("%f\n%f\n%f\n%f\n",d1,sqrt(d2),pow(d3,1.0/3.0),d4);
}


Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if (x<1000) puts("ABC");
  else puts("ABD");
  //system("pause");
  return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int N;
vvi es;
vb vis;
void dfs(int n) {
    if (n >= N) return;
    vis[n] = true;
    for (int nx : es[n]){
        if (vis[nx]) continue;
        dfs(nx);
    }
}

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

    int M;  cin >> N >> M;
    vi X(M), Y(M), Z(M);
    REP(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--; Y[i]--;
    }

    es = vvi(N);
    REP(i,M) {
        es[X[i]].push_back(Y[i]);
        es[Y[i]].push_back(X[i]);
    }

    vis = vb(N, false);
    int ans = 0;
    REP(i,N) {
        if (vis[i]) continue;

        dfs(i);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9984
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int a = arr[0];
    int b = arr[1];
    int c = arr[2];
    int d = arr[3];
    var L = Math.Max(a, c);
    var r = Math.Min(b, d);
    Console.WriteLine(L <= r ? r - L : 0);
  }
}

Measured memory_bytes: 13268
#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 1e9
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 m,d;
    cin>>m>>d;
    ll cnt=0;
    for (int i = 1; i <=m; i++)
    {
        for (int j = 10; j <= d; j++)
        {
            int d_1=j%10;
            int d_10=j/10;
            if(d_1>=2  && d_10>=2 && d_1*d_10==i) cnt++;
        }
        
    }
    cout<<cnt<<endl;    

    return 0;
}

Measured memory_bytes: 256
# 初期入力
import sys
input = sys.stdin.readline
a =[]
for i in range(5):
    x = int(input())
    x2 =x %10
    x3 =x
    #10分刻みにする
    x /= 10 
    if not x.is_integer():
        x=int(x)*10 +10
    else:
        x =int(x)*10
    if x2 ==0:
        x2 =10
    a.append((x2,x,x3))
a.sort(reverse=True)
ans =0
for i in range(4):
    ans +=a[i][1]
ans +=a[4][2]
print(ans)

Measured memory_bytes: 9084
# main関数
if __name__ == '__main__':

    n, m = map(int,input().split())

    if abs( n - m ) > 1 :
        print(0);
    else:
        ans = 1
        for i in range(1, n+1) :
            ans *= i
            ans %= 1000000007

        for i in range(1, m+1) :
            ans *= i
            ans %= 1000000007
        
        if n == m :
            ans *= 2
            ans %= 1000000007
        
        print(ans)


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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Train
        {
            public readonly int c;
            public readonly int s;
            public readonly int f;
            public Train(int[] args)
            {
                c = args[0];
                s = args[1];
                f = args[2];
            }
            public int Calculate(int t)
            {
                return Math.Max((t + f - 1) / f * f, s) + c;
            }
        }
        static IEnumerable<int> Solve(int N, Train[] trains)
        {
            int[] t = new int[N];
            for (int i = 0; i < N - 1; ++i)
            {
                for (int j = 0; j < N; ++j)
                {
                    if (j <= i) { t[j] = trains[i].Calculate(t[j]); }
                }
            }
            return t;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var trains = new Train[N];
            for (int i = 0; i < N - 1; ++i) { trains[i] = new Train(ReadInts()); }
            foreach (int t in Solve(N, trains))
            {
                Console.WriteLine(t);
            }
        }
    }
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var K_S = Console.ReadLine().Split(' ').Select(x => int.Parse(x.ToString())).ToArray();
            var K = K_S[1];
            var S = K_S[0];
            int counter = 0;


            for (int i = 0; i <= S; i++)
            {
                for (int j = 0; j <= S - i; j++)
                {
                    int k = S - i - j;

                    if (i * 10000 + j * 5000 + k * 1000 == K)
                    {
                        Console.WriteLine("{0} {1} {2}", i, j, k);
                        Console.ReadKey();
                        return;
                    }
                }
            }
            Console.WriteLine("{0} {1} {2}", -1, -1, -1);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vector<unordered_map<int, int>> g(n);
    rep(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        g[u][v] = w;
        g[v][u] = w;
    }

    vec res(n, -1);
    res[0] = 0;

    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int v1 = que.front();
        que.pop();

        for (auto&& p : g[v1]) {
            int v2 = p.first;
            if (res[v2] == -1) {
                int w = g[v1][v2];
                if (w % 2 == 0) res[v2] = res[v1];
                else res[v2] = (res[v1]+1) % 2;
                que.push(v2);
            }
        }
    }

    rep(i, n) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 16768
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int Maxn=1e5;
const int INF=0x3f3f3f3f;
struct Edge {
	int to,cost;
	Edge(int a,int b){to=a,cost=b;}
};
vector<Edge> G[8*Maxn+5];
void AddEdge(int u,int v,int w) {
	G[u].push_back(Edge(v,w));
	G[v].push_back(Edge(u,w));
}

int dist[8*Maxn+5];
bool vis[8*Maxn+5];
void SPFA(int s) {
	memset(dist,0x3f,sizeof dist);
	memset(vis,false,sizeof vis);
	queue<int> q;
	
	q.push(s);
	vis[s]=true,dist[s]=0;
	
	while(!q.empty()) {
		int u=q.front();
		q.pop();vis[u]=false;
		
		for(int i=0;i<G[u].size();i++) {
			int v=G[u][i].to,w=G[u][i].cost;
			if(dist[v]>dist[u]+w) {
				dist[v]=dist[u]+w;
				if(!vis[v]) {
					vis[v]=true;
					q.push(v);
				}
			}
		}
	}
}

map<pair<int,int>,int> P;
int cnt;
int Getid(int u,int c) {
	if(P.find(make_pair(u,c))!=P.end())
		return P[make_pair(u,c)];
	return P[make_pair(u,c)]=++cnt;
}

int N,M;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&M);
	cnt=N;
	for(int i=1;i<=M;i++) {
		int u,v,c;
		scanf("%d %d %d",&u,&v,&c);
		int t1=Getid(u,c);
		int t2=Getid(v,c);
		AddEdge(t1,t2,0);
		AddEdge(u,t1,1);
		AddEdge(v,t2,1);
	}
	SPFA(1);
	if(dist[N]==INF)puts("-1");
	else printf("%d\n",dist[N]/2);
	return 0;
}

Measured memory_bytes: 66432