akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	
	ll N, M;
	cin >> N >> M;
	vll A(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
	}

	ll sum = 0;
	for (int i = 0; i < M; i++)
	{
		sum += A[i];
	}

	cout << max(N - sum, ll(-1));



}





Measured memory_bytes: 3692
a={}
b=[]
for i in range(1,120):
    for j in range(i,120):
        for k in range(j,120):
            n=i*i+j*j+k*k+i*j+i*k+j*k

            if n not in a:
                if i==j and j==k:
                    a[n]=1
                elif i==j or j==k or i==k:
                    a[n]=3
                else:
                    a[n]=6
            else:
                if i==j and j==k:
                    a[n]+=1
                elif i==j or j==k or i==k:
                    a[n]+=3
                else:
                    a[n]+=6

t=int(input())
for i in range(1,t+1):
    if i in a:
        print(a[i])
    else:
        print(0)


Measured memory_bytes: 76232
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=102;
ll dp[M][M];
ll n,m;
char grid[M][M];
ll solve(ll x,ll y)
{
	if(dp[x][y]!=-1)
		return dp[x][y];
	if(x==n && y==m)
		return dp[x][y] = 0;
	dp[x][y] = 1000;
	if(x+1<=n)
	{
		if(grid[x+1][y]!=grid[x][y])
			dp[x][y]=min(dp[x][y],1+solve(x+1,y));
		else
			dp[x][y]=min(dp[x][y],solve(x+1,y));
	}
	if(y+1<=m)
	{
		if(grid[x][y+1]!=grid[x][y])
			dp[x][y]=min(dp[x][y],1+solve(x,y+1));
		else
			dp[x][y]=min(dp[x][y],solve(x,y+1));
	}
	return dp[x][y];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=m;j++)
			cin>>grid[i][j];
	memset(dp,-1,sizeof(dp));
	ll res = solve(1,1);
	res++;
	if(grid[1][1]=='#')
	{
		cout<<(res+1)/2<<"\n";
	}
	else
	{
		cout<<res/2<<"\n";
	}
	return 0;
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    string s, t, r;
    cin >> s >> t >> r;
    Int res = 0;
    rep(i, 0, n) {
        map<char, Int> mp;
        mp[s[i]]++;
        mp[t[i]]++;
        mp[r[i]]++;
        res += mp.size() - 1;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    ll k;
    cin >> k;
    queue<ll> que;
    REP(i, 9){
        que.push(i + 1);
    }
    REP(i, k){
        ll v = que.front(); que.pop();
        if(i == k - 1){
            cout << v << endl;
            break;
        }
        if(v % 10 > 0) que.push(v * 10 + (v % 10) - 1);
        que.push(v * 10 + (v % 10));
        if(v % 10 < 9) que.push(v * 10 + (v % 10) + 1);
    }
}

Measured memory_bytes: 1792
#include <iostream>
#define llint long long

using namespace std;

llint e;

