akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const LL INF = 1e9 + 7;
//-------------------------------------------


LL n;
LL b,c;
vector<LL> a(MAX);


//LL dp[100000][100000];
vector<LL> dp(100010, INF);


int main(){

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

    b = 6;
    c = 9;

    cin >> n;
    a[0] = 1;
    a[1] = 6;
    a[2] = 9;


    FOR(i,1,n){
        b = b*6;
        if( b > n) break;
        a.push_back(b);
    }

    FOR(i,1,n){
        c = c*9;
        if( c > n) break;
        a.push_back(c);

    }

    dp[0] = 0;

    for(LL i = 0; i < a.size(); i++){
        for(LL j = a[i]; j <= n; j++){   // 範囲外アクセス c[i] - j >= 0
                dp[j] = min( dp[j], dp[j - a[i]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1280
import sys
input = sys.stdin.buffer.readline


def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                        return True
                else:
                    return True
    return False


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)


Measured memory_bytes: 50300
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  int X; cin>>X;
  cout<<X/500*1000 + (X-X/500*500)/5*5<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
using namespace std;

const long long mod=1000000007;

bool m[100000 + 1];
long long dp[100000 + 1];

int main(void){
    int n,ml;
    
    memset(dp,0,sizeof(dp));
    memset(m,false,sizeof(m));
    
    scanf("%d%d",&n,&ml);
    
    for(int i=0;i<ml;i++){
        int x;
        scanf("%d",&x);
        m[x]=true;
    }
    
    dp[0]=1;
    
    for(int i=0;i<n;i++){
        
        if(m[i]) continue;
        
        if(!m[i+1]){
            dp[i+1]+=dp[i];
            dp[i+1]%=mod;
        }
       
        if(i >= n-1) continue;
       
        if(!m[i+2]){
            dp[i+2]+=dp[i];
            dp[i+2]%=mod;
        }
    }
    
    printf("%d\n",dp[n]);
    
    return 0;
    
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i)cin>>a[i];

    int ans=INT_MAX,t;
    for(int i=0;i<n-k+1;++i){
        t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
        if(ans>t)ans=t;
    }
    cout<<ans;
}

Measured memory_bytes: 640
a,b,c,d=map(int,input().split())
if (a-c)**2 <= d*d:
    print("Yes")
else:
    if (a-b)**2 > d*d:
        print("No")
    elif (b-c)**2 >d*d:
        print("No")
    else:
        print("Yes")

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    ll a;
    long double b;
    cin>>a>>b;
    cout<<int(a*b)<<endl;
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int N,M,Dsum=0;
	cin >> N>>M;
	vector<int> X(M),D(M-1);
	rep(i,M)cin>>X[i];
	sort(all(X));
	rep(i,M-1){
		D[i] = X[i+1] - X[i];
		Dsum += D[i];
	}
	sort(all(D));
	if(N<M){
		rep(i,N-1){
			Dsum-=D[M-2-i];
		}
	}
	else Dsum = 0;
	cout << Dsum << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        int tmp1 = x;
        x=y;
        y=tmp1;

        int tmp2 = x;
        x=z;
        z=tmp2;
        System.out.println(x + " "+ y + " " + z);

    }
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

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

    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    vll b;

    vll head;
    vll foot;



    if(n%2){
        rep(i, n-1){
            if(i%2){
                head.push_back(a[i+1]);
            }
            else{
                foot.push_back(a[i+1]);
            }
        }
    }
    else{
        rep(i, n-1){
            if(i%2){
                foot.push_back(a[i+1]);
            }
            else{
                head.push_back(a[i+1]);
            }
        }
    }

    reverse(head.begin(), head.end());

    rep(i, head.size()){
        b.push_back(head[i]);
    }
    b.push_back(a[0]);
    rep(i, foot.size()){
        b.push_back(foot[i]);
    }

    rep(i, b.size()){
        cout << b[i] << sp;
    }
    cout << endl;


    return 0;
}


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

int main() {
    int n, t, a;
    double mini = 10000000;
    cin >> n >> t >> a;
    vector<int> h(n);
    vector<double> tem(n);
    for (int i = 0; i < n; i++) {
        cin >> h.at(i);
        tem.at(i) = a - (t - (double)(h.at(i) * 0.006));
        if (tem.at(i) < 0) {
            tem.at(i) *= -1;
        }
        mini = min(mini, tem.at(i));
    }
    for (int i = 0; i < n; i++) {
        if(tem.at(i) == mini) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << "error" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
 
using namespace std;
const int N = 50005;
#define ll long long int
ll stone[N];
ll n,t,ans;
 
void combine(ll k)
{
    ll tmp = stone[k] + stone[k-1];
    ans += tmp;
    for(ll i=k;i<t-1;i++)
        stone[i] = stone[i+1];
    t--;
    ll j = 0;
    for(j=k-1;j>0 && stone[j-1] < tmp;j--)
        stone[j] = stone[j-1];
    stone[j] = tmp;
    while(j >= 2 && stone[j] >= stone[j-2])
    {
        ll d = t - j;
        combine(j-1);
        j = t - d;
    }
}
 
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        if(n == 0) break;
        for(ll i=0;i<n;i++)
            scanf("%lld",stone+i);
        t = 1;
        ans = 0;
        for(ll i=1;i<n;i++)
        {
            stone[t++] = stone[i];
            while(t >= 3 && stone[t-3] <= stone[t-1])
                combine(t-2);
        }
        while(t > 1) combine(t-1);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3768
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
};

int main()
{
    int n;
    cin >> n;
    vector<Point> p(n);
    vector<int> v(n);
    for(int i=0; i<n; ++i){
        cin >> p[i].x >> p[i].y;
        v[i] = i;
    }

    double ans = 0;
    do{
        for(int i=0; i<n-1; ++i)
            ans += p[v[i]].dist(p[v[i+1]]);
    }while(next_permutation(v.begin(), v.end()));
    for(int i=1; i<=n; ++i)
        ans /= i;
    printf("%.10f\n", ans);

    return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;
  string s;
  cin >> s;
  cout << (sz(s)%2 == 0 && s.substr(0,sz(s)/2) == s.substr(sz(s)/2,sz(s)/2) ? "Yes" : "No");
  

  return 0;
}






// Coded by Z..

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1 && y == 1){
        ans = 1000000;
    }else {
        ans = 100000*(max(4-x, 0) + max(4-y, 0));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2) //O2优化？

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	unsigned long long a[3];
	cin>>a[0]>>a[1]>>a[2];
	int k;
	cin>>k;
	unsigned long long l=pow(2,k);
	sort(a,a+3);
	cout<<a[0]+a[1]+a[2]*l;
	return 0;
}

