akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)

    val a = argList.nextLine().toInt()
    val s = argList.nextLine()

    val e = RedOrNot()
    e.execute(a, s)

}

class RedOrNot {
    fun execute(a: Int, s: String) {
        if (a >= 3200) {
            println(s)
        } else {
            println("red")
        }
    }
}

Measured memory_bytes: 29468
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> as(N);
    rep(i, N){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    int index = 0;
    rep(i, N - 1){
        ll a = as[i + 1];
        if(a > 2 * as[i]){
            // as[i]以下は生き残れない
            index = i + 1;
        }
        as[i + 1] += as[i];

    }
    cout << N - index << endl;
    return 0;
}


Measured memory_bytes: 1024
import Control.Applicative ((<$>))

main = do
  n <- read <$> getLine :: IO Integer
  let f a b = max c d
            where c = (length.show) a
                  d = (length.show) b
  print $ minimum [f a b|a<-[1..(ceiling.sqrt.fromIntegral) n],let (b,m)=n`divMod`a,m==0]


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

int m,n,p[10100],sum[10100],c[550],e[550];
int dp[10100];

int main(){
  cin >> m >> n;
  for(int i=0;i<m;i++)cin >> p[i];
  sort(p,p+m);
  for(int i=0;i<m;i++)sum[i+1] = sum[i]+p[m-1-i];

  for(int i=0;i<n;i++)cin >> c[i] >> e[i];
  for(int i=0;i<=m;i++)dp[i] = 1e9;
  dp[0] = 0;
  for(int i=0;i<n;i++){
    for(int j=m+c[i];j>=c[i];j--){
      int nxt = min(j,m);
      dp[nxt] = min(dp[nxt], dp[j-c[i]] + e[i]);
    }
  }

  int ans = 0;
  for(int i=0;i<=m;i++)ans = max(ans, sum[i] - dp[i]);
  cout << ans << endl;
}

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cfenv>
#include <cmath>

using namespace std;

