akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int i1, i2, i3;
    char c1, c2;
    cin >> i1 >> c1 >> i2 >> c2 >> i3;

    cout << 2018 << c1;
    cout << setw(2) << setfill('0') <<  i2;
    cout << c2 << setw(2) << setfill('0') <<i3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>



int fac(int n);

int N,M,L;
int i,j,x,g,c,y,z; 
int a[100000];



int main(){

g=0;

scanf("%d%d", &N,&L);


if(0<(L+1-1)){

for (i=2;i <= N ;i++){ 

	g=g+(L+i-1);

}



}else{


	if((L+N-1)<0){

		for (i=1;i < N ;i++){ 

		g=g+(L+i-1);

		}

	}else{


		for (i=1;i <= N ;i++){ 

		g=g+(L+i-1);
		
		}

	}

}

printf("%d",g);

   return(0);
} 





Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long

using namespace std;

vector<int> As;

int main() {
  int N;
  cin >> N;
  
  int A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    As.push_back(A);
  }
  
  ll tmp, ans = 0;
  for (int i = 0; i < N-1; i++) {
    tmp = As[i+1] - As[i];
    if (tmp < 0) {
      ans -= tmp;
      As[i+1] -= tmp;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4288
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin>>a>>b>>c;
  cout<<"A"<<b[0]<<"C"<<"\n";
  return 0;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        while (!isAllSame(N)) {
            N++;
        }

        System.out.println(N);
    }

    private static boolean isAllSame(int N) {
        String str = String.valueOf(N);
        char[] chars = str.toCharArray();

        char c = chars[0];
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] != c) return false;
        }
        return true;
    }

}

Measured memory_bytes: 22996
from fractions import gcd
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
now = A[0]
ans = 0
for i in range(1,N):
    now = now//gcd(now, A[i])*A[i]
for i in range(N):
    ans += now//A[i]
print(ans%MOD)

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int a[n],i,j;
    map<int,int> mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(mp.find(a[i])!=mp.end())
        {
            mp[a[i]]=-1;
        }
        else
        mp[a[i]]=i;
    }
    int count=0,flag;
    for(i=0;i<n;i++)
    {
        flag=1;
        for(j=1;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                auto it=mp.find(a[i]/j);
                if((it!=mp.end() && it->second!=i) || it->second==-1)
                {
                 flag=0;
                 break;
                }
                it=mp.find(j);
                if((it!=mp.end() && it->second!=i) || it->second==-1)
                {
                 flag=0;
                 break;
                }
            }
        }
        if(flag)
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 13784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

set<int> st;
vector<int> t;
int num[3] = {3, 5, 7};

void dfs(int i, const int size)
{
  if (i == size)
  {
    int sum = 0;
    int cnt[10] = {};
    for (int i = t.size() - 1; i >= 0; --i)
    {
      sum += t[i] * pow(10, i);
      cnt[t[i]]++;
    }
    if (cnt[3] > 0 && cnt[5] > 0 && cnt[7] > 0)
      st.insert(sum);
  }
  else
  {
    for (int j = 0; j < 3; ++j)
    {
      t[i] = num[j];
      dfs(i + 1, size);
    }
  }
}