Measured memory_bytes: 256
BIG = 10**10

N, K = map(int, input().split())
A = list(map(int, input().split()))
# N, K = 2*10**5, 2*10**5
# A = [10**9]*N

def solve(x):
    m = 0
    for a in A:
        m += -(-(a//x))
    # print(x, m)
    return m > K

A = [a*BIG for a in A]

# c = 0
ok, ng = 0, max(A)
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    # print(mid)
    if solve(mid):
        ok = mid
    else:
        ng = mid
    # c += 1

# print(c)

print(-(-ok//BIG))

Measured memory_bytes: 104852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int a[100010];
int main(){
	int a,b,c,d;
	bool flag=true;
	cin>>a>>b>>c>>d;	
	while(1)
	{
		c-=b;
		if(c<=0)
		{
			cout<<"Yes"<<endl;
			break;
		}
		a-=d;
		
		if(a<=0)
		{
			cout<<"No"<<endl;
			break;
		}
	
	}
    
	
	return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.*;

public class Main {

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

		Scanner scanner = new Scanner(System.in);

		String s = scanner.next();
		int K = scanner.nextInt();

		System.out.println(genSubstring(s).toArray()[K-1]);
	}

	public static TreeSet<String> genSubstring(String s) {
		TreeSet<String> set = new TreeSet<>();
		int n = s.length();
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j<=Math.min(n, i+6); j++) {
				set.add(s.substring(i, j));
			}
		}
		return set;
	}
}

Measured memory_bytes: 24220
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <vector>
#include <ctype.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int i, j, k;

int main(){

    int A,P,num;
    cin >> A >> P;

    num = P + A * 3;
    
    cout << num / 2;
}

Measured memory_bytes: 256
MOD = 10**9+7
h, w = map(int, input().split())
S = [input() for _ in range(h)]
L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if j > 0:
      if S[i][j-1] == ".":
        L[i][j] = L[i][j-1]+1
      if S[i][w-j] == ".":
        R[i][w-1-j] = R[i][w-j]+1
    if i > 0:
      if S[i-1][j] == ".":
        U[i][j] = U[i-1][j]+1
      if S[h-i][j] == ".":
        D[h-1-i][j] = D[h-i][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    if S[i][j] == ".":
      temp = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
      ans = max(ans, temp)
print(ans)

Measured memory_bytes: 205844
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int n,m;
	cin>>n>>m;
	cout<<((m*1900)+((n-m)*100))*(1<<m);
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<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 = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
struct edge {
    i64 to, money, Tim;
    edge(i64 to,i64  money, i64 Tim): to(to), money(money), Tim(Tim) {};
};

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

    i64 n, m, s;
    cin >> n >> m >> s;
    chmin(s, 2500);

    vec<edge> graph[55][2505];
//    memset(graph, 0, sizeof(graph));
    i64 u, v, a, b;
    rep(i,m) {
        cin >> u >> v >> a >> b;
        --u, --v;
        for(i32 sil = 0; sil <= 2500; ++sil) if(sil-a >= 0) {
            graph[u][sil].emplace_back(v, sil-a, b);
            graph[v][sil].emplace_back(u, sil-a, b);
        }
    }

    i64 c, d;
    rep(i,n) {
        cin >> c >> d;
        for(i32 sil = 0; sil < 2500; ++sil) {
            graph[i][sil].emplace_back(i, min<i64>(sil+c, 2500), d);
        }
    }

    using tup = tuple<i64, i32, i32>;
    minheap<tup> heap;  // time, to, silver
    vec<vl> TimeToReach(n, vl(2501, infll));
    TimeToReach[0][s] = 0;
    heap.emplace(0, 0, s);
    while(heap.size()) {
        i64 t, u_to, u_sil;
        tie(t, u_to, u_sil) = heap.top(); heap.pop();
        for(auto e : graph[u_to][u_sil]) {
            if(!chmin(TimeToReach[e.to][e.money], TimeToReach[u_to][u_sil] + e.Tim)) continue;
            heap.emplace(TimeToReach[e.to][e.money], e.to, e.money);
        }
    }

    i64 output;
    for(int i = 1; i < n; ++i) {
        output = infll;
        rep(sil,2501) {
            chmin(output, TimeToReach[i][sil]);
        }
        cout << output << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 31508
N , K = map(int, input().split())

S = []
for i in range(K):
  L, R = map(int, input().split())
  S.append((L, R))
dp = [0 for i in range(N+1)]
sumdp = [0 for i in range(N+1)]
sumdp[1] = 1
dp[1] = 1
for i in range(2,N+1):
  buf = 0
  for L, R in S:
    if i-L < 0:
      continue
    l = max(0, i-R-1)
    r = i-L
    #print(l,r,sumdp[r],sumdp[l])
    buf += sumdp[r]-sumdp[l]
    #print(i, buf)
    buf %= 998244353
  dp[i] = buf
  sumdp[i] = sumdp[i-1] + buf
  
print(dp[N])

Measured memory_bytes: 94324
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Dice dice = new Dice();
		for(int i = 0 ; i < 6 ; i ++){
			dice.d[i]=scan.nextInt();
		}
		int n = scan.nextInt();
		while(n--!=0){
			int top = scan.nextInt();
			int front = scan.nextInt();
			System.out.println(dice.getRight(top, front));
		}
	}
}
class Dice{
	public int[] d = new int[6];
	private int temp=0;	
	void N(){
		temp=d[0];
		d[0]=d[1];
		d[1]=d[5];
		d[5]=d[4];
		d[4]=temp;
	}
	void S(){
		temp=d[0];
		d[0]=d[4];
		d[4]=d[5];
		d[5]=d[1];
		d[1]=temp;
	}
	void E(){
		temp=d[0];
		d[0]=d[3];
		d[3]=d[5];
		d[5]=d[2];
		d[2]=temp;
	}
	void W(){
		temp=d[0];
		d[0]=d[2];
		d[2]=d[5];
		d[5]=d[3];
		d[3]=temp;
	}
	void R(){
		temp=d[1];
		d[1]=d[2];
		d[2]=d[4];
		d[4]=d[3];
		d[3]=temp;
	}
	int getRight(int t, int f){
		for(int i = 0 ; i < 3 ; i ++){
			if(t == d[0]){
				break;
			}
			N();
			if(t == d[0]){
				break;
			}
			W();
		}for(int i = 0 ; i < 3 ; i ++){
			if(f == d[1]){
				break;
			}
			R();
		}
		return d[2];
		
	}
}

Measured memory_bytes: 17208
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int>a(4);
	for(int i=0;i<4;i++){cin>>a[i];}
	SO(a);
	if(a[0]==a[1]&&a[2]==a[3]){cout<<"yes"<<endl;}
	else{cout<<"no"<<endl;}
	
	return 0;
}



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

int main(){

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


Measured memory_bytes: 3088
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, K, A[105];
bool DP[100005], visited[100005];

bool Calc(int turn){
  if (visited[turn] == true) return DP[turn];
  visited[turn] = true;
  if (turn == 0) return DP[0] = false;

  for (int i = 0; i < N; i++){
    if (turn - A[i] < 0) continue;
    if (!Calc(turn - A[i])) return DP[turn] = true;
  }
  return DP[turn] = false;
}

int main(){
  scanf("%d%d",&N,&K);
  for (int i=0;i<N;i++)scanf("%d",&A[i]);

  Calc(K);
  if (DP[K]) printf("First\n");
  else printf("Second\n");

  return 0;
}


Measured memory_bytes: 5120
N, M, *AB = [int(_) for _ in open(0).read().split()]
A, B = AB[::2], AB[1::2]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.root[self.find(x)]


uf = UnionFind(N)
for a, b in zip(A, B):
    uf.unite(a, b)
ans = len(set(uf.find(i) for i in range(1, N + 1))) - 1
print(ans)


Measured memory_bytes: 31664
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,k;
  cin>>n>>k;
  int l = (n+1)/2;
  if(k<=l){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i);

	double ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += sqrt( pow((x.at(i)-x.at(j)),2.0) + pow((y.at(i)-y.at(j)),2.0) );
		}
	}
	ans /= n;
	printf("%.8lf", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int r,b,g;
    cin>>r>>b>>g;
    if((r*100+b*10+g)%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
// Abu Hurayra (HurayraIIT)
// IIT, Jahangirnagar University

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long LL;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int> vi; 

#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio(0);  cin.tie(0);
#define sz(a) int((a).size())
#define space " "
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define pi acos(-1.0)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define MOD 1000000007
#define PRECISION(x) cout << fixed << setprecision(x); 

 
int main()
{
    fast_io
    
    LL n , i , j , ans = 0 ;
    cin >> n ;
    LL divs[n+1] = {0} ;

    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j+=i)
        {
            divs[j]++;
        }
    }
    for(i=1;i<=n;i++)
    {
        ans += i*divs[i] ;
    }
    
    cout << ans << endl;
    
    return 0;
}


 