int main() {
  string s;
  int k;
  cin>>k>>s;
  if(s.size()<=k)
    cout<<s<<endl;
  else{
    string ss = s.substr(0,k);
    string sss= "...";
    cout<<ss + sss<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
//Name: Space Coconut Crab
//Level: 2
//Category: 数学,探索
//Note: 

/**
 * zの範囲は0≦z≦E^(1/3)、yの範囲は0≦y≦E^(1/2)で表される。
 * zとyが決まればxも一意に決まるので、zとyを全探索し、x,y,z≧0を満たすような組み合わせについてx+y+zの最小値を求めればよい。
 *
 * オーダーは O(E^(5/6))。
 */
#include <iostream>
#include <algorithm>

using namespace std;

bool solve(bool first) {
    int E;
    if(!(cin >> E)) return false;
    if(!E) return false;

    int ans = E;
    for(int z = 0; z*z*z <= E; ++z) {
        for(int y = 0; y*y <= E; ++y) {
            const int x = E - z*z*z - y*y;
            if(x >= 0) {
                ans = min(ans, x+y+z);
            }
        }
    }
    cout << ans << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*;
 
public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		int d=0,e=0,f=0;
		
		d=Math.abs(a-b);
		e=Math.abs(c-b);
		f=Math.abs(a-c);
		int aa=Math.max(d,e);
		System.out.println(Math.max(aa,f));
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
using namespace std;
static const int max_n = 10000;
static const int INF = 1e8;
const long mod =1e9 + 7;
static long long x,a,b,V,m,n,h=0,y,D=0,amax=1;
typedef pair<long long, long long> p;
static long long s[max_n],t[max_n],u[max_n],v[max_n],w[2*max_n],z[2*max_n];
static long long dp[max_n][max_n];
long long k = -2e9-1;
bool hantei[max_n];
long long minv;
void solve(){
    long long v;
    for(int i=1 ; i<n ; i++){
        v = s[i];
        a = i-1;
        while(v<s[a]&&a>=0){
            s[a+1] = s[a];
            a--;
        }
        s[a+1] = v;
        for(int j=0 ; j<n ; j++){
        if(j==n-1){
            printf("%lld\n", s[j]);
        }else{
        printf("%lld ", s[j]);
        }
    }   
     }
}
int main(){
    
    cin >> n;
    for(int  i=0 ; i<n ; i++){
        cin >> s[i];
    }
    for(int j=0 ; j<n ; j++){
        if(j==n-1){
            printf("%lld\n", s[j]);
        }else{
        printf("%lld ", s[j]);
        }
    }   
    solve();
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
	long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}
int main() {
	fast;
	lli n,m,x,ans1=mod,i,j,k;
	cin>>n>>m>>x;
	lli c[n],d[n][m];
	fr(i,n)
	{
		cin>>c[i];
		fr(j,m)
		{
			cin>>d[i][j];
		}
	}
	fr(i,binpow(2,n))
	{
		lli temp=i,flag=0,ans=0;
		vector<lli>v,w;
		while(temp>0)
		{
			v.pb(temp%2);
			temp/=2;
		}
		if(v.empty())
			continue;
		fr(j,v.size())
		{
			if(v[j]==1)
				w.pb(j);
		}
		lli cost[m]={0};
		fr(j,w.size())
		{
			ans+=c[w[j]];
			fr(k,m)
			{
				cost[k]+=d[w[j]][k];
			}
		}
		fr(j,m)
		{
			if(cost[j]<x)
			{
				flag=1;
			}
		}
		if(flag==0)
		{
			ans1=min(ans1,ans);
		}
	}
	if(ans1==mod)
	    cout<<"-1";
	else
	    cout<<ans1;
	
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    string s[110];
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < h; i++)
    {
        cout << s[i] << endl
             << s[i] << endl;
    }
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;
	set<P>se;
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
		se.insert(P(i+1,j+1));
	}
	if(n%2==0){
		for(int i=1;i<=n/2;i++){
			se.erase(P(i,n-i+1));
		}
	}
	else{
		for(int i=1;i<=n/2;i++){
			se.erase(P(i,n-i));
		}
	}
	cout<<se.size()<<endl;
	for(auto p:se){
		cout<<p.first<<' '<<p.second<<endl;
	}
}

Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = 0; i < (f); --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

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

  vector<int> B(m);
  rep(i,m) cin >> B[i];

  int ans = 0;
  rep(i,n){
    int sum = c;
    rep(j,m){
      int a;
      cin >> a;
      sum+= a * B[j];
    }
    if (sum > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, tmp int
	sum := 0
	max := 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > max {
			// 入力された値がそれまでで最大であれば、maxに格納する。
			// その上で古いmaxの値はsumに入れる。
			sum += max
			max = tmp
		} else {
			// そうでなければ、そのままsumに加算する。
			sum += tmp
		}
	}
	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
n = int(input())
s = list(map(int, list(input())))

f = [0]*1000

rnum = [0]*10
lnum = [0]*10

for i in s:
    rnum[i] += 1

rnum[s[0]] -= 1
lnum[s[0]] += 1

for i in range(1, n-1):
    rnum[s[i]] -= 1
    for j in range(10):
        for k in range(10):
            if lnum[j] >= 1 and rnum[k] >= 1:
                f[j*100+s[i]*10+k] = 1
    lnum[s[i]] += 1

cnt = 0
for i in f:
    if i == 1:
        cnt += 1
    
print(cnt)

Measured memory_bytes: 9584
[n, conti_time] = map(int, input().split())
t = list(map(int, input().split()))

cnt = 0
tmp_start_time = 0
tmp_end_time = 0

for i in t:
  if tmp_end_time <= i:
    cnt += tmp_end_time - tmp_start_time
    tmp_start_time = i
    tmp_end_time = i + conti_time
  else:
    tmp_end_time = i + conti_time

cnt += tmp_end_time - tmp_start_time

print(cnt)

Measured memory_bytes: 26708
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N+1);
		REP(i, N+1) cin>>A[i];
		ll w = accumulate(ALL(A), 0LL);
		ll legs = 1;
		ll ok=1;
		ll ans=0;
		REP(i, N+1) {
			ans += legs;
			if(legs<A[i]) {ok=0;break;}
			w -= A[i];
			legs = min(w, 2*(legs-A[i]));
		}
		if(!ok) ans=-1;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		
		long k = sc.nextInt();
		long seven = 7%k;
		
		for(int i=1;i<=k;i++) {
			if(seven==0) {
				System.out.println(i);
				return;
			}
			//sevenの桁数が大きくなりすぎるので、割ったあまりを入れておく
			seven=(seven*10+7)%k;
		}
 
		System.out.println(-1);
 
 
	}
 
}

