akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>


#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  string s, t;
  cin >> s >> t;

  if(s.size() < t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  int flag = 100;
  for(int i = 0; i < s.size() - t.size() + 1; i++) {
    for(int j = i; j - i < t.size(); j++) {
      if(s[j] == t[j - i] || s[j] == '?') {
        if(j-i == t.size() -1) {
          flag = i;
        }
      } else {
        break;
      }
    }
  }

  if(flag != 100) {
    string ans = "";
    for(int i = 0; i < s.size(); i++) {
      if(s[i] == '?' && i != flag) {
        ans += "a";
      } else if(i == flag) {
        ans += t;
        i += t.size() - 1;
      } else {
        ans += s[i];
      }
    }
    cout << ans << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

}


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

using namespace std;

int  N, K;

int calc(vector<int> &V){
  int ans = 1;
  for(int i = 0; i < N; i++){
    if(V[i] == 0) ans *= 2;
    else if(V[i] == 1) ans += K;
  }
  return ans;
}


int dfs(int depth, vector<int> &V){
  if(depth == N) return calc(V);
  else{
    V[depth] = 0;
    int a = dfs(depth + 1, V);
    V[depth] = 1;
    int b = dfs(depth + 1, V);
    return min(a,b);
  }
}

int main(){
  cin >> N >> K;
  
  vector<int> A(N,0);
  //0 := 2* 1:= +K;
  cout << dfs(0, A);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int ans,n;
int num[100105],x;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		num[x]++;num[x-1]++;
		num[x+1]++;
		ans=max(ans,num[x]);
		ans=max(ans,num[x-1]);
		ans=max(ans,num[x+1]);
	}
	printf("%d",ans);
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s; int n; cin >> n>> s;
    int cnt = 0;
    for(int i = 0; i < n - 2; ++i) {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    } 
    cout << cnt << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();

		if(b<a) {
			System.out.println(a-1);
		}
		else {
			System.out.println(a);
		}

		sc1.close();
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[][] field = new String[h + 2][w + 2];
		for (int i = 0; i < h; i++) {
			String[] line = sc.next().split("");
			for (int j = 0; j < w; j++) {
				field[i + 1][j + 1] = line[j];
			}
		}
		sc.close();

		for (int i = 0; i < h + 2; i++) {
			for (int j = 0 ; j < w + 2; j++) {
				if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
					field[i][j] = ".";
				}
			}
		}

		for (int i = 0; i < h + 2; i++) {
			for (int j = 0; j < w + 2; j++) {
				if (i == 0 || i == h + 1) {
					continue;
				} else if (j == 0 || j == w + 1) {
					continue;
				} else if (field[i][j].equals("#")) {
					System.out.print("#");
				} else {
					int count = 0;
					for (int row = i - 1; row <= i + 1; row++) {
						for (int col = j - 1; col <= j + 1; col++) {
							if (field[row][col].equals("#")) {
								count++;
							}
						}
					}
					System.out.print(String.valueOf(count));
				}
			}
			if (i != 0 && i != h + 1) System.out.println();
		}
	}
}

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

using P = pair<int, int>;

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

vector<vector<int>> bfs(P p, vector<string> const& v) {
    const int H = v.size();
    const int W = v[0].size();
    vector<vector<int>> d(H, vector<int>(W, INF));
    d[p.first][p.second] = 0;
    queue<P> que;
    que.push(p);
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        for(int i=0; i<4; ++i) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(ny < 0 || H <= ny || nx < 0 || W <= nx || v[ny][nx] == 'x' || d[ny][nx] != INF) {
                continue;
            }
            d[ny][nx] = d[p.first][p.second] + 1;
            que.push(make_pair(ny, nx));
        }
    }
    return d;
}

