akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int n, m, a[110];
signed main() {
	cin >> n >> m;
	int oddcount = 0;
	rep(i, m) {
		cin >> a[i];
		if (a[i] & 1)oddcount++;
	}
	if (m == 1) {
		if (a[0] == 1) {
			cout << 1 << endl << 1 << endl << 1 << endl;
			return 0;
		}
		cout << a[0] << endl;
		cout << 2 << endl;
		cout << a[0] - 1 << " " << 1 << endl;
		return 0;
	}
	if (oddcount >= 3) {
		puts("Impossible");
		return 0;
	}
	if (oddcount == 2 && (n & 1)) {
		puts("Impossible");
		return 0;
	}
	REP(i, m - 1) {
		if (a[i] & 1) {
			if (a[0] & 1) {
				swap(a[i], a[m - 1]);
				break;
			}
			swap(a[0], a[i]);
		}
	}
	mt19937_64 mt;
	if (oddcount == 0)shuffle(a, a + m, mt);
	if (oddcount == 1)shuffle(a + 1, a + m, mt);
	if (oddcount == 2 && m >= 3)shuffle(a + 1, a + m - 1, mt);
	vector<int> b;
	rep(i, m - 1) {
		if (i == 0) {
			b.push_back(a[i] + a[i + 1] - 1);
		}
		else b.push_back(a[i + 1]);
	}
	rep(i, m - 1)cout << a[i] << " ";
	cout << a[m - 1] << endl;
	cout << b.size() << endl;
	rep(i, b.size() - 1)cout << b[i] << " ";
	cout << b.back() + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
n,c = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

import numpy as np
a = np.zeros((c+1, 10**5))

for i in range(n):
    a[ab[i][2]][(ab[i][0]-1):ab[i][1]] = [1]*(ab[i][1]-ab[i][0]+1)

b = a.sum(axis=0)

print(int(max(b)))

Measured memory_bytes: 61412
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

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

	ll ans = 0;

	sort(all(a), greater<int>());

	queue<int> que;
	que.push(a[0]);
	rep1(i,n-1) { 
		ans += que.front();
		que.pop();
	  que.push(a[i]);
		que.push(a[i]);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 4780
#include <cstdio>
#include <cstdlib>
#include <algorithm>
typedef long long int64;
static const int MAXN = 200004;
static const int MAXQ = 200002;
static const int64 INF = 1LL << 61;

int n, q, a, b, x[MAXQ];

struct sgt {

static const int MAXN = ::MAXN * 2;
int sz;
int l[MAXN], r[MAXN], lch[MAXN], rch[MAXN];
int64 min[MAXN];

inline int build(int L, int R) {
    int idx = sz++;
    l[idx] = L, r[idx] = R, min[idx] = INF;
    if (L == R) {
        lch[idx] = rch[idx] = -1;
    } else {
        int M = (L + R) >> 1;
        lch[idx] = build(L, M);
        rch[idx] = build(M + 1, R);
    }
    return idx;
}
inline void build(int N) { sz = 0, build(1, N); }

int QL, QR; int64 QV;

inline void modify(int idx) {
    min[idx] = std::min(min[idx], QV);
    if (lch[idx] == -1) return;
    if (r[lch[idx]] >= QL) modify(lch[idx]); else modify(rch[idx]);
}
inline void modify(int P, int64 V) { QL = P, QV = V; modify(0); }

inline int64 query(int idx) {
    if (l[idx] >= QL && r[idx] <= QR) return min[idx];
    int64 ans = INF;
    if (r[lch[idx]] >= QL) ans = std::min(ans, query(lch[idx]));
    if (l[rch[idx]] <= QR) ans = std::min(ans, query(rch[idx]));
    return ans;
}
inline int64 query(int L, int R) { QL = L, QR = R; return query(0); }

} posi, nega;

int main()
{
    scanf("%d%d%d%d", &n, &q, &a, &b);
    x[0] = b;
    for (int i = 1; i <= q; ++i) scanf("%d", &x[i]);

    posi.build(n);
    nega.build(n);
    posi.modify(a, 0 + a);
    nega.modify(a, 0 - a);
    int64 global_offset = 0;
    for (int i = 1; i <= q; ++i) {
        int offset_delta = std::abs(x[i] - x[i - 1]);
        int64 real_value = std::min(nega.query(1, x[i]) + x[i], posi.query(x[i], n) - x[i]);
        posi.modify(x[i - 1], real_value + x[i - 1] - offset_delta);
        nega.modify(x[i - 1], real_value - x[i - 1] - offset_delta);
        global_offset += offset_delta;
    }

    int64 ans = INF;
    for (int i = 1; i <= n; ++i) ans = std::min(ans, posi.query(i, i) - i);
    printf("%lld\n", ans + global_offset);

    return 0;
}


Measured memory_bytes: 19712
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;



int main() {
	int n;
	string s;
	char c;
	cin >> n >> s;

	//cin.get(c);
	//cin.get(c);
	int count = 1;

	char pre = s[0];

	for (int i=1; i<n; i++) {
		c = s[i];
		if (pre != c) {
			count++;
			pre = c;
		}
	}
	
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String a=sc.next();
        switch (a){
            case "A":
                System.out.println("T");
                break;
            case "T":
                System.out.println("A");
                break;
            case "C":
                System.out.println("G");
                break;
            case "G":
                System.out.println("C");
                break;
        }
    }
}


Measured memory_bytes: 21716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            long total = 0;
            total += (1000 * (N / 500));
            total += ((N % 500) / 5) * 5;
            out.print(total);
        }

    }
}



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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e5+10;