Measured memory_bytes: 35816
from sys import stdin
readline = stdin.readline


adjacent = (
    (1, 3),        # 0
    (0, 2, 4),     # 1
    (1, 5),        # 2
    (0, 4, 6),     # 3
    (1, 3, 5, 7),  # 4
    (2, 4, 8),     # 5
    (3, 7),        # 6
    (4, 6, 8),     # 7
    (5, 7)         # 8
)


def next_board(board, space, prev):
    for nxt in adjacent[space]:
        if nxt == prev:
            continue
        b = board[:]
        b[space], b[nxt] = b[nxt], 0
        yield b, nxt
from heapq import heappop, heappush

end = [1, 2, 3, 4, 5, 6, 7, 8, 0]

# ???????????¨????????°
FORE = 1
BACK = 0


def search(start):
    if start == end:
        return 0
    table = {}

    table[tuple(start)] = (FORE, 0)
    table[tuple(end)] = (BACK, 0)

    heap = [(0, start, start.index(0), None, FORE), (0, end, end.index(0), None, BACK)]
    while heap:
        i, board, space, prev, direction = heappop(heap)
        i += 1
        for b, nxt in next_board(board, space, prev):
            key = tuple(b)
            if key in table:
                if table[key][0] != direction:
                    return table[key][1] + i
                continue
            table[key] = (direction, i)
            if b == end:
                return i
            heappush(heap, (i, b, nxt, space, direction))


def main():
    start = (map(int, readline().split()) for _ in range(3))
    start = [y for x in start for y in x]
    print(search(start))
main()

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll a, b, c, d;
  cin >> a >>b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d});
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(i, n)    for(int i = 0; (i) < (1 << (n)); ++(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m)
            cin >> a[i][j];
    }

    int ans = INF9;
    repbit(is, n){
        int cost = 0;
        vector<int> us(m, 0);
        rep(i, n){
            if(is & (1 << i)){
                cost += c[i];
                rep(j, m)
                    us[j] += a[i][j];
            }
        }

        rep(j, m){
            if(us[j] < x) break;
            if(j == m - 1) chmin(ans, cost);
        }
    }

    cout << (ans == INF9 ? -1 : ans) << endl;

return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    ll a;
    string s;
    cin >> a >> s;
    ll nb = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
    cout << a * nb / 100 << endl;

    return 0;
}


Measured memory_bytes: 3628
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  writeln(k*(k-1)^^(n-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,w,a[105][2],dp[105][100005];
long long f(long long i,long long c)
{
	if(i==n)
	return 0;
	if(dp[i][c] != -1)
		return dp[i][c];
	if(a[i][0]<=c)
	{
		return dp[i][c]=max(f(i+1,c-a[i][0])+a[i][1],f(i+1,c));
	}
	else
		return dp[i][c]=f(i+1,c);
}
int main()
{
	cin>>n>>w;
	for(int i=0;i<n;i++)
	cin>>a[i][0]>>a[i][1];
	memset(dp,-1,sizeof(dp));
	cout<<f(0,w)<<endl;
	return 0;
}

Measured memory_bytes: 82304
import java.util.Scanner;

/**
 * Main
 */
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long N = s.nextLong();

        long mini = N + 1;

        for (long i = 1; i*i <= N; i++) {
            if (N % i == 0) {
                long j = N/i;
                mini = Math.min(i+j, mini);
            }
        }
        System.out.println(mini - 2);
        s.close();
    }
    
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) cout << s.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll dp[5010][5010][2] = {},dp1[5010][5010][2] = {},val[5010];
constexpr ll mod = 1000000007;
vector<int> G[5010];
const int MAX = 5010;
ll inv[MAX],fact[MAX],fi[MAX];
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