int main() {
    int w, h;
    while(cin >> w >> h, w) {
        vector<string> v(h);
        int sy, sx;
        vector<P> dirty;
        for(int i=0; i<h; ++i) {
            cin >> v[i];
            for(int j=0; j<w; ++j) {
                if(v[i][j] == '*') {
                    dirty.emplace_back(i, j);
                }
                if(v[i][j] == 'o') {
                    sy = i;
                    sx = j;
                }
            }
        }
        vector<vector<vector<vector<int>>>> d(h, vector<vector<vector<int>>>(w));
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                d[i][j] = bfs(make_pair(i, j), v);
            }
        }
        sort(dirty.begin(), dirty.end());
        int res = INF;
        do {
            int t = 0;
            if(d[sy][sx][dirty[0].first][dirty[0].second] == INF) {
                continue;
            }
            t += d[sy][sx][dirty[0].first][dirty[0].second];
            for(int i=0; i<dirty.size()-1; ++i) {
                if(d[dirty[i].first][dirty[i].second][dirty[i+1].first][dirty[i+1].second] == INF) {
                    t = INF;
                    break;
                } else {
                    t += d[dirty[i].first][dirty[i].second][dirty[i+1].first][dirty[i+1].second];
                }
            }
            res = min(res, t);
        } while(next_permutation(dirty.begin(), dirty.end()));

        if(res == INF) {
            cout << -1 << endl;
        } else {
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3928
n,m=map(int,input().split())

city_inf=[]

for i in range(m):
	array=[i]
	array.extend(list(map(int,input().split())))
	city_inf.append(array)

#sort by year
city_inf.sort(key=lambda x:x[2])

#make a dictionary,order in each Prefecture
order_counter={}

#fill in dictionary and append their order in their Prefecture
for list in city_inf:
	if list[1] in order_counter.keys():
		order_counter[list[1]]+=1
		list.append(order_counter[list[1]])
	else:
		order_counter[list[1]]=1
		list.append(1)

#sort by index
city_inf.sort(key=lambda x:x[0])

#append their number
zero_p=""
zero_y=""

for list in city_inf:
	zero_p="0"*(6-len(str(list[1])))
	zero_y="0"*(6-len(str(list[3])))
	list.append(zero_p+str(list[1])+zero_y+str(list[3]))
	print(list[4])

Measured memory_bytes: 45784
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing


int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	if(s[n - 1] == '1' || s[0] != '1') {
		cout << -1;
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		if(s[i] != s[n - i - 2]) {
			cout << -1;
			return 0;
		}
	}
	pair <int, int> p[n];
	int x = 0, c = 0;
	for (int i = 1; i < n; i++) {
		if(s[i] == '1') {
			int t = i - x + 1;
			while(t--) {
				p[c++] = {x + 1, x + 1 + t + 1};
			}
			x = i + 1;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		cout << p[i].ff << " " << p[i].ss << "\n";
	}
}


Measured memory_bytes: 2432
import math


def combination_count(n, r):
    if n - r < 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

blue = K
red = N - K

num = 10 ** 9 + 7

for k in range(K):
    space_comb = combination_count(red + 1, k + 1)

    ball_comb = combination_count(K - 1, k)

    print((space_comb * ball_comb) % num)


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<(T)>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

const int kMax = 680000;
int fac[kMax], finv[kMax], inv[kMax];
int d = 1'000'000'007;

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

	REP2(i, 2, kMax) {
		fac[i] = fac[i - 1] * i % d;
		inv[i] = d - inv[d % i] * (d / i) % d;
		finv[i] = finv[i - 1] * inv[i] % d;
	}
}

int COM(int n, int k){
	if (n < k) {
		return 0;
	}
	if (n < 0 || k < 0) {
		return 0;
	}
	return fac[n] * (finv[k] * finv[n - k] % d) % d;
}

itn main() {
	ios::sync_with_stdio(false);

	int x, y;

	cin >> x >> y;

	if (x * 2 < y || x > y * 2) {
		cout << 0;
		return 0;
	}
	if (x * 2 == y || x == y * 2) {
		cout << 1;
		return 0;
	}

	if ((x + y) % 3) {
		cout << 0;
		return 0;
	}

	int n, m;

	n = (-x + 2 * y) / 3;
	m = (2 * x - y) / 3;

	COMinit();

	cout << COM(n + m, n);

	return 0;
}


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