Measured memory_bytes: 81692
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch DivRemNumber | diff DivRemNumber.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address DivRemNumber.cpp && ./a.out

/*
 
 5/11/2019
 
 6:06-
 
 */

LL N;

vector<LL> divisors(LL N) {
  assert(N>=1);
  vector<LL> res;
  for(LL p=1; p*p<=N; ++p) if(N%p==0) {
    res.push_back(p);
    if(p!=N/p) res.push_back(N/p);
  }
  sort(res.begin(),res.end());
  return res;
}

void solve() {
  vector<LL> ds=divisors(N);
  LL res=0;
  FORR(s,ds) {
    LL m=N/s-1;
    if(0<m&&m>s) res+=m;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stack>
using namespace std;
stack<char> st;
int main()
{
    string s;
	cin>>s;
	int ans=s.size();
	for(int i=0;i<(int)s.size();i++)
    {
		if(!st.empty()&&st.top()=='S'&&s[i]=='T')
		{
			ans-=2;
			st.pop();
		}
		else
		st.push(s[i]);
	}
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 644
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 3005;
typedef long long ll;

int n,a[MAX_N];
ll dp[MAX_N][MAX_N][2];

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%d",a+i);
	for (int s=1; s<=n; s++)
		for (int i=1; i+s-1<=n; i++)
		{
			int j=i+s-1;
			if (i==j)
			{
				dp[i][j][0]=a[i];
				dp[i][j][1]=-a[i];
			}
			else
			{
				dp[i][j][0]=max(a[i]+dp[i+1][j][1],a[j]+dp[i][j-1][1]);
				dp[i][j][1]=min(-a[i]+dp[i+1][j][0],-a[j]+dp[i][j-1][0]);
			}
		}
	printf("%lld\n",dp[1][n][0]);
	return 0;
}


Measured memory_bytes: 139520
#include<cstdio>
#include<cmath>
#include<utility>
using namespace std;
pair<double,double> solve(double *a){
    double x,y;
    if(a[0]==0){
        y=a[2]/a[1];
        x=(a[5]-a[4]*y)/a[3];
    }else if(a[1]==0){
        x=a[2]/a[0];
        y=(a[5]-a[3]*x)/a[4];
    }else if(a[3]==0){
        y=a[5]/a[4];
        x=(a[2]-a[1]*y)/a[0];
    }else if(a[4]==0){
        x=a[5]/a[3];
        y=(a[2]-a[0]*x)/a[1];
    }else{
        y=(a[2]-(a[5]*(a[0]/a[3])))/(a[1]-(a[4]*(a[0]/a[3])));
        x=(a[2]-a[1]*y)/a[0];
    }
    return make_pair(x,y);
}
int main(){
    double a[6];
    for(;;){
        for(int i=0;i<6;i++){
            if(scanf("%lf",&a[i])==-1)return 0;
        }
        pair<double,double> ans=solve(a);
        printf("%.3lf %.3lf\n",rint(ans.first*1000)/1000.0,rint(ans.second*1000)/1000.0);
    }
}

Measured memory_bytes: 0
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

p1 = []
p2 = []
p3 = []

for i in range(N):
    p1.append(xy[i][0] + xy[i][1])
    p2.append(xy[i][0] - xy[i][1])
    p3.append(-xy[i][0] + xy[i][1])

p1_r = max(p1) - min(p1)
p2_r = max(p2) - min(p2)
p3_r = max(p3) - min(p3)

print(max(p1_r, p2_r, p3_r))

Measured memory_bytes: 143252
/// awoooooo

# include <bits/stdc++.h>

# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, k;
int d[N];
vector < int > g[N];
vector < pii > edges;
pii ban;

void dfs(int v, int p){
  for(int i : g[v]){
    if(i == p || i == ban.first || i == ban.second){
      continue;
    }
    d[i] = d[v] + 1;
    dfs(i, v);
  }
}

int main(){
  scanf("%d %d", &n, &k);
  for(int i = 1; i < n; ++i){
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
    edges.push_back(make_pair(a, b));
  }
  int ans = n;
  if(k % 2 == 0){
    for(int i = 1; i <= n; ++i){
      d[i] = 0;
      dfs(i, i);
      int cur = 0;
      for(int j = 1; j <= n; ++j){
        cur += d[j] > k / 2;
      }
      ans = min(ans, cur);
    }
  } else{
    for(auto i : edges){
      ban = make_pair(i.first, i.second);
      d[i.first] = 0;
      d[i.second] = 0;
      dfs(i.first, i.first);
      dfs(i.second, i.second);
      int cur = 0;
      for(int j = 1; j <= n; ++j){
        cur += d[j] > k / 2;
      }
      ans = min(ans, cur);
    }
  }
  printf("%d\n", ans);
  return 0;
}


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


int main(){
  int n,a,b;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }
  
  if(n == 2){
    cin >> a >> b;
    cout << a + b << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    string a,b;
    cin >> a >> b;
    int ans;
    if(LEN(a)>LEN(b)) ans = 0;
    else if(LEN(a)<LEN(b)) ans = 2;
    else if(a>b) ans = 0;
    else if(b>a) ans = 2;
    else ans = 1;

    switch(ans){
        case 0: puts("GREATER");
                break;
        case 1: puts("EQUAL");
                break;
        case 2: puts("LESS");
                break;
    }
    return 0;
}

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

int main(){
  int a, b;

  cin >> a >> b;

  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }

  return 0;
}


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

int main(){
    INT(n);
    vector<int> vec(n),mai(100001,0);
    rep(i,n){
        in(vec[i]);
        mai[vec[i]]++;
    }
    sort(rall(mai));
    priority_queue<int> card;
    for(int i=0;i<100001;i++){
        if(mai[i]>=1)card.push(mai[i]);
        else break;
    }
    //同じカードが2枚以上ある場合に対して操作
    //カードが2枚の時はそのカードと他に2枚のものがあればそれを選んで同時に消すことができる
    //ちょうど3枚の時はそのカードだけを選択して1枚残すことができる
    int a,b;
    while(card.top()>1){
        if(card.top()>=3){
            card.push(card.top()-2);
            card.pop();
        }
        if(card.top()==2){
            a=card.top();
            card.pop();
            b=card.top();
            card.pop();
            a--;
            b--;
            card.push(a);
            if(b>=1)card.push(b);
        }
    }
    out(card.size());
}

Measured memory_bytes: 4620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <time.h>
using namespace std;
int n, m, tmpx, tmpy, r[1005], st[1005], ans[1005];
vector< int > edg[1005];
int dfs(int nown) {
	if(st[nown]) return 1;
	st[nown]= 1;
	for(int i= 0; i < edg[nown].size(); i++) {
		++r[edg[nown][i]];
		if(r[edg[nown][i]] > 1 && st[edg[nown][i]]) {
			for(int j= 0; j <= i; j++) --r[edg[nown][j]];
			st[nown]= 0;
			return 0;
		}
	}
	for(int i= 0; i < edg[nown].size(); i++) {
		if(r[edg[nown][i]] == 1 && dfs(edg[nown][i])) {
			ans[++ans[0]]= nown;
			return 1;
		}
	}
	for(int i= 0; i < edg[nown].size(); i++) --r[edg[nown][i]];
	st[nown]= 0;
	return 0;
}
int main() {
    srand(time(0));
	cin >> n >> m;
	for(int i= 1; i <= m; i++) {
		cin >> tmpx >> tmpy;
		edg[tmpx].push_back(tmpy);
	}
	while(clock() < CLOCKS_PER_SEC * 1.8)
		if(dfs(rand() % n + 1)) break;
	if(ans[0] == 0)
		cout << -1 << endl;
	else {
		cout << ans[0] << endl;
		sort(ans + 1, ans + ans[0] + 1);
		for(int i= 1; i <= ans[0]; i++) cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	vector<vector<int> >d(h, vector<int>(w, -1));
	vector<char*>b(h);
	deque<pair<int, int>> path;
	rep(y, 0, h) {
		b[y] = new char[w + 1];
		scanf("%s", b[y]);
	}
	path.push_back(make_pair(0, 0));
	d[0][0] = 1;
	const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
	while (!path.empty()) {
		pair<int, int> pos = path.front();
		path.pop_front();
		int x = pos.first, y = pos.second;
		if (x == w - 1 && y == h - 1)break;
		rep(i, 0, 4) {
			int x2 = pos.first + dx[i], y2 = pos.second + dy[i];
			if (x2 < 0 || x2 >= w || y2 < 0 || y2 >= h)continue;
			if (d[y2][x2] != -1 || b[y2][x2] == '#')continue;
			d[y2][x2] = d[y][x] + 1;
			path.push_back(make_pair(x2, y2));
		}
	}
	if (d[h - 1][w - 1] == -1)printf("-1\n");
	else {
		int b_count = 0;
		rep(y, 0, h)rep(x, 0, w)if (b[y][x] == '#')b_count++;
		printf("%d\n", w * h - b_count - d[h - 1][w - 1]);
	}
	return 0;
}

Measured memory_bytes: 256
// Shift-JIS（シフトジス）

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

int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int n[] = {A, B, C, D, E};
    int a = 9, b;
    for (int i = 0; i < 5; i++)
    {
        if (n[i] % 10 < a && n[i] % 10 > 0)
        {
            a = n[i] % 10;
            b = i;
        }
    }
    int temp;
    temp = n[b];
    n[b] = n[4];
    n[4] = temp;
    int t = 0;
    int k = 0;
    for (;;)
    {
        if (t % 10 == 0)
        {
            t += n[k];
            k++;
            if (k == 5)
            {
                break;
            }
        }
        else
        {
            t++;
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mi=1
ma=N
for i in range(M):
    L,R=map(int,input().split())
    if L>mi:
        mi=L
    else:
        pass
    if R<ma:
        ma=R
    else:
        pass
if ma<mi:
    print(0)
else:
    print(ma-mi+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, a[200005], b[200005];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii ans;
  erep(i, 1, n) cin >> a[i];
  eper(i, n, 1) {
    int j = i, sum = 0;
    while(j <= n) {
      sum += b[j];
      j += i;
    }
    if (a[i] % 2 != sum % 2) {
      b[i] = 1;
      ans.push_back(i);
    }
  }
  erep(i, 1, n) {
    int j = i, sum = 0;
    while(j <= n) {
      sum += b[j];
      j += i;
    }
    if (a[i] % 2 != sum % 2) {
      return cout << -1 << endl, 0;
    }
  }
  cout << ans.size() << endl;
  rep(i, 0, ans.size()) cout << ans[i] << (i != ans.size()-1 ? " " : "\n");
  return 0;
}




Measured memory_bytes: 4980
n, k = map(int, input().split())
p_list = list(map(int,input().split()))

from collections import deque
d=deque(p_list[:k])
max_val = sum(p_list[:k])
total = max_val
max_idx = 0

for i in range(k, n):
    num = p_list[i]
    total = total + num - d.popleft()
    if total > max_val:
        max_val = total
        max_idx = i-k+1
    d.append(num)

def exp(n):
    return 1+(n-1)*0.5

print(sum(map(exp, p_list[max_idx:max_idx+k])))

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
ll a, b, c;

int main () {
	boost ();
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0;
	else cout << min ({a * b, b * c, a * c});
	return 0;
}

        

Measured memory_bytes: 256