int main(void)
{
  while(1){
    cin >> e;
    if(e == 0) break;
    llint ans = 1e18;
    for(llint y = 0; y*y <= e; y++){
      for(llint z = 0; z*z*z <= e; z++){
        llint x = e - (y*y + z*z*z);
        if(x < 0) continue;
        ans = min(ans, x+y+z);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
  int a,b,c,d;
  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 printf("Balanced\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int   N   = 302;
int n, K, mod;
void add(int& a,int b) {
    a += b;
    if(a >= mod)    a -= mod;
}
int f[N][N];
int S[N][N];
int C[N][N];
signed main()  {
    ios_base::sync_with_stdio(false);   cin.tie(0);
    cin >> n >> K >> mod;
    n++;    K++;
    for(int i = 0 ; i <= n ; ++i) {
        C[i][0] = 1;
        for (int j = 1 ; j <= i ; ++j)
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
    for(int i = 1 ; i <= n ; ++i)   {
        for(int j = 1 ; j <= K ; ++j)   {
            if (i == 1) f[i][j] = 1;
            else
                for(int k = 1 ; k < i ; ++k) {
                    int res = f[k][j] * S[i - k][j - 1] % mod;
                        res = res * C[i - 2][k - 1] % mod;
                    add(f[i][j], res);
                }
            S[i][j] = (S[i][j - 1] + f[i][j]) % mod;
        }
    }
    cout << f[n][K] << endl;
}

Measured memory_bytes: 2432
N, M = map(int, input().split())
Q = [list(map(str, input().split())) for _ in range(M)]

ans = [0] * N
AC = 0
WA = 0

for P in Q:
    p = int(P[0])
    S = P[1]
    if ans[p - 1] == "END":
        continue
    if S == "WA":
        ans[p - 1] += 1
    if S == "AC":
        WA += ans[p - 1]
        AC += 1
        ans[p - 1] = "END"


print(AC, WA)


Measured memory_bytes: 33920
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
c=Counter(l)

edges=[]
for k,v in c.items():
    if v>=2:
        for i in range(v//2):
            edges.append(k)
if len(edges)>=2:
    edges.sort(reverse=True)
    print(edges[0]*edges[1])
else:
    print(0)

Measured memory_bytes: 18592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.next());
		int[][] cards = new int[4][13];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				cards[i][j] = 0;
			}
		}
		for (int k = 1; k <= n; k++) {
			String str = in.next();
			int num = Integer.parseInt(in.next());
			switch (str) {
			case "S":
				cards[0][num - 1] = 1;
				break;
			case "H":
				cards[1][num - 1] = 1;
				break;
			case "C":
				cards[2][num - 1] = 1;
				break;
			case "D":
				cards[3][num - 1] = 1;
				break;
			}
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (cards[i][j] == 0) {
					switch (i) {
					case 0:
						System.out.println("S" + " " + (j + 1));
						break;
					case 1:
						System.out.println("H" + " " + (j + 1));
						break;
					case 2:
						System.out.println("C" + " " + (j + 1));
						break;
					case 3:
						System.out.println("D" + " " + (j + 1));
						break;
					}
				}
			}
		}
	}
}	


Measured memory_bytes: 26200
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    A[i-1] -= i

from statistics import median
#b = math.floor(sum(A) / N)
b = median(A)
ans = 0
for i in range(N):
    ans += abs(A[i] - b)
print(int(ans))


Measured memory_bytes: 26180
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
#define vec vector<int>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, int now) {
	/*if (depth == n)return !now;
	for (int i = 0; i < k; i++) {
		if (dfs(depth + 1, now ^ t[depth][i]))return true;
	}
	/**/
	return false;
}