int main() {
    int x;
    int count=0;
    cin >> x;
    while(x != 0){
        count += x%10;
        x /= 10;
    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
def main():
    N,M = map(int,input().split())
    array = list(map(int,input().split()))
    array.sort(reverse=True)
    all = sum(array)
    for i in range(M):
        if(array[i] < all/(4*M)):
            print("No")
            return 0
    print("Yes")
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#define md double
#define LL long long
using namespace std;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int head[N],nxt[N],w[N],tot;
struct E{ int u,v,w; bool operator < (const E &b) const { return w<b.w; } }e[N];
inline void add(int k,int _w) { w[++tot]=_w,nxt[tot]=head[k],head[k]=tot; }
int fa[N];inline int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
int main() {
	int n=gi(),m=gi(),i,a,b,c,k,t;LL ans=0;
	for (i=1;i<=m;i++) {
		a=gi(),b=gi(),c=gi();
		add(a,c+1);
		add(b,c+2);
		e[i]=(E){a,b,c};
		if (a) add(0,c+1+((n-a)<<1));
		if (b) add(0,c+2+((n-b)<<1));
	}
	for (k=0,t=1<<30;k<n;k++,t+=2) {
		for (i=head[k];i;i=nxt[i]) t=min(t,w[i]);
		e[++m]=(E){k,k+1==n?0:k+1,t};
	}
	sort(e+1,e+1+m);
	for (i=0;i<n;i++) fa[i]=i;
	for (i=1;i<=m;i++)
		if (find(e[i].u)!=find(e[i].v)) {
			ans+=e[i].w;
			fa[fa[e[i].u]]=e[i].v;
		}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 21376
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>

template<typename T>
struct SegmentTree {
	using value_type = T;
	using const_reference = const value_type &;
	using F = std::function<value_type(const_reference, const_reference)>;
	using size_type = std::size_t;
	
private:
	size_type n, n_;
	value_type id_elem;
	F f;
	std::vector<value_type> node;
	
public:
	SegmentTree(size_type n, const_reference id_elem, const F & f) : n(n), id_elem(id_elem), f(f) {
		n_ = 1;
		while (n_ < n) n_ <<= 1;
		node.resize(2 * n_, id_elem);
	}
	
	SegmentTree(std::vector<value_type> v, const_reference id_elem, const F & f) :
			SegmentTree(v.size(), id_elem, f) {
		for (size_type i = 0; i < v.size(); ++i) node[i + n_] = v[i];
		for (size_type i = n_ - 1; i > 0; --i) node[i] = f(node[i << 1], node[i << 1 | 1]);
	}
	
	size_type size() const noexcept {
		return n;
	}
	
	void set(size_type i, const_reference x) {
		assert(i < size());
		node[i += n_] = x;
		while (i > 1) {
			i >>= 1;
			node[i] = f(node[i << 1], node[i << 1 | 1]);
		}
	}
	
	const_reference get(size_type i) const {
		assert(i < size());
		return node[i + n_];
	}
	
	value_type fold(size_type l, size_type r) const {
		assert(l <= r);
		assert(r <= size());
		value_type lv = id_elem, rv = id_elem;
		for (l += n_, r += n_; l < r; l >>= 1, r >>= 1) {
			if (l & 1) lv = f(lv, node[l++]);
			if (r & 1) rv = f(node[r - 1], rv);
		}
		return f(lv, rv);
	}
	
	const_reference fold_all() const {
		return node[1];
	}
	
	size_type max_right(size_type l, std::function<bool(const_reference)> g) const {
		assert(l < size());
		l += n_;
		
		value_type sum = id_elem;
		while (true) {
			while (~l & 1) l >>= 1;
			const value_type nex_sum = f(sum, node[l]);
			if (g(nex_sum)) { sum = nex_sum; ++l; }
			else break;
			if ((l & -l) == l) return size();
		}
		
		while (l < n_) {
			const value_type nex_sum = f(sum, node[l << 1]);
			l <<= 1;
			if (g(nex_sum)) { sum = nex_sum; l |= 1; }
		}
		
		return l - n_;
	}
};

#include <cstdio>
#include <vector>

int INF = 1'000'000'001;

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	
	std::vector<int> A(N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	
	SegmentTree<int> seg(A, -INF, [](int a, int b) { return a < b ? b : a; });
	
	while (Q--) {
		int t, a, b;
		scanf("%d %d %d", &t, &a, &b); --a;
		if (t == 1) seg.set(a, b);
		else if (t == 2) printf("%d\n", seg.fold(a, b));
		else printf("%d\n", seg.max_right(a, [b](int x) { return x < b; }) + 1);
	}
	return 0;
}


Measured memory_bytes: 6464
while True:
    try:
        n = int(raw_input())
        cnt = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if n == a+b+c+d:
                            cnt+=1
        print cnt
    except:
        break    


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

//Constants
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;

//MACROS
#define pb push_back
#define fi first
#define se second
#define rep(i, begin, end) for (int i = (begin); i < (end); i++)
#define per(i, begin, end) for (int i = (begin) - 1; i >= (end); i--)
typedef long long LL;
typedef pair <int,int> PII;

int a[1<<20], n, L;

int main() {
    int it = -1;
    cin >> n >> L;
    rep(i,0,n) cin >> a[i];
    rep(i,0,n-1) if (a[i] + a[i+1] >= L) { it = i + 1; break; }
    if (it == -1) { cout << "Impossible\n"; return 0; }
    cout << "Possible\n";
    rep(i,1,it) cout << i << '\n';
    per(i,n,it+1) cout << i << '\n';
    cout << it;
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    vector<int> X(100000, 0);

    int mx = -1;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        gc(tmp);

        if (tmp - 1 < 0)
        {
            X[tmp]++;
            X[tmp + 1]++;

            mx = max(X[tmp], mx);
            mx = max(X[tmp + 1], mx);
        }
        else if (100000 <= tmp + 1)
        {
            X[tmp - 1]++;
            X[tmp]++;

            mx = max(X[tmp - 1], mx);
            mx = max(X[tmp], mx);
        }
        else
        {
            X[tmp - 1]++;
            X[tmp]++;
            X[tmp + 1]++;

            mx = max(X[tmp - 1], mx);
            mx = max(X[tmp], mx);
            mx = max(X[tmp + 1], mx);
        }
    }

    printf("%d\n", mx);
    return 0;
}


Measured memory_bytes: 640
# coding: utf-8
# Your code here!
from itertools import product

ans = 10**9

D, G=map(int, input().split()) 
problem=[list(map(int,list(input().split()))) for i in range(D)]

for p in product([True, False], repeat=D):
    
    point = 0
    num = 0
    
    for i in range(D):
        if p[i]:
            point += (i+1) * 100 * problem[i][0] + problem[i][1]
            num += problem[i][0]
            
    if point >= G:
        ans = min(ans, num)
    
    for i in reversed(range(D)):
        if p[i] == False:
            if point >= G:
                ans = min(ans, num)
                break
            for j in range(problem[i][0]):
                point += (i+1) * 100
                num += 1
                if point >= G:
                    break
    if point >= G:
        ans = min(ans, num)
print(ans)



Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	ll N,M;
  	cin>>N>>M;
  
  	cout<<(1800*M+100*N)*pow(2,M)<<endl;
  	
  	
  
}	

Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int mp[3][3];
bool flag = false;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> mp[i][j];
        }
    }
    cin >> N;
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(mp[j][k] == b) mp[j][k] = 0;
            }
        }
    }
    for(int i = 0; i < 3; i++){
        int sum1 = 0, sum2 = 0;
        for(int j = 0; j < 3; j++){
            sum1 += mp[i][j];
            sum2 += mp[j][i];
        }
        if(sum1 == 0 || sum2 == 0) flag = true;
    }
    int sum1 = 0, sum2 = 0;
    for(int i = 0; i < 3; i++){
        sum1 += mp[i][i];
        sum2 += mp[2 - i][i];
    }
    if(sum1 == 0 || sum2 == 0) flag = true;
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 200005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int cnt[30005] ;

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

