akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

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

    ll n; cin >> n;
    vl a(n); REP(i, n) cin >> a[i];
    ll sum;
    ll cnt;
    ll ans = INFL;

    // + - + ...
    sum = 0;
    cnt = 0;
    REP(i, n)
    {
        sum += a[i];
        if(i % 2 == 0)
        {
            if(sum <= 0)
            {
                cnt += -sum + 1;
                sum = 1;
            }
        }
        else
        {
            if(sum >= 0)
            {
                cnt += sum + 1;
                sum = -1;
            }
        }
    }
    chmin(ans,  cnt);

    // - + - ...
    sum = 0;
    cnt = 0;
    REP(i, n)
    {
        sum += a[i];
        if(i % 2 == 0)
        {
            if(sum >= 0)
            {
                cnt += sum + 1;
                sum = -1;
            }
        }
        else
        {
            if(sum <= 0)
            {
                cnt += -sum + 1;
                sum = 1;
            }
        }
    }
    chmin(ans,  cnt);

    cout << ans << endl;
}

Measured memory_bytes: 3972
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb          push_back
#define pp          pop_back
#define nl          cout << "\n"
#define MIN(con)    (*min_element(ALL(con)))
#define MAX(con)    (*max_element(ALL(con)))
#define NX(cont)    next_permutation(ALL(cont))
#define PX(cont)    prev_permutation(ALL(cont))
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define all(c)      c.begin(),c.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sp          cout << " "
#define ifalse      ios_base::sync_with_stdio(false),cin.tie(NULL)
#define debug(x)    cout << #x << " = " << x << "\n";

using ll = long long;
using ld = long double;
 
template <typename T> T GCD(T a, T b) { ll t; while(a){ t=a; a=b%a; b=t; } return b; }
template <typename T> T LCM(T a, T b) { return (a*b) / GCD(a, b); }
template <typename T> string toString(T a) { return to_string(a); }
template <typename T> void toInt(string s, T &x) { stringstream str(s); str >> x; }

ll add(ll x, ll y, ll MOD) { x += y; if(x >= MOD) x -= MOD; return x; }
ll sub(ll x, ll y, ll MOD) { x -= y; if(x < 0) x += MOD; return x; }
ll mul(ll x, ll y, ll MOD) { return ((x % MOD) * (y % MOD)) % MOD; }

ll powr(ll a, ll b, ll MOD) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a, MOD);
    a = mul(a, a, MOD);
    b >>= 1;
  }
  return x;
}

ll inv(ll a, ll MOD) { return powr(a, MOD-2, MOD); }
const ll INF =  1e18;
const int SINF = 1e9;
const ll MOD = 1e9 + 7;

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/************************************START***************************************/
const int N = 100005;

int main()
{
  ifalse;
  int n = 5;
  vector < int > v;
  rep(i, 0, n) {
    int x;
    cin >> x;
    v.pb(x);
  }
  sort(all(v));
  int ans = SINF;

  do {
    int res = 0;
    int prev = 0;
    for(int i = 0; i < 5; i ++) {
      if(i == 4) {
        res += v[i];
      }
      else {
        res += ((v[i] + 9) / 10) * 10; 
      }
    } 
    ans = min(ans, res);
  } while(next_permutation(all(v)));
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll N;
ll a[444];
ll s[444];
ll mem[444][444];
ll rec(ll l, ll r) {
  if(l+1==r) return 0;
  if(mem[l][r-1]!=-1) return mem[l][r-1];
  
  
  ll res=INF;
  for(ll m=l+1; m<r; m++) {
    chmin(res, rec(l, m)+rec(m, r)-s[l-1]+s[r-1]);
  }
  
  return mem[l][r-1]=res;
}

int main() {
  cin >> N;
  ll i, j;
  
  for(i=1; i<=N; i++) {
    cin >> a[i];
    s[i]=s[i-1]+a[i];
  }
  
  memset(mem, -1, sizeof(mem));
  
  pt(rec(1, N+1));
  
}








Measured memory_bytes: 1792
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    ll min_ = INF, max_ = 0;
    rep(i,0,n) {
        cin >> a[i];
        chmin(min_, a[i]);
        chmax(max_, a[i]);
    }

    cout << max_ - min_ << endl;

}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define ff 					first
#define ss 					second
#define sz(x) 				(int)(x).size()
#define all(x) 				begin(x), end(x)
#define rall(x) 			(x).rbegin(), (x).rend() 
#define rsz 				resize
#define ins 				insert 
#define ft 					front() 
#define bk 					back()
#define pf 					push_front 
#define pb 					push_back
#define eb 					emplace_back 
#define lb 					lower_bound 
#define ub 					upper_bound 
#define pqmax				priority_queue<int>
#define pqmin				priority_queue<int,vector<int>,greater<int>>
#define transup(x)			transform(x.begin(),x.end(),x.begin(),::toupper)
#define translow(x)			transform(x.begin(),x.end(),x.begin(),::tolower)
#define rep(i,a,b) 			for (int i = (a); i < (b); ++i)
#define per(i,a,b) 			for (int i = (b)-1; i >= (a); --i)
#define trav(a,x) 			for (auto a: x)

