akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vvl G;
ll n,k;
ll ans;
void dfs(ll u, ll p, ll ppc){
	for(auto v : G[u]){
		if(v==p) continue;
		ans *= k-1-ppc;
		ans %= mod;
		dfs(v,u,1);
		ppc++;
	}
}

int main(){
	cin >> n >> k;
	G.resize(n);
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ans = k;
	dfs(0,-1,0);
	cout << ans << endl;
}

Measured memory_bytes: 10368
S = input()

dic = {}

for i in S:
 if not i in dic:
     dic[i] = 1
 else:
     dic[i] += 1

if len(dic) == 2 :
    for i in dic:
        if dic[i] != 2:
            break

    print("Yes")
    quit()

print("No")


Measured memory_bytes: 38384
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Measured memory_bytes: 121720
#!/usr/bin/env python3
import sys

input = sys.stdin.readline
mod = 1000000007


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N = I()
A = LI()

ans = 0
sum = 0
for i in reversed(range(1, N)):
    sum += A[i]
    sum %= mod
    ans += (sum * A[i - 1]) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 91992
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = ((n*(n-1))/2) + ((m*(m-1))/2);
        System.out.println(ans); 
    }
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    double ans = 0;
    REP(n, N) {
        double t = 1.0 / N;
        ll m = n + 1;
        while (m < K) {
            m *= 2LL;
            t *= 0.5;
        }
        ans += t;
    }
    cout << OF64 << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll a, b, c, d, e, f;
    scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f);

    set<ll> denominator;
    for(int i = 0; i <= 100; i++)
        for(int j = 0; j <= 100; j++) {
            denominator.insert(100 * a * i + 100 * b * j);
        }
    denominator.erase(0);

    set<ll> numerator;
    for(int i = 0; i <= 1000; i++)
        for(int j = 0; j <= 1000; j++) {
            if(c * i + d * j > 3000)
                break;
            numerator.insert(c * i + d * j);
        }

    ll ansUpper = 0;
    ll ansLower = *(denominator.begin());
    // printf("%d %d\n", numerator.size(), denominator.size());
    for(auto i : numerator)
        for(auto j : denominator) {
            ll upper = i;
            ll lower = j;

            if(upper + lower > f)
                continue;
    
            {
                int newUpper = 100 * upper;
                int newE = e * lower;

                if(newUpper > newE)
                    continue;
            }
            
            // printf("%lld %lld\n", lower, upper);

            {
                ll newAnsUpper = ansUpper * lower;
                ll newUpper = upper * ansLower;

                if(newUpper > newAnsUpper) {
                    ansUpper = upper;
                    ansLower = lower;
                }
            }
            
        }
    
    printf("%lld %lld\n", ansLower + ansUpper, ansUpper);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; int k; cin >> s >> k;
	rep(i, s.size()) {
		if (s[i] == 'a')continue;
		int tmp = 'z' - s.at(i) + 1;
		if (k >= tmp) {
			s.at(i) = 'a'; k -= tmp;
		}
	}
	k %= 26;
	s.back() = (s.back() - 'a' + k) % 26 + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 592
using System;

namespace hellounihara
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			for (int i = 0; i < 200; i++) {
			int a = 0;
				int b = 0;
			string arr02 =Console.ReadLine();
				if (arr02 == null) {
					break;
				}
		    string[] starr02 = arr02.Split();
			foreach (var item in starr02) {
				a += int.Parse(item);
			}
			//int digit = a.ToString().Length;
				if (a == 0 ) {
					b = 1;
				}
				else{
					while(a>0){ //aが0以上の時
						b++;
						a/=10;
					}
				}
				Console.WriteLine(b);

			}
		}
	}
}

