akhauriyash/Code-Regression huggingface dataset:
import itertools
n=int(input())
h = list(itertools.product(['7','5','3'],repeat=len(str(n))))
s=[0, 0, 0, 6, 36, 150, 540, 1806, 5796, 18150]
cnt=sum(s[:len(str(n))])
if n < 100:
    print(0)
else:
    for i in h:
        if any([j not in i for j in ['7','5','3']]):
            continue
        else:
            t=int(''.join(i))
            if n >= t:
                cnt+=1
    print(cnt)

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;

    vector<pii> g[n];
    int color[n];

    rep(i, n) color[i] = -1;

    rep(i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        g[u].push_back(pii(v, w));
        g[v].push_back(pii(u, w));
    }

    queue<int> q;
    color[0] = 0;
    q.push(0);

    while (!q.empty())
    {
        int s = q.front();
        q.pop();
        rep(i, g[s].size())
        {
            pii ns = g[s][i];
            if (color[ns.first] != -1)
                continue;
            if (ns.second % 2 == 0)
                color[ns.first] = color[s];
            else
                color[ns.first] = (color[s] == 0 ? 1 : 0);
            q.push(ns.first);
        }
    }

    rep(i, n) OP(color[i]);

    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<pair<ll, ll>> a(n);
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(a.begin(), a.end(), greater<pair<ll, ll>>());
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -INF));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, i + 1) {
      chmax(dp[j + 1][i - j], dp[j][i - j] + a[i].first * abs(a[i].second - j));
      chmax(dp[j][i - j + 1], dp[j][i - j] + a[i].first * abs(n - 1 - (i - j) - a[i].second));
    }
  }
  ll ans = -INF;
  rep(i, n + 1) chmax(ans, dp[i][n - i]);
  cout << ans << '\n';





  



  
  return 0;
}