int main()
{
	int i , j , k , l , m ,n ;

	scanf("%d",&n) ;

	int sum = 0 ;

	for(i=1 ; i<=n-1 ; i++)
	{
		if( i%2==0 )
		{
			sum += (i/2)*3 ;
			cnt[(i/2)*3] = 1 ;
		}
		else{
			j = (i+1)/2 ;
			if( (j*3 - 1)%2==0 ){
				sum += j*3 - 1 ;
				cnt[ j*3 - 1 ] = 1 ;
			}
			else{
				sum += j*3 - 2 ;
				cnt[ j*3 - 2 ] = 1 ;
			}
		}
	}

	for(i=1 ; i<=30000 ; i++)
	{
		if(cnt[i]==0)
		{
			if( (i+sum)%2==0 && (i+sum)%3==0 && gcd(i+sum,i)!=1 )
			{
				cnt[i] = 1 ;
				break ;
			}
		}
	}

	if(i==30001)
	{
		printf("no solution") ;
		return 0 ;
	}
//	else printf("yes\n") ;

	for(i =1 ; i<=30000 ; i++)
	{
		if(cnt[i]==1) printf("%d ",i) ;
	}


	return 0 ;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
	for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
	int rx = root(x); //xの根をrx
	int ry = root(y); //yの根をry
	if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
	par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
  }
};


int main(void){
  int n,m;
  cin >> n >> m;
  
  UnionFind tree(n);

  rep(i,m){
	int x,y,z;
	cin >> x >> y >> z;
	tree.unite(x-1,y-1);
  }

  set<int> s;
  rep(i,n){
	s.insert(tree.root(i));
  }
	
  cout << s.size() << endl;
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, d, x, a[100];

int main() {
	cin >> n >> d >> x;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) { x += (d + a[i] - 1) / a[i]; }
	
	cout << x << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int INF=~0u>>2;
int G[16][16],n,dp[1<<16][16],cost[1<<16],m,sum;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<=m;++i){
		int x=read(),y=read(),z=read();
		x--;y--;
		G[x][y]=G[y][x]=z;
		sum+=z;
	}
	for(int i=1;i<(1<<n);++i){
		for(int j=0;j<n;++j) if(i&(1<<j)){
			for(int k=j+1;k<n;++k) if(i&(1<<k)) cost[i]+=G[j][k];
		}
	}
	for(int i=1;i<(1<<n);++i) for(int j=0;j<n;++j) dp[i][j]=-INF;
	for(int i=1;i<(1<<n);++i) if(i&1) dp[i][0]=cost[i];
	for(int i=1;i<(1<<n);++i){
		for(int j=0;j<n;++j){
			if(dp[i][j]==-INF) continue;
			for(int k=(~i)&((1<<n)-1);k>0;k=(k-1)&(~i)){
				for(int l=0;l<n;++l) if((k&(1<<l))&&G[j][l]) dp[i|k][l]=max(dp[i|k][l],dp[i][j]+G[j][l]+cost[k]);
			}
		}
	}
	printf("%d",sum-dp[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
vector<int> A;
int H;
// 1-indexed
void maxHeapify(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]);
    maxHeapify(largest);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H;
  A.resize(H+1);
  FOR(i,0,H){
    cin>>A[i+1];
  }
  for(int i = H / 2; i > 0; i--){
    maxHeapify(i);
  }
  FOR(i,1,H+1){
    cout << " " << A[i];
  }
  cout << endl;
}