#define setbits(x)  		__builtin_popcountll(x)
#define zerobits(x)			__builtin_ctzll(x)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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


int main(){

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
    auto start = std::chrono::high_resolution_clock::now();
    /*start from here*/
    
    int x;
    cin>>x;
    if(x>=30){
    	cout<<"Yes\n";
    }else{cout<<"No\n";}

	

	auto stop = std::chrono::high_resolution_clock::now(); 
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); 
    
    // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;     

    return 0;

    /*STUFF TO LOOK:	
	1. Special cases/corner cases(n==0||n==1)
	2. Variables in loops
	3. Input ranges
	*/
}


Measured memory_bytes: 3644
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    x, y = i_map()

    for i in range(x+1):
        turu = i
        kame = x - turu
        # print(turu,kame)
        if (turu * 2 + kame * 4) == y:
            print('Yes')
            exit() 

    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 72656
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int64_t n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
      cout<<((b-a)/2)<<endl;
  }else{
      if(a-1>n-b){
        cout<<(n-b)+1+(n-(a+((n-b)+1)))/2<<endl;
       }else{
        cout<<a+(b-(a+1))/2<<endl;    
        }
  }
  
}

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

using namespace std;
typedef long long ll;

ll V, E;
struct edge{ ll from, to, cost; };
edge edges[2020];
const ll INF = 1LL << 50;

template<typename T>
bool FindNegativeLoop(T& d) {
  for (int i = 0; i < V; i++) {
    d[i] = 0;
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < E; j++) {
      edge e = edges[j];
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;

        if (i == V - 1 && e.to == V - 1) {
          return true;
        }
      }
    }
  }
  return false;
}
template<typename T>
void BellmanFord(T& d, ll s) {
  for(int i = 0; i < V; i++) {
    d[i] = INF;
  }
  d[s] = 0;
  for (int i = 0; i < V - 1; i++) {
    for (int j = 0; j < E; j++) {
      edge e = edges[j];
      if ((d[e.from] != INF) && (d[e.to] > d[e.from] + e.cost)) {
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }
}
int main() {
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    edges[i].from = a - 1;
    edges[i].to = b - 1;
    edges[i].cost = -c;
  }

  vector<ll> d(V);
  if (FindNegativeLoop(d)) {
    cout << "inf" << endl;
  } else {
    BellmanFord(d, 0);
    cout << -d[V - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sumA = a;
		int sumB = b;
		for(int i=1;i<b;i++){
			sumA = Integer.valueOf("" + sumA + a);
		}
		for(int i=1;i<a;i++){
			sumB = Integer.valueOf("" + sumB + b);
		}
		System.out.println(Math.max(sumA, sumB));
		sc.close();
	}

}


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


def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))
    tmp = [0 for _ in range(n)]
    diff = 10 ** 6

    for i, hi in enumerate(h):
        tmp[i] = abs(a - (t - hi * 0.006))

    ans = 0

    for index, j in enumerate(tmp, 1):
        if j < diff:
            diff = j
            ans = index

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int a = ri();
	int b = ri();
	int c = ri();
	int needed = max(0,c-1);
	if (needed > a+b) {
		cout << min(needed,b)+a+b+1 << endl;
	} else cout << b+c << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;


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

    double p = 0;

    for (int i = 1; i <= n; i++) {
        // iを何回２倍したらkを超えるか
        int c = 0;
        int s = i;
        while (true) {
            if (s >= k) {
                break;
            }
            s *= 2;
            c++;
        }
        double ap = 1 / pow(2, c);
        p += ap;
    }

    cout << printf("%.10f", p / n) << endl;
}