ll a[MAXN];
ll b[MAXN];
ll ps[MAXN];
ll ss[MAXN];

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

	ll n , res=0;
	cin>>n;

	for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        ps[i]=ps[i-1]+a[i];
    }

    for(ll i=1;i<=n;i++)
    {
        cin>>b[i];
    }

    for(ll i=n;i>=1;i--)
    {
        ss[i]=ss[i+1]+b[i];
        res=max(res , ps[i]+ss[i]);
    }

    cout<<res;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===




int main()
{
	int N; 
	cin >> N;
	Vi A(N), B(N), C(N);
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		--tmp;
		A[i] = tmp;
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; ++i) {
		cin >> C[i];
	}

	int ans = 0;
	int prev = -100;
	for (int i = 0; i < N; ++i) {
		ans += B[A[i]];
		if (A[i] == prev + 1) ans += C[A[i] - 1];
		prev = A[i];
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>

// https://umbccd.io/challenges


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

using namespace std;


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


int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			ll l = gcd(i,j);
			for (int k = 1; k <= n; k++) {
				ans += gcd(l, k);
			}
		}
	}

	cout << ans << endl;

 	return 0;
}


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


using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}

double const eps = 1e-10;
ll const mod = 1e9+7;

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

    int w;
    int a,b;
    cin >> w >> a >> b;
    if ( w+a < b ) cout << b-(w+a);
    else if (w+b < a ) cout << a-(w+b);
    else cout << 0;


    return 0;

    // 274751WM
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvp List;
	public:
	int DIJ(int s,int t){
		priority_queue<P> que;
		vi d(V,inf);
		d[s]=0;
		que.push({0,s});
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<List[v].size();i++){
				int F=List[v][i].first,S=List[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push({-d[F],F});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		V=v;
		List=vvp(v);
	}
	void add_edge(int s,int t,int c){
		List[s].push_back(P(t,c));
		List[t].push_back(P(s,c));
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		g.add_edge(s-1,t-1,1);
	}
	if(g.DIJ(0,n-1)==2) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

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

int main(){
    string S;
    string weather[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    cin >> S;
    for(int i=0; i < 3; i++){
        if(S == weather[i]){
            cout << weather[i+1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime> 
#define full(a) a.begin(), a.end()

#define sz(x) ((ll)(x).size())
#define ll long long
using namespace std;

ll inp() {
    ll n; cin >> n;
    return n;
}

void prvc(vector<ll> vec) {
    for (auto i : vec)cout << i << " ";
    cout << endl;
}

pair<int, int> hat(pair<int, int> l, pair<int, int> r) {
    pair<int, int> ans;
    if (l.first > r.first)swap(l, r);
    if (r.first > l.second) {
        return pair<int, int>(-1, -1);
    }
    ans.first = r.first;
    ans.second = min(l.second, r.second);
    return ans;
}

ll cnm(ll n, ll m) {
    ll k = n - m;
    if (k < m)std::swap(k, m);
    ll l1 = 1;
    for (int i = k + 1; i <= n; i++) {
        l1 *= i;
        if (l1 % m == 0)l1 /= m, m--;
    }
    for (int i = 2; i <= m; i++)
    {
        l1 /= i;
    }
    return l1;
}

void solve() {
    int n = inp();
    ll sum = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        mx = max(v[i], mx);
        if (mx != v[i]) {
            sum += mx - v[i];
        }
    }
    cout << sum;
}

int main()
{
    //ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //ll n; cin >> n;
    //while (n--)
        solve();

    return 0;
}

Measured memory_bytes: 3968
import bisect
A, B, Q = map(int, input().split())
S = [int(input()) for i in range(A)]
S = [-(10**11+1)] + S + [10**11+1]
T = [int(input()) for i in range(B)]
T = [-(10**11+1)] + T + [10**11+1]
X = [int(input()) for i in range(Q)]

for x in X:
    s_left = bisect.bisect_right(S, x)
    s_right = s_left - 1
    t_left = bisect.bisect_right(T, x)
    t_right = t_left - 1
    s1, s2 = S[s_left], S[s_right]
    t1, t2 = T[t_left], T[t_right]
    dis1 = abs(s1-x)+abs(s1-t1)
    dis2 = abs(s1-x)+abs(s1-t2)
    dis3 = abs(s2-x)+abs(s2-t1)
    dis4 = abs(s2-x)+abs(s2-t2)
    dis5 = abs(t1 - x) + abs(t1 - s1)
    dis6 = abs(t1 - x) + abs(t1 - s2)
    dis7 = abs(t2 - x) + abs(t2 - s1)
    dis8 = abs(t2 - x) + abs(t2 - s2)
    print(min(dis1, dis2, dis3, dis4, dis5, dis6, dis7, dis8))

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

int main() {
  int a, i, c = 0;
  cin >> a;
  i = a;
  while (!i == 0) {
    if (i % 10 == 1) c += 1;
    i /= 10;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string date[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
 
int main(){
    int M, D;
    while( cin >> M >> D, M ){
        int d = 3;
        for(int i=0; i<M-1; i++ ){
            d += month[i];
        }
        d += D;
        d %= 7;
        cout << date[d] << endl;
    }
}

Measured memory_bytes: 3124
import java.util.Scanner;
class Main
{
  public static void main(String []args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();
    String s = sc.nextLine();
    if(n<3200)
    {
      System.out.println("red");
      
    }else
    {
      System.out.println(s);
    }

    
  }
}



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

lst = [0] * N #お菓子の数を格納するリスト

for i in range(K):
    d = input() #今回は使用しない
    A = list(map(int, input().split()))
    for a in A:
        lst[a-1] += 1 #indexを合わせてお菓子の数をカウントする。

print(lst.count(0))

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

signed main(void)
{
	int n, cnt, ans;
	cin >> n;
	map<int, int> mp;
	rep(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	ans = cnt = 0;
	for (auto p : mp)
	{
		if (p.second % 2 == 1)
			ans++;
		else
			cnt++;
	}
	if (cnt % 2 == 0)
		ans += cnt;
	else
		ans += cnt - 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
while (input = STDIN.gets)!=nil do
 
    if input == "\n"
        break
    end

	data = [0.000,0.000,0.000,0.000,0.000,0.000]
	
	input = input.split(" ")

	for i in 0..5 
		data[i] = input[i].to_f
	end
		
	num = (data[0]*data[4]) - (data[1]*data[3])

	x = ( data[4]    *data[2] + (data[1]*-1)*data[5])/num + 0
	y = ((data[3]*-1)*data[2] +  data[0]    *data[5])/num + 0
	
    print sprintf("%.3f %.3f\n",x ,y )
	
end

Measured memory_bytes: 6136
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll A[200000], S[200000];

signed main(){
    cin >> N;
    rep(i, N){
        cin >> A[i];
        S[i] = A[i] + (i != 0 ? S[i-1] : 0);
    }

    ll ans = LLONG_MAX;
    rep(i, N-1){
        ans = min(ans, abs(S[N-1]-2*S[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6676
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, w, i;
	char *S = (char *)malloc(sizeof(char) * 1001);
	scanf("%s", S);
	scanf("%d", &w);
	for(N = 0; S[N] != '\0'; N++){}
	for(i = 0; i * w < N; i++){
		printf("%c", S[i * w]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
N=int(input())
nums=list(map(int, input().split()))
dic={}
for each in nums:
  if each not in dic.keys():
    dic.update({each:1})
  else:
    dic.update({each:dic[each]+1})

ans=sum([ int( m*(m-1)/2 ) for m in dic.values() ] )

for each in nums:
  m=dic[each]

  if m<=1:
    print(ans)
  else:
    print(ans-m+1)

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

using namespace std;

#define ll long long

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

	ll nn = N;
	ll sn = 0;

	while (nn > 0) {
		sn += nn % 10;
		nn /= 10;
	}

	if (N % sn == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str,str1;
  cin>>str>>str1;
  int a,b;
  cin>>a>>b;
  string str3;
  cin>>str3;
  if(str3==str)
    cout<<a-1<<" "<<b<<endl;
  else
    cout<<a<<" "<<b-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss,ssss;
  cin>>a>>b;
  if(a<b)
  cout<<0<<endl;
  else cout<<10<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long
const int mod = (int) (1e9) + 7;
const int MX = 777777 + 5;
int fac[MX+5];
int power(int x, int y, int p){
   int res = 1;
   x = x % p;
   while (y){
       if (y & 1)res = (res*x) % p;
       y = y>>1;
       x = (x*x) % p;
   }
   return res;
}
int modInverse(int n, int p){
   return power(n, p-2, p);
}
int C(int n, int r, int p){
   if (r==0)return 1;
   return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p;
}
void init(int mod){
   fac[0] = 1;
   for (int i=1; i<=MX; i++)fac[i] = fac[i-1]*i%mod;
}
main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  init(mod);
  int res=0;
  for(int t=1;t<=h-a;++t){
    int x =  C(t-1+b-1,min(t-1,b-1),mod);
    int y = C(h-t+w-b-1,min(h-t,w-b-1),mod);
    res = (res + (x*y)%mod) % mod;
  }
  cout<<res;
}

Measured memory_bytes: 6272
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]

dp = [[0] * (w + 1) for i in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - wv[i][0] >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(max(dp[n]))

Measured memory_bytes: 152484
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
//const int MOD=1e9+7;
const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}

  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }

  int lower_bound(int w){
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }

  T sum0(int i){
    return sum(i+1);
  }
  void add0(int i,T a){
    add(i+1,a);
  }

  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(int l,int r){
    return sum(r)-sum(l);
  }
};
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> x(N),y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  typedef pair<int,int> P;
  std::vector<P> v(N);
  for(int i=0;i<N;i++)v[i]=P(x[i],y[i]);
  sort(v.begin(),v.end());
  map<int,int> mx,my;//mxはデバッグする時にあると楽
  for(int i=0;i<N;i++)mx[x[i]]=my[y[i]]=0;
  int cnt=0;for(auto &p:my)p.second=++cnt;
  cnt=0;for(auto &p:mx)p.second=++cnt;
  BIT<int> b1(223456,0),b2(223456,0);
  std::vector<int> ru(N,0),rd(N,0),lu(N,0),ld(N,0);
  for(int i=0;i<N;i++){
    ld[i]=b1.sum(my[v[i].second]);
    lu[i]=i-ld[i];
    b1.add(my[v[i].second],1);
  }
  for(int i=N-1;i>=0;i--){
    rd[i]=b2.sum(my[v[i].second]);
    ru[i]=N-1-i-rd[i];
    b2.add(my[v[i].second],1);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int a=pw(2,lu[i]),b=pw(2,ru[i]),c=pw(2,ld[i]),d=pw(2,rd[i]);
    ans+=(((b-1)*(c-1)%MOD)*((a*d)%MOD))%MOD;ans%=MOD;
    ans+=((a-1)*(d-1))%MOD*(b+c-1)%MOD;ans%=MOD;
  }
  ans+=pw(2,N-1)*N%MOD;ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 41216
N=int(input())
D=list(map(int, input().split()))
M=int(input())
T=list(map(int, input().split()))
if N<M:
  print('NO')
  exit()
  
A={}
B={}
for i in D:
  if i not in A:
    A[i]=0
  A[i]+=1
  
for i in T:
  if i not in B:
    B[i]=0
  B[i]+=1
  
for i in B.keys():
  if not i in A:
    print('NO')
    exit()
  if A[i]<B[i]:
    print('NO')
    exit()
print('YES')


Measured memory_bytes: 57684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 9875321
#define maxn 2010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int q(int x){
	int ans=0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int main(){
	int n;
	in(n);
	int ans=inf;
	FOR(i,1,n-1)ans=min(ans,q(i)+q(n-i));
	out(ans);
}
	

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


////////////////////////////////////////////////////////////////////////////////////////
int ans[100010];
int r[100010],l[100010];
int main(){
    cin.tie(0); ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();
    memset(ans,0,sizeof(ans));
    memset(r,0,sizeof(r));
    memset(l,0,sizeof(l));

    for (int i = 0;i < n;i++){

        if (s[i] == 'R'){
            r[i] = i;
        }
        else{
            r[i] = r[i-1];
        }
    }

    for (int i = n - 1;i >= 0;i--){
        if (s[i] == 'L'){
            l[i] = i;
        }
        else{
            l[i] = l[i+1];
        }
    }

    for (int i = 0;i < n;i++){
        int x;
        if (s[i] == 'R'){
            int dist = abs(l[i] - i);
            if (dist % 2 == 0){
                x = l[i]; 
            }
            else{
                x = l[i] - 1;
            }
        }
        else{
            int dist = abs(r[i] - i);
            if (dist % 2 == 0){
                x = r[i];
            }
            else{
                x = r[i] + 1;
            }
        }

        ans[x]++;
    }

    for (int i = 0;i < s.size();i++){
        cout << ans[i] << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

	int tmp = n % 10;
	for (int i = 1; i < 4; ++i)
	{
		int tmp2 = (n / static_cast<int>(pow(10, i))) % 10;
		if (tmp2 == tmp)
		{
			cout << "Bad" << endl;
			return 0;
		}
		tmp = tmp2;
	}

	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<list>

using namespace std;

int main(){
    int n;
    cin >> n;
    list<int> l;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        
        l.push_back(temp);
    }
    auto itr = l.begin();
    int i = 1;
    int cnt = 0;
    while (itr != l.end())
    {
        if(*itr != i)
        {
            cnt++;
            itr = l.erase(itr);
            //brickBrake!
        }
        else
        {
            itr++;
            i++; //nextBrick
        }
    }
    if(*l.begin()!=1)
    {
        cnt = -1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define MAX_A 100010
int cnt[MAX_A];
int main(void){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        cnt[++a]++;
    }                     //读入数列 
    int ans = 0;
    for (int i = 0; i < MAX_A; i++) {
        int cur = cnt[i - 1] + cnt[i] + cnt[i + 1];
        if (cur > ans) ans = cur;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
  int N,L;
  cin >> N >> L;
  vector<string> str(N);
  for(int i=0; i<N; i++){
    cin >> str.at(i);
  }
  sort(str.begin(), str.end());
  for(int i=0; i<N; i++){
    cout << str.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int cnt[MAXSIZE];

int32_t main(){
	fastio();
	int n;
	cin >> n;
	cnt[1] = 1;
	for(int i = 1; i < MAXSIZE; i++){
		cnt[i] = 1;
	}
	for(int i  = 2; i < MAXSIZE; i++){
		if(cnt[i] == 1){
			for(int j = i; j  < MAXSIZE; j += i){
				int k = 0;
				int p = j;
				while(p % i == 0){
					p /= i;
					k++;
				}
				cnt[j] *= (k + 1);
			}
		}
	}
	int ans = 0;
	for(int i = 1; i < n; i++) ans += cnt[i];
	cout << ans;
}

Measured memory_bytes: 11460
n = int(input())
l = [list(input()) for _ in range(3)]

x=[[] for _ in range(n)]
for i in range(3):
    for j in range(n):
        x[j].append(l[i][j])

ans=0
for i in x:
    ans += len(set(i)) - 1

print(ans)

Measured memory_bytes: 9108
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, M[MAX][MAX];

void dijkstra() {

	int minv;
	int d[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while (1)
	{
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}

		if (u == -1)break;
		color[u] = BLACK;

		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}

	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}
	int k, c, u, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}

	dijkstra();

	return 0;
}


Measured memory_bytes: 3112
<?php
$n = (int)fgets(STDIN);
$input = str_split(fgets(STDIN));

//var_dump($input);
//echo count($input);
$intCount=1;
for($i = 1; $i < $n; $i++){
   if($input[$i-1] != $input[$i]) $intCount += 1;
}

echo $intCount.PHP_EOL;

Measured memory_bytes: 10872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5*2+7;
int a[N];
bool st[N];
int main()
{
    ll n,k;
	cin>>n>>k;
	k++;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int> v;
	int res=1;
	while(!st[res])
	{
		v.push_back(res);
		st[res]=1;
		res=a[res];
	}
	int l;
	for(int i=0;i<v.size();i++)
	{
		if(v[i]==res)
		{
			l=i;
			break;
		}
	}
	int len=v.size()-l;
	if(k>v.size())
	{
		k-=v.size();
		k%=len;
		if(k==0) cout<<v[v.size()-1]<<'\n';
		else cout<<v[k+l-1]<<'\n';
	}
	else cout<<v[k-1]<<'\n';
	return 0;
}

Measured memory_bytes: 5236
import java.awt.Point;
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedInputStream bis = new BufferedInputStream(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(bis));
		int N = Integer.parseInt(br.readLine());
		Point [] points = new Point[2*N];
		for (int j = 1;j >= -1;j -= 2) {
			int delta = (j==1)?0:N;
			for (int i = 0;i < N;i++) {
				points[delta + i] = new Point(Integer.parseInt(br.readLine()), j);
			}
		}
		Arrays.sort(points, new Comparator<Point>() {
			public int compare(Point o1, Point o2) {
				return o1.x-o2.x;
			}
		});
		long unmatched = 0, ans = 1;
		long mod = 1000000007;
		for (int i = 0; i < points.length; i++) {
			if (unmatched * points[i].y < 0) {
				ans = ans*Math.abs(unmatched);
				if (ans > mod)
					ans %= mod;
			}
			unmatched += points[i].y;
		}
		System.out.println(ans);
		br.close();
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int,int> P;

int main() {
  int N; cin >> N;
  vector<vector<int>> ab(N, vector<int>(2,0));
  rep(i,N) cin >> ab[i][0]; rep(i,N) cin >> ab[i][1];
  sort(ab.begin(), ab.end(), [](const vector<int> &x, const vector<int> &y){return x[1]<y[1];});
  // for (auto x: ab) cout << x[0] << " " << x[1] << endl;

  vector<P> A, B;
  rep(i,N) {
    A.push_back(make_pair(i,ab[i][0]));
    B.push_back(make_pair(i,ab[i][1]));
  }
  sort(A.begin(),A.end(), [](const P &x, const P &y){return x.second<y.second;});

  rep(i,N) if (A[i].second>B[i].second) { cout << "No" << endl; return 0; }
  int now = 0, count = 0;
  do { now = A[now].first; count++; } while(now!=0);
  if (count!=N) { cout << "Yes" << endl; return 0; }

  string result = "No";
  rep(i,N-1) if (A[i+1].second<=B[i].second) result = "Yes";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7412
#include<stdio.h>
void quick_sort(int *ptr, int left, int right);
void swap(int *ptr1, int *ptr2);

int main()
{
  int i,j,k,N,temp;
  int L[2000];
  int num=0;
  // 数を取得
  scanf("%d",&N);
  // 長さを取得
  scanf("%d",&L[0]);
  for(i=1;i<N;i++)
  {
	  scanf("%d",&L[i]);

  }
  quick_sort(L, 0, N-1);
  
  for(i=0;i<N-2;i++)
  {
    for(j=i+1;j<N-1;j++)
    {
      for(k=j+1;k<N;k++)
      {
        if(L[i] >= L[j]+L[k]) 
        {
          continue;
        }
        if(L[j] >= L[i]+L[k]) 
        {
          continue;
        }
        if(L[k] >= L[j]+L[i]) 
        {
          continue;
        }
        num++;
      }
    }
  }
  
  printf("%d",num);
 
}

void quick_sort(int *ptr, int left, int right)
{
    int i, j;
    
    if(left >= right)
        return;

    j = left;

    for(i=left+1; i <= right; i++)
        if(*(ptr+i) > *(ptr+left))
            swap(ptr+(++j), ptr+i);

    swap(ptr+left, ptr+j);

    quick_sort(ptr, left, j-1);
    quick_sort(ptr, j+1, right);
}

void swap(int *ptr1, int *ptr2)
{
    int w;

    w     = *ptr1;
    *ptr1 = *ptr2;
    *ptr2 = w;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;   
    int g = 0;
    for(int i = 0; i < k; i++){
        if(a > 0){
            g++;
            a--;
        }else if(b > 0){
            b--;
        }else{
            c--;
            g--;
        }
    }
    cout << g;
    return 0;
}

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

int main (){
    int ans=1;
    int a,b,k;cin>>a>>b>>k;
    for(int i=min(a,b);i>=1;i--){
        if(a%i==0&&b%i==0) k--;//,cout<<i<<endl;
        if(k==0){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#b
n = int(input())

pairs = []
if n % 2 == 0:
    for x in range(1, int(n/2) + 1):
        pairs.append([x, n-x + 1])
else:
    for x in range(1, int((n-1)/2) +1):
        pairs.append([x, int((n-1))-x+1])
    pairs.append([n])
# print(f'pairs >>>>> {pairs}')

# connect nodes
edges = []
for x in range(1, n+1):
    for p in pairs:
#         print(f'x: {x}, p: {p}')
        if x in p:
            break
        for node in p:
#             print(sorted([x, node]))
            edges.append(sorted([x, node]))

# print(f'edges >>>>> {edges}')
print(len(edges))
for e in edges:
    print(' '.join([str(i) for i in e]))
    

Measured memory_bytes: 3860
#include <stdio.h>
int main(void)
{
    int m,f,r,i,j;
 
 for(i=1;i>0;i++)
 {
    
        scanf("%d %d %d",&m,&f,&r);
 
		if(m==-1&&f==-1&&r==-1)
		{
			i = i*-1;
		}
     
		else
		{
	
		if(m==-1||f==-1)
		{
			printf("F\n");
		}
		else
		{
 
			if(m+f>=80)
			{
				printf("A\n");
			}   
     
			if(m+f>=65&&m+f<80)
			{
				printf("B\n");
			}
			
			if(m+f>=50&&m+f<65)
			{
			
				printf("C\n");
			
			}
			
			if(m+f>=30&&m+f<50)
			{
				if(r>=50)
				{
					printf("C\n");
				}
				else
				{
					printf("D\n");
				}   
			} 
 
				if(m+f<30)
				{
					printf("F\n");
				}
 
			
		}
	  }
 }	
    return 0;
 
 
 
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    int le=s.size();
    int counter=0;
    rep(i,le){
        if(pow(-1,i)==-1){
            if(s[i]=='1')counter++;
            //else counter--;
        }else{
            if(s[i]=='0')counter++;
            //else counter--;
        }
    }
    std::cout << min(counter,le-counter) << std::endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# 入力
s = input()

def kaibun(s):
  for i in range(len(s)-(len(s)%2)):
    if s[i] != s[-1*i-1]:
      return False
  return True

if len(s) < 3:
  ans = 'No'
else:
  if kaibun(s):
    s_half = s[:(len(s)-1)//2]
    if kaibun(s_half):
      ans = 'Yes'
    else:
      ans = 'No'
  else:
    ans = 'No'
    
print(ans)

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

unsigned GetDigit(unsigned num);

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

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

    int odd_cnt;
    for(int i=1;i<=n;i++){
        if(GetDigit(i)%2 != 0) odd_cnt++;
    }
    cout << odd_cnt << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N>888) cout << 999 << endl;
  else if(N>777) cout << 888 << endl;
  else if(N>666) cout << 777 << endl;
  else if(N>555) cout << 666 << endl;
  else if(N>444) cout << 555 << endl;
  else if(N>333) cout << 444 << endl;
  else if(N>222) cout << 333 << endl;
  else if(N>111) cout << 222 << endl;
  else cout << 111 << endl;
}


Measured memory_bytes: 256
n = int(input())
sl = []
for _ in range(n):
    sl.append(sorted(input()))
sl.sort()
ans = 0
k = 1
prev = []
for s in sl:
    if s == prev:
        ans += k
        k += 1
    else:
        k = 1
        prev = s
print(ans)

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    char a;
    int x=0;
    for (;;) {
        scanf("%c",&a);
        if (a=='\n' || a=='\0') if (x==0) break;
        if (a=='\n' || a=='\0') {
            printf("%d\n",x);
            x=0;
        }
        if (isdigit(a))  x+=(a-48);
    }
    return 0;
}



Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int k = saori.saori_hayami();
		int s = saori.saori_hayami();

		int ans = 0;

		for(int x = 0;x < k+1;x++){
			for(int y = s-x;y >=0;y--){
				int z = s-x-y;
				if(x <= k && y <= k && z <= k){
					ans++;
				}
			}
		}
		System.out.println(ans);


		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21588
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        long n = scanner.nextLong();
        long A = scanner.nextLong();
        long B = scanner.nextLong();
 
        long s = n / (A + B);
        long t = n % (A + B);
        long count = 0;
 
        count = s * A;
        if(t >= A){
            count += A;
        }else{
            count += t;
        }
        System.out.println(count);
        
	}
}

Measured memory_bytes: 35712
import java.util.Scanner;
import java.util.InputMismatchException;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		double ans=(double)(a+b)/2+0.5;
		System.out.println((int)ans);
	}
}


Measured memory_bytes: 23124
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
m = 100
sum = 0
for i in range(N):
	if A[i] % 10 != 0 and m > A[i]:
		m = A[i]
	sum += A[i]
if m == 100:
	print(0)
else:
	if sum % 10 == 0:
		print(sum-m)
	else:
		print(sum)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct UnionFind{
    vector<ll> data;
    UnionFind(ll n): data(n, -1){}
    bool unite(ll a, ll b){
        a = root(a); b = root(b);
        if(a == b) return 1;
        if(data[a] > data[b]) swap(a, b);
        data[a] += data[b];
        data[b] = a;
        return 0;
    }
    bool find(ll a, ll b){ return root(a) == root(b); }
    ll root(ll a){ return data[a] < 0 ? a : data[a] = root(data[a]); }
    ll size(ll a){ return -data[root(a)]; }
    ll operator[](ll a){ return root(a); }
};
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for(auto& i : a) cin >> i;
  for(auto& i : b) cin >> i;
  vector<ll> c(n);
  iota(c.begin(), c.end(), 0);
  sort(c.begin(), c.end(), [&a](ll x, ll y){ return a[x] < a[y]; });
  vector<ll> A(n), B(n);
  for(ll i = 0; i < n; i++){
    A[i] = a[c[i]];
    B[i] = b[c[i]];
  }
  sort(b.begin(), b.end());
  for(ll i = 0; i < n; i++) if(A[i] > b[i]) return puts("No") & 0;
  for(ll i = 0; i < n - 1; i++) if(A[i + 1] <= b[i]) return puts("Yes") & 0;
  vector<ll> d(n);
  iota(d.begin(), d.end(), 0);
  sort(d.begin(), d.end(), [&B](ll x, ll y){ return B[x] < B[y]; });
  UnionFind uf(n);
  for(ll i = 0; i < n; i++) uf.unite(i, d[i]);
  if(uf.size(0) == n) return puts("No") & 0;
  puts("Yes");
}


Measured memory_bytes: 5760