int main() {
	int n; cin >> n;
	vector<double> v(n); rep(i, n)cin >> v[i];
	double tmp = 0;
	rep(i, n) {
		tmp += 1 / v[i];
	}
	cout<<d10 << 1 / tmp << endl;


	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int abs(int n){
    if (n < 0){
        n = -1 * n;
    }
    return n;
}

int minimum(int a, int b){
    int ans = a;
    if (a > b){
        ans = b;
    }
    return ans;
}

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

    vector <int> A(N);
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        A[i] = a - (i + 1);
    }
    
    sort(A.begin(), A.end());

    long long ans = 0;
    if (N % 2 == 0){
        int b1, b2;
        b1 = A[N / 2 - 1];
        b2 = A[N / 2];

        for (int i = 0; i < N; i++){
            ans += abs(A[i] - b1);
        }
        for (int i = (b1 + b2) / 2 - 1; i <= (b1 + b2) / 2 + 1; i++){
            long long sum = 0;
            for (int j = 0; j < N; j++){
                sum += abs(A[j] - i);
            }
            if (ans > sum){
                ans = sum;
            }
        }
    }else{
        int b;
        b = A[N / 2];
        for (int i = 0; i < N; i++){
            ans += abs(A[i] - b);
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,K) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
int a=Integer.parseInt(line);
BigInteger x=BigInteger.valueOf(a);
System.out.println(prevProbablePrime(a)+" "+x.nextProbablePrime());
}
}
public static int prevProbablePrime(int a){
a--;
while(true){
BigInteger y=BigInteger.valueOf(a);
if(y.isProbablePrime(8)){
return a;
}
a--;
}
}
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;

    int l, r, d;
    cin >> l >> r>> d;
    int count = 0;
    FOR(i, l, r+1) {
        if (i % d == 0) {
            count++;
        }
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	int N, x;
	cin >> N >> x;
	if (N == 2) {
		if (x == 1 || x == 3) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
			cout << 1 << endl << 2 << endl << 3 << endl;
		}
		return 0;
	}
	if (x <= 1 || x >= N * 2 - 1) {
		cout << "No" << endl;
		return 0;
	}
	vector<int> ans(2 * N - 1, -1), used(2 * N, 0);
	if (x == 2) {
		ans[N - 1] = 1;
		ans[N - 2] = x;
		ans[N - 3] = x + 1;
		ans[N] = x + 2;
		used[x] = used[1] = used[x + 1] = used[x + 2] = 1;
	}
	else {
		ans[N - 1] = x+1;
		ans[N - 2] = x;
		ans[N - 3] = 1;
		ans[N] = 2;
		used[x] = used[x + 1] = used[1] = used[2] = 1;
	}
	for (int i = 0, j = 1; i < ans.size(); i++) {
		if (ans[i] == -1) {
			while (used[j])j++;
			ans[i] = j;
			used[j] = 1;
		}
	}
	cout << "Yes" << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

int nth_bit(LL num, int n){
    return (num >> n) & 1;
}

void chmax(LL& a, LL b){
    a = max(a, b);
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    LL N,K;
    cin >> N >> K;
    vector<LL> A(N);
    REP(i,N) cin >> A[i];

    LL dp[41][2];
    for(int d = 40; d>=0; d--) for(int j = 0; j<2; j++) dp[d][j] = -1e18;
    dp[40][0] = 0;

    for(int d = 39; d>=0; d--)
    {
        LL D = 1LL << d;
        int num1 = 0; // その桁の1の数
        for(int i = 0; i < N; i++) if(nth_bit(A[i], d)) num1++;
        int num0 = N - num1; //その桁の0の数

        if(nth_bit(K,d)) //もしKのd桁目が1なら
        {
            chmax(dp[d][0], dp[d+1][0] + D * num0); //1を取れる桁で1を採用
            chmax(dp[d][1], dp[d+1][0] + D * num1); //1を取れる桁で0を採用
        } //もしKのd桁目が0なら
        else
        {
            chmax(dp[d][0], dp[d+1][0] + D * num1);
        }

        chmax(dp[d][1], dp[d+1][1] + D * max(num1, num0));
    }

    cout << max(dp[0][0], dp[0][1]) << endl;


}


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

#define IN freopen("in.txt", "r", stdin);
#define OUT freopen("out.txt", "w", stdout);
#define LL long long int
#define MX 500001
#define max3(a, b, c) max(a, max(b, c)
#define min3(a, b, c) min(a, min(b, c)
#define max4(a, b, c, d) max(a, max3(b, c, d)
#define min4(a, b, c, d) min(a, min3(b, c, d)
#define EPS 1e-9
#define MOD 1000000007
#define PI 2.0 * acos(0.0)
#define PII pair <int, int>
#define VI vector <int>

int a[200][200], dp[200][200];