Measured memory_bytes: 256
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int n = scanInt(), x = scanInt(), t = scanInt();
        out.print(n % x != 0 ? (n / x + 1) * t : (n / x) * t);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32752
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input().split()
    if a[0] == "0":
        if a[1] == "1":Q.append(a[2])
        else: Q.appendleft(a[2])
    elif a[0] == "1": print(Q[int(a[1])])
    else:
        if a[1] =="1":Q.pop()
        else: Q.popleft()


Measured memory_bytes: 34648
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll n;
vector<vector<ll> >dp(3010,vector<ll>(3010,-1));
vector<ll>a(3010);
ll solve(ll x,ll y){
    if(x>y)return 0;
    if(dp[x][y]!=-1)return dp[x][y];
    ll t=(n-y-x+1)%2;
    ll res;
    if(t){
        res=min(solve(x+1,y)-a[x],solve(x,y-1)-a[y]);
    }else{
        res=max(solve(x+1,y)+a[x],solve(x,y-1)+a[y]);
    }
    dp[x][y]=res;
    return res;
}
int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    ll ans=solve(0,n-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 71296
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  double a;
  cin>>a;
  cout<<pow((a/3),3)<<endl;

}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//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(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/


/*long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}*/

int main(){
    map<string, int> cnt;
    int n;
    cin >> n;
    REP(i, n){
        string tmp;
        cin >> tmp;
        cnt[tmp]++;
    }
    int ans = cnt.size();
    cout << ans << endl;
   
}


Measured memory_bytes: 19116
import sys


def main():
    n = int(input())
    t0 = x0 = y0 = 0
    for line in sys.stdin:
        t1, x1, y1 = map(int, line.split())
        dx = abs(x1 - x0) + abs(y1 - y0)
        dt = t1 - t0
        if dx > dt or dx % 2 != dt % 2:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    long long i;
    long long n,k;
    long long m,cnt=0,t;
    while(~scanf("%lld%lld%lld",&n,&m,&k))
    {
        if(n>m)
        {t=m;
        m=n;
        n=t;
        }
        if(m-n+1<=2*k)
            for(i=n;i<=m;i++)
            printf("%lld\n",i);
            else {
                for(i=n;i<=n+k-1;i++)
                    printf("%lld\n",i);
                for(i=m-k+1;i<=m;i++)
                    printf("%lld\n",i);
            }
           cnt=0;


    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename T>
vector<T> convert_base(T x, T b){
    vector<T> ret;
    T t = 1, k = abs(b);
    while(x){
        ret.emplace_back((x * t) % k);
        if(ret.back() < 0)  ret.back() += k;
        x -= ret.back() * t;
        x /= k;
        t *= b / k;
    }
    if(ret.empty()) ret.emplace_back(0);
    reverse(begin(ret), end(ret));
    return ret;
}

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

    int n;
    cin >> n;
    vector<int> res = convert_base<int>(n, -2);
    int sz = res.size();
    for(int i = 0; i < sz; ++i) cout << res[i];
    cout << "\n";
}

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

