akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mp make_pair
using namespace std;

map<pair<int,int>,int> m;

struct dsu
{
    int fa[200010],rank[200010];
    
    void init(int n)
    {
        for(int i=1;i<=n;i++)
        {
            fa[i]=i;
        }
    }
    
    int find(int x)
    {
        if(fa[x]==x)
        {
            return x;
        }
        return fa[x]=find(fa[x]);
    }
    
    void union_(int x,int y)
    {
        int fx=find(x);
        int fy=find(y);
        if(fx==fy)
        {
            return ;
        }
        if(rank[fx]<rank[fy])
        {
            fa[fx]=fy;
        }
        else
        {
            fa[fy]=fx;
            if(rank[fx]==rank[fy])
            {
                rank[x]++;
            }
        }
    }
    
    int same(int x,int y)
    {
        return find(x)==find(y);
    }
}a,b;

int main()
{
    //give the fucking vjudge a flying fucking
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    a.init(n);
    b.init(n);
    int from,to;
    for(int i=1;i<=x;i++)
    {
        scanf("%d%d",&from,&to);
        a.union_(from,to);
    }
    for(int i=1;i<=y;i++)
    {
        scanf("%d%d",&from,&to);
        b.union_(from,to);
    }
    for(int i=1;i<=n;i++)
    {
        m[mp(a.find(i),b.find(i))]++;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",m[mp(a.find(i),b.find(i))]);
    }
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X;
    cin >> X;
    ll now = 100;
    int ans = 0;
    while (now < X) {
        now *= 1.01;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var count = s.Length - t.Length;
            var ans = t.Length;
            if(s.Contains(t))
            {
                ans = 0;
                System.Console.WriteLine(ans);
                return;
            }
            for (int i = 0; i <= count; i++)
            {
                var sum = 0;
                for (int j = 0; j < t.Length; j++)
                {
                    if(t[j] != s[i+j]) sum++;
                }
                ans = Math.Min(ans, sum);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25968
a=list(map(int,input().split()))
b=0
if a[0]==a[1]==a[2]:
  f=False
else:
  f=True
  
while f:
  if max(a)-min(a)>1:
    a.sort()
    a[0]+=2
    b+=1
  else:
    a.sort()
    a[0]+=1
    a[1]+=1
    b+=1
  if a[0]==a[1]==a[2]:
    f=False

print(b)

Measured memory_bytes: 9108
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a = IO.RSInt;

            Array.Sort(a);
            var ans = a[n / 2] - a[n / 2 - 1];
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static int GCD(int x, int y)
        {
            if (x < y) Swap(ref x, ref y);
            if (y == 0) return x;
            else return GCD(x % y, y);
        }

        public static void Swap(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 20064
t[99],h[99];
main(i,s,N,T,L){
scanf("%d%d%d%d",&N,&T,&L,&L);
for(i=0;i<N;i++)scanf("%d%d",t+i,h+i);
for(i=s=0;;i=(i+1)%N){
	if(t[i]){
		t[i]--;
		if(++T>L)break;
		if(++s==9)s=0;
	}else if(h[i]){
		h[i]--;
		s++;
		if(T<s)break;
		t[i]=s;
		T-=s;
		s=0;
	}else break;
}
printf("%d\n",i+1);exit(0);}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  string s;
  cin>>s;
  rep(i,3){
    if(s[i]=='7'){
      cout<<"Yes";return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        int[] a = new int[n];
        for (int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        ans+=a[n-1];
        int count = n-2;
        boolean b = true;
        for (int i=n-3;i>=0;i--){
            ans+=a[count];
            b=!b;
            if (b)count--;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60232
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<long long> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    long long ans=0;
    sort(h.begin(),h.end());
    for(int i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    for(int i=a[1]; i>=1; i--) {
        int counter = 0;
        REP(j, n) {
            if (a[j]%i == 0) counter++;
            if (counter-j < 0) break; 
        }
        if (counter >= n-1) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 640
<?php
$K = (int)fgets(STDIN);
list($A, $B) = explode(' ', fgets(STDIN));

$A = (int)$A;
$B = (int)$B;

$ans = ceil($A/$K);
if ($A <= $ans * $K && $ans * $K <= $B) {
    echo 'OK';
} else {
    echo 'NG';
}

Measured memory_bytes: 16080
#include <bits/stdc++.h>
using namespace std;
const int maxn = 233;
int c[maxn][maxn];
int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) cin >> c[i][j];
  for(int k = 0; k < 10; k++)
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++)
      c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  int ans = 0;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++){
      int x; cin >> x;
      if(x != -1) ans += c[x][1];
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String N = in.next();
            int K = in.nextInt();

            int length = N.length();
            long[][][] dp = new long[length + 1][K + 1][2];
            dp[0][0][0] = 1;
            for (int i = 0; i < length; i++) {
                int c = N.charAt(i) - '0';
                for (int k = 0; k <= K; k++) {
                    for (int l = 0; l < 2; l++) {
                        for (int n = 0; n < 10; n++) {
                            int kk = k, ll = l;
                            if (n > 0) kk++;
                            if (kk > K) continue;
                            if (ll == 0) {
                                if (n > c) continue;
                                if (n < c) ll++;
                            }
                            dp[i + 1][kk][ll] += dp[i][k][l];
                        }
                    }
                }
            }
            out.println(dp[length][K][0] + dp[length][K][1]);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main(void){
    double a, b; cin >> a >> b;
    double x = (a + b) / 2;
    for(int i = 1; i < 400; i++){
        if(i >= x){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 10L^^9 + 7;

int N;
int X;
int[] S;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      X = readInt();
      S = new int[N];
      foreach (i; 0 .. N) {
        S[i] = readInt();
      }
      S.sort();
      
      auto crt = new long[X + 1];
      foreach (x; 0 .. X + 1) {
        crt[x] = x;
      }
      foreach (i; 0 .. N) {
        auto nxt = new long[X + 1];
        foreach (x; 0 .. X + 1) {
          // insert first
          nxt[x] += crt[x % S[i]];
          // otherwise
          nxt[x] += crt[x] * i;
          nxt[x] %= MO;
        }
        crt = nxt;
      }
      writeln(crt[X]);
    }
  } catch (EOFException e) {
  }
}


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

ll com[2005][2005];

void solve(ll n,ll k) 
{ 
    ll i,j; 
    for (i=0;i<=n;i++) 
    { 
        for(j=0;j<=min(i,k);j++) 
        { 
            if (j==0||j==i) 
                com[i][j] = 1; 
            else
                com[i][j]=(com[i-1][j-1]+com[i-1][j])%mod; 
        } 
    } 
    
}

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

    ll n;
    cin>>n;
    ll k,i;
    cin>>k;
    solve(n,k);
    for(i=1;i<=k;i++)
    {
        cout<<(com[k-1][i-1]*com[n-k+1][i])%mod<<endl;
    }
}

Measured memory_bytes: 30208
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int ll;

int main(){
  ll n, sum = 0;
  cin >> n;
  if(n%2 == 1) cout << 0;
  else{
    ll p = 10, p5 = 5;
    while(n >= p){
      sum += n / p;
      p *= p5;
    }
    cout << sum;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s,t,u; int a,b; 
  cin >> s>>t; cin>>a>>b; cin>>u;
  if (u==s) a--;
  else b--;
  printf("%d %d\n", a,b);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    for(int a=0; a<=2000; a++){
        for(int b=0; b<=2000; b++){
            int c = n-a-b;
            if(a+b+c != n || c < 0) continue;

            if(10000*a + 5000*b + 1000*c == y){
                printf("%d %d %d\n", a, b, c);
                return 0;
            }
        }
    }
    
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n: u128 = read();
    let mut array: Vec<u128> = Vec::new();

    let a = vec![
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
        's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    ];

    while n != 0 {
        n -= 1;
        array.push(n % 26);
        n /= 26;
    }

    for &i in array.iter().rev() {
        print!("{}", a[i as usize]);
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll x, y, ans = 0;
    cin >> x >> y;
    ll k = x;
    while(k <= y)
    {
        ans++;
        k = k*2; //cout << k << " ";
    }
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
s = [[0 for i in range(m)] for i in range(n)]
for i in range(m):
    l = list(map(int,input().split()))
    l.pop(0)
    #print(i)
    for j in l:
        s[j-1][i] = 1
ans = list(map(int,input().split()))
#print(ans)
answer = 0
for i in range(2**n):
    c = [0 for j in range(m)]
    for j in range(n):
        if ((i >> j) & 1):
            for k,l in enumerate(s[j]):
                if l == 1 and c[k] == 1:
                    c[k] = 0
                elif l == 1:
                    c[k] = 1
            #print(c)
            
    if ans == c:
        answer += 1
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = a + b;
    int f = c + d;
    if(e > f) cout << "Left";
    else if(e == f) cout << "Balanced";
    else cout << "Right";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define true_order 0
#define reverse_order 1
int main() {
    string S;
    cin >> S;
    long long int Q;
    cin >> Q;
    deque<char> deq;
    for(int i = 0; i < S.size(); i++) {
        deq.push_back(S[i]);
    }
    int insert_mode = 0;
    for(int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if(T == 1) {
            insert_mode = (insert_mode + 1) % 2;
        } else if(T == 2) {
            int F;
            char C;
            cin >> F >> C;
            if(F == 1 && insert_mode == true_order) {
                deq.push_front(C);
            } else if(F == 2 && insert_mode == true_order) {
                deq.push_back(C);
            } else if(F == 1 && insert_mode == reverse_order) {
                deq.push_back(C);
            } else if(F == 2 && insert_mode == reverse_order) {
                deq.push_front(C);
            }
        }
    }
    long long int size = deq.size();
    for(int i = 0; i < size; i++) {
        char word;
        if(insert_mode == true_order) {
            word = deq.front();
            deq.pop_front();
        } else {
            word = deq.back();
            deq.pop_back();
        }
        cout << word;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
N, A, B = map(int, input().split())

if A % 2 == B % 2:
    print((B - A) // 2)
elif B - A == 1:
    print(min(B - 1, N - A))
else:
    a = ((B - (A - 1) - 1) - 1) // 2 + (A - 1) + 1
    b = (N - (A + (N - B) + 1)) // 2 + (N - B) + 1
    #print(a)
    #print(b)
    print(min(a, b))

Measured memory_bytes: 38256
# -*- coding: utf-8 -*-
n = int(input())
a = [[]]*2
for i in range(2):
    a[i] = list(map(int, input().split()))

result = 0
top_sum = [0]*n
bottom_sum = [0]*n

top_sum[0] = a[0][0]
bottom_sum[0] = sum(a[1])

for j in range(0, n):
    tmp_count = 0
    tmp_count += top_sum[j]
    tmp_count += bottom_sum[j]
    if j < n-1:
        top_sum[j+1] = top_sum[j] + a[0][j+1]
        bottom_sum[j+1] = bottom_sum[j] - a[1][j]
    if result < tmp_count:
        result = tmp_count

print(result)


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

void shellsort(int a[], int n);
void insertionSort(int a[], int n, int g);

long long cnt;
vector<int> G;

int main() {
    int n;
    cin >> n;
    int a[1000000];
    for ( int i = 0; i < n; i++ ) scanf("%d", &a[i]);
    //多くなるかも　速いscanf
    cnt = 0;
    shellsort(a, n);
    cout << G.size() << endl; //line1 m
    for ( int i = G.size() - 1; i >= 0; i-- ) { //line2 m int G[i]
        printf("%d", G[i]);
        if ( i ) printf(" "); //not 0
    }
    printf("\n");
    
    printf("%d\n",cnt); //line3 cnt
    for ( int i = 0; i < n; i++ ) printf("%d\n", a[i]);
    return 0;
}

void shellsort(int a[], int n) {
    for ( int h = 1; ; ) {
        if ( h > n ) break;
        G.push_back(h); //1, 4, 13, 
        h = 3 * h + 1;
    }
    for ( int i = G.size()-1; i >= 0; i-- ) insertionSort(a, n, G[i]);
}

void insertionSort(int a[], int n, int g) {
    for ( int i = g; i < n; i++ ) {
        int v = a[i];
        int j = i - g;
        while ( j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}


Measured memory_bytes: 7208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

struct UnionFind{
    vector<int> parent;
    // parent[i] = jのとき、iの親はj
    // 負の値のとき根であり、その絶対値はは木の要素数
    UnionFind(int N) : parent(N, -1){
        // 初期化
    }
    int root(int x){
    if(parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
    }
    void unite(int x, int y){
        // xとyの木を結合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(size(x) > size(y)){
            // 小さい方の木を大きい方につなげる
            // サイズは負の値で管理している
            parent[rx] += parent[ry];
            parent[ry] = rx;
        }
        else{
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
        return;
    }
    bool isSame(int x, int y){
        // 同じ木に所属するか?
        return root(x) == root(y);
    }
    int size(int x){
        int rx = root(x);
        return -parent[rx];
    }
};

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

    UnionFind uf(n);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i, n){
        ans = max(ans, uf.size(i));
    }

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

Measured memory_bytes: 4060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> v1(n, 0);
    ll k;
    cin >> k;
    for (int i = 1; i < n; ++i) {
        ll u;
        scanf("%lld", &u);
        v1[i] = (u-k)%MOD;
    }
    vector<ll> t1(n, 0);
    ll s = 0;
    for (int i = 1; i < n; ++i) {
        s = (s + v1[i])%MOD;
        t1[i] = s;
    }
    ll x = 0;
    for (int i = 1; i < n; ++i) {
        x = (x + v1[i]*i+(MOD-t1[i-1]))%MOD;
    }
    vector<ll> v2(m, 0);
    cin >> k;
    for (int i = 1; i < m; ++i) {
        ll u;
        scanf("%lld", &u);
        v2[i] = (u-k)%MOD;
    }
    vector<ll> t2(m, 0);
    s = 0;
    for (int i = 1; i < m; ++i) {
        s = (s + v2[i])%MOD;
        t2[i] = s;
    }
    ll y = 0;
    for (int i = 1; i < m; ++i) {
        y = (y + v2[i]*i+(MOD-t2[i-1]))%MOD;
    }
    cout << (x*y)%MOD << "\n";
    return 0;
}


Measured memory_bytes: 3328
N=int(input())
A=map(int, input().split())

color=[0]*9

for a in A:
	if a < 400:
		color[0] = 1
	elif a < 800:
		color[1] = 1
	elif a < 1200:
		color[2] = 1
	elif a < 1600:
		color[3] = 1
	elif a < 2000:
		color[4] = 1
	elif a < 2400:
		color[5] = 1
	elif a < 2800:
		color[6] = 1
	elif a < 3200:
		color[7] = 1
	else:
		color[8] += 1

label=0
for i in range(8):
	label += color[i]

minres = max(label,1)
maxres = label + color[8]

print(minres, maxres)

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

ofstream out("debug.txt");

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

    int n;
    ll cnt = 0;
    cin >> n;
    vl v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(all(v));
    reverse(all(v));
    cnt += v[0];
    int i = 1, j = 1;
    for (; j + 2 <= n - 1; ++i, j += 2)
        cnt += (2LL * v[i]);
    if (j < n - 1)
        cnt += v[i++];
    cout << cnt << '\n';
}

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

int main(){
  double h[10];
  int n=0;

  while(cin>>h[n]){
    n++;
    if(n==10)break;
  }
  sort(h,h+n);
  cout<<h[9]<<endl<<h[8]<<endl<<h[7]<<endl;

    return 0;
}

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

#define MAX 4
int main(void)
{
	int n,i,j;
	char c;
	int num;
	unsigned short his[MAX] = {0};
	char c1[MAX];

	cin >> n;
	for (i=0; i<n; i++) {
		cin >> c;
		cin >> num;

		switch (c) {
		case 'S':
			his[0] |= (1 << (num-1));
			break;
		case 'H':
			his[1] |= (1 << (num-1));
			break;
		case 'C':
			his[2] |= (1 << (num-1));
			break;
		case 'D':
			his[3] |= (1 << (num-1));
			break;
		default:
			break;
		}
	}
	c1[0] = 'S';
	c1[1] = 'H';
	c1[2] = 'C';
	c1[3] = 'D';
	for (i = 0; i < MAX; i++) {
		for (j = 0; j < 13; j++) {
			if ((his[i] & 1) == 0) {
				cout << c1[i] << " " << j+1 << endl;
			}
			his[i] >>= 1;
		}
	}
	return 0;
}



Measured memory_bytes: 3056
#include <stdio.h>

int main(void){
  int w, h, n;
  scanf("%d %d %d", &w, &h, &n);
  int m[n][3];
  for(int i = 0; i < n; i++){
    scanf("%d %d %d", &m[i][0], &m[i][1], &m[i][2]);
  }
  int mw = 0;
  int mh = 0;
  for(int i = 0; i < n; i++){
    switch(m[i][2]){
    case 1:
      if(m[i][0] > mw) mw = m[i][0];
      break;
    case 2:
      if(m[i][0] < w) w = m[i][0];
      break;
    case 3:
      if(m[i][1] > mh) mh = m[i][1];
      break;
    default:
      if(m[i][1] < h ) h = m[i][1];
      break;
    }
  }
  w -= mw;
  h -= mh;
  if(w < 0) w = 0;
  if(h < 0) h = 0;
  printf("%d\n", w * h);
  return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, W, w;
void max_self(ll &a, ll b) {
	a = max(a, b);
}
int main () {
	IOS;
	
	scanf("%d%d", &n, &W);
	vl dp(W + 1);
	for (int i = 0; i < n; i++) {
		ll v;
		scanf("%d%lld", &w, &v);
		for (int j = W - w; j >= 0; j--) {
			max_self(dp[j + w], dp[j] + v); // jika barang ke-i tidak diambil maka j + w
		}
	}
	ll answer = 0;
	for (int i = 0; i <= W; i++) {
		max_self(answer, dp[i]);
	}
	printf("%lld\n", answer);
	return 0;
}

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

int main() {
  ll n;
  cin>>n;
  vector<int> v(n);
  vector<vector<int>> vec(n+1);
  for(int i=0; i<n; i++){
    cin>>v.at(i);
    vec.at(v.at(i)).push_back(i);
  }
  ll s=0;
  for(int i=0; i<=n; i++){
    if(vec.at(i).size()<2)continue;
    else{
      s+=vec.at(i).size()*(vec.at(i).size()-1)/2;
    }
  }
  //cout<<s;
  for(int i=1; i<=n; i++){
    cout<<s-(vec.at(v.at(i-1)).size()>1 ? vec.at(v.at(i-1)).size()-1:0)<<endl;
  }
}






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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.rbegin(), a.rend());
  vector<ll> b;
  b.push_back(a[0]);
  for(int i = 1; i < N; i++) {
    b.push_back(a[i]);
    b.push_back(a[i]);
  }
  ll ans = 0;
  rep(i, N-1) {
    ans += b[i];
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 8944
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v._size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v._size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }
        

        
        ll arr[10000009];
        void solve(){
            cin >> n;

            for(int i=1;i<=n;i++){
                for(int j=i; j <= n; j+=i) arr[j]++;
            }
            ll cnt = 0;
            for(int i=1;i<=n;i++){
                cnt += arr[i] * i;
            }
            cout << cnt << endl;
            

        }



            



        int main(){
            ios_base::sync_with_stdio(false);

         

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 81704
#include <iostream>

int main()
{
	unsigned long N;
	std::cin >> N;

/*
	int modSum = 0;
	for (int i = 1; i < N; i++){
		mod = i % (i + 1);
		modSum += mod;
	}
	mod = N % 1;
	modSum += mod;
*/

	unsigned long modSum = 0;
	for (unsigned long i = 1; i < N; i++)
		modSum += i;

	std::cout << modSum;

	return 0;
}


Measured memory_bytes: 384
"use strict";

function Main(input) {
  input = input.split("\n");
  input = input[0].split(" ");
  var A = parseInt(input[0], 10);
  var B = parseInt(input[1], 10);
  var sum = 0;

  if (A > B) {
    sum += A;
    A--;
  } else {
    sum += B;
    B--;
  }

  sum += Math.max(A, B);
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
const int N = 100054, M = N * 2;

int V, E, Es = 0;
int a[N], d[N], o[N];
int to[M], first[N], next[M];
int p[N];
bool used[N];
ll D[N], f[N];

inline int doz(int x) {return ~(x >> 31) & x;}
inline void down(ll &x, const ll y) {x > y ? x = y : 0;}
inline ll max(const ll x, const ll y) {return x < y ? y : x;}
int ancestor(int x) {return p[x] == x ? x : (p[x] = ancestor(p[x]));}

inline void addedge(int u, int v) {
	to[++Es] = v, next[Es] = first[u], first[u] = Es;
	to[++Es] = u, next[Es] = first[v], first[v] = Es;
}

int main() {
	int i, j, u, v; ll c;
	scanf("%d%d", &V, &E);
	for (i = 1; i <= V; ++i) scanf("%d%d", a + i, d + i), a[i] = doz(a[i] - d[i]), D[i] = d[i];
	for (i = 0; i < E; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	std::iota(p, p + (V + 1), 0), std::iota(o, o + V, 1);
	std::sort(o, o + V, [] (const int x, const int y) {return a[x] < a[y];});
	for (i = 0; i < V; ++i) {
		used[u = o[i]] = true, c = a[u];
		for (j = first[u]; j; j = next[j])
			if (used[to[j]] && (v = ancestor(to[j])) != u)
				p[v] = u, D[u] += D[v], down(c, max(f[v], a[u]) - D[v]);
		f[u] = D[u] + c;
	}
	printf("%lld\n", f[u]);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[n];
    rep(i, n){
        string s;
        int t;
        cin >> s >> t;
        p[i] = make_pair(make_pair(s, -t), i);
    }
    sort(p, p+n);
    rep(i, n){
        cout << p[i].second+1 << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n; i++)
		if (a[i] == a[i - 1])
		{
			ans++;
			a[i] = -1;
		}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{

	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		mathClass keisan =new mathClass();
		for(int i=0; i<times;i++){
			num[i] = scan.nextInt();
		}
//		int[] nouse = keisan.shellSort(num, times);
		int[] nouse = new int[times];
		nouse = keisan.shellSort(num,times);
		keisan.disp(nouse);


	}
}
class mathClass{
	static int cnt = 0;
	public mathClass(){

	}
	//?????????????????????????????????
	public int[] insertSort(int[] A,int n,int g){
		for(int i=g ;i<n;i++){
			int v = A[i];
			int j = i-g;
			while(j>=0 && A[j]>v){
				A[j+g] = A[j];
				j = j - g;
				cnt ++;
			}
			A[j+g] = v;
		}
		return A;
	}
	//?????§?????????????????????
	public int[] shellSort(int[] A,int n){
		int tm=0;
		mathClass keisan =new mathClass();
		cnt = 0;
		int[] ret = A.clone();
		int importG[]  = new int[100];
		tm =0;

		//???????????§?£???°?????°G????¨?????????????G???????????\??????????????\???
		for(int i=1; i<n; i=3*i+1){
			importG[tm] = i;
			tm++;
		}
		//??°???????°?????????¨tm???0??????????????§1????????´??????
		if(tm == 0){
			tm = 1;
			importG[0]=1;
		}
		

		//G?????°????????????????????????????????????????????????
		int G[] = new int [tm];
		for(int i=0;i<tm;i++){

			G[i] = importG[tm-1-i];
		}
		int m = G.length;

		//G?????°?????????????????°????????¨?????????
		keisan.disp2(m,G);

		//?????\??????????????????
		for(int i=0;i<m;i++){
			ret = keisan.insertSort(A, n, G[i]);

		}
		return ret;
	}
	//???????????¨???
	public void disp(int[] ary){//		?????????????????°????????¨?????????
		System.out.println(cnt);
		for(int i=0;i<ary.length;i++){
			System.out.println(ary[i]);
		}
	}
	public void disp2(int m,int[] ary){//		N?????°???N????????°????????¨?????????
		System.out.println(m);
		for(int i=0;i<ary.length;i++){

			System.out.print(ary[i]);
			if(i == ary.length-1){
				System.out.println();
			}
			else{
				System.out.print(" ");
			}
		}
	}
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

int main( void )
{
	ll l, r, d;
	cin >> l >> r >> d;

	ll cnt = 0;
	ll dd = d;
	while ( dd <= 100 ) {
		if ( (l <= dd) && (dd <= r) ) {
			cnt++;
		}
		dd += d;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える
	int id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
void readgraph(){
	//適宜変える
	ll n;
	ll m=0;
	scanf("%lld",&n);
	rep(i,0,n){
		ll t,k;
		scanf("%lld%lld",&t,&k);
		while(k--){
			int s;
			scanf("%d",&s);
			g.e[m].s=t;
			g.e[m].g=s;
			m++;
		}
	}
	g.vcnt=n+1;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


int in[110];
int out[110];
int time;
//dfs
ll dfs(int v,int pre){
	in[v]=++time;
	rep(i,g.id[v],g.id[v+1]){
		if(!in[g.e[i].g]){
			dfs(g.e[i].g,v);
		}
	}
	out[v]=++time;
}

int main(){
	readgraph();
	for(int i=1;i<g.vcnt;i++)if(!in[i])dfs(i,-1);
	for(int i=1;i<g.vcnt;i++)printf("%d %d %d\n",i,in[i],out[i]);
}


Measured memory_bytes: 2112
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
while a[0] >= a[1]:
  a[1] = a[1] * 2
  c += 1
while a[1] >= a[2]:
  a[2] = a[2] * 2
  c += 1
if c <= b[0]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
#include<stdio.h>

int main()
{
    long h,w;
    scanf("%ld%ld",&h,&w);
    long long times=h*w;

    long long num=times/2;
    if(h==1||w==1){
        printf("1\n");
    }else{
        if(times%2==0){
            printf("%lld\n",num);
        }else{
            printf("%lld\n",num+1);
        }
    }

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll INF = 1001001001001001001;
int N, W;
int ws[110], vs[110];
ll dp[110][100100];

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

    std::cin >> N >> W;

    for(int i=0;i<N;++i){
        std::cin >> ws[i] >> vs[i];
    }

    std::fill(&dp[0][0], &dp[0][0] + 110 * 100100, -INF);
    dp[0][0] = 0;

    for(int i=0;i<N;++i){
        for(int j=0;j<=W;++j){
            dp[i+1][j] = std::max(dp[i+1][j], dp[i][j]);

            if(j + ws[i] <= W){
                dp[i+1][j+ws[i]] = std::max(dp[i+1][j+ws[i]], dp[i][j] + vs[i]);
            }
        }
    }

    ll res = 0;
    for(int i=0;i<=W;++i){
        res = std::max(res, dp[N][i]);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 86400
import numpy as np
n, k = map(int, input().split())
MOD = 10**9+7
dp = np.zeros(k+1, dtype=np.int64)
for i in range(k, 0, -1):
  dp[i] = pow((k//i), n, MOD)
  dp[i] -= dp[i+i::i].sum()
j = np.arange(k+1)
ans = (j*dp).sum() % MOD
print(ans)

Measured memory_bytes: 28932
#include <stdio.h>

#define N_MAX	20002
struct sNode
{
	int cost;
};
sNode Node[N_MAX];





int CostList[N_MAX];


int main()
{
	#ifdef _WIN32
		freopen("input.txt", "r", stdin);
	#endif

	int N, X, Y;
	scanf("%d %d %d", &N, &X, &Y);


	for (int n = 1; n <= N; n++)
	{
		// Initialize
		for (int k = 1; k <= N; k++)
			Node[k].cost = (n - k < 0) ? -(n - k) : (n - k);


		if (Node[X].cost < Node[Y].cost)
		{
			if(Node[Y].cost > Node[X].cost + 1)
				Node[Y].cost = Node[X].cost + 1;

			for (int i = 1; (1 <= Y - i) || (Y + i <= N); i++)
			{
				if ((Node[Y].cost + i < Node[Y + i].cost) && (Y+i <= N))
					Node[Y + i].cost = Node[Y].cost + i;
				if ((Node[Y].cost + i < Node[Y - i].cost) && (1 <= Y - i))
					Node[Y - i].cost = Node[Y].cost + i;
			}
		}
		else
		{
			if(Node[X].cost > Node[Y].cost + 1)
				Node[X].cost = Node[Y].cost + 1;

			for (int i = 1; (1 <= X - i) || (X + i <= N); i++)
			{
				if ((Node[X].cost + i < Node[X + i].cost) && (X + i <= N))
					Node[X + i].cost = Node[X].cost + i;
				if ((Node[X].cost + i < Node[X - i].cost) && (1 <= X - i))
					Node[X - i].cost = Node[X].cost + i;
			}
		}

		

#ifdef _WIN32
		for (int k = 1; k <= N; k++)
			printf("%d / %d\n", k, Node[k].cost);
		printf("\n");
#endif
		
		for (int k = 1; k <= N; k++)
			CostList[Node[k].cost]++;
	}

	for (int n = 1; n < N; n++)
		printf("%d\n", CostList[n] / 2);
	return 0;
}







Measured memory_bytes: 128
ls = [list(map(int,input().split())) for _ in range(3)]
def sub(p,q):
    return p-q
for i in range(len(ls)):
    new = [ls[i][0]]*3
    ls[i] = list(map(sub,ls[i],new))
if (list(map(sub,ls[0],ls[1])) == [0,0,0]) and (list(map(sub,ls[0],ls[2])) == [0,0,0]) and (list(map(sub,ls[2],ls[1])) == [0,0,0]):
    print("Yes")
else:
    print("No")

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d)
        OP("Left");
    else if (a + b == c + d)
        OP("Balanced");
    else
        OP("Right");

    return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const X = parseInt(args[0][0], 10)
	const A = parseInt(args[0][1], 10)
	const B = parseInt(args[0][2], 10)
	if (A - B >= -1) console.log('delicious')
	else if (Math.abs(A - B) < X + 1) console.log('safe')
	else console.log('dangerous')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  int N,M;
  cin >> N >> M;
  
  if (N <= M){
    for (int i = 0; i < M; i++) {
      cout << N;
    }
  }
  else {
    for (int i = 0; i < N; i++) {
      cout << M;
    }
  }
  cout << endl;
  
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

vector<bool> x;
set<int> ans;

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    vector<bool> visited;
    bool dfs(int v) {
        visited[v] = true;

        for (auto &e : edge[v]) {
            int to = e.to;
            if (visited[to]) continue;
            if (dfs(to)) {
                ans.insert(e.cost);
                x[v] = x[v] ^ true;
            }
        }
        return x[v];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, bool>> v(N);
    for (int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    x.resize(N + 1);
    x[0] = v[0].second;
    for (int i = 1; i < N; i++) x[i] = v[i - 1].second ^ v[i].second;
    x[N] = v[N - 1].second;

    Graph<int> g(N + 1, 0);
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        l = lower_bound(v.begin(), v.end(), make_pair(l, false)) - v.begin();
        r = upper_bound(v.begin(), v.end(), make_pair(r, true)) - v.begin();
        g.add_edge(l, r, i + 1, false);
    }
    g.visited.assign(N + 1, false);
    for (int i = 0; i < N + 1; i++) {
        if (g.visited[i]) continue;
        if (g.dfs(i)) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans.size() << endl;
    for (auto ite = ans.begin(); ite != ans.end(); ++ite) {
        cout << *ite << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25516