int main() {
	// IN OUT		//ThisIsForDebuggingPurposes
	
	int n, m;
	scanf("%d%d", &n, &m);

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;

			a[i][j] = (c == '#');
		}
	}

	for (int i = 0; i <= n; i++) {
		dp[i][0] = 500;
	}

	for (int j = 0; j <= m; j++) {
		dp[0][j] = 500;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (i == 1 && j == 1) {
				dp[i][j] = a[i][j];
				continue;
			}
			dp[i][j] = min(dp[i - 1][j] + (a[i - 1][j] == 0 && a[i][j] == 1), dp[i][j - 1] + (a[i][j - 1] == 0 &&  a[i][j] == 1));
			// printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
		}
	}

	cout << dp[n][m] << endl;
}

Measured memory_bytes: 384
import Text.Printf

ft (x,y,z) =
  printf "%d %d %.5F\n" x y z

abp :: [Int] -> (Int, Int, Double)
abp (a:b:_)
  = ( div a b, mod a b, (fromIntegral a) / (fromIntegral b))

main = do
  ab <- getLine
  putStrLn $ ft $ abp $ map (read :: String -> Int) $ words ab

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 100005
ll inf = 1e14;
ll mod = 1e9 + 7;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

vector<ll> adj[N];

ll dp[N][2];