Measured memory_bytes: 4996
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M;
LL ans;

int main()
{
	in >> N >> M;

	ans = (N - M) * 100LL + M * 1900LL;
	ans <<= M;

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i;
        int j = 0;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for(i = a; i <= b; i++) {
            int r = c % i;
            if(r == 0) {
                j++;
            }
        }
        System.out.println(j);
    }
}


Measured memory_bytes: 26424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            int aPoint = Integer.parseInt(inputString.get(0));
            int bPoint = Integer.parseInt(inputString.get(1));
            int cPoint = Integer.parseInt(inputString.get(2));
            int transceiverRange = Integer.parseInt(inputString.get(3));

            int aToB = getXtoY(aPoint, bPoint);
            int aToC = getXtoY(aPoint, cPoint);
            int bToC = getXtoY(bPoint, cPoint);

            String canAandCTalk = "No";

            if (aToC <= transceiverRange || (aToB <= transceiverRange && bToC <= transceiverRange)) {
                canAandCTalk = "Yes";
            }

            System.out.println(canAandCTalk);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static int getXtoY(int x, int y) {

        int xToY = 0;

        if (x - y < 0) {
            xToY = y - x;
        } else {
            xToY = x - y;
        }

        return xToY;
    }
}

Measured memory_bytes: 23380
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str;

        //String[] num = str.split(" ",0);
        int i = 1;
        int sum = 0;
        str = scan.nextLine();
        String[] num = str.split(" ",0);
        for(i = Integer.valueOf(num[0]); i <= Integer.valueOf(num[1]); i++){
            if(Integer.valueOf(num[2]) % i == 0){
                sum++;
            }
        }


        System.out.println(sum);
        scan.close();
        
    }

}



Measured memory_bytes: 28116
gets.to_i.times{
	a,b=gets.split.map &:to_i
	t=a*b
	s=Math.sqrt(t).to_i
	r=2*s-2
	r-=1 if s*s==t
	r+=1 if s*(s+1)<t
	r+=1 if a==b
	p r
}

Measured memory_bytes: 1788
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,h[200005],a[200005];
ll A[200005],B[200005],ans;
int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;++i)cin>>h[i];
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i){
        ll o=0;
        int k=0;
        while(k+400<h[i]){
            k+=400;
            if(o<B[k])o=B[k];
        }
        while(k<h[i]){
            if(o<A[k])o=A[k];
            ++k;
        }
        o+=a[i];
        if(o>ans)ans=o;
        int K=((k-1)/400)*400+400;
        if(o>A[k])A[k]=o;
        if(o>B[K])B[K]=o;
    }
    cout<<ans<<endl;       
	//system("pause");
	return 0;
}


Measured memory_bytes: 4992
h,w = map(int,input().split())

s = []

for i in range(h):
    s.append(input())
ok = True
for i in range(h):
    for j in range(w):
        tmp = False
        if s[i][j] == '#':
            if i+1 < h and s[i+1][j] == '#':
                tmp = True
            elif j+1 < w and s[i][j+1] == '#':
                tmp = True
            elif i-1 > -1 and s[i-1][j] == '#':
                tmp = True
            elif j-1 > -1 and s[i][j-1] == '#':
                tmp = True
        
            if tmp == False:
                ok = False

if ok : print('Yes')
else : print('No')

Measured memory_bytes: 3064
import sys
import array
input = sys.stdin.readline
N,K = map(int,input().split())
xyc = []
for i in range(N):
    x,y,c = input().split()
    x = int(x)
    y = int(y)
    xyc.append([x % (2*K), y % (2*K), c])