ll dfs(int s, int p){
	int i,j,sz = 1;
	dp[s][1][0] = 1;
	for(int v:G[s]){
		if(v==p) continue;
		int num = dfs(v,s);
		for(i=1;i<=sz;i++){
			for(j=1;j<=num;j++){
				(dp1[s][i][0] += dp[s][i][0]*val[j]%mod*dp[v][j][1]%mod + dp[s][i][1]*val[j]%mod*dp[v][j][0]%mod) %= mod;
				(dp1[s][i][1] += dp[s][i][0]*val[j]%mod*dp[v][j][0]%mod + dp[s][i][1]*val[j]%mod*dp[v][j][1]%mod) %= mod;
				(dp1[s][i + j][0] += dp[s][i][0]*dp[v][j][0]%mod + dp[s][i][1]*dp[v][j][1]%mod) %= mod;
				(dp1[s][i + j][1] += dp[s][i][0]*dp[v][j][1]%mod + dp[s][i][1]*dp[v][j][0]%mod) %= mod;
			}
		}
		sz += num;
		for(i=0;i<=sz;i++){
			dp[s][i][0] = dp1[s][i][0];
			dp[s][i][1] = dp1[s][i][1];
			dp1[s][i][0] = 0;
			dp1[s][i][1] = 0;
		}
	}
	return sz;
}

int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n - 1;i++){
		int a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	inverse();
	val[0] = 1;
	for(i=2;i<=n;i+=2){
		val[i] = comb(i,2)*val[i - 2]%mod*inv[i/2]%mod;
	}
	dfs(0,-1);
	ll ans0 = 0,ans1 = 0;
	for(i=0;i<=n;i++){
		(ans0 += dp[0][i][0]*val[i]%mod) %= mod;
		(ans1 += dp[0][i][1]*val[i]%mod) %= mod;
	}
	cout << (ans0 - ans1 + mod)%mod << endl;
}