void dfs(ll curr, ll prev1 = -1) {

  dp[curr][0] = 1;
  dp[curr][1] = 1;

  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr);
      dp[curr][0] *= dp[x][1];
      dp[curr][0] %= mod;

      dp[curr][1] *= (dp[x][0] + dp[x][1]);
      dp[curr][1] %= mod;
    }
  }
}

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

  ll n;
  cin >> n;
  for (ll i = 1; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  dfs(1);

  cout << (dp[1][0] + dp[1][1]) % mod << en;

  return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
int main()
{
	int X, Y, N, K, sum=0;
	scanf("%d%d%d%d",&N,&K,&X,&Y);
	if (N < (K + 1))
	{
		sum = N * X;
		printf("%d", sum);
	}

	else
	{
		sum = X * K + (N - K) * Y;
		printf("%d", sum);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

set<ll>sset;
ll mas=3234566667;

void dfs(string t){
	int k=t.size();
	int last=t[k-1]-'0';
	deque<string>cand;
	rep(i,3){
		string now=t;
		int d=-1+i;
		if(last+d>=0&&last+d<10){
			now.push_back('0'+last+d);
		}
		ll num=stoll(now);
		if(mas>=num&&!sset.count(num)){
			sset.insert(num);
			dfs(now);
		}
	}
	
}

void solve()
{
	int n;
	cin>>n;
	rep(i,9){
		string m="0";
		m[0]+=i+1;
		sset.insert(i+1);
		dfs(m);
	}
	auto i=sset.begin();
	int cnt=0;
	ll ans;
	while(i!=sset.end()){
		//cout<<*i<<endl;
		if(cnt==n-1){
			cout<<*i<<endl;
			break;
		}
		i++;
		cnt++;
	}

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


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

int dp[31];

void solve(int n)
{
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 4;
  for(int i = 4; i <= n; i++)
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
}

int main()
{
  int n;
  while(1){
    cin >> n;
    if(n == 0){
      break;
    }else{
      solve(n);
      cout << ceil((double) (ceil((double) dp[n] / 10) / 365)) << endl;
    }
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int alpha[26]={0};
	string s;
	int i;
	cin>>s;
	rep(i,s.length())alpha[s[i]-'a']++;
	rep(i,26){
		if(alpha[i]==0){
			cout<<(char)('a'+i)<<endl;
			return 0;			
		}
	}
	cout<<"None"<<endl;
	
//////////////////////////////////////////////////////
	return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
const int maxn = 100050;

int n, m, deg[maxn], x, y;

int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,m)
	{
		scanf("%d%d",&x,&y);
		deg[x] ++; deg[y] ++;
	}
	fo(i,1,n) if(deg[i]&1) return 0*printf("NO");
	printf("YES"); 
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

void Gaussian_elimination(vector<Bit> &v){
	int v_size = v.size();
    REP(i, m) {
        int pla = -1;
        for(int j = ran;j < v_size;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < v_size;j++){
				if(j == ran)continue;
                if(v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

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

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 4464
#include<cstdio>
#include<cstring>
int main(void){
	char a[][5]={"","SAT","FRI","THU","WED","TUE","MON","SUN"};
	char s[5];
	scanf("%s",s);
	for(int i=1;i<=7;i++){
		if(strcmp(s,a[i])==0) printf("%d",i);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	char s[1000];
	int m,i,j,n=0;
	gets(s);
	m=strlen(s);
	for(i=0;i<m;i++)
	{
		for(j=i+1;j<m;j++)
		{
			if(s[i]==s[j])
			{
				n++;
			}
		}
	}
	if(n==0)
	{
		printf("yes\n");
	}
	else
	{
		printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b){
        for(int i=0;i<a;i++)printf("%d",b);
        printf("\n");
    }
    else{
        for(int i=0;i<b;i++)printf("%d",a);
        printf("\n");
    }
    return 0;
}

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

int main() {
	int num;
	cin >> num;
	int sum = 0;
	int calc = num;
	int digit;
	while (calc) {
		digit = calc % 10;
		sum += digit;
		calc /= 10;
	}
	if (num % sum == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
#define PI 3.14159265359
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int dp[10010];
int main() {
	int h, n; cin >> h >> n;
	int a[1010], b[1010];
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	REP(i, 10010)dp[i] = INF;
	dp[h] = 0;
	for (int i = h; i >= 0; --i) {
		for (int j = 0; j < n; ++j) {
			if (i - a[j] <= 0) {
				dp[0] = min(dp[0], dp[i] + b[j]);
			}
			else {
				dp[i - a[j]] = min(dp[i - a[j]], dp[i] + b[j]);
			}
		}
	}
	cout << dp[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    i64 n, d, a=0,b,c=0;
    string aa, bb, cc;
    cin >> n >> d;
    i64 an[n][d];
        rep(i, n)
    {
        rep(j, d)
        {
            cin >> an[i][j];
        }
    }
    rep(i,n-1)
    {
        for(int j = i+1;j<n;j++)
        {
          b=0;
            rep(k,d)
            {
                b += (an[i][k] - an[j][k]) * (an[i][k] - an[j][k]);
            }
           a = sqrt(b);
               if(a*a==b)c++;
        }
    }
    cout << c;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
const int MAX_N = 100;
int a[MAX_N], b[MAX_N];
int memo[MAX_N + 1][MAX_N + 1];

int getMinCost(int bottom, int top) {
	if (bottom == top) return 0;
	if (memo[bottom][top] != -1) {
		return memo[bottom][top];
	}
	int cost = 0x7ffffff;
	for (int i = bottom; i < top; i++) {
		cost = min(cost, getMinCost(bottom, i) + getMinCost(i + 1, top) + a[bottom] * b[i] * a[i + 1] * b[top]);
	}
	return memo[bottom][top] = cost;
}

int main () {
	int n;
	cin >> n;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << getMinCost(0, n - 1) << endl;
	return 0;
}

Measured memory_bytes: 1212
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  // c
  int n, k, s;
  cin >> n >> k >> s;
  vector<int> ans(n);
  for (int i = 0; i < k; i++) ans[i] = s;
  if (s == 1e9) {
    for (int i = k; i < n; i++) ans[i] = 1;
  } else {
    for (int i = k; i < n; i++) ans[i] = s + 1;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

using namespace atcoder;

li op(li x, li y) {
    return max(y, x);
}

li e() {
    return 0ll;
}

li a[300300];

int main() {

    segtree<li, op, e> seg(300300);
    li n, k;
    cin >> n >> k;
    rin{
        cin >> a[i];
    }
    rin{
        li tmp = 1;
        tmp = max(tmp, seg.prod(max(0ll, a[i] - k), min(a[i] + k + 1, 300300ll)) + 1);
        seg.set(a[i], tmp);
    }

    cout << seg.prod(0, 300300) << endl;

    return 0;
}


Measured memory_bytes: 13708
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] a = new int[M];
        for (int i=0; i<M; i++) {
            a[i] = sc.nextInt();
        }

        int ans = solve(N, M, X, a);
        System.out.println(ans);
    }

    private static int solve(int N, int M, int X, int[] a) {
        int[] score = new int[2];

        int idx = 0;
        for (int i=0; i<M; i++) {
            if (a[i] > X) {
                idx = 1;
            }

            score[idx]++;
        }

        return Math.min(score[0], score[1]);
    }
}


Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h1 = nextInt(scanner);
        int m1 = nextInt(scanner);
        int h2 = nextInt(scanner);
        int m2 = nextInt(scanner);
        int k = nextInt(scanner);
        int h = h2 - h1;
        int m = m2 - m1;
        int day = (h * 60) + m;
        System.out.println(day - k);

    }

    public static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }
}


Measured memory_bytes: 35724
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextString();
        var flg = 0;

        for (var i = 0; i < n.Length; i++) {
            if (i != 0 && n[i] != '9') {
                flg = 1;
            }
        }
        WriteLine(Convert.ToInt32(n[0] + "") + 9 * (n.Length - 1) - flg);
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		boolean flag = true;
		int count = 0;
		while (flag) {
			flag = false;
			int temp = 0;
			for (int i = 1; i < N; i++) {
				if (A[i - 1] > A[i]) {
					temp = A[i];
					A[i] = A[i - 1];
					A[i - 1] = temp;
					count++;
					flag = true;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				System.out.println(A[i]);
			} else {
				System.out.print(A[i] + " ");
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26300
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if i<x:
      if j<=x:
        ans[j-i-1]+=1
      elif j<=y:
        ans[min(j-i-1,x-i+y-j)]+=1
      else:
        ans[x-i+j-y]+=1
    elif i<y:
      if j<=y:
        ans[min(j-i-1,i-x+y-j)]+=1
      else:
        ans[min(j-i-1,i-x+j-y)]+=1
    else:
        ans[j-i-1]+=1

for i in range(n-1):
  print(ans[i])

Measured memory_bytes: 3444
/*
* Desciption:  Desciption
* Created:    2016-02-21
* Author:      JIngwei Xu [mail:xu_jingwei@outlook.com]
*
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<memory.h>
using namespace std;
const int maxn=15,INF=100000;
int dp[maxn][maxn];
int n,t,a,b,c,temp,ans,ai;
int main()
{
	while (scanf("%d",&t)&&t)
	{
		n=0;
		for (int i = 0; i < maxn; i += 1)fill(dp[i],dp[i]+maxn,INF);
		for (int i = 0; i < maxn; i += 1)dp[i][i]=0;
		for (int i = 0; i < t; i += 1)
		{
			scanf("%d",&a);
			scanf("%d",&b);
			scanf("%d",&c);
			dp[a][b]=dp[b][a]=c;
			if(a>n)n=a;
			if(b>n)n=b;
		}
		ans=INF;
		for (int k = 0; k <= n; k += 1)
		{
			for (int i = 0; i <= n; i += 1)
			{
				for (int j = 0; j <= n; j += 1)
				{
					dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
				}
			}
		}
		ans=INF;
		for (int i = 0; i <= n; i += 1)
		{
			temp=0;
			for (int j = 0; j <= n; j += 1)
			{
				if(i==j)continue;
				temp+=dp[i][j];
			}
			if(temp<ans){
				ai=i;
				ans=temp;
			}
		}
		printf("%d %d\n",ai,ans);
		
	}
	return 0;
}

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

string s;

int main()
{
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.length() / 2; i++){
		if(s[i] != s[s.length() - i - 1]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

char mat[8][8];
string ox = "ox";

void output(){
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            cout << mat[i][j];
        }
        cout << endl;
    }
}

int num(int i, int j, int x){
    int ret = 0;
    for(int k = 0; k < 8; k++){
        int ni = i+di[k], nj = j+dj[k], cnt = 0;
        while(inRange(ni,0,8)&&inRange(nj,0,8)&&mat[ni][nj]==ox[1-x]){
            ni += di[k], nj += dj[k], cnt++;
        }
        if(inRange(ni,0,8)&&inRange(nj,0,8)&&mat[ni][nj]==ox[x]){
            ret += cnt;
        }
    }
    return ret;
}

void put(int i, int j, int x){
    for(int k = 0; k < 8; k++){
        int ni = i+di[k], nj = j+dj[k];
        while(inRange(ni,0,8)&&inRange(nj,0,8)&&mat[ni][nj]==ox[1-x]){
            ni += di[k], nj += dj[k];
        }
        if(inRange(ni,0,8)&&inRange(nj,0,8)&&mat[ni][nj]==ox[x]){
            while(ni != i || nj != j){
                ni -= di[k], nj -= dj[k];
                mat[ni][nj] = ox[x];
            }
        }
    }
}

int main(){
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            cin >> mat[i][j];
        }
    }
    bool update = true;
    while(update){
        update = false;
        for(int s = 0; s < 2; s++){
            int pi = -1, pj = -1, cnt = 0;
            for(int i = 0; i < 8; i++){
                for(int j = 0; j < 8; j++){
                    int gi = s==0 ? i : 7-i;
                    int gj = s==0 ? j : 7-j;
                    if(mat[gi][gj] != '.')    continue;
                    int tmp = num(gi, gj, s);
                    if(tmp > cnt)   cnt = tmp, pi = gi, pj = gj;
                }
            }
            if(cnt == 0)    continue;
            update = true;
            put(pi, pj, s);
        }
    }
    output();
    return 0;
}


Measured memory_bytes: 3176
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = ReadLine();
            switch (b)
            {
                case "A":
                    WriteLine("T");
                    break;
                case "T":
                    WriteLine("A");
                    break;
                case "C":
                    WriteLine("G");
                    break;
                case "G":
                    WriteLine("C");
                    break;
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

constexpr int MOD = 1e9+7;

using Pii = pair<int, int>;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Cins(int, n, b);
    
    vc<int> u(n);
    For(i, n) u[i] = min(a[i], b[i]);
    
    ll ans = 1;
    For(i, n){
        // cout << "#" << i << " ";
        int ub = -1;
        if(i == 0 || a[i] != a[i-1]) ub = a[i];
        if(i == n-1 || b[i] != b[i+1]){
            if(ub != -1 && ub != b[i]) Return(0);
            ub = b[i];
        }
        // Cout(ub);
        if(ub > u[i]) Return(0);
        if(ub == -1) ans = (ans * u[i]) % MOD;
        
    }
    Cout(ans);
    
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N * 2);
  for(int i = 0; i < N * 2; i++)cin >> data.at(i);
  sort(data.begin(), data.end());
  long ans = 0;
  for(int i = 0; i < N; i++){
    ans += data.at(i * 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
 
void inorder(Node u){
  if(u !=NIL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}
 
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int mx=10000;
int a[mx];
int tree[mx*4];
//void init(int node, int b, int e)
//{
//    if (b == e) {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    tree[node] = __gcd(tree[Left],tree[Right]);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    return __gcd(p1,p2);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
int main()
{
    ll h,w,c;
    cin>>h>>w;
    if (h == 1 || w == 1) cout << 1 << endl;
	else if (h%2 == 1 && w%2 == 1) 	cout << ((h*w)/2)+1 << endl;
	else cout << h*w/2 << endl;
}


Measured memory_bytes: 256