int main()
{
	int i, j;
	int N, M, a[50], b[50], c[50], d[50];
	for ( i = 0; i < 50; i++ ){
		a[i] = 0;
		b[i] = 0;
		c[i] = 0;
		d[i] = 0;
	}

	std::cin >> N >> M;
	for ( i = 0; i < N; i++ ){
		std::cin >> a[i] >> b[i];
	}
	for ( j = 0; j < M; j++ ){
		std::cin >> c[j] >> d[j];
	}

	for ( i = 0; i < N; i++ ){  //i番目の学生について
		int j0 = 0;	//j0はi番目の学生からの距離が最も小さいチェックポイント。小さければ更新される
		for ( j = 0; j < M; j++ ){	//番号jのチェックポイントへのマンハッタン距離について
			if( abs( a[i] - c[j0] ) + abs( b[i] - d[j0] ) >  abs( a[i] - c[j] ) + abs( b[i] - d[j] ) ){
			j0 = j;	
			}
			
		}
		std::cout << j0 + 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    U = [[0 for i in range(W)] for j in range(H)]
    D = [[0 for i in range(W)] for j in range(H)]
    L = [[0 for i in range(W)] for j in range(H)]
    R = [[0 for i in range(W)] for j in range(H)]

    for i in range(H):
        for j in range(W):
            # 上方向
            if i > 0:
                if S[i - 1][j] == '#':
                    U[i][j] = 0
                else:
                    U[i][j] = U[i - 1][j] + 1
            
            # 左方向
            if j > 0:
                if S[i][j - 1] == '#':
                    L[i][j] = 0
                else:
                    L[i][j] = L[i][j - 1] + 1
    
    for i in range(H - 1, -1, -1):
        for j in range(W - 1, -1, -1):
            # 下方向
            if i < H - 1:
                if S[i + 1][j] == '#':
                    D[i][j] = 0
                else:
                    D[i][j] = D[i + 1][j] + 1
            
            # 右方向
            if j < W - 1:
                if S[i][j + 1] == '#':
                    R[i][j] = 0
                else:
                    R[i][j] = R[i][j + 1] + 1

    res = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] != '#':
                res = max(res, U[i][j] + D[i][j] + R[i][j] + L[i][j])
    
    print(res + 1)

if __name__ == "__main__":
    main()

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

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

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

    vector<int> a(n);
    map<int, ll> mp;
    ll ans = 0;

    for(int i = 0;i < n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }

    for(auto tmp : mp){
        ans += tmp.second * (tmp.second - 1) / 2;
    }

    for(int i = 0;i < n;i++){
        cout << max(ans - (mp[a[i]] - 1), (ll)0) << endl;
    }




    return 0;
}

Measured memory_bytes: 10240
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String a = input.nextLine();
        int A = Character.getNumericValue(a.charAt(0));
        int B = Character.getNumericValue(a.charAt(1));
        int C = Character.getNumericValue(a.charAt(2));
        int D = Character.getNumericValue(a.charAt(3));
        if(A + B + C + D == 7){
            System.out.printf("%d+%d+%d+%d=7", A, B, C, D);
        }
        else if(A + B + C - D == 7){
            System.out.printf("%d+%d+%d-%d=7", A, B, C, D);
        }
        else if(A + B - C + D == 7){
            System.out.printf("%d+%d-%d+%d=7", A, B, C, D);
        }
        else if(A - B + C + D == 7){
            System.out.printf("%d-%d+%d+%d=7", A, B, C, D);
        }
        else if(A + B - C - D == 7){
            System.out.printf("%d+%d-%d-%d=7", A, B, C, D);
        }
        else if(A - B + C - D == 7){
            System.out.printf("%d-%d+%d-%d=7", A, B, C, D);
        }
        else if(A - B - C + D == 7){
            System.out.printf("%d-%d-%d+%d=7", A, B, C, D);
        }
        else if(A - B - C - D == 7){
            System.out.printf("%d-%d-%d-%d=7", A, B, C, D);
        }
        else{
            return;
        }
    }
}

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