Measured memory_bytes: 5636
/*
    ~A_Pessimist~:)
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int sz=1e5+10;
ll w[105],v[105],n,W;
ll dp[105][sz];

ll knapsack(ll index, ll ojon)
{
    if(index==n) return 0;

    if(~dp[index][ojon]) return dp[index][ojon];

    ll ans = knapsack(index+1, ojon);

    if(ojon+w[index]<=W)
    {
        ans = max(ans, knapsack(index+1, ojon+w[index])+v[index]);
    }

    return dp[index][ojon] = ans;
}

void solve()
{
    cin>>n>>W;
    memset(dp, -1, sizeof dp);

    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<knapsack(0,0)<<endl;
}

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

    int t=1;
   // cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 85684
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (v[i] == 1) {
			L = i;
			R = i;
		}
	}
	int ans = 0;
	while (L > 0) {
		L -= K - 1;
		ans++;
	}
	R -= L;
	while(R < N - 1) {
		R += K - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import std.stdio;
import std.typecons;
import std.container;
import std.algorithm;

alias Edge = Tuple!(int, "dst", int, "cost");

void main()
{
    int n, m, s, t;

    readf(" %s %s %s %s", &n, &m, &s, &t);
    s--;
    t--;

    auto yen = new Edge[][](n, 0);
    auto snk = new Edge[][](n, 0);

    foreach (j; 0..m)
    {
        int u, v, a, b;
        readf(" %s %s %s %s", &u, &v, &a, &b);
        u--;
        v--;

        yen[u] ~= Edge(v, a);
        yen[v] ~= Edge(u, a);
        snk[u] ~= Edge(v, b);
        snk[v] ~= Edge(u, b);
    }

    auto f = dijkstra(yen, s);
    auto b = dijkstra(snk, t);

    auto ans = new long [n + 1];
    ans[$ - 1] = long.max;
    foreach_reverse (i; 0..n)
    {
        ans[i] = min(ans[i + 1], f[i] + b[i]);
    }

    ans[] = 10L ^^ 15 - ans[];
    writefln ("%(%s\n%)", ans[0..n]);
}

auto dijkstra(Edge[][] edges, int s) {
    alias Distance = Tuple!(int, "node", long, "distance");
    auto heap = BinaryHeap!(Array!Distance,"a.distance > b.distance")();
    heap.insert(Distance(s, 0));

    auto ret = new long[edges.length];
    ret[] = long.max;
    ret[s] = 0;

    while (!heap.empty) {
        auto v = heap.front;
        heap.removeFront();

        if (ret[v.node] < v.distance) continue;

        foreach (e; edges[v.node])
        {
            if (ret[e.dst] > ret[v.node] + e.cost) {
                ret[e.dst] = ret[v.node] + e.cost;
                heap.insert(Distance(e.dst, ret[e.dst]));
            }
        }
    }

    return ret;
}


Measured memory_bytes: 19836
#include <bits/stdc++.h>
using namespace std;
long long ans=0,a;
int n;
int main(){
cin>>n;
for(int i=0;i<n;i++){
   cin>>a;
   while(a%2==0) {
    a/=2;
    ans++;
   }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005;
const int MAXM= 15000005;
ll n,m;
/*
int getsg(int n)  //sg[n]=1 P  sg[n]=0 N  一个点v是P-状态当且仅当它的所有后继都为N-状态,一个点v是N-状态当且仅当它的一些后继是P-状态
{
	int vis[50]={0};
	if(sg[n]!=-1) return sg[n];
	if(n==0) return sg[n]=0;
	for(int i=0;i<n;i++)
	{
		sg[i]=getsg(i);
		vis[sg[i]]=1;
	}
	for(int i=0;;i++)
	{
		if(vis[i]==0)
		return i;
	}
}
*/

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>m;
  for(ll i=m/n;i>=1;i--)
  {
  	if(m%i==0&&i*n<=m)
  	{
	    cout<<i<<endl;
	    return 0;
	}
  	
  }
}


Measured memory_bytes: 256
KN = list(map(int,input().split()))
A = list(map(int,input().split()))

K = KN[0]
N = KN[1]

kyori = []

#家と家の間の距離を計算(1番目~2番目、2番目~3番目...)
for i in range(N-1):
    kyori.append(A[i+1] - A[i])
kyori.append(A[0]+K-A[N-1])

print(K - max(kyori))

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  for (int i=0; i<b/(a-1)+2/*←ここは曖昧では甘いけどね*/; i++) {
    if ((a-1)*i+1-b>=0) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
    auto n = readLong();
    long[] a;
    foreach(i; iota(n)) {
        a ~= readLong();
    }
    long ans;
    foreach(i; iota(n)) {
        ans += a[i] / 2;
        a[i] %= 2;
        if(i < n-1) {
            if(a[i+1] > 0) {
                ans += a[i];
                a[i+1] -= a[i];
            }
        }
    }
    writeln(ans);
}



Measured memory_bytes: 2044
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
ans=0
for i in range(n):
  if i<=k-1:
    if t[i]=='s':
      ans+=r
    elif t[i]=='p':
      ans+=s
    elif t[i]=='r':
      ans+=p
    if i==k-1:
      kl=t[i]
  else:
    if (t[i]=='s')and(t[i-k]!='s'):
      ans+=r
    elif (t[i]=='p')and(t[i-k]!='p'):
      ans+=s
    elif (t[i]=='r')and(t[i-k]!='r'):
      ans+=p
    else:
      t[i]=0
print(ans)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define FIO "E"
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

template<typename T> inline void Min(T &x, T y) {if(x>y) x=y;}
template<typename T> inline void Max(T &x, T y) {if(x<y) x=y;}

const int maxn=2e5+10;
const int mod=1e9+7;

struct node{
	int x,v;
	node(){}
	node(int x,int v):x(x),v(v){}
	inline bool operator < (const node &rhs) const {
		return v < rhs.v;
	}
}a[maxn];

inline bool cmp(const node &a,const node &b) {return a.x<b.x;}

int n,mx[maxn],mn[maxn],f[maxn],g[maxn],pos[maxn];