Measured memory_bytes: 784640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    vector<int>in(a);
    in[0]=2;
    if(a>1)
      in[1]=3;
    if(a>2)
      loop(i,2,a){
	in[i]=in[i-1]+in[i-2];
	in[i]=in[i]%1001;
      }
    sort(all(in));
    int out=1;
    rep(i,a-1)
      if(in[i+1]-in[i]>=b)out++;
    cout<<out<<endl;
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;
    double a,b;
    cin>>a>>b;
    printf("%.10f\n", a/b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int>
 
int32_t main(){
    
    //int mx=INT_MAX;
    int a,b;
    cin>>a>>b;
    for(int n=10;n<=1250;n++){
        int x=(n*8)/100;
        int y=n/10;
        if(x==a and y==b){
            cout<<n<<endl;
            return 0;
        }
        
    }
    cout<<-1<<endl;
    return 0;
}

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

typedef long long ll;

int n,a[20];

ll dfs(int l,int r,ll mul_l,ll mul_r){
	if(l>r)return 0;
	ll ret=1e18;
	for(int mid=l;mid<=r;mid++){
		ret=min(ret,dfs(l,mid-1,mul_l,mul_l+mul_r)+dfs(mid+1,r,mul_l+mul_r,mul_r)+a[mid]*(mul_l+mul_r));
	}
	return ret;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<a[1]+a[n]+dfs(2,n-1,1,1)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e4+10, M = N * 2;

int main() {
	int n;
	cin>>n;
	cout<<(1000 - n % 1000) % 1000;
	return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long pow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = pow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return pow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (int i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (int i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int rez = 99999999;
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    int temp;
    for (int i = 1; i <= 100; i++)
    {
        temp = 0;
        for (int j = 0; j < n; j++)
        {
            temp += (x[j] - i) * (x[j] - i);
        }
        rez = min(rez, temp);
    }
    cout << rez << '\n';
    return 0;
}


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

int main()
{
        ll N, K;
        cin >> N >> K;
        vector<ll> X(N, 0);
        for (int i = 0; i < N; ++i) {
                cin >> X[i];
        }
        ll ans = 0;
        for (int i = 0; i < N; ++i) {
                ans += min(X[i] * 2, (K-X[i]) * 2);
        }
        cout << ans << endl;
}


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

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

  int total = 0;
  int previous = 0;

  for (int i = 0; i < N; i++) {
    int B;
    cin >> B;

    if (i == 0 || i == N - 1) {
      total += B;
    } else {
      total += min(previous, B);
    }

    previous = B;
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,M,K,num;
vector<int>adjList[MAXN];
int ans[MAXN],comp[MAXN],sz[MAXN];

int dfs(int u){
	if(comp[u])return 0;
	comp[u]=num;
	int ret=1;
	for(auto v:adjList[u]) ret+=dfs(v);
	return ret;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>K;
	FOR(i,1,M){
		int a,b;cin>>a>>b;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
	}
	num=1;
	FOR(i,1,N){
		if(comp[i])continue;
		sz[num]=dfs(i);
		num++;
	}
	FOR(i,1,N){
		//db(sz[comp[i]]);
		ans[i]=sz[comp[i]]-sz(adjList[i])-1;
	}
	FOR(i,1,K){
		int c,d;cin>>c>>d;
		if(comp[c]==comp[d]){
			ans[c]--;ans[d]--;
		}
	}
	FOR(i,1,N)cout<<ans[i]<<" ";
}


Measured memory_bytes: 7552
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,A[200020],memo[200200]={};
string S;

int main()
{
    cout << fixed << setprecision(18);
    cin>>S;
    for(long long int i = 0; i < 3; i++){
        if(S[i]=='7'){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
    

}    


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    rep(i,n) scanf("%d", &vec.at(i));
    int p1 = 0, p2 = 1, p3 = 2;
    int ans = 0;
    while (p3 != n) {
        if (!(vec.at(p2) > vec.at(p1) && vec.at(p2) > vec.at(p3)) && !(vec.at(p2) < vec.at(p1) && vec.at(p2) < vec.at(p3)))
        ans++;
        p1++, p2++, p3++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int X,A,B;
    cin>>X>>A>>B;
    if(A>=B) cout<<"delicious"<<endl;
    else if((B-A) <= X) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

vector<int> ans;

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

  reverse(s.begin(),s.end());

  int i = 0;
  while(true) {
    int j = m;
    while((j+i > n) || (s[j+i] == '1')) j--;

    if(j == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(j);
    // cout << i << endl;
    i += j;
    if(i >= n) break;
  }

  reverse(ans.begin(),ans.end());

  for(int i = 0; i < ans.size() - 1; i++) {
    cout << ans[i] <<" ";
  }
  cout << ans.back() << endl;
}
  


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define PI acos(-1LL)


#ifdef LOCAL
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#else
#define debug(...) 11;
#endif

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 2e18 + 12;

void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max({a*c , b*d, b*c, a*d});
    cout << ans << endl;
}
signed main(){
    FAST
#ifdef TIMER
    clock_t start;
    double duration;
    start = clock();
#endif
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int tt = 1; tt <= tc; tt++) {
        solve();
    }
#ifdef TIMER
    duration = (clock() - start) / (double) CLOCKS_PER_SEC;
    cerr <<"\n\nTotal time elapsed: "<< duration <<"sec\n";
#endif
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    char a[3];
    int num = 0;
    cin >> a[0] >> a[1] >> a[2];
    for(int i=0;i<3;i++){
        if(a[i] == '1') num++;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
 
using namespace std;
typedef long long ll;
 
int main(){
  int a, b, c;
  int count = 0;
  scanf("%d %d %d", &a, &b, &c);
  count++;
  if(b != a){
    count++;
  }
  if(c != a && c != b){
    count++;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 256
# 高橋くんが根性ありすぎるので, ループではTLE
# 単純に商と剰余の和と思いがちだが, そうでないことに注意
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
# 剰余がaを超えていた場合, aにする
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int k;
i64 a[100010];

i64 func(i64 n,int i)
{
    if(i == k) return n;
    return func(n - (n % a[i]),i + 1);
}

//func(N,0) <= 2 is ok
i64 binary_max()
{
    i64 ng = 1e18;
    i64 ok = 0;

    while(abs(ng - ok) > 1)
    {
        i64 mid = (ok + ng) / 2;
        if(func(mid,0) <= 2)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}

//func(N,0) >= 2 is ok
i64 binary_min()
{
    i64 ok = 1e18;
    i64 ng = 0;
    while(abs(ng - ok) >1)
    {
        i64 mid = (ok + ng) / 2;
        if(func(mid,0) >= 2)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}

int main()
{
    cin >> k;
    rep(i,0,k - 1) cin >> a[i];

    i64 mi = binary_min();
    i64 ma = binary_max();

    if(mi <= ma)
    {
        cout << mi << " " << ma << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GS(S);
  int ans = 0;
  for (int i = 2; i < S.size(); i += 2) {
    int p = i / 2;
    if (S.substr(0, p) == S.substr(p, p))
      ans = i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
ll a[MAX];
int main()
{
    int k,n;
    cin>>k>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
       scanf("%lld",&a[i]);
    }
    a[n+1]=k+a[1];
    for(int i=2;i<=n+1;i++){
        sum+=a[i]-a[i-1];
    }
    ll maxx=0;
    for(int i=2;i<=n+1;i++){
        maxx=max(maxx,a[i]-a[i-1]);
    }
    cout<<sum-maxx<<endl;

    
    return 0 ;
 }

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

int main() {
  int n,count=200001;
  cin>>n;
  vector<string> s(n),t;
  vector<int> a;
  for(int i=0; i<n; i++) cin>>s[i];
  sort(s.begin(),s.end());
  
  for(int i=0; i<n-1; i++){
    if(s[i]==s[i+1]) count--;
    else {
      t.push_back(s[i]);
      a.push_back(count);
      count = 200001;
      if(i==n-2) {
        t.push_back(s[i+1]);
        a.push_back(count);
        break;
      }
    }
    if(i==n-2){
      t.push_back(s[i]);
      a.push_back(count);
    }
  }
  
  vector<pair<int,string>> p(t.size());
  for(int i=0; i<t.size(); i++) p[i] = make_pair(a[i],t[i]);
  sort(p.begin(),p.end());
  for(int i=0; i<p.size(); i++){
    cout<<p[i].second<<endl;
    if(p[i].first != p[i+1].first) return 0;
  }
}

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

vector<int64_t> divisor(int64_t n){
  vector<int64_t> div;
  for(int64_t i=1;i*i<= n;++i) {
    if(n%i==0) {
      div.push_back(i);
      if(i*i!=n) div.push_back(n/i);
    }
  }
  sort(begin(div),end(div));
  return (div);
}

int main(){
  int64_t N;
  cin>>N;
  vector<int64_t> d;
  d=divisor(N);
  int64_t sum=0;

  for(int i=0;i<d.size();++i){
    int64_t m=(N/d[i])-1;
    if(d[i]<m){
      sum +=m;
    }
  }
  cout<<sum<<endl;
}


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

using namespace std;
////
char in[11];
pair<pair<string,int>,int> p[101];

int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
  int t;scanf("%s%d",in,&t);
  p[i]=make_pair(make_pair(in,-t),i);
}
sort(p,p+a);
for(int i=0;i<a;i++) printf("%d\n",p[i].second+1);
}


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

#define pb push_back
#define pbk pop_back
#define mk_pr make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<string> vss;
typedef queue<int> qi;

const int MX = 5e3;
int n, x;
ll ar[120], dp[120][MX+100];

ll ff( int pos, int vlu ) {
        if( pos == n ) {
                if( vlu%2 == x ) return 1LL;
                else return 0LL;
        }
        if( dp[pos][vlu] != -1 ) return dp[pos][vlu];

        return dp[pos][vlu] = ff( pos+1, ar[pos]+vlu ) + ff( pos+1, vlu );
}

int main() {
        ios_base :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> x;
        for(int i=0; i<n; i++) cin >> ar[i];
        memset(dp, -1, sizeof dp);
        ll ans = ff(0, 0);
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++)
        cout << i << ' ';
    cout << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[3001][3001]={};//dp[i][j]:i番目まで決めていて、最後に置いた値が「残っている未使用の値のうちj番目に小さい値」であるような場合の数
int main(){
	ll MOD=1e+9+7;
	int N;
	string s;
	scan(N);
	scan(s);
	rep(i,N) dp[0][i]=1;
	rep(i,N-1){
		if(s[i]=='<'){
			for(int j=0;j<N-i-1;j++){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=MOD;
			}
			for(int j=0;j<N-i-2;j++){
				dp[i+1][j+1]+=dp[i+1][j];
				dp[i+1][j+1]%=MOD;
			}
		}
		else{
			for(int j=N-i-1;j>0;j--){
				dp[i+1][j-1]+=dp[i][j];
				dp[i+1][j-1]%=MOD;
			}
			for(int j=N-i-1;j>0;j--){
				dp[i+1][j-1]+=dp[i+1][j];
				dp[i+1][j-1]%=MOD;
			}
		}
	}
	ll ans=0;
	prin(dp[N-1][0]);
	return 0;
}


Measured memory_bytes: 70016
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//D	Knapsack 1
public class Main {

	static void chMin(long[][] dp, int i, int j, long v) {
		if (dp[i][j] > v) {
			dp[i][j] = v;
		}
	}

	static void chMax(long[][] dp, int i, int j, long v) {
		if (dp[i][j] < v) {
			dp[i][j] = v;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());

		final int DP_SIZE = 100 + 10;

		int[] wArr = new int[N];
		long[] vArr = new long[N];
		for (int i = 0; i < N; i++) {
			wArr[i] = Integer.parseInt(sc.next());
			vArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long[][] dp = new long[DP_SIZE][100010];

		for (int i = 0; i < N; i++) {
			for (int sumW = 0; sumW <= W; sumW++) {
				// 採用する場合
				if (sumW >= wArr[i]) {
					chMax(dp, i + 1, sumW, dp[i][sumW - wArr[i]] + vArr[i]);
				}

				// 採用しない場合
				chMax(dp, i + 1, sumW, dp[i][sumW]);
			}
		}

		long ans = dp[N][W];
		System.out.println(ans);
	}
}


Measured memory_bytes: 127572
#include <iostream>
using namespace std;
 
int gcd(int n,int m){
  if(n<m){
    swap(n,m);
  }
  while(m>0){
    int r=n%m;
    n=m;
    m=r;
  }
  return n;
}
   
int main(){
  int n,m;
 
  cin>>n>>m;
 
  int ans=gcd(n,m);
 
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
	int D, G;
	int p[15] = {}, c[15] = {};
	int ans = 2e9;

	cin >> D >> G;
	for (int i = 0; i<D; i++)
		cin >> p[i] >> c[i];

	for (int i = 1; i<(1 << D); i++)
	{
		int tmp = 0;
		int cnt = 0;
		for (int j = D - 1; j >= 0; j--)
		{
			if (i & (1 << j))
			{
				for (int k = 0; k<p[j]; k++)
				{
					if (tmp >= G)break;
					tmp += (j + 1) * 100;
					if (k == p[j] - 1)tmp += c[j];
					cnt++;
				}
			}
		}
		if (tmp >= G)ans = min(ans, cnt);
	}

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


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

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

  int r=0;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]==')') r++;
    else{
      r--;
      if(r < 0) r = 0;
    }
  }
  cerr << r << endl;
  s = string(r,'(') + s;
  cerr << s << endl;

  int l = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='(') l++;
    else{
      l--;
      if(l < 0) l = 0;
    }
  }
  cerr << l << endl;
  cout << s + string(l,')') << endl;

  return 0;
}

Measured memory_bytes: 256