wmap = [array.array('I',[0]*3*K) for i in [0]*3*K]
hmap = [array.array('I',[0]*3*K) for i in [0]*3*K]
for x,y,c in xyc:
    if c == 'W':
        wmap[y][x] += 1
        if y < K:
            wmap[y+2*K][x] += 1
        if x < K:
            wmap[y][x+2*K] += 1
        if x < K and y < K:
            wmap[y+2*K][x+2*K] += 1
    else:
        hmap[y][x] += 1
        if x < K:
            hmap[y][x+2*K] += 1
        if y < K:
            hmap[y+2*K][x] += 1
        if x < K and y < K:
            hmap[y+2*K][x+2*K] += 1

def accum(L):
    res = [0]*(len(L)+1)
    res[1] = L[0]
    for i in range(2,len(L)+1):
        res[i] = res[i-1] + L[i-1]
    return res
wcumsum = [array.array('I',[0]*(3*K+1))] + [array.array('I',accum(row)) for row in wmap]
hcumsum = [array.array('I',[0]*(3*K+1))] + [array.array('I',accum(row)) for row in hmap]

for y in range(1,3*K+1):
    for x in range(3*K+1):
        wcumsum[y][x] += wcumsum[y-1][x]
        hcumsum[y][x] += hcumsum[y-1][x]

def cs2(m, ltx, lty, rbx, rby):
    S = m[rby-1][rbx-1]
    S -= m[rby-1][ltx-1]
    S -= m[lty-1][rbx-1]
    S += m[lty-1][ltx-1]
    return S

ans = 0
for y in range(1,K+1):
    for x in range(1,K+1):
        ltw = cs2(wcumsum,x,y,x+K, y+K)
        rbw = cs2(wcumsum,x+K,y+K,x+2*K, y+2*K)
        lbh = cs2(hcumsum,x,y+K,x+K, y+2*K)
        rth = cs2(hcumsum,x+K,y,x+2*K, y+K)
        temp = ltw + rbw + lbh + rth
        ans = max(ans,temp)

        ltw = cs2(hcumsum,x,y,x+K, y+K)
        rbw = cs2(hcumsum,x+K,y+K,x+2*K, y+2*K)
        lbh = cs2(wcumsum,x,y+K,x+K, y+2*K)
        rth = cs2(wcumsum,x+K,y,x+2*K, y+K)
        temp = ltw + rbw + lbh + rth
        ans = max(ans,temp)

print(ans)
        



Measured memory_bytes: 255204
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

C = Counter(A).most_common()
p = 0
for k,v in C:
    if v==1 and k==0 and N%2==1:
        continue
    elif v==2:
        p += 1
        continue
    else:
        p = 0
        break
if N==1 and A==[0]:
    print(1)
else:
    print(p if p==0 else (2**p)%(10**9+7))

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