int main()
{
#ifdef dxymaster
	freopen(FIO".in","r",stdin);
	freopen(FIO".out","w",stdout);
#endif

	n=read();
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].v=read();
	sort(a+1,a+1+n,cmp);for(int i=1;i<=n;i++) a[i].x=i;
	sort(a+1,a+1+n);mn[n]=a[n].x;
	for(int i=n-1;i;i--) mn[i]=min(mn[i+1],a[i].x);mx[0]=0;
	for(int i=1;i<=n;i++) mx[i]=max(mx[i-1],a[i].x),Max(pos[mx[i]],mn[i]);
	f[0]=g[0]=1;int Mx=0;
	for(int i=1;i<=n+1;i++)
	{
		f[i]=(g[i-1]-((Mx)?g[Mx-1]:0)+mod)%mod;
		g[i]=(g[i-1]+f[i])%mod;Max(Mx,pos[i]);
	}
	cout << f[n+1] << endl;
#ifdef dxymaster
	cerr<< " Time: " << (double) clock() / CLOCKS_PER_SEC << "s			It Runs So Fast!" << endl;
#endif

	return 0;
}



Measured memory_bytes: 5760
import Data.List
main = do
  _ <- getLine
  l' <- map (read::String->Int) . words <$> getLine
  let l = zip [1..] l'
  print $ length [(,,)|a<-l, b<-(delete a l), c<-(delete b (delete a l)),
                      (snd a)+(snd b)>(snd c),
                      (snd b)+(snd c)>(snd a),
                      (snd c)+(snd a)>(snd b),
                      (snd a)/=(snd b),
                      (snd b)/=(snd c),
                      (snd c)/=(snd a),
                      (fst a)<(fst b),
                      (fst b)<(fst c)]

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int x,y,a,b,c;
    in>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    for(auto&i:p) in>>i;
    for(auto&i:q) in>>i;
    for(auto&i:r) in>>i;
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.rbegin(),r.rend());
    ll s{},ans{};
    Fr(i,x) s+=p[a-i];
    Fr(i,y) s+=q[b-i];
    int P{a-x},Q{b-y};
    ans=s;
    fr(i,c){
        if(P==a&&Q==b) break;
        if(P==a){
            s-=q[Q++];
        }
        else if(Q==b){
            s-=p[P++];
        }
        else if(p[P]<q[Q]) s-=p[P++];
        else s-=q[Q++];
        s+=r[i];
        ans=max(ans,s);
    }
    cout<<ans<<'\n';
}

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

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    if (t.size() != s.size() + 1) {
        cout << "No";
        return 0;
    }
    for (int i = 0; i < int(s.size()); i++) {
        if (s[i] != t[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
class Main{
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] argv){
		int n = scan.nextInt();
		int n1 = n%10;
		int n2 = (n%100 - n1)/10;
		int n3 = (n - n1 -n1)/100;
		if(n3==9){n = 999; System.out.println(n);return;}
		if(n1>n3 || n2>n3){
			n3 += 1;
		}
		n = n3*100 + n3*10 + n3;
		System.out.println(n);
	}
}

Measured memory_bytes: 23636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int w, h;
  while(cin>>w>>h,w||h) {
    int wall_tate[h][w], wall_yoko[h][w];
    FOR(i,0,2*h-1) {
      if(i % 2 == 0) {
        FOR(j,0,w-1) cin >> wall_tate[i / 2][j];
      } else {
        FOR(j,0,w) cin >> wall_yoko[i / 2][j];
      }
    }
    int d[h][w]; FOR(i,0,h) FOR(j,0,w) d[i][j] = 0;
    queue<P> Q;
    Q.push(P(0, 0));
    d[0][0] = 1;
    while(!Q.empty()) {
      P p = Q.front(); Q.pop();
      int nowy = p.first, nowx = p.second;
      // can go right
      if(nowx < w - 1 && wall_tate[nowy][nowx] != 1) {
        if(d[nowy][nowx + 1] == 0) {
          Q.push(P(nowy, nowx + 1));
          d[nowy][nowx + 1] = d[nowy][nowx] + 1;
        }
      }
      // can go left
      if(nowx > 0 && wall_tate[nowy][nowx-1] != 1) {
        if(d[nowy][nowx - 1] == 0) {
          Q.push(P(nowy, nowx - 1));
          d[nowy][nowx - 1] = d[nowy][nowx] + 1;
        }
      }
      // can go up
      if(nowy > 0 && wall_yoko[nowy-1][nowx] != 1) {
        if(d[nowy - 1][nowx] == 0) {
          Q.push(P(nowy - 1, nowx));
          d[nowy - 1][nowx] = d[nowy][nowx] + 1;
        }
      }
      // can go down
      if(nowy < h - 1 && wall_yoko[nowy][nowx] != 1) {
        if(d[nowy + 1][nowx] == 0) {
          Q.push(P(nowy + 1, nowx));
          d[nowy + 1][nowx] = d[nowy][nowx] + 1;
        }
      }
    }
    cout << d[h-1][w-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
S = input()
T = input()
len_S = len(S)
len_T = len(T)
qc = 0
ans = ''
for i in range(len_S-1, -1, -1):
    si = S[i]
    if (si == '?' or si == T[0]) and len_S - i >= len_T:
        flag = True
        for ii in range(1, len_T):
            if T[ii] == S[i+ii] or S[i+ii] == '?':
                continue
            else:
                flag = False
                break
        if flag:
            ans = S[:i] + T + S[i+len_T:]
            break

if ans:
    print(ans.replace('?', 'a'))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split("\n");
	var num = parseInt(args[0],10);
	var num = parseInt(args[0],10);
	var sum_alice = 0;
	var sum_bob = 0;

	var array = args[1].split(" ").map(function(element,index,array){return parseInt(element,10)});
	array.sort(function(a,b){
		if(a>b) return -1;//not swap
		if(a<b) return 1;//swap
		return 0;
	});

	for(var i in array){
		if(i % 2 ==0){//alice
			sum_alice += array[i];
		}else{//bob
			sum_bob += array[i];
		}
	}
	//出力
	console.log(sum_alice - sum_bob);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
   ll n;
   cin >> n;
   ll a[n];
   int e=0;
   int ans=0;
   for(int i=0;i<n;i++) {
       cin >> a[i];
       if(a[i]%2==0) {
           e++;
           if(a[i]%3==0 || a[i]%5==0) {
               ans++;
           }
       }
       
   }
   if(e==ans) {
           cout <<"APPROVED\n";
       }
       else cout<<"DENIED\n";
  
   
    
}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    ans = 0
    a = 10**3
    for i in range(5):
        x = int(input())
        ans += ((x + 9) // 10) * 10
        aa = x % 10
        if aa == 0:
            continue
        a = min(a, aa)
    if a == 10 ** 3:
        a = 10
    ans -= 10 - a
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, m;
	cin >> n >> m;
	
	int start = (n == 1 ? 0 : pow(10,n-1));
	int end = pow(10,n) - 1;
	
	int c[m][2];
	for(int i = 0; i < m; i++)
		cin >> c[i][0] >> c[i][1];
		
	for(int i = start; i <= end; i++){
		string no = to_string(i);
		int flag = 0;
		for(int j = 0; j < m; j++){
			if(no[c[j][0]-1] != ('0' + c[j][1])){
				flag = 1;
			}
		}
		if(flag == 0){
			cout << i;
			return 0;
		}
	}
	cout << -1;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 int n,k,x,y;
 cin>>n>>k>>x>>y;
 if(n<k)
 cout<< x*n <<endl;
 else
 cout<<(n-k)*y + k*x <<endl;
  }


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
	vector<int>q;
	int n;
	cin >> n;
	long long sum=0;
	for (int i = 0, x; i < n; i++)
	{
		cin >> x;
		sum += x;
		q.push_back(x);
	}
	sum = sum / n;
	long long sum2 = sum + 1;
	long long ans = 0, ans2 = 0;
	for (int i = 0; i < n; i++)
	{
		ans += (q[i] - sum) * (q[i] - sum);
		ans2 += (q[i] - sum2) * (q[i] - sum2);
	}
	cout << min(ans, ans2);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000+1
#define rep(a,b) for(ll i=a;i<b;i++)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()
{   io

    ll n=0,totw=0;
    cin>>n>>totw;
    ll w[n],v[n];

    ll dp[n][totw+1];
    rep(0,n)
        cin>>w[i]>>v[i];

    rep(0,totw+1)
        for(ll j=0;j<n;j++)
            dp[j][i]=0;

    //construct dp table
    rep(1,totw+1)
    {
        if(w[0]<=i)
        dp[0][i]=+v[0];
    }

    rep(1,n)
    {
        for(ll j=1;j<totw+1;j++)
        {
            dp[i][j]=max(dp[i][j],dp[i-1][j]);

            if(w[i]<=j)
            dp[i][j]=max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
        }
    }

    cout<<dp[n-1][totw];

    return 0;
}


Measured memory_bytes: 78336
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def fac(n):
    ans=1
    for i in range(n,0,-1):
        ans*=i
    return ans

n=int(input())
c = Counter(prime_factorize(fac(n)))
v=c.values()
cnt={74:0,24:0,14:0,4:0,2:0}
for i in v:
    if i>=74:
        cnt[74]+=1
    if i>=24:
        cnt[24]+=1
    if i>=14:
        cnt[14]+=1
    if i>=4:
        cnt[4]+=1
    if i>=2:
        cnt[2]+=1
ans=cnt[74]+cnt[24]*(cnt[2]-1)+cnt[14]*(cnt[4]-1)+cnt[4]*(cnt[4]-1)*(cnt[2]-2)//2
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	int now = 1, id = 0, MAX = 1, ans = 0;
	rep(i, 0, n){
		if(a[i] > now){
			ans += (a[i] - 1) / now;
		}else{
			MAX = max(MAX, a[i]);
		}
		if(now <= MAX) now = MAX + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int n;

int solve(int a,int b){
    if(a > b)return b;
    else return a;
}

int solve(char a,string st){
    int res=0;
    for(int i=0;i<n;i++){
        if(i % 2 == 1){
            if(st[i] != a)res++;
        }else{
            if(st[i] == a)res++;
        }
    }
    return res;
}

int main(void){
    string s;
    cin >> s;
    n = s.length();
    int res1 = solve('1',s);
    int res2 = solve('0',s);
    cout << min(res1,res2) << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define Mod 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s; cin>>n>>s;
    if(n<3200) cout<<"red";
    else cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N, Q;
    cin >> N >> Q;
    vector<vector<ll>> tree(N);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<ll> val(N);
    rep(i, Q) {
        ll p, x;
        cin >> p >> x; p--;
        val[p] += x;
    }
    auto dfs = [&](auto dfs, ll u, ll p) -> void {
        for (ll v : tree[u]) if (v != p) {
            val[v] += val[u];
            dfs(dfs, v, u);
        }
    };
    dfs(dfs, 0, -1);

    cout << val << endl;
    return 0;
}

Measured memory_bytes: 22528
import sys
import copy
def input():
    return sys.stdin.readline()
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))


A = max(a)
if a.count(A) >= 2:
  for i in range(n):
    print(A)
else:
  index = a.index(A)
  for i in range(index):
    print(A)
  print(sorted(a)[-2])
  for i in range(index+1,n):
    print(A)

Measured memory_bytes: 14800
k = gets.chomp.to_i

def s(n)
    nn = n
    ret = 0
    while(nn>0) do
        ret += nn % 10
        nn /= 10
    end
    return ret
end

def f(n)
    nn = n
    i = 0
    ret = 0
    val = 10 ** 16
    while(nn>0) do
        nn /= 10
        i += 1
        m = (nn+1) * 10 ** i - 1
        if val > m.to_f / s(m)
            val = m.to_f / s(m)
            ret = m
        end
    end
    return ret
end

(1..9).each do |i|
    puts i
    k -= 1
    exit if k == 0
end

n = 10
while(k>0)
    n = f(n+1)
    puts n
    k -= 1
end

Measured memory_bytes: 1788
# vim: set fileencoding=utf-8:
import sys
from functools import lru_cache

n = int(sys.stdin.readline().rstrip())
graph = [[0] * (n+1) for _ in range(n+1)]
for i in range(1, n+1):
    tmp = [int(ele) for ele in sys.stdin.readline().rstrip().split()]
    for j in tmp[2:]:
        graph[i][j] = 1

d = [-1] * (n+1)
f = [-1] * (n+1)
yet = [ele for ele in range(1, n+1)]
ct = 0


def main():
    while yet:
        stack = [min(yet)]
        dfs(stack)

    for i, detected_at, finished_at in zip(range(1, n + 1), d, f):
        print(str(i) + " " + str(detected_at) + " " + str(finished_at))


def dfs(stack):
    global yet, ct, graph, d, f
    ct += 1
    d[stack[-1]-1] = ct
    yet.remove(stack[-1])

    for i, adjacency in enumerate(graph[stack[-1]]):
        if adjacency == 1 and i in yet:  # 隣接かつ未探索であれば、stackにpush
            stack.append(i)
            dfs(stack)
    else:
        ct += 1
        f[(stack[-1]-1)] = ct
        stack.pop()


if __name__ == "__main__":
    main()



Measured memory_bytes: 6372
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll val[3003][3003], mem[3003][3003][5], n, m;
ll dp(int r, int c, int cnt)
{
    if(r>n || c>m || cnt>3)return -100000000000000000;
    if(r==n && c== m)return (cnt<3)*val[n][m];
    if(mem[r][c][cnt]!=-1)return mem[r][c][cnt];
    return mem[r][c][cnt]= max(max((cnt<3)*val[r][c]+dp(r+1, c, 0), dp(r, c+1, cnt)), val[r][c]+dp(r, c+1, cnt+1));
}
int main()
{
    ll k;
    scanf("%lld %lld %lld", &n, &m, &k);
    while(k--)
    {
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        val[x][y]= z;
    }
    memset(mem, -1, sizeof mem);
    printf("%lld\n", dp(1, 1, 0));
    return 0;
}


Measured memory_bytes: 426828
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ans[2000001];
int n,l,t;
signed main(){
    scanf("%lld%lld%lld",&n,&l,&t);
    int tmp=1;
    for(int i=1;i<=n;++i){
        int x,w;
        scanf("%lld%lld",&x,&w);
        if(w==1){
            ans[i]=(x+t)%l;
            tmp+=(x+t)/l;
        }
        else {
            ans[i]=(x-t)%l;
            tmp+=(x-t)/l;
            if(ans[i]<0)ans[i]+=l,tmp--;
        }
    }
    //cout<<tmp<<endl;
    sort(ans+1,ans+1+n);
    tmp=((tmp%n)+n)%n;
    if(tmp==0)tmp=n;
    for(int i=tmp;i<=n;++i)printf("%lld\n",ans[i]);
    for(int i=1;i<tmp;++i)printf("%lld\n",ans[i]);
}
/*
3 3 8
0 1
1 2
2 1
*/


Measured memory_bytes: 1920
#define llint long long
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;

int n;
unordered_map<string, llint> mp;
string s1,s2;
llint ans = 0;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        s1 += c;
    }
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        s2.insert(s2.begin(), c);
    }

    for (int i = 0; i < (1 << n); i++) {
        string r, b;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) r += s1[j];
                else b += s1[j];
        }
        string p = r + ' ' + b;
        auto itr = mp.find(p);
        if (itr == mp.end()) mp[p] = 1;
            else itr -> second++;
    }

    for (int i = 0; i < (1 << n); i++) {
        string r, b;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) r += s2[j];
                else b += s2[j];
        }
        string p = b + ' ' + r;
        auto itr = mp.find(p);
        if (itr != mp.end()) {
            ans += itr -> second;
        }
    }

    cout << ans << endl;

    return 0;
}

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