int N,M,C;
int h,w;
int cnt=0;
int temp;
int b[20];
int a[20][20];
int main()
{
  cin >> N >> M>> C;
  for(int i = 0; i < M; i++)
  {
    cin >> b[i];
  }
  for(int i = 0; i < N; i++)
    for(int j = 0; j < M; j++)
      cin >> a[i][j];

  for(int i = 0; i < N; i++) {
   temp = 0;
   for(int j = 0; j < M; j++) {
     temp += a[i][j] * b[j];
   }
   if(temp + C > 0)
     cnt++;

  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
/*
*/
#include<bits/stdc++.h>
using namespace std;
vector<vector<long>>A;
vector<bool>B;
long N,M;
long solve(){
  long s=0;
  for(long i=0;i<M;i++)s+=B[i];if(s==1)return N;
  vector<long>C(M,0);
  for(long i=0;i<N;i++){
    for(long j=0;j<M;j++){
      if(B[A[i][j]-1]){C[A[i][j]-1]++;break;}
    }
  }
  long ans=C[0],id=0;
  for(long i=1;i<M;i++)if(C[i]>=ans){ans=C[i];id=i;}
  assert(B[id]);
  B[id]=0;
  return min(ans,solve());
}
int main(){
  cin>>N>>M;
  A=vector<vector<long>>(N,vector<long>(M));
  for(long i=0;i<N;i++)for(long j=0;j<M;j++)cin>>A[i][j];
  B=vector<bool>(M,1);
  cout<<solve();
}




Measured memory_bytes: 1664
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();

		sc.close();

		int c = 1;
		for (int i = 1; i < S.length(); i++) {
			if (S.charAt(i - 1) != S.charAt(i)) {
				c++;
			}
		}

		out.println(c - 1);

	}

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


Measured memory_bytes: 24508
a = []
[a.append(list(map(int, input().split()))) for _ in range(3)]
n = int(input())
b = [int(input())for _ in range(n)]
for i in b:
  for j in range(3):
    for k in range(3):
      if a[j][k] == i:
        a[j][k] = 1
ans = 0
count =0
for j in range(3):
  if a[j].count(1) == 3:
    ans += 1
  elif (a[0][j] == a[1][j] == a[2][j]) == 1:
    ans += 1
  elif (a[0][0] == a[1][1] == a[2][2]) == 1:
    ans += 1
  elif (a[0][2] == a[1][1] == a[2][0]) == 1:
    ans += 1
if ans > 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#!/usr/bin/env python3
N = int(input())
H = [0]+list(map(int, input().split()))
# same as [0]+[int(h) for h in input().split()]

a = 0
for i in range(1, N+1):
	a += max(H[i]-H[i-1], 0)

print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
int main() {
    LL n,a,b;
    cin >> n >> a >> b;

    LL k  = n / (a+b);
    LL ans = 0;
    ans = a*k;
    LL tmp;
    tmp = n - (a+b) * k;
    if(a <= tmp) {
        ans += a;
    } else {
        ans += tmp;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
<?php
 // 入力を受け取る
 $input = trim(fgets(STDIN));
 $fizbuz = array();
 $ans = 0;
 for($i = 1; $i <= $input; $i++){
     if($i % 3 == 0 && $i % 5 == 0){
        $fizbuz[] = $i;
     }elseif($i % 3 == 0){
        $fizbuz[] = $i;
     }elseif($i % 5 == 0){
        $fizbuz[] = $i;
     }else{
         $ans += $i;
     }
 }
 echo $ans;
?>

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(NULL);
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s[i] - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {
    }
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    vector<int> ans(n);
    rep(i, n) cin >> x[i] >> y[i], x[i]--, y[i]--;
    vector<int> v(n);
    rep(i, n) v[x[i]] = y[i];
    UnionFind uf(n);
    set<int> st;
    rep(i, n) {
        int vi = v[i];
        while (sz(st) && *st.begin() < v[i]) {
            chmin(vi, *st.begin());
            uf.unite(v[i], *st.begin());
            st.erase(st.begin());
        }
        st.insert(vi);
    }
    rep(i, n) {
        cout << uf.size(y[i]) << '\n';
    }
}

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

int main(){
  int s;
  cin >> s;
  int ans=0;
  if(s%10==1) ans++;
  if(s/100==1) ans++;
  if(s/10%10==1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if x > sum(a):
    print(n-1)
    exit()
if x == sum(a):
    print(n)
    exit()
for i in range(n):
    a.pop(0)
    if len(a) == 0:
        print(0)
        exit()
    if x >= sum(a):
        print(n-i-1)
        exit()

Measured memory_bytes: 38384
N=int(input())
S=str(input())

cnt=0
for i in range(N-2):
    k=1
    while True:
        if i+2*k>N-1:
            break
            
        if (S[i]!=S[i+k])and(S[i]!=S[i+k*2])and(S[i+k]!=S[i+k*2]):
            cnt+=1
        k+=1

RGB_cnt=[0,0,0]
for i in range(N):
    if S[i]=="R":
        RGB_cnt[0]+=1
    elif S[i]=="G":
        RGB_cnt[1]+=1
    else:
        RGB_cnt[2]+=1

print(RGB_cnt[0]*RGB_cnt[1]*RGB_cnt[2]-cnt)

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

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

  int r = 0, g = 0, b = 0;
  for (char c : S) {
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }

  long ans = (long) r * g * b;

  for (int i = 0; i < N; i++) {
    for (int j = 1; i + j + j < N; j++) {
      // j = interval
      char c1 = S.at(i);
      char c2 = S.at(i + j);
      char c3 = S.at(i + j + j);
      if (c1 != c2 && c2 != c3 && c3 != c1) ans--;
    }
  }

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long K;
  cin >> K;
  long long cnt = 0;
  queue<string> que;
  rep(i, 9) {
    que.push(to_string(i+1));
    cnt++;
    if(cnt == K) {
      cout << i+1 << endl;
      return 0;
    }
  }

  while(que.size()) {
    string p = que.front();
    que.pop();
    char last = p[p.size()-1];
    string temp;
      if(last != '0') {
          temp = p + to_string(last - '0' - 1);
          que.push(temp);
          cnt++;
          if(cnt == K) {
            cout << temp << endl;
            return 0;
          }
      }
        temp = p + to_string(last - '0');
        que.push(temp);
        cnt++;
        if(cnt == K) {
          cout << temp << endl;
          return 0;
        }
      if(last != '9') {
        temp = p + to_string(last - '0' + 1);
        que.push(temp);
        cnt++;
        if(cnt == K) {
          cout << temp << endl;
          return 0;
        }
      }
  }

  return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

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

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

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

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

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

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N >> M;


	string ans;
	//SOLVE
	if (N==M) {
		ans = "Yes";
	} else {
		ans = "No";
	}

	//OUTPUT
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
for i in range(n-1):
    if h[i] < h[i+1]:
        if h[i] > 0:
            h[i+1] -= 1
for i in range(n-1):
    if h[i] > h[i+1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 14396
#include <iostream>
using namespace std;
int main ()
{
	string a;
	int signal{0};
	cin>>a;
	if (a[0]==a[1]&&a[0]==a[2]) signal=1;
	if (a[1]==a[2]&&a[1]==a[3]) signal = 1;
	if(signal==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author jcg
 */

#include <iostream>

#include <iostream>
#include <iomanip>

class BResistorsInParallel
{
public:
    void solve(std::istream& in, std::ostream& out)
    {
        int n;
        in >> n;

        long double ans = 0;
        for (int i = 0; i < n; ++i)
        {
            int a;
            in >> a;
            ans += 1.0L / a;
        }
        out << std::fixed << std::setprecision(20) << 1.0L / ans << '\n';
    }
};


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    in.tie(0);
    BResistorsInParallel solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

// 入力
long long x;

int main(void) {
    cin >> x;

    long long cnt;
    cnt = x / 11 * 2;
    long long rem = x % 11;
    if (rem > 6) {
        cnt += 2;
    } else if (rem > 0) {
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

struct edge{ll to,cost;};
ll n,k,q;
vector<vector<edge>> g;
vector<ll> dis;
//k点対他点距離
vector<bool> checked;
void dfs(ll from,ll d){
    checked[from]=true;
    dis[from]=d;
    for(auto x:g[from]){
        if(checked[x.to]) continue;
        dfs(x.to,d+x.cost);
    }
}
int main(){
    /*考察
    K点を根として距離を持てばいい。
     */
    cin>>n;
    g.resize(n);
    rep(i,n-1){
        ll a,b,c;edge e1,e2;
        cin>>a>>b>>c;
        a--;b--;
        e1.to=b;e1.cost=c;
        e2.to=a;e2.cost=c;
        g[a].push_back(e1);
        g[b].push_back(e2);
    }
    cin>>q>>k;k--;
    checked.resize(n);dis.resize(n);
    rep(i,n){checked[i]=false;dis[i]=0;}
    dfs(k,0);
    vector<ll> ans(q);
    rep(i,q){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        ans[i]=dis[x]+dis[y];
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15104
input()
d = {}
for a in input().strip().split():
    x = int(a)
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

w = 0
for k in sorted(d.keys(), reverse=True):
    if d[k] >= 2:
        if not w:
            if d[k] >= 4:
                print(k * k)
                raise SystemExit
            else:
                w = k
        else:
            print(k * w)
            raise SystemExit
print(0)

Measured memory_bytes: 23848
#include<iostream>

using namespace std;

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

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < 26; i++){
		bool ok = true;
		for(int j = 0; j < s.length(); j++){
			if(s[j] - 'a' == i) ok = false;
		}
		if(ok){
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N, M, X; cin >> N >> M >> X; 
	int C[15] = {}; 
	int A[15][15] = {}; 
	for(int i = 0; i < N; i++){
		cin >> C[i]; 
		for(int j = 0; j < M; j++) cin >> A[i][j]; 
	}
	int ans = 1145141919; 
	for(int bit = 0; bit < (1 << N); bit++){
		int P[15] = {}; int cost = 0; 
		for(int i = 0; i < N; i++){
			if(!((bit >> i) & 1)) continue; 
			cost += C[i]; 
			for(int j = 0; j < M; j++) P[j] += A[i][j]; 
		}
		bool ok = true; 
		for(int i = 0; i < M; i++){
			if(P[i] < X) ok = false; 
		}
		if(ok) ans = min(ans, cost); 
	}
	if(ans == 1145141919) cout << -1 << endl; 
	else cout << ans << endl; 
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b; cin >> a >> b;
    cout << (a+b)%24 << endl;

    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w = [0 for i in range(N+1)]
v = [0 for i in range(N+1)]
for i in range(1, N+1):
  a, b = map(int, input().split())
  w[i] = a
  v[i] = b
dp = [[0 for j in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
  for j in range(1, W+1):
    if j - w[i] >= 0:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[N][W])

Measured memory_bytes: 217692
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int k,n,ans=0;
    cin>>k>>n;
    vector<int> a(n);
    rep(i,n)
    {
        cin>>a[i];
        if(i==0) continue;
        ans=max(a[i]-a[i-1],ans);
    }
    ans=max(ans,k-a[n-1]+a[0]);
    cout<<k-ans;
}

Measured memory_bytes: 4028
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] v = new int[w];
        
        for (int i = 0; i < w; i++) {
            v[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            String[] s = sc.next().split(",",0);
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            a--;b--;
            int buf = v[a] ;
            v[a] = v[b];
            v[b] = buf;
        }

        sc.close();
        printary(v);
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.println();
            System.out.print(a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26160
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

long long min(int len, ...) {
    long long i, _min, num;
    va_list ap;
    va_start(ap, len);

    _min = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num < _min)
            _min = num;
    }
    va_end(ap);
    return _min;
}

typedef struct {
    long long a, b;
} SHOP;

int cmp(const void *a, const void *b) {
    long long c = (*(SHOP *)a).a - (*(SHOP *)b).a;
    if (c>0) return 1;
    else if (c==0) return 0;
    else return -1;
}

int main(void) {
    int i, j, k, M, N;
    long long C, X;
    SHOP shop[100010];
    scanf("%d%d", &N, &M);
    for (i=0;i<N;i++) scanf("%lld%lld", &shop[i].a, &shop[i].b);

    qsort(shop, N, sizeof(SHOP), cmp);
    X = 0LL;
    C = 0LL;
    for (i=0;i<N;i++) {
        C += shop[i].a * min( 2, M-X, shop[i].b );
        X += min( 2, M-X, shop[i].b );
        if (X == M) break;
    }
    printf("%lld\n", C);
    return 0;
}

Measured memory_bytes: 3324