int main(){
    int N;
    int X;
    cin >> N >> X;
    const int MAX_N = N;
    int M[MAX_N];
    for (int i = 0; i < MAX_N; i++){
        cin >> M[i];
    }
    int count = MAX_N;
    int quant = 0;
    for (int i = 0; i < MAX_N; i++){
        quant += M[i];
    }
    X -= quant;
    int min_cost = M[0];
    for (int i = 1; i < MAX_N; i++){
        min_cost = min(min_cost, M[i]);
    }
    count += X / min_cost;
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n, m;
  cin >> n >> m;

  string a[n], b[m];

  REP(i, n) cin >> a[i];
  REP(i, m) cin >> b[i];

  int rec;

  REP(i, n - m + 1){
    REP(j, n - m + 1){
      rec = 0;
      REP(k, m){
        REP(l, m){
          if(b[k][l] != a[i + k][j + l]) rec++;
        }
      }
      if(rec == 0){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#define endl '\n'
#define ll long long
#define NCONS 16001

using namespace std;

struct El{
    int t;
    int x;
    int y;
};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<El> vec;
    int cur_t = 0, cur_x = 0, cur_y = 0;
    for(int i = 0; i < N; i++)
    {
        int t, x, y; cin >> t >> x >> y;
        vec.push_back(El{t, x, y});
    }
    sort(vec.begin(), vec.end(), [](El a, El b){ return a.t < b.t;} );
    
    /*
     10번 움직여야 하는데, 최단거리가 11인 경우 실패
     10번 움직여야 하는데, 최단거리가 8인 경우 성공
     10번 움직여야 하는데, 최단거리가 9인 경우 실패
     10번 움직여야 하는데, 최단거리가 7인 경우
     */
    for(int i = 0; i < vec.size(); i++)
    {
        int dx = abs(cur_x - vec[i].x);
        int dy = abs(cur_y - vec[i].y);
        int dt = abs(cur_t - vec[i].t);
        if(dt < dx + dy || abs(dt - (dx + dy)) % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
        cur_x = vec[i].x;
        cur_y = vec[i].y;
        cur_t = vec[i].t;
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1912
#include <stdio.h>
int main() {
  int x,i,f=0;
  scanf("%d",&x);
  for (i=1;i<1000000000;i*=10) {
    f+=x/i-(x/(10*i))*10;
  }
  if (x%f==0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if( a != b && a != c && b != c ){
    cout << 3 << endl;
  }else if( a == b && a == c && b == c ){
    cout << 1 << endl;
  }else{
    cout << 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct Dice {
	int face[6];
};

void Rotate(struct Dice *d, char *comm)
{
	int i, t;

	for (i = 0; comm[i] != '\n' && comm[i] != '\0'; i++) {
		switch (comm[i]) {
		case 'N':
			t = d->face[0];
			d->face[0] = d->face[1];
			d->face[1] = d->face[5];
			d->face[5] = d->face[4];
			d->face[4] = t;
			break;
		case 'S':
			t = d->face[0];
			d->face[0] = d->face[4];
			d->face[4] = d->face[5];
			d->face[5] = d->face[1];
			d->face[1] = t;
			break;
		case 'E':
			t = d->face[0];
			d->face[0] = d->face[3];
			d->face[3] = d->face[5];
			d->face[5] = d->face[2];
			d->face[2] = t;
			break;
		case 'W':
			t = d->face[0];
			d->face[0] = d->face[2];
			d->face[2] = d->face[5];
			d->face[5] = d->face[3];
			d->face[3] = t;
			break;
		case 'R':
			t = d->face[1];
			d->face[1] = d->face[2];
			d->face[2] = d->face[4];
			d->face[4] = d->face[3];
			d->face[3] = t;
			break;
		case 'L':
			t = d->face[1];
			d->face[1] = d->face[3];
			d->face[3] = d->face[4];
			d->face[4] = d->face[2];
			d->face[2] = t;
			break;
			
		}
	}
}

int searchDice(struct Dice *d, int n)
{
	int i;
	for (i = 0; i < 6; i++) {
		if (d->face[i] == n) {
			return i;
		}
	}
	return -1;
}

int main(void)
{
	struct Dice d;
	int i, n, top, front, right;

	for (i = 0; i < 6; i++) {
		scanf("%d", &d.face[i]);
	}
	scanf("%d", &n);
	while (n--) {
		scanf("%d %d", &top, &front);
		switch (searchDice(&d, top)) {
		case 0:
			break;
		case 1:
			Rotate(&d, "N");
			break;
		case 2:
			Rotate(&d, "W");
			break;
		case 3:
			Rotate(&d, "E");
			break;
		case 4:
			Rotate(&d, "S");
			break;
		case 5:
			Rotate(&d, "SS");
			break;
		}
		switch (searchDice(&d, front)) {
		case 0:
			break;
		case 1:
			break;
		case 2:
			Rotate(&d, "R");
			break;
		case 3:
			Rotate(&d, "L");
			break;
		case 4:
			Rotate(&d, "RR");
			break;
		case 5:
			break;
		}
		printf("%d\n", d.face[2]);
	}

	return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}
	return 0;
}

//Ctrl+Aを使わない

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a+b-1)/a << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

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

	vector<lint> cnt(N), xorsum(N);
	cnt[0] = 1, xorsum[0] = A[0];

	lint ans = 0;
	for (int i = 1; i < N; i++) {
		if ((A[i] & xorsum[i - 1]) == 0) {
			xorsum[i] = (A[i] ^ xorsum[i - 1]);
			cnt[i] = cnt[i - 1] + 1;
		}
		else if ((A[i] & A[i - 1]) == 0) {
			xorsum[i] = A[i] ^ A[i - 1];
			cnt[i] = 2;
			int j = i - 2;
			while ((xorsum[i] & A[j]) == 0) {
				xorsum[i] ^= A[j];
				j--;
				cnt[i]++;
			}
		}
		else {
			xorsum[i] = A[i];
			cnt[i] = 1;
		}
	}

	for (int i = 0; i < N; i++) {
		ans += cnt[i];
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int arraymin = -1;

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] strArray = br.readLine().split(" ");
		int numOfBag = Integer.parseInt(strArray[0]);
		int numOfTruck = Integer.parseInt(strArray[1]);

		int[] weight = new int[numOfBag];
		//int sumOfWeight = 0;
		for(int i = 0; i < numOfBag ; i++){
			weight[i] = Integer.parseInt(br.readLine());
		//	sumOfWeight++;
		}

		//int capacity;

		System.out.println(calcMinimumCapacityBinary(weight, numOfTruck));


	}



	private static int calcMinimumCapacity(int[] weight, int numOfTruck) {
		// TODO ?????????????????????????????????????????????
		int result = 0;
		int sum = sumOfArray(weight);

		min(weight);

		for(int i = arraymin; i <= sum; i++){
			if(isEnough(weight, numOfTruck, i)){
				return i;
			}
		}

		return result;
	}

	private static int calcMinimumCapacityBinary(int[] weight, int numOfTrack){
		int left = 0;
		int right = sumOfArray(weight) + 1;
		int mid;

		while(left < right){
			mid = (left + right)/2;
			if(mid == 0){
				return 0;
			}
			if(isEnough(weight, numOfTrack, mid) && !isEnough(weight, numOfTrack, mid - 1)){
				return mid;
			}
			else if(isEnough(weight, numOfTrack, mid)){
				right = mid;
			}
			else {
				left = mid + 1;
			}
		}

		return -1;
	}

	private static int sumOfArray(int[] weight) {
		// TODO ?????????????????????????????????????????????
		int sum = 0;
		for(int i = 0; i < weight.length ; i++){
			sum += weight[i];
		}

		return sum;
	}




	static boolean isEnough(int[] weight, int truckNum, int capacity){
		int currentTruckWeight = 0;
		int currentTruck = 1;
		for(int i = 0; i < weight.length ; i++){
			if(weight[i] > capacity){
				return false;
			}
			currentTruckWeight += weight[i];
			if(currentTruckWeight > capacity){
				currentTruckWeight = weight[i];
				currentTruck++;
				if(currentTruck > truckNum){
					return false;
				}
			}
		}
		return true;
	}

	static int min(int [] weight){

		if(arraymin > 0){
			return arraymin;
		}

		arraymin = weight[0];

		for(int i = 1; i < weight.length ; i++){
			if(arraymin > weight[i]){
				arraymin = weight[i];
			}
		}

		return arraymin;
	}

}

Measured memory_bytes: 35420
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	private static ArrayList<ArrayList<Byte>> adj_list   = new ArrayList<ArrayList<Byte>>(),
                                              adj_matrix = new ArrayList<ArrayList<Byte>>();

	private static final int U = 0,
			                 K = 1;

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
         Byte N = sc.nextByte();

         for(int i = 0;i < N;i++){
        	 ArrayList<Byte> ar = new ArrayList<Byte>();
        	 for(String s:sc.next().split("\\s")){
        		 ar.add(Byte.parseByte(s));
        	 }
        	 adj_list.add(ar);
        	 adj_matrix.add(new ArrayList<Byte>());
         }

         byte u,k,zero=0,one=1;
         ArrayList<Byte> il,o;
         for(int i = 0; i < N; i++){
        	 il = adj_list.get(i);
        	 u = il.get(U);
        	 k = il.get(K);
        	 o = new ArrayList<Byte>();
        	 for(int j = 0;j < N;j++){o.add(zero);}
        	 for(int j = 0;j < k;j++){
        		 o.set(il.get(j+2)-1,one);}
        	 adj_matrix.set(u-1,o);
         }

         for (ArrayList<Byte> ol:adj_matrix) {
			for(int i=0;i<N;i++){
				System.out.print(ol.get(i));
				if(i<N-1){System.out.print(" ");}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 26000
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	priority_queue<double,vector<double>,greater<double> > pq;
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		double v;
		cin >> v;
		pq.push(v);
	}
	while(pq.size()>1){
		auto a=pq.top();
		pq.pop();
		auto b=pq.top();
		pq.pop();
		pq.push((a+b)/2);
	}
	cout.precision(17);
	cout << pq.top() << endl;

	return 0;
}



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

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

mod = 1000000007

fibonacci = [1,1,2,3,5,8,13,21] # W <= 8なのでこれだけでいい

Amida = [ [0] * W for h in range(H+1)]

for h in range(H+1):
	if W == 1:
		break
	for w in range(W):
		if h == 0:
			if w == 0:
				Amida[h][w] = 1
			else:
				break
		elif w == 0:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w+1] + fibonacci[W-1] * Amida[h-1][w]
		elif w == W-1:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w-1] + fibonacci[W-1] * Amida[h-1][w]
		else:
			Amida[h][w] += (fibonacci[w-1] * fibonacci[W-w-1] * Amida[h-1][w-1])
			Amida[h][w] += (fibonacci[w] * fibonacci[W-w-1] * Amida[h-1][w])
			Amida[h][w] += fibonacci[w] * fibonacci[W-w-2] * Amida[h-1][w+1]

		Amida[h][w] = Amida[h][w] % mod

if W == 1:
	if K == 1:
		print(1)
	else:
		print(0)
else:
	print(Amida[H][K-1])

Measured memory_bytes: 3064