struct Card
{
  char suit;
  int value;
};

void printCardArray(struct Card *, int);
int isStable(struct Card *, struct Card *, int);
void bubbleSort(struct Card *, int);
void selectionSort(struct Card *, int);

int main(void)
{
  int n, i;
  struct Card *list, *listBub, *listSel, current;
  scanf(" %d", &n);
  list = (struct Card *) malloc(sizeof(struct Card[n]));
  listBub = (struct Card *) malloc(sizeof(struct Card[n]));
  listSel = (struct Card *) malloc(sizeof(struct Card[n]));
  for (i = 0; i < n; i++)
    {
      scanf(" %c%d", &current.suit, &current.value);
      list[i] = current;
      listBub[i] = current;
      listSel[i] = current;
    }
  bubbleSort(listBub, n);
  printCardArray(listBub, n);
  printf("%s\n", isStable(listBub, list, n) == 0 ? "Stable" : "Not stable");
  selectionSort(listSel, n);
  printCardArray(listSel, n);
  printf("%s\n", isStable(listSel, list, n) == 0 ? "Stable" : "Not stable");
  return 0;
}

// printCardArray prints the cards in the given array with length len.
void printCardArray(struct Card *list, int len)
{
  int i;
  for (i = 0; i < len; i++)
    printf("%c%d%s", list[i].suit, list[i].value, i != len - 1 ? " " : "\n");
}