Measured memory_bytes: 34612
#include<iostream>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=0;i<(tx-sx);i++) cout << 'R';
    for(int i=0;i<(ty-sy);i++) cout << 'U';
    for(int i=0;i<(tx-sx);i++) cout << 'L';
    for(int i=0;i<(ty-sy);i++) cout << 'D';
    cout << 'D';
    for(int i=0;i<=(tx-sx);i++) cout << 'R';
    for(int i=0;i<=(ty-sy);i++) cout << 'U';
    cout << "LU";
    for(int i=0;i<=(tx-sx);i++) cout << 'L';
    for(int i=0;i<=(ty-sy);i++) cout << 'D';
    cout << 'R' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;
    ll n = s.size();

    ll now = 0, ans = 0;
    vector<bool> used(4);
    used[0] = true;
    REP(i, n) {
        if(s[i] == 'L') now--;
        else {
            now++;
            used[(now+10000)%4] = true;
        }
        if(now%4 == 0) {
            if(used[0] && used[1] && used[2] && used[3]) ans++;
            used.assign(4, false);
            now = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
	int n;
	int temp;
	string str;

	while(1){
		int north = 5;
		int east = 3;
		int top = 1;
		int ans = 1;
		cin >> n;
		if(n == 0)break;

		for(int i=0;i<n;++i){
			cin >> str;
			if(str == "North"){
				temp = top;
				top = 7-north;
				north = temp;
			}
			else if(str == "East"){
				temp = top;
				top = 7-east;
				east = temp;
			}
			else if(str == "West"){
				temp = east;
				east = 7-top;
				top = temp;
			}
			else if(str == "South"){
				temp = north;
				north = 7-top;
				top = temp;
			}
			else if(str == "Right"){
				temp = north;
				north = 7-east;
				east = temp;
			}
			else if(str == "Left"){
				temp = east;
				east = 7-north;
				north = temp;
			}
			ans += top;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
n=int(input())
a=input().split()
min=0
max=0
c=[]
for i in range(n):
    per=int(int(a[i])/400)
    
    if per not in c and per<8:
        min+=1
        max+=1
    if (per>=8):
        max+=1
    c.append(per)
flag=0
for i in range(n):
    if(c[i]<8):
        flag=1
if flag==0:
    min+=1
print(min," ",max)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct edge{ int to,cost; };
struct state{
  int cost,pos,last;
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};
 
int N,M,X;
vector<edge> G[10000];
int t[10000];
 
int D[10000][401];
int* d[10000];
 
int main(){
  scanf("%d %d %d",&N,&M,&X);
  for(int i=0;i<N;i++){
    scanf("%d",&t[i]);
  }
  for(int i=0;i<M;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    a--,b--;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
 
  fill(D[0],D[10000],1e9);
  for(int i=0;i<N;i++){
    d[i]=&D[i][200];
  }
   
 
  priority_queue< state > Q;
   
  d[0][-X]=0;
  Q.push( (state){0,0,-X} );
  while(!Q.empty()){
    state s=Q.top();Q.pop();
     
    if(s.pos==N-1){
      printf("%d\n",s.cost);
      break;
    }
     
    if(s.cost > d[s.pos][s.last])continue;
     
    for(int i=0;i<(int)G[s.pos].size();i++){
      edge e=G[s.pos][i];
      state next=s;
      next.pos=e.to;
      next.cost+=e.cost;
      if(next.last<0)next.last=min(0,next.last+e.cost);
      if(next.last>0)next.last=max(0,next.last-e.cost);
 
      if(next.last>0&&t[e.to]==0)continue;
      if(next.last<0&&t[e.to]==2)continue;
 
      if(t[e.to]==0)next.last=-X;
      if(t[e.to]==2)next.last=X;
 
      if( d[next.pos][next.last] > next.cost ){
        d[next.pos][next.last]=next.cost;
        Q.push( next );
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 19892
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

int n, k;
bool dp[2002][10001];
bool good[2002][10001];
string s[2002];
vector <int> which;
vector <int> pos;
vector <int> next_which;
vector <int> next_pos;

char getBest()
{
	char ret = 'z';
	for (int i = 0; i < which.size(); i++)
	{
		ret = min(ret, s[which[i]][pos[i]]);
	}
	return ret;
}

void updateNext(char c, int remain)
{
	next_which.clear();
	next_pos.clear();
	int firstFinish = n + 1;
	int rate = which.size() / 4000;
	for (int i = 0; i < which.size(); i += (rate + 1))
	{
		if (s[which[i]][pos[i]] == c)
		{
			if (pos[i] == s[which[i]].length() - 1)
			{
				firstFinish = min(firstFinish, which[i]);
			}
			else
			{
				next_which.push_back(which[i]);
				next_pos.push_back(pos[i] + 1);
			}
		}
	}
	for (int i = firstFinish + 1; i <= n; i++)
	{
		if (good[i][remain])
		{
			next_which.push_back(i);
			next_pos.push_back(0);
		}
	}
	which = next_which;
	pos = next_pos;
}

void solve()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> s[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[n + 1][0] = true;
	for (int i = n; i >= 1; i--)
	{
		for (int j = 0; j <= k; j++)
		{
			if (dp[i + 1][j] == true)
			{
				dp[i][j] = true;
			}
			if (j - (int)s[i].length() >= 0 && dp[i + 1][j - (int)s[i].length()])
			{
				dp[i][j] = true;
			}
		}
	}
	memset(good, false, sizeof(good));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (s[i].length() <= j && dp[i + 1][j - (int)s[i].length()])
			{
				good[i][j] = true;
			}
		}
	}
	int remain = k;
	for (int i = 1; i <= n; i++)
	{
		if (good[i][remain])
		{
			which.push_back(i);
			pos.push_back(0);
		}
	}
	string ret;
	for (int i = 1; i <= k; i++)
	{
		char c = getBest();
		remain--;
		updateNext(c, remain);
		ret += c;
	}
	cout << ret << endl;
}

int main()
{

	solve();
	return 0;
}


Measured memory_bytes: 40704
import math
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())
kaijo = 1
for i in range(1,N+1):
    kaijo *= i
kaisu = kaijo * (N-1)
hen = N * (N-1) // 2
wa = 0
for i in range(N):
    for j in range(i+1,N):
        kyori = math.sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)
        wa += kyori * kaisu / hen
print(wa / kaijo)

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

int main(){
    int x,y,sw;
    for(int i = 1;;i++){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y){
            sw = x; x = y; y = sw;
        }

        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n,a,b;
  cin >> n >> a >> b;

  vector<int> p(n);
  REP(i,n) cin >> p[i];
  
  sort(p.begin(),p.end());

  vector<int> cnt(3,0);
  REP(i,n){
    if(p[i] <= a) cnt[0]++;
    else if(p[i] <= b) cnt[1]++;
    else cnt[2]++;
  }

  cout << min({cnt[0],cnt[1],cnt[2]}) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int m=100000009;
int k,dist[100000];
deque<int> q;
int main()
{
	cin.tie(0);
	cin>>k;
	for (int i=0;i<k;i++)
	{
		dist[i]=m;
	}
	dist[1]=1;
	q.push_back(1);
	while(q.size())
	{
		int f=q.front();
		q.pop_front();
		if (dist[(10*f)%k]>dist[f])
		{
			dist[(10*f)%k]=dist[f];
			q.push_front((10*f)%k);	
		}
		if (dist[(f+1)%k]>dist[f]+1)
		{
			dist[(f+1)%k]=dist[f]+1;
			q.push_back((f+1)%k);	
		}
	}
	cout<<dist[0];
	return 0;
}

Measured memory_bytes: 896
from math import *
from collections import deque, defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappush, heappop
from copy import copy, deepcopy

N = int(input())
xs = []
for i in range(N):
    x = input()
    xs.append(x)

us = "abcdefghijklmnopqrstuvwxyz"

cs = []
ess = []
for x in xs:
    c = Counter(x)
    es = [0,] * 26
    for i,u in enumerate(us):
        e = c[u]
        es[i] = e
    cs.append(c)
    ess.append(tuple(es))


g = Counter(ess)

re = 0
for k,v in g.items():
    re += v*(v-1)//2
print(re)

Measured memory_bytes: 238084
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std; 

typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N, Q;
	cin >> N >> Q;
	
	vector<int> t(N), x(N);
	vector<LL> w(N);
	for(int i=0 ; i < N ; i++ ){
		cin >> w[i] >> t[i] >> x[i];
	}
	vector<int> y(Q);
	for(int i=0 ; i < Q ; i++ ){
		cin >> y[i];
	}
	
	// p := 復旧度
	LL p=0, a = 1, b = 0, c = 0;
	// id := 復旧させたサービスの個数
	// d := 日にち
	// k := y[0..Q-1]について, 何個目のクエリまで求めているか
	int id = 0, d = 0, k = 0;
	
	// close[d] := d 日目にサービスが終わるものを保持
	// close[d][i] := (サービスの種類,お手伝いが終了する日にち)
	map<int,vector<P> > close;
	// ans[i] := サービス i が復旧した日にち
	vector<int> ans(N, -1);
	// ans_2[i] := クエリ i について y[i] 日目の復旧度
	vector<LL> ans_2(Q);
	
	for(int d=0 ; d <= 3652425 ; d++ ){
		// d 日目(= y[k]) の復旧度を記録
		if( k < Q && d == y[k] ){
			ans_2[k] = p;
			k++;
		}
		// サービス id が復旧しているとき
		while( id < N && w[id] <= p ){
			ans[id] = d;
			if( t[id] == 0 ){
				a++;
			}else if( t[id] == 1 ){
				a++;
				b++;
			}else{
				a++;
				b += 3;
				c += 2;
			}
			close[d+x[id]].push_back( P(t[id],x[id]) );
			id++;
		}
		// d 日目にお手伝いが終了するサービスがあるとき
		if( close.count(d) > 0 ){
			for(int i=0 ; i < close[d].size() ; i++ ){
				int type = close[d][i].first;
				int t = close[d][i].second;
				if( type == 0 ){
					a--;
				}else if( type == 1 ){
					a -= t + 1;
					b--;
				}else{
					a -= (t+1) * (t+1);
					b -= t * 2 + 3;
					c -= 2;
				}
			}
		}
		
		p += a;
		a += b;
		b += c;
	}
	for(int i=0 ; i < N ; i++ ){
		if( ans[i] == -1 )
			cout << "Many years later" << endl;
		else
			cout << ans[i] << endl;
	}
	for(int i=0 ; i < Q ; i++ ){
		cout << ans_2[i] << endl;
	}
}

Measured memory_bytes: 5392
import collections
import math
import numpy as np
K, N = map(int, input().split(' '))

A = sorted(list(map(int, input().split(' '))))
for i in range(N):
    A.append(A[i]+K)


m = float('inf')

for i in range(N):
    kyori = A[i+N-1]-A[i]
    m = min(m, kyori)
print(m)





Measured memory_bytes: 34152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int h, w; cin >> h >> w;
  int l = 80*(h+w-1);
  vector<vector<int> > a(h, vector<int> (w, 0));
  vector<vector<vector<bool> > > dp(h, vector<vector<bool> > (w, vector<bool>(l, false)));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int tmp; cin >> tmp;
      a[i][j] = abs(a[i][j] - tmp);
    }
  }
  dp[0][0][a[0][0]] = true;
  for (int i = 1; i < max(h, w); i++) {
    for (int k = 0; k < l; k++) {
      if (i < h) {
        if (dp[i-1][0][k]) {
          dp[i][0][abs(k - a[i][0])] = true;
          dp[i][0][k + a[i][0]] = true;
        }
      }
      if (i < w) {
        if (dp[0][i-1][k]) {
          dp[0][i][abs(k - a[0][i])] = true;
          dp[0][i][k + a[0][i]] = true;
        }
      }
    }
  }
  for (int i = 1; i < h; i++) {
    for (int j = 1; j < w; j++) {
      for (int k = 0; k < l; k++) {
        if (dp[i-1][j][k] || dp[i][j-1][k]) {
          dp[i][j][abs(k - a[i][j])] = true;
          dp[i][j][k + a[i][j]] = true;
        }
      }
    }
  }

  for (int k = 0; k < l; k++) {
    if (dp[h-1][w-1][k]) {
      cout << k << endl; break;
    }
  }
  return 0;
}

Measured memory_bytes: 10624
/* 

Author: Vishal Singh  
(singhvishal0304@gmail.com)

"The days that break you are the days that make you."

*/

#include <bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);

#define md 1000000007


#define lli long long int
#define pb push_back
#define mp make_pair
#define vvi(r,c) vector<vector<lli>> v(r,vector<lli>(c));
#define fi first
#define se second
#define mem(arr,x) memset(arr,x,sizeof(arr))

lli power(lli a,lli b){
	if(b==0)
		return 1;
	if(b%2)
		return ((a%md)*(power(a,b-1)))%md;
	else
	{
		lli x=power(a,b/2);
		return (x*x)%md;
	}
}

void solve(){
	int c;
	cin>>c;
	if(c>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


int main()
{	
    fastio();
	int t;
	
	t=1;
	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#define maxv 100000
#define fi first
#define se second
using namespace std;
int n, a[100005], v[100005], cnt[100005];
pair < pair <int, int>, pair <int, int> > solve(){
	for (int i = 0; i <= maxv; ++ i)
		cnt[i] = 0;
	for (int i = 1; i <= n / 2; ++ i)
		++ cnt[a[i]];
	pair <int, int> mx, _mx;
	mx = _mx, make_pair(0, 0);
	for (int i = 0; i <= maxv; ++ i){
		if (cnt[i] > mx.fi){
			_mx = mx;
			mx = make_pair(cnt[i], i);
		}
		else if (cnt[i] > _mx.fi)
			_mx = make_pair(cnt[i], i);
	}
	return make_pair(mx, _mx);
}
int main(){
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		cin >> v[i];
	int m = 0;
	for (int i = 1; i <= n; i += 2)
		a[++ m] = v[i];
	pair < pair <int, int>, pair <int, int> > p1 = solve();
	m = 0;
	for (int i = 2; i <= n; i += 2)
		a[++ m] = v[i];
	pair < pair <int, int>, pair <int, int> > p2 = solve();
	if (p1.fi.se != p2.fi.se)
		cout << n - (p1.fi.fi + p2.fi.fi) << endl;
	else
		cout << n - max(p1.fi.fi + p2.se.fi, p2.fi.fi + p1.se.fi) << endl;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int a, b, c, d;
int main()
{
	while(~scanf("%d %d %d %d",&a, &b, &c, &d))
	{
		if((a + b) > (c + d))  printf("Left\n");
		else if ((a + b) < (c + d))  printf("Right\n");
		else if((a + b) == (c + d))  printf("Balanced\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int id;
vector<int> cc_id;   
void dfs(vector<vector<int>> &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto i : G[v]) {
        if (cc_id[i] != -1) continue;
        dfs(G, i, cnt);
    }
}
int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> G(N);  
    vector<int> cc_num;  
    rep(i, M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cc_id.assign(N, -1);  
    id = 0;
    rep(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }
    vector<int> ans(N);
    rep(i, N) ans[i] = cc_num[cc_id[i]]-(int)G[i].size()-1;
    rep(i, K) {  
        int c,d;
        cin >> c >> d;
        c--;d--;
        if (cc_id[c] == cc_id[d]) {
            ans[c]--;
            ans[d]--;
        }
    }
    rep(i,N) cout << ans[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 10584
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll m[55][55];

ll dfs(ll a, ll b, ll v) {
  if (a < b) return INF;
  if (m[a][b] != INF) return max(v, m[a][b]);
  ll res = INF;
  FOR(i, 1, a + 1) chmin(res, dfs(a % i, b, max(v, i)));
  return m[a][b] = max(v, res);
}

void init() {
  rep(i, 55) rep(j, 55) m[i][j] = INF;
  rep(i, 55) m[i][i] = 0;
  rep(i, 55) rep(j, i) dfs(i, j, 0);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  init();

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  //rep(i, n) cout << m[a[i]][b[i]] << '\n';
  vector<ll> v;
  ll maxv = INF, ans = 0;
  while (maxv) {
    maxv = 0;
    rep(i, n) {
      ll tmp = m[a[i]][b[i]];
      set<ll> res;
      res.insert(a[i]);
      for (ll x: v) {
        set<ll> nxt = res;
        for (auto y: res) nxt.insert(y % x);
        res = nxt;
        for (auto y: res) chmin(tmp, m[y][b[i]]);
      }
      //for (auto y: res) cout << y << '\n';
      chmax(maxv, tmp);
    }
    if (maxv == INF) {
      cout << -1 << '\n';
      return 0;
    }
    if (maxv) ans += 1LL << maxv;
    v.push_back(maxv);
  }
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
int main(){
  int N,i,j,k,v;
  int a[100];
  scanf("%d",&N);
  for(i = 0;i < N; i++){
    scanf("%d",&a[i]);
  }
  for(i = 1;i <= N-1; i++){
    for(k = 0;k < N; k++){
      printf("%d",a[k]);
      if(k != N-1)
	printf(" ");
    }
    printf("\n");
    v = a[i];
    j = i-1;
    while(j >= 0&&a[j]>v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    
  }
  
  for(k = 0;k < N; k++){
    printf("%d",a[k]);
    if(k != N-1)
	printf(" ");
  }
  printf("\n");
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int a =  n - k;
    if( k == 1 ) cout << 0 << endl;
    else cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, size):
        self.rank = [0] * size
        self.p = list(range(size))

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))


if __name__ == '__main__':
    n, q = [int(v) for v in input().split()]
    ds = DisjointSet(n)

    for i in range(q):
        com, x, y = [int(v) for v in input().split()]
        if com == 0:
            ds.unite(x, y)
        elif com == 1:
            if ds.same(x, y):
                print(1)
            else:
                print(0)


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

using namespace std;

typedef int ll;
typedef vector<ll> v1;
typedef vector<v1> v2;

string s1,s2;
v2 rui1,rui2;
set<v1> s;
ll ans;

bool solve(ll x){
  s = set<v1>();
  for(ll i = 0;i+x <= s1.size();i++){
    v1 v(26);
    for(ll j = 0;j < 26;j++){
      v[j] = rui1[j][i+x]-rui1[j][i];
    }
    s.insert(v);
  }
  for(ll i = 0;i+x <= s2.size();i++){
    v1 v(26);
    for(ll j = 0;j < 26;j++){
      v[j] = rui2[j][i+x]-rui2[j][i];
    }
    if(s.count(v)){
      return true;
    }
  }
  return false;
}

int main(){
  cin >> s1 >> s2;
  rui1 = v2(26,v1(s1.size()+1));
  rui2 = v2(26,v1(s2.size()+1));
  for(ll i = 1;i <= s1.size();i++){
    rui1[s1[i-1]-'a'][i] = 1;
  }
  for(ll i = 1;i <= s2.size();i++){
    rui2[s2[i-1]-'a'][i] = 1;
  }
  for(ll i = 0;i < 26;i++){
    for(ll j = 1;j <= s1.size();j++){
      rui1[i][j] += rui1[i][j-1];
    }
    for(ll j = 1;j <= s2.size();j++){
      rui2[i][j] += rui2[i][j-1];
    }
  }
  for(ll i = 0;i <= s1.size();i++){
    if(solve(i)) ans = i;
  }


  cout << ans << endl;

}



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

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

int main() {
    string S;
    cin >> S;
    set<char> t;

    rep(i,S.size())
        t.insert(S.at(i));
    
    rep(i,'z'-'a'+1)
        if(!t.count(i+'a')) {
            cout << (char)(i+'a') << endl;
            return 0;
        }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
int BASE = 131;
int MOD = 3037000493;

int powMod(int x, int y) {
  int res = 1;
  for(; y > 0; y >>= 1, (x *= x) %= MOD) {
    if(y & 1) (res *= x) %= MOD;
  }
  return res;
}

int subMod(int x, int y) {
  x %= MOD; y %= MOD;
  if(x < 0) x += MOD;
  if(y < 0) y += MOD;
  int res = x - y;
  if(res < 0) res += MOD;
  return res % MOD;
}

int partial(const vector<int> &hashary, int i, int j) {
  // cerr << "(" << i << "," << j << ") = ";
  int sub = hashary[i] * powMod(BASE, j - i);
  sub %= MOD;
  if(sub < 0) sub += MOD;
  // cerr << hashary[j] << " - " << sub << " = " << subMod(hashary[j], sub) << endl;
  return subMod(hashary[j], sub);
}

signed main() {
  ios::sync_with_stdio(false);
  string S; cin >> S;
  vector<int> hashary(S.size() + 1, 0);
  REP(i,S.size()) {
    hashary[i + 1] = (hashary[i] * BASE + S[i]) % MOD;
  }

  bool flag = false;
  string strA, strB;
  REP(i,S.size()) {
    int A = i + 1;
    if(((int)S.size() - 3 * A) % 2 != 0) continue;
    int B = ((int)S.size() - 3 * A) / 2;
    if(B < 1) continue;
    // DEBUG(A);
    // DEBUG(B);
    if(partial(hashary, 0, A) == partial(hashary, A + B, A + B + A)
        && partial(hashary, 0, A) == partial(hashary, A + B + A + B, A + B + A + B + A)
        && partial(hashary, A, A + B) == partial(hashary, A + B + A, A + B + A + B)) {
      if(flag == false) {
        flag = true;
        strA = S.substr(0, A);
        strB = S.substr(A, B);
      }
      else {
        if(strA.size() + strB.size() > A + B) {
          strA = S.substr(0, A);
          strB = S.substr(A, B);
        }
      }
    }
  }
  if(!flag) {
    cout << "mitomerarenaiWA" << endl;
  }
  else {
    cout << "Love " << strA << strB << "!" << endl;
  }
}

Measured memory_bytes: 12992
package main

import (
	"fmt"
)

func test(s string) bool {
	//string型は、中身がbyte配列
	//文字列を文字単位で扱うには、rune型を使う
	//日本語の時は注意‼︎
	n := len(s)
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-i-1] {
			return false
		}
	}
	return true
}

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)

	if test(s) && test(s[0:((n-1)/2)]) && test(s[(n+3)/2-1:n]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

int main() {
  int n;
  cin >> n;

  n %= 1000;
  if(n == 0) cout << 0 << endl;
  else cout << (1000 - n) << endl;

  return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;

int d,w;

int G[11][11];

bool get_input(){
    scanf("%d %d",&d,&w);
    if(!d && !w) return false;
    _for(i,0,d){
        _for(j,0,w){
            scanf("%d",&G[i][j]);
        }
    }
    return true;
}

int check(int x,int y,int x2,int y2){
    int minv = inf;
    int ok = 1;
    int ret = 0;

    _rep(i,x,x2){
        chmin(minv,G[i][y]);
        chmin(minv,G[i][y2]);
    }
    _rep(j,y,y2){
        chmin(minv,G[x][j]);
        chmin(minv,G[x2][j]);
    }

    _for(i,x+1,x2){
        _for(j,y+1,y2){
            if(G[i][j] >= minv) ok = 0;
            else ret += minv - G[i][j];
        }
    }



    if(ok)
        return ret;
    else return 0;
}

int main()
{
    while(get_input()){
        int ans = 0;

        _for(i,0,d) _for(j,0,w) _for(k,i+1,d) _for(l,j+1,w){
            chmax(ans,check(i,j,k,l));

        }
        cout << ans << endl;


    }
    return 0;
}



Measured memory_bytes: 3168
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
  sort(all(a));
  a.erase(unique(all(a)), a.end());
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

#define int li
//const int mod = 1000000007;

void solve(bool read) {
    vector<int> a(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    for (int i = 1; i < 4; ++i) {
        relax_min(a[i], 2 * a[i - 1]);
    }
    int n;
    cin >> n;
    n *= 4;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (n & 1) {
            ans += a[i];
        }
        n >>= 1;
    }
    ans += a[3] * n;

    cout << ans << endl;

}

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

int main() {
    int n;
    cin >> n;
    int p[n];
    int q[n];
    for(int i=0; i<n; ++i){
        cin >>p[i] ;
    }
    for(int i=0; i<n; ++i){
        cin >> q[i];
    }
    int r[n+1];
    r[0]=1;
    for(int i=1; i<=n; ++i){
        r[i]=r[i-1]*i;
    }
    int ansp=1;
    for(int i=0; i<n-1; ++i){
        int d=0;
        for(int j=0; j<i; ++j){
            if(p[j]<p[i]){
                ++d;
            }
        }
        ansp+=(p[i]-1-d)*r[n-i-1];
    }
    int ansq=1;
    for(int i=0; i<n-1; ++i){
        int e=0;
        for(int j=0; j<i; ++j){
            if(q[j]<q[i]){
                ++e;
            }
        }
        ansq+=(q[i]-1-e)*r[n-i-1];
    }
    cout << abs(ansp-ansq) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String str2 = sc.next();
        char[] c = str.toCharArray();
        char[] c2 = str2.toCharArray();
        boolean ok = true;
        for (int i = 0; i < 3; i++) {
            if (c[i] != c2[2-i]) ok = false;
        }
        if(ok) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> H >> W;
	vll A(H, vl(W, 0));
	vll B(H, vl(W, 0));
	vll D(H+1, vl(W+1, 0));
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> B[i][j];
			D[i+1][j+1] = abs(A[i][j] - B[i][j]);
		}
	}
	ll M = (H + W) * 80;
	vector<vll> dp(H+1, vll(W+1, vl(M, 0)));
	dp[1][1][D[1][1]] = 1;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			for (k = 0; k < M; k++) {
				if (i == H && j == W) continue;
				if (i != H) {
					if (k + D[i + 1][j] < M) dp[i + 1][j][k + D[i + 1][j]] |= dp[i][j][k];
					if (abs(k - D[i + 1][j]) < M) dp[i + 1][j][abs(k - D[i + 1][j])] |= dp[i][j][k];
				}
				if (j != W) {
					if (k + D[i][j + 1] < M) dp[i][j + 1][k + D[i][j + 1]] |= dp[i][j][k];
					if (abs(k - D[i][j + 1]) < M) dp[i][j + 1][abs(k - D[i][j + 1])] |= dp[i][j][k];
				}
			}
		}
	}
	for (k = 0; k < M; k++) {
		if (dp[H][W][k]) { 
			cout << k; 
			exit(0);
		}
	}
}

Measured memory_bytes: 667008
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------
int R, C;
int mat[3001][3001];
int dp[3001][3001][4];

int solve(int x, int y, int curr)
{
    if (x > R || y > C)
    {
        return 0;
    }
    
    if (dp[x][y][curr] != -1)
    {
        return dp[x][y][curr];
    }
    if (mat[x][y] == 0)
    {
        dp[x][y][curr] = max(solve(x, y + 1, curr), solve(x + 1, y, 0));
        return dp[x][y][curr];
    }
    else
    {
        if (curr < 3)
        {
            int op1 = mat[x][y] + solve(x, y + 1, curr + 1);
            int op2 = solve(x, y + 1, curr);
            int op3 = mat[x][y] + solve(x + 1, y, 0);
            int op4 = solve(x + 1, y, 0);
            dp[x][y][curr] = max({op1, op2, op3, op4});
            return dp[x][y][curr];
        }
        else
        {
            dp[x][y][curr] = max(solve(x + 1, y, 0),solve(x,y+1,curr));
            return dp[x][y][curr];
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int K;
    cin >> R >> C >> K;
    memset(mat, 0, sizeof(mat));
    memset(dp, -1, sizeof(dp));
    while (K--)
    {
        int r, c, val;
        cin >> r >> c >> val;
        mat[r][c] = val;
    }
    cout << solve(1, 1, 0) << endl;
}

Measured memory_bytes: 356212
#include <cstdio>
int l,r,d,x,ans=0;
int main()
{
	scanf("%d%d%d",&l,&r,&d);
	x=0;
	while(x<l) x+=d;
	while(x<=r) ++ans,x+=d;
	printf("%d",ans);
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		PriorityQueue<Integer> que = new PriorityQueue<>(N, Comparator.comparingInt(Integer::intValue).reversed());
		for (int i = 0; i < N; ++i) que.add(sc.nextInt());
		
		for (int i = 0; i < M; ++i) {
			que.offer(que.poll() / 2);
		}
		long result = 0L;
		for (int i = 0; i < N; ++i) result += que.poll();
		System.out.println(result);
	}
	
	static 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: 28872
import itertools

n = int(input())
a = [input() for _ in range(n)]

suits = ['S', 'H', 'C', 'D']
cards = ["%s %d" % (s, r) for s, r in itertools.product(suits, range(1, 14))]
answers = [c for c in cards if c not in a]
for card in answers:
    print(card)



Measured memory_bytes: 5648
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	string S;
	cin >> S;
	int N = S.size();
	string ans = "yes";
	for(int i = 0; i < N; ++i){
		for(int j = i + 1; j < N; ++j){
			if(S[i] == S[j]){
				ans = "no";
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, max_a=-INF, min_a=INF, a;
    in >> n;
    REP(i, n) {
        in >> a;
        chmax(max_a, a);
        chmin(min_a, a);
    }
    out << (max_a - min_a) << endl;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
min = x if x<y else y
price=0
if a+b > 2*c:
    price = min*2*c
    if a < c*2 and y<x:
        price+=a*(x-y)
    elif b<c*2 and x<y:
        price+=b*(y-x)
    else:
        diff = y-x if x<y else x-y
        price+=2*c*(diff)
else:
    price = a*x+b*y
print(price)

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

using ll = long long;
using namespace std;

int main(){
    ll W,H; cin >> W >> H;
    ll x,y; cin >> x >> y;

    cout << (double)(W*H)/2.0 << " " ;

    int dup = 0;
    if (W%2 == 0 && H%2 == 0 && x == W/2 && y == H/2) dup++;
    
    if (dup != 0) cout << 1 << endl;
    else cout << 0 << endl;
    
}


Measured memory_bytes: 256