int main()
{
  int n;
  cin >> n;
  for (int i = 3; i < 10; ++i)
  {
    t.clear();
    t.resize(i);
    dfs(0, i);
  }
  dfs(0, 3);
  int cnt = 0;
  for (auto &e : st)
  {
    if (e <= n)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

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

  vector<vector<long long>> dp(N.size()+1,vector<long long>(5,0));
  //dp.at(0).at(0)=1;
  int count=0;
  for(int i=0;i<N.size();i++){
    for(int j=0;j<=K;j++){
      if(j>0) dp.at(i+1).at(j)=dp.at(i).at(j) + dp.at(i).at(j-1)*9;
      else  dp.at(i+1).at(j)=dp.at(i).at(j);
    }
    if(N.at(i)=='0')  continue;
    if(count<5) dp.at(i+1).at(count)++;
    if(count+1<5) dp.at(i+1).at(count+1)+=(N.at(i)-'0')-1;
    count++;
  }
  if(count==K)  dp.at(N.size()).at(K)++;
  cout << dp.at(N.size()).at(K) << endl;

  return 0;
}


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

vector<bool> IsPrime;
void sieve(ll max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(ll i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(ll j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}



int main(){
    int n;
    cin >> n;
    sieve(55556);
    int cnt = 0;
    rep(i, 55556){
        if (IsPrime[i + 2] && (i + 2) % 5 == 1 && cnt < n){
            cout << i + 2 << " ";
            cnt ++;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int stepNum = sc.nextInt();
		int brokenNum = sc.nextInt();
		int[] brokenSteps = new int[brokenNum];
		for(int i = 0; i < brokenNum; i++)brokenSteps[i] = sc.nextInt();
        
        Dp dp = new Dp(stepNum+1);
        for(int index : brokenSteps) Dp.dp[index] = 0;
        int ans = dp.part(stepNum);

		System.out.println(ans);
    }
}

class Dp {
    public static int[] dp;
    public Dp (int num) {
        dp = new int[num];
        for(int i = 0; i < num; i++)dp[i] = -1;
    }

    public int part(int index) {
        if(dp[index] != -1)return dp[index];
        if(index == 0) dp[index] = 1;
        else if(index == 1) dp[index] = 1;
        else dp[index] = part(index-1) + part(index-2);
        while(dp[index] >= Mod.mod) dp[index] -= Mod.mod;
        return dp[index];
    }
}

class Mod{
    static int mod = 1000000007;
}

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

using namespace std;

int main(){
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    */
    int n,k;cin>>n>>k;
    if(k==1){
        cout<<0;
        return 0;
    }
    cout<<(n-k);

   /* #ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> a[1111];
int dp[1111], mn, par[1111];
bool vis[1111], vis1[1111];
vector<int> v;
void dfs(int x, int pa){
    if(vis[x])
        return;
    vis[x]=1;
    dp[x]=dp[pa]+1;
    par[x]=pa;
    vis1[x]=1;
    for(int i=0; i<a[x].size(); ++i){
        if(vis1[a[x][i]]){
            if(dp[x]-dp[a[x][i]]+1<mn){
                mn=dp[x]-dp[a[x][i]]+1;
                int tmp2=a[x][i];
                int tmp1=x;
                v.clear();
                v.push_back(tmp1);
                while(tmp1!=tmp2){
                    tmp1=par[tmp1];
                    assert(tmp1!=0);
                    v.push_back(tmp1);
                }
                assert(mn==v.size());
            }
        }
        else{
            dfs(a[x][i], x);
        }
    }
    vis1[x]=0;
}

int main(){
    int n, m;
    while(cin>>n>>m){
        int x, y;
        for(int i=0; i<m; ++i){
            scanf("%d%d",&x,&y);
            a[x].push_back(y);
        }
        mn=100000;
        for(int i=n; i>=1; --i){
            if(!vis[i]){
                dfs(i, 0);
            }
        }
        if(mn==100000){
            cout<<-1<<endl;
        }
        else{
            cout<<v.size()<<endl;
            assert(mn==v.size());
            for(int i=0; i<v.size(); ++i){
                cout<<v[i]<<endl;
            }
        }
    }
  return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
}




Measured memory_bytes: 3584
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct Edge
{
    int from, to, cost;
};

struct State
{
    ll pos, cnt, cost;
};

bool operator<(const State &e, const State &f)
{
    return e.cost > f.cost;
}

using Graph = vector<vector<Edge>>;

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

    int N, M, C;
    while (cin >> N >> M >> C, N || M || C)
    {
        // dp[i][j] := 点iにj回変更してたどり着いた時のコスト最小値
        vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, INF));
        Graph g(N);
        for (int i = 0; i < M; i++)
        {
            int f, t, c;
            cin >> f >> t >> c;
            f--;
            t--;
            g[f].push_back(Edge{f, t, c});
        }
        priority_queue<State> q;
        q.push(State{0, 0, 0});
        dp[0][0] = 0;
        while (!q.empty())
        {
            auto st = q.top();
            q.pop();
            int pos = st.pos, cnt = st.cnt, c = st.cost;
            if (dp[pos][cnt] < c)
                continue;
            if (cnt >= N)
                continue;
            for (auto const &e : g[pos])
            {
                int to = e.to;
                if (dp[pos][cnt] + e.cost < dp[to][cnt])
                {
                    dp[to][cnt] = dp[pos][cnt] + e.cost;
                    q.push(State{to, cnt, dp[to][cnt]});
                }
                if (dp[pos][cnt] < dp[to][cnt + 1])
                {
                    dp[to][cnt + 1] = dp[pos][cnt];
                    q.push(State{to, cnt + 1, dp[to][cnt + 1]});
                }
            }
        }
        int32_t res = INF;
        for (int j = 0; j <= N; j++)
        {
            if (dp[N - 1][j] > C)
                continue;
            res = min(res, j);
        }
        cout << res << endl;
    }
}



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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*(._.)*/
ll N,K;
vector<ll> A(502);

ll S = 0;


ll solve(ll d){
	vector<ll> r;
	REP(i,N){
		ll Y = A[i] % d;
		//if (Y == 0) continue;
		r.PB(Y);
	}

	sort(ALL(r));

	ll tot = 0;
	REP(i,N){
		tot += r[i];
	}
	int l = N - tot/d;
	ll kneed = 0;
	REP(i,l){
		kneed += r[i];
	}


	if (kneed <= K) return d;
	else return 0;
}

int main(){

	SCLLD2(N,K);

	REP(i,N){
		SCLLD(A[i]);
		S += A[i];
	}
	ll X = 0;
	ll ans = 1;

	while(X * X <= S){
		X++;
		if (S % X != 0) continue;
		ll d = S / X;
		chmax(ans,solve(d));
		chmax(ans,solve(S/d));

	}

	cout << ans << endl;
}


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

int main() {
  int a ,b ,c ,d;
  cin >>a >>b >>c >>d;
  int e = a + b ,f = c + d;
  if (e > f) {
    cout << "Left" << endl;
  }
  if (e == f){
     cout << "Balanced" << endl;
  }
  if (e < f) {
    cout << "Right" << endl;
  }
  
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<pair<double, int>> vec(n);
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    vec.at(i) = make_pair(abs(a - (t - h*0.006)), i);
  }
  sort(vec.begin(), vec.end());
  cout << vec.at(0).second+1 << endl;
}



Measured memory_bytes: 256
N = int(input())
lst = list(map(int, input().split()))

if N < 3:
  print(0)
  exit()

c = 0
for i in range(N-2):
  for j in range(i, N-1):
    for k in range(j, N):
      if sum([lst[i], lst[j], lst[k]]) > 2*max([lst[i], lst[j], lst[k]]):
        if lst[i] != lst[j] and lst[j] != lst[k] and lst[k] != lst[i]:
          c += 1
print(c)

Measured memory_bytes: 9208
N, M = map(int, input().split())
H = tuple(map(int, input().split()))

int1 = lambda x: int(x) - 1
lst = [1] * N
for _ in range(M):
    a, b = map(int1, input().split())
    if H[a] >= H[b]:
        lst[b] = 0
    if H[b] >= H[a]:
        lst[a] = 0
print(sum(lst))


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

int main() {
    string s;
    cin>>s;
    int cnt = 0;
    for(int i=1;s[i];++i) {
        if(s[i]!=s[i-1]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 512
st = list(input())

#print(s)

n = 0
s = 0
w = 0
e = 0

for i in range(len(st)):
    if st[i] == 'N':
        n = 1
    elif st[i] == 'S':
        s = 1
    elif st[i] == 'W':
        w = 1
    elif st[i] == 'E':
        e = 1


if w == e and n == s:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 3060
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort(reverse = True)
    ans = a[0]
    n -= 2
    i = 1
    while n > 0:
        if n == 1:
            ans += a[i]
            break
        else:
            ans += 2 * a[i]
            i += 1
            n -= 2
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 31532
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[sc.nextInt()];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = sc.nextInt();
        }
        long output = 0;
        for(int i=0;i<nums.length;i++){
            nums[i]-=i;
        }
        Arrays.sort(nums);
        int c=nums[(int)((nums.length+1)/2)-1];
        
        for(int i=0;i<nums.length;i++){
            if(nums[i]-c>=0){
                output+=nums[i]-c;
            }else{
               output-=nums[i]-c; 
            }
        }
        System.out.println(output);

    }

}

Measured memory_bytes: 88152
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    map<int, int> mp;
    rep(i, n) {
        mp[a[i]-1]++;
        mp[a[i]]++;
        mp[a[i]+1]++;
    }

    int ans = 0;
    for (auto x : mp) ans = max(ans, x.se);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {

	static int[] swap(int[] card,int n,int p,int c){
		int tmp [];
		tmp=card.clone();
		for(int i=n;i>n-p-c+1;i--){
			if(i>n-p+1)
				tmp[i-c]=card[i];
			else
				tmp[i+p-1]=card[i];
		}

		return tmp;
	}

	public static void main(String[] args){
	int card [];
	int i;

	Scanner s = new Scanner(System.in);
	while(true){
		int n = s.nextInt();
		int r = s.nextInt();

		if(n==0 && r==0) break;
		card = new int[n+1];

		for(i=0;i<n+1;i++)
			card[i]=i;

		for(i=0;i<r;i++){
			int p = s.nextInt();
			int c = s.nextInt();

			card=swap(card,n,p,c);
		}

		System.out.println(card[n]);

	}

	}
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;
int A[200200], B[200200];
int w[200200], v[200200];
int dp[200200];

signed main() {
    cin >> N;
    int ans = 0;
    int mini = INF;
    rep(i, N) {
        cin >> A[i] >> B[i];
        ans += A[i];
        if (A[i] <= B[i]) {
            //cerr << ans << endl;
        } else {
            mini = min(mini, B[i]);
            //cerr << ans << endl;
        }
    }
    bool same = true;
    rep(i, N) {
        same &= (A[i] == B[i]);
    }
    if (same) {
        cout << 0 << endl;
        return 0;
    }
    if (mini == INF)mini = 0;
    cout << ans - mini << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};

signed main(){
  int n,m;cin>>n>>m;
  vector<int> edge[n];
  UnionFind uf(n);
  while(m--){
    int u,v;cin>>u>>v;u--;v--;
    uf.unite(u,v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  vector<int> arr(n,-1);
  vector<int> ni,no,si;
  for(int i=0;i<n;i++){
    if(uf.size(i)==1){
      si.push_back(i);
      continue;
    }
    if(~arr[i])continue;
    arr[i]=0;
    bool out=false;
    queue<int> que;
    que.push(i);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:edge[p]){
        if(~arr[q]){
          if(arr[q]==arr[p])out=1;
        }
        else{
          arr[q]=arr[p]^1;
          que.push(q);
        }
      }
    }
    if(out)no.push_back(uf.size(i));
    else ni.push_back(uf.size(i));
  }
  int ans=0;
  int a=ni.size(),c=no.size(),e=si.size();
  ans=2*a*a+2*a*c+c*c+2*e*n-e*e;
  cout<<ans<<endl;
}

/*
解説AC
連結成分なのでどう言う時に繋がっていくかを考える必要があって、それを元のグラフでの連結成分と結びつける問題
実験コードでひらめく感じはしなくて、でも手を動かすのも相当大変
解説記事も全然なくて考察フローがしっかり考えることしかなさそう？えーちょっとまだ分からんな
自分で解説記事書くしかないかなぁ
FA13分ってなんだよ
*/


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#include<math.h>
#include<iostream>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
int main(){
   //A
   int r;cin>>r;
   cout<<2*M_PI*r<<endl;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++)
	cin>>h[i];
	ll dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1408
def picture_frame(H: int, W: int, A: list)->list:
    return ['#' * (W+2)] + ['#' + s + '#' for s in A] + ['#' * (W+2)]


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    ans = picture_frame(H, W, A)
    print('\n'.join(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


typedef pair<double,double> Pd;

int n;

Pd solve(Pd a, Pd b){
  // a, bを1辺とする正三角形のもう一つの頂点が求めるやつ
  // ただし案時計回りにa, b, cとする
  double a1,a2,b1,b2;
  a1 = a.first; a2 = a.second; b1 = b.first; b2 = b.second;
  Pd c;
  if (a2 == b2){
    // a, b が水平の場合
    c.first = (a1 + b1) / 2;
    c.second = a2;
    double dy = b1 - a1;
    c.second += dy * (double)sqrt(3.0) / 2;
  }else if (a1 < b1){
    c.second = max(a2, b2);
    double dx = (b1 - a1) * 2;
    if (a2 < b2) c.first = b1 - dx;
    else c.first = a1 + dx;
  }else if (a1 > b1){
    c.second = min(a2, b2);
    double dx = abs(b1-a1);
    if (a2 < b2) c.first = b1-dx;
    else c.first = a1+dx;
  }
  return c;
}

void dfs(Pd a, Pd b, int depth){
  // 引数a,bがn=depthのときの始点と終点。
  if (n == depth){
    // 被りを防ぐために始点のみ出力すう
    cout <<fixed <<setprecision(12) <<a.first <<" " <<a.second <<endl;
    return;
  }
  // a, b は4つの領域に分けられる
  Pd a1;
  a1.first = (a.first * 2 + b.first) / 3;
  a1.second= (a.second* 2 + b.second)/ 3;
  Pd a3;
  a3.first = (a.first + b.first * 2) / 3;
  a3.second = (a.second + b.second * 2) / 3;
  Pd a2 = solve(a1, a3);
  dfs(a, a1, depth+1);
  dfs(a1, a2, depth+1);
  dfs(a2, a3, depth+1);
  dfs(a3, b, depth+1);
}

int main() {
  cin >>n;
  dfs(Pd(0.0, 0.0), Pd(100.0, 0), 0);
  cout <<fixed <<setprecision(12) <<100.0 <<" " <<0.0 <<endl;
}


Measured memory_bytes: 3256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import bisect
from heapq import heappop, heappush

import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
l = sorted(LIST())
res = 0

for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        index = bisect.bisect_left(l,a+b)
        res += max(index-j-1,0)

print(res)



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

#define MAX_N 1000000

int bit[MAX_N],n,m,a,b,c;

int sum(int i){
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}

int add(int i,int x){
	while(i<=n){
		bit[i]+=x;
		i+=i&-i;
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		if(a==0){add(b,c);}
		if(a==1){cout<<sum(c)-sum(b-1)<<endl;}
	}
	return 0;
}

Measured memory_bytes: 1552
import sys

N,M = map(int,input().split())
Data = []
for _ in range(M):
    s,c = map(int,input().split())
    Data.append([s,c])

Num = [-1]*N
flag = True
for i in range(M):
    s,c = Data[i]
    if Num[s-1] == -1:
        Num[s-1] = c
    else:
        if Num[s-1] != c:
            print(-1)
            sys.exit()
if N == 1:
    if Num[0] == -1:
        Num[0] = 0
    print(Num[0])

if N == 2:
    if Num[0] == 0:
        print(-1)
    else:
        if Num[0] == -1:
            Num[0] = 1
        if Num[1] == -1:
            Num[1] = 0
        print(Num[0]*10+Num[1])

if N == 3:
    if Num[0] == 0:
        print(-1)
    else:
        if Num[0] == -1:
            Num[0] = 1
        if Num[1] == -1:
            Num[1] = 0
        if Num[2] == -1:
            Num[2] = 0
        print(Num[0]*100+Num[1]*10+Num[2])


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

static const int N = 100;

int main() {
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    
    for(int i = 1; i <= n; i++) {
        cin >> p[i - 1] >> p[i];
    }
    
    for(int i = 1; i <= n; i++) m[i][i] = 0;
    for(int l = 2; l <= n; l++) {
        for(int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            
            for(int k = i; k <= j - 1; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    
    return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	while(1){
	    int t,n,time = 0;
	    cin >> t;
	    if(t == 0) break;
	    cin >> n;

	    int s,f;
	    for(int i = 0; i < n; i++){
            cin >> s >> f;
            time = time + f - s;
	    }
	    if(time >= t) cout << "OK" << endl;
	    else cout << t - time << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
one = [int(i) for i in input().split()]
data = []
while one != [-1, -1, -1]:
    data.append(one)
    one = [int(i) for i in input().split()]

answer = ['F' if i[0] == -1 or i[1] == -1 else 'A' if i[0] + i[1] >= 80 else 'B' if 65 <= i[0] + i[1] < 80 else 'C' if 50 <= i[0] + i[1] < 65 else 'C' if 30 <= i[0] + i[1] < 50 and 50 <= i[2] else 'D' if 30 <= i[0] + i[1] < 50 else 'F' for i in data]
print(*answer, sep="\n")



Measured memory_bytes: 5604
//T??????????????????2?????\????????????????????????
#include <iostream>
#include <string>
using namespace std;

int n;
string s;
int pack[26];

int main(){
	int i;
	cin >> n >> s;
	for( i = 0; i < n; i += 2 ){ pack[s[i] - 'a']++; }
	
	int h, w;
	int ans = 0;
	for( h = 1; h < 10; h++ ){
		int cnt = 0;
		for( w = 0; w < 26; w++ ){
			if( pack[w] == h ){
				cnt++;
			}
		}
		if( h == 1 )
			ans += max(0, 2 * cnt - 1);
		else
			ans += max(0, min(3 + 2 * cnt, 4 * cnt - 1));
		ans += ( cnt > 0 );
	}
	ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using Graph = vector <vector <int>>;

typedef long long ll;

vector <bool> seen;
int dfs (const Graph &G, int v) {
	seen[v] = true;
	int n = 1;
	for (auto next_v : G[v]) {
		if (seen[next_v])
			continue;
		n += dfs(G, next_v);
	}
	return n;
}

int main () {
	int N, M;
	cin >> N >> M;
	Graph G(N);
	for (int i=0; i<M; i++) {
		int a, b;
		cin >> a >> b;
		a --; b --;
		G[a].push_back (b);
		G[b].push_back (a);
	}

	int max = 0;
	seen.assign (N, false);
	for (int v=0; v<N; v++) {
		if (seen[v])
			continue;
		int tmp = dfs (G, v);
		if (tmp > max)
			max = tmp;
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 23516
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
  double p = acos(-1.0);
  double r;
  cin >> r;
  cout << fixed;
  cout << p*r*r << " " << 2*p*r << endl;
  return 0;
}



Measured memory_bytes: 3288
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  int N, a = 0, b = 0;
  ci(N);
  ve<int> H(N);
  rep(i, N){
    ci(H.at(i));
  }
  rep(i, N){
    if(b <= H.at(i)){
      b = H.at(i);
      a++;
    }
  }
  co(a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)

const int MAXN = 2e5+4;
const int MOD = 1e9+7;
const int INF = 1e9+1;
double PI = 3.14159265358979323846;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cout << std::fixed << setprecision(8);
    double a,b,x;
    cin >> a >> b >> x;

    double n = a*a*b/2;
    if(n == x) cout << 45 << endl;
    else if(x < n) {
        double c = x/a/b*2;
        cout << 90-atan(c/b)*180/PI << endl;
    } else {
        double s = a*a*b-x;
        double c = s/a/a*2;
        cout << atan(c/a)*180/PI << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n, k, c = LI()
s = S()
l = [0] * n
r = [0] * n
a = c
x = 0
for i in range(n):
    a += 1
    if s[i] == 'o' and a > c:
        x += 1
        a = 0
    l[i] = x

l = [0] + l
a = c
x = 0
for j in range(n - 1, -1, -1):
    a += 1
    if s[j] == 'o' and a > c:
        x += 1
        a = 0
    r[j] = x

r = r + [0]
for m in range(n):
    if l[m] + r[m + 1] == k - 1:
        print(m + 1)

Measured memory_bytes: 55096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>l(2*n);
    REP(i,2*n)cin >> l[i];
    SORT(l);

    int answer = 0;
    for(int i = 0;i < 2*n;i+=2){
        answer += l[i];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(x) for(int i=0; i<x; i++)
int main(){
    string s1, s2;
    cin >> s1 >> s2;

    char d[256];
    f(256){
        d[i] = '\0';
    }
    f(s1.size()){

        if(d[s1[i]] == s2[i]) continue;
        else{
            if(d[s1[i]] != '\0'){
                cout << "No";
                return 0;
            }
            d[s1[i]] = s2[i];
        }
    }
    f(256){
        d[i] = '\0';
    }
    f(s1.size()){

        if(d[s2[i]] == s1[i]) continue;
        else{
            if(d[s2[i]] != '\0'){
                cout << "No";
                return 0;
            }
            d[s2[i]] = s1[i];
        }
    }
    cout << "Yes";


}


Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i=1; i<=n; i++)
    {
        if (i%2 == 0) continue;
        int cnt = 0;
        for (int j=1; j<=n; j++)
        {
            if (i%j == 0) cnt ++;
        }
        if (cnt == 8) ans ++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
int numbA, numbB;

cin >>  numbA >>  numbB;
if( numbA == 1)
{
   numbA += 13;
}
if( numbB == 1)
{
     numbB += 13;
}
if( numbA >  numbB)
cout << "Alice";
else if( numbA ==  numbB)
cout << "Draw";
else
cout << "Bob";



return 0;
 }


Measured memory_bytes: 256
l,r = map(int,input().split())
l2 = l % 2019
r2 = r % 2019
if r - l >= 2019:
    print(0)
    exit()
else:
    result = 2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            result = min(result,(i*j)% 2019)
            if result == 0:
                print(0)
                exit()
    print(result)


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}


int main()
{
    ll N;
    cin >> N;
    PR((modpow(10,N,MOD)-2*modpow(9,N,MOD)+modpow(8,N,MOD)+MOD*2)%MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 3668
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll N;
ll H;
ll A[100000];
ll K;
ll sa[100000];
ll S;
int main()
{
	cin>>N;
	rep(i,N){
		cin>>A[i];
		S+=A[i];
	}
	H=(N)*(N+1);
	H/=2;
	if(S%H !=0){
		puts("NO");
		return 0;
	}
	K=S/H;
	sa[0]=A[0]-A[N-1];
	rep1(i,N-1){
		sa[i]=A[i]-A[i-1];
	}
	rep(i,N){
		sa[i]-=K;
	}
	bool b=0;
	ll x=0;
	rep(i,N){
		if((-sa[i])%N!=0) b=1;
		if(sa[i]>0) b=1;
		x-=(sa[i]/N);
	}
	if(x!=K) b=1;
	if(b){
		puts("NO");
		return 0;
	}
	else{
		puts("YES");
	}
}

Measured memory_bytes: 1792
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n + 1]; for( i=1; i<=n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n; ll a[n + 1][n + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES
    


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ll n;
        cin >> n;
        ll sum = 0;
        for(ll i = 1;i <= n;++i)
        {
            for(ll j = 1;j <= n;++j)
            {
                for(ll k = 1;k <= n;++k)
                {
                    sum += __gcd(__gcd(i,j),k);
                }
            }
        }
        
        cout << sum;
    }

Measured memory_bytes: 5996
program b 
	real :: n, ansExists, ans
    ansExists = 0
    
    ! nを読む
    read *, n
    
    ! nを1からNまで試し、あてはまるものがあれば出力する
    do i = 1, n
    	if (int(i * 1.08) == n) then
        	ansExists = 1
        	ans = i
            exit
        end if
    end do
    
    ! 答えがあれば出力
    if (ansExists == 1) then
    	print '(i0)', int(ans)
    else
    	print *, ':('
    end if
end program b

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  ll n, d, a;
  cin >> n >> d >> a;
  vector<pll> monster(n);
  for (int i = 0; i < n; i++) cin >> monster[i].first >> monster[i].second;
  sort(monster.begin(), monster.end());

  vector<int> effindex(n);
  //[l, r)の区間で
  int r = 1;
  for (int l = 0; l < n; l++) {
    if (r == n) effindex[l] = n;
    else {
      while((monster[r-1].first - monster[l].first <= 2*d) && (r <= n)) r++;
      effindex[l] = r-1;
    }
  }
  //for (int i = 0; i < n; i++) cout << effindex[i] << " ";
  //cout << endl;

  vector<ll> sublist(n+1);
  ll sub = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    sub += sublist[i];
    //cout << i << " " << sub << endl;
    ll cnt = (monster[i].second - sub * a <= 0) ? 0 :((monster[i].second - sub * a - 1) / a) + 1;
    ans += cnt;
    sub += cnt;
    sublist[effindex[i]] -= cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8740
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    in>>s;
    fr(i,s.length()) cout<<"x";
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[5050],a[5050],n,k,sum=0;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),a[i]=min(a[i],k),sum+=a[i];
	sort(a+1,a+n+2),f[0]=1;
	for(int i=n+1;i;--i){
		bool check=true;
		for(int j=k-1;j>=k-sum&&j>=0;--j)if(f[j]){check=false;break;}
		if(check){printf("%d",i-1);return 0;}
		for(int j=k;j>=a[i];--j)f[j]|=f[j-a[i]];
		sum-=a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

template<typename T>
vector<T> smallest_prime_factors(T n) {
  //1-indexedにできるようにする
    vector<T> spf(n+1);
    //最初は全て素数と仮定する．このとき最小の素因数はその数自身になるはず
    for (T i=0;i<=n;i++) spf[i]=i;
    
    //ある素数の一定倍したものは必ず最小の素因数として元の素数を持つはず
    //これに従い，小さいほうから順に更新をかけていく
    for (T i = 2; i*i <= n; i++) {
        //iが素数の場合
        if (spf[i]==i) {
            // i以上の数でiを素因数に含むものを探し，最小の素因数を更新する
            // i*iより小さいものは必ずiよりも小さい素数ですでに更新されているはず
            for (T j=i*i; j<=n; j+=i) {
                //まだ更新されていないものだけ更新する
                if (spf[j]==j) spf[j]=i;
            }
        }
    }
    return spf;
}

//素因数分解
template<typename T>
vector<T> factolization(T x, vector<T>&spf) {
    vector<T> ret;
    //本来は2から順に割り切れるか試すが，すでに最小の素因数を得ているので，試す必要はない
    while (x!=1) {
        ret.push_back(spf[x]);
        x/=spf[x];
    }
    return ret;
}

ll num_div(ll n, vector<ll> &spf) {
  auto tmp=factolization(n,spf);
  map<ll,ll> mp;
  for(auto&& e: tmp) 
  {
    mp[e]++;
  }
  ll ans=1;
  for(auto&& e: mp) 
  {
    ans*=(e.second+1);
  }
  return ans;
}

int main()
{
  auto spf = smallest_prime_factors(1000050LL);
  ll n,ans=0;
  cin>>n;
  for (int i = 1; i < n; ++i)
  {
    ans+=num_div(n-i,spf);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10996
from bisect import bisect_left
N,H = map(int,input().split())
A = [0]*N
B = [0]*N

for i in range(N):
  a,b = map(int,input().split())
  A[i] = a
  B[i] = b

A = max(A)
B = sorted(B)

count,damage = 0,0
b = bisect_left(B,A)

for i in range(len(B)-1,b-1,-1):
  damage += B[i]
  count += 1
  if damage >= H:
    print(count)
    exit()

count,damage = 0,0
damage = sum(B[b:])
count += len(B[b:])
count += (H-damage)//A
damage = H - (H-damage)%A
if damage == H:
  pass
else:
  count += 1
print(count)

Measured memory_bytes: 11236
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int D[50];
bool dp[2][1<<24];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", D + i);
	
	int cnt[13] = {};
	REP(i, N) cnt[D[i]]++;
	
	bool ng = false;
	if (cnt[0]) ng = true;
	FOR(i, 1, 13) ng |= cnt[i] > 2;
	
	if (ng) {
		puts("0");
		return 0;
	}
	
	// N < 24
	
	int ans = 0;
	
	REP(s, 1<<N) {
		
		int state = 1;
		bool ok = true;
		REP(i, N) {
			if (s >> i & 1) {
				if (state >> (24-D[i]) & 1) ok = false;
				state |= 1 << (24-D[i]);
			}
			else {
				if (state >> D[i] & 1) ok = false;
				state |= 1 << D[i];
			}
		}
		
		if (!ok) continue;
		
		int cur = 100;
		REP(i, 24) if (state >> i & 1) {
			int cnt = 1;
			while (i + cnt < 48 && !(state >> ((i + cnt) % 24) & 1)) cnt++;
			chmin(cur, cnt);
			
			i = i + cnt - 1;
		}
		
		if (cur < 24) chmax(ans, cur);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256