// isStable returns 0 if the lists are stable, 1 otherwise.
int isStable(struct Card *sortedList, struct Card *list, int len)
{
  int i, j, lastVal, lastPos, jStart;
  lastVal = -1;
  for (i = 0; i < len; i++)
    {
      // check if a value is duplicated
      if (sortedList[i].value == lastVal)
	{
	  jStart = lastPos + 1;
	  if (jStart == len)
	    return 1;
	}
      else
	jStart = 0;
      for (j = jStart; j < len; j++)
	{
	  if ((sortedList[i].suit == list[j].suit) &&
	      (sortedList[i].value == list[j].value))
	    break;
	  else if (j == len-1)
	    return 1;
	}
      lastVal = list[j].value;
      lastPos = j;
    }
  return 0;
}

void bubbleSort(struct Card *list, int len)
{
  int i, j;
  struct Card holder;
  for (i = 0; i < len; i++)
    for (j = len - 1; j > i; j--)
      if (list[j].value < list[j-1].value)
	{
	  holder = list[j];
	  list[j] = list[j-1];
	  list[j-1] = holder;
	}
}

void selectionSort(struct Card *list, int len)
{
  int i, j, mini;
  struct Card holder;
  for (i = 0; i < len; i++)
    {
      mini = i;
      for (j = i + 1; j < len; j++)
	if (list[j].value < list[mini].value)
	  mini = j;
      holder = list[i];
      list[i] = list[mini];
      list[mini] = holder;
    }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B;
  cin >> A >> B;

  int ans = 0;
  FOR(i, A, B)
  {
    string n = to_string(i);
    string rn = n;
    reverse(rn.begin(), rn.end());
    if (n == rn)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x;
    cin>>x;
    string s,t;
    cin>>s>>t;
    for (int i=0;i<x;i++){
        cout<<s[i]<<t[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int ignore = 1;
    //cin>>ignore;
    while(ignore--)
    {
        long double d,t,s;
        
        cin>>d>>t>>s;
        
        if((d/s) <= t )
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        
    }
    
}

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

using namespace std;

int main(){
    vector<int> a(101);
    for(int i=0;i<3;i++){
        int tmp;
        cin>>tmp;
        a[tmp]++;
    }
    sort(a.begin(),a.end(),greater<int>());
    int cnt=0;
    for(int i=0;i<3;i++){
        if(a[i]!=0)
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
string s, t;
int main(void){
    // Your code here!
    cin >> n >> s >> t;
    for (ll i = 0; i < n; i++) {
        if (s.substr(i, n - i) == t.substr(0, n - i)) {
            cout << n + i << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
#define Nmax 1000000000000
using namespace std;
int main()
{
    IOS;
    int n,w;cin>>n>>w;
    ll val[n+1];
    ll we[n+1];
    for(int i=1;i<=n;i++)cin>>we[i]>>val[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    ll res=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j<we[i]) dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-we[i]]);
            }
            if(i==n) res=max(res,dp[i][j]);
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 79232
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for(int i = 0; i < n; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        int ans = list.get(n-1)-list.get(0);
        for(int i = 1; i < n; i++){
            ans = Math.min(ans, k-(list.get(i) - list.get(i-1)));
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 84272
import java.util.*;
public class Main {
	public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      Map<String,Integer> map = new HashMap<>();
      int maxVal = 1;
      for (int i=0; i<N; i++) {
        String key = sc.next();
        if (map.keySet().contains(key)) {
          int mgk = map.get(key);
          maxVal = Math.max(maxVal,++mgk);
          map.replace(key,mgk);
        } else {
          map.put(key,1);
        }
      }
      final int finalVal = maxVal;
      ArrayList<String> list = new ArrayList<>();
      map.forEach((k,v) -> {
        if (v == finalVal) {
          list.add(k);
        }
      });
      Collections.sort(list);
      for (String ans : list)
        System.out.println(ans);
      
    }
}

Measured memory_bytes: 82012
n = int(input())
a1 = input()
a2 = input()

a = []
a.append(a1.split())
a.append(a2.split())
sum=0
max=0
for i in range(n):
    sum = 0
    for j in range(i+1):
        sum += int(a[0][j])
    for k in range(i,n):
        sum += int(a[1][k])
    if sum >= max:
        max=sum
print(max)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int ab(int b){
    int c=0;
    while(b%2==0){
        b/=2;
        c++;
    }
    return c;
}
int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=ab(a[i]);
    }
    sort(b,b+n);
    cout<<b[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(void)
{
 
  int i, j, tmp;
 
  /* 数値を格納する配列 */
  int number[3];
 
  /* 数値の総数を入力 */
  int total=3;

 
  /* 配列に格納する数値を入力 */
  scanf("%d %d %d",&number[0],&number[1],&number[2]);

 
  /* 数値を昇順にソート */
  for (i=0; i<total; ++i) {
    for (j=i+1; j<total; ++j) {
      if (number[i] > number[j]) {
        tmp =  number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }
 
  /* 昇順ソートした数値を出力 */
  printf("%d %d %d\n",number[0],number[1],number[2]);
  return 0;
}

Measured memory_bytes: 596
# 19/4/17再戦
# -x + a = x + b だと x = (sum)/2で~.5になる可能性がある
# う～～～ん

n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
sum_t = sum(ts)
n = 2*sum_t+1
max_v = [float("inf")]*n
# 0から右上、-1から左上
for i in range(n):
    max_v[i] = min(i/2, (sum_t-i/2))

# intでtimeは管理するか...
# 0→0, 0.5→1, 1→2 ... i/2→i
t_cnt = 0
for t, v in zip(ts, vs):
    for j in range(2*t+1):
        max_v[t_cnt + j] = min(max_v[t_cnt + j], v)

    # 左側に伸ばしていく
    left = t_cnt
    while left >= 0:
        v_left = v + (t_cnt - left)/2
        if max_v[left] < v_left:
            break
        max_v[left] = v_left
        left -= 1
    # 右側に伸ばしていく
    t_cnt += 2*t
    right = t_cnt
    while right < n:
        v_right = v + (right - t_cnt)/2
        if max_v[right] < v_right:
            break
        max_v[right] = v_right
        right += 1

#print(max_v)
ans = sum(max_v) - (max_v[0]+max_v[-1])/2
print(ans/2)

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		final int TH = 400;
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++ ){
			a[i] = scan.nextInt();
		}
		int gray =0;
		int braun=0;
		int green=0;
		int cyan=0;
		int blue=0;
		int orange=0;
		int bulaun=0;
		int red=0;
		int over =0;

		for( int hoge : a){
			if(hoge < TH){
				gray++;
			}else if(hoge < 2*TH){
				braun++;
			}else if(hoge < 3*TH){
				green++;
			}else if(hoge < 4*TH){
				cyan++;
			}else if(hoge < 5*TH){
				blue++;
			}else if(hoge < 6*TH){
				orange++;
			}else if(hoge < 7*TH){
				bulaun++;
			}else if(hoge < 8*TH){
				red++;
			}else{
				over++;
			}
		}
		
		int maxColor=0;
		int minColor=0;
		
		if (gray>0){
			maxColor++;
			minColor++;
		}
		if (braun>0){
			maxColor++;
			minColor++;
		}
		if (green>0){
			maxColor++;
			minColor++;
		}
		if (cyan>0){
			maxColor++;
			minColor++;
		}
		if (blue>0){
			maxColor++;
			minColor++;
		}
		if (orange>0){
			maxColor++;
			minColor++;
		}
		if (bulaun>0){
			maxColor++;
			minColor++;
		}
		if (red>0){
			maxColor++;
			minColor++;
		}
		if (over>0){
			maxColor += over;
			if(minColor==0){
				minColor=1;
			}
		}
		
		System.out.println("" + minColor + " "+ maxColor);
		
	}
}

Measured memory_bytes: 23764
Query=list(input())
Q=int(input())
flag = True
strF=[]
strB=[]
for i in range(Q):
  S2=input()
  if S2=="1":
    flag = not flag
  else:
    x=S2.split()
    if flag:
      if x[1]=="1":
        strF.append(x[2])
      else:
        strB.append(x[2])
    else:
      if x[1]=="1":
        strB.append(x[2])
      else:
        strF.append(x[2])

if flag:
  strF.reverse()
  Query=strF+Query+strB
else:
  strB.reverse()
  Query.reverse()
  Query=strB+Query+strF
 
print("".join(Query))

Measured memory_bytes: 9888
N = int(input())
MOD = int(1e9)+7

ps = []
ans = 1
for n in range(2, N+1):
    for p in ps:
        if n%p == 0:
            break
    else:
        ps.append(n)
     
        cnt = 0
        i = 1
        while True:
            c = N//(n**i) 
            if c==0: 
                break
            else:
                cnt += c
                i += 1
        ans *= (cnt+1)
        ans %= MOD
                
print(ans)

        
        


Measured memory_bytes: 3064
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const i = parseInt(args[0][1], 10)
	console.log(n - i + 1)
}

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


Measured memory_bytes: 9420
a3={'357','375','537','573','735','753'}
def make_a(a,n):
    new_a=set()
    for i in a:
        for j in range(n+1):
            new_a.add(i[:j]+'3'+i[j:])
            new_a.add(i[:j]+'5'+i[j:])
            new_a.add(i[:j]+'7'+i[j:])
    return new_a
a4=make_a(a3,3)
a5=make_a(a4,4)
a6=make_a(a5,5)
a7=make_a(a6,6)
a8=make_a(a7,7)
a9=make_a(a8,8)
a=list(map(int,a3))+list(map(int,a4))+list(map(int,a5))+list(map(int,a6))+list(map(int,a7))+list(map(int,a8))+list(map(int,a9))
n=int(input())
a.append(n)
a.sort()
ans=a.index(n)
if ans!=len(a)-1:
    if a[ans]==a[ans+1]:
        ans+=1
print(ans)

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

int p[1010];

int main() {
	int n, k;
	int sum = 0;

    ios::sync_with_stdio(false);
    cin.tie(0);

	cin >> n >> k;

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

	int len = sizeof(p) / sizeof(int);
//	cout << "len" << len << endl;
	sort(p, p+n);


	for(int i = 0; i < k; i++) {
//		cout << p[i] << endl;
		sum += p[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<cstdlib>
using namespace std;

void split( const string str, vector<string> &in ){
	in.push_back("");
	int index = 0;
	for( int i=0; i<str.length(); i++ ){
		if( str[i] == ' ' ){
			in.push_back("");
			index++;
		}else{
			in[index] += str[i];
		}
	}
}

int main(){
	stack<int> st;
	vector<string> in;
	string str;
	getline( cin, str );
	split( str, in );
	for( int i=0; i<in.size(); i++ ){
		if( in[i][0] == '+' ){
			int a, b;
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(a+b);
		}
		else if( in[i][0] == '*' ){
			int a, b;
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(a*b);
		}
		else if( in[i][0] == '-' ){
			int a, b;
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(b-a);
		}
		else{
			st.push( atoi(in[i].c_str()) );
		}
	}
	cout << st.top() << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n,m;

    while(cin>>n>>m)
    {
        vector<int> v(n+1),w(n+1);
        vector<vector<int> > dp(n+1,vector<int>(m+1));
        for(int i=1;i<=n;i++)
        {
            cin>>v[i]>>w[i];
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                dp[i][j]=dp[i-1][j];
                if(j-w[i]>=0)
                {
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
                }
            }
        }
        cout<<dp[n][m]<<endl;
    }

    return 0;
}



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

int main() {

    int n,k;
    cin >> n >> k;
    vector<int> bucket(n);

    int a;
    for(int i = 0; i < n; i++){
      cin >> a;
      bucket.at(a-1)++;
    }

    sort(bucket.begin(), bucket.end());

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

        if( bucket.at(i) > 0 ){
            if( n-i <= k )
              break;
            else
              ans += bucket.at(i);
        }

    }
  
    cout << ans << endl;

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0&&W==0)  break;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          System.out.print("#");
        }
        System.out.print("\n");
      }
      System.out.print("\n");
    }
  }
}



Measured memory_bytes: 37700