akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<cstdio>
    using namespace std;
    long long NMAX,NMIN;
    int K;
    int A[100005];
    long long eval(long long N){
        for(int i = 1;i <= K;i++){
            N =N - N % A[i];}
        return N;
    }
    int main()
    {
        cin >> K;
        for(int i = 1;i <= K;i++){
            cin >> A[i];
        }
        long long st = 0,dr = 1e18;
        while(dr - st >= 1){
            long long mid = (st + dr) / 2;
            if(eval(mid) >= 2){
                dr = mid;
            }
            else {
                st = mid + 1;
            }
        }
      long long L = dr;
        st = 0,dr = 1e18;
        while(dr - st >= 1){
            long long mid = (st + dr) / 2;
            if(eval(mid) <= 2){
                st = mid + 1;
            }
            else {
                dr = mid;
            }
        }

    long long R = st - 1;
//    cout << L << ' '<< R << endl;
    if(L > R) puts("-1");
    else cout << L << ' '<< R << endl;
        return 0;
    }


Measured memory_bytes: 640
#B
import collections

N = int(input())
D = list(map(int, input().split()))
is_first_zero = True
if D[0] != 0:
    is_first_zero = False
if is_first_zero:
    c = sorted(collections.Counter(D).items(), key=lambda x:x[0])
    if len(c) == 2:
        res = 1
    for index, i in enumerate(c):
        ind = i[0]
        num = i[1]
        if ind == 0:
            if num != 1:
                is_first_zero = False
                break
        else:
            if ind != pre_ind + 1:
                is_first_zero = False
                break
            else:
                if index == 2:
                    res = pre_num ** num
                elif index > 2:
                    res = res * (pre_num ** num)
                #print(res)
        pre_ind = ind
        pre_num = num
                
if is_first_zero:
    print(res % 998244353)
else:
    print("0")

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

int main() {
  int N, S;
   cin >> N;
  
  S = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    S += r - l + 1;
    }
   cout << S <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int cnt = 0;
int m = 0;
std::vector<int> g;

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

void shell_sort(int a[], int n) {
  cnt = 0;
  for (int i = 0; i < m; ++i)
    insertion_sort(a, n, g[i]);
}

int main() {
  int n;
  std::cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    std::cin >> a[i];

  int gg = 1;
  while (gg <= n) {
    g.push_back(gg);
    gg = 2 * gg + 1;
  }
  std::reverse(g.begin(), g.end());
  m = g.size();

  shell_sort(a, n);
  std::cout << m << std::endl;
  for (int i = 0; i < m; ++i) {
    if (i > 0)
      std::cout << " ";
    std::cout << g[i];
  }
  std::cout << std::endl;
  std::cout << cnt << std::endl;
  for (int &v : a)
    std::cout << v << std::endl;
}



Measured memory_bytes: 6968
#!/usr/bin/env python3

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ab = [LI() for _ in range(n)]
cd = [LI() for _ in range(n)]
ab.sort(key = itemgetter(0))
cd.sort(key = itemgetter(0))
ans = 0
for i in range(n):
    lst = []
    x,y = cd[i]
    for j in range(len(ab)):
        a,b = ab[j]
        if a <= x and b <= y:
            lst.append([a,b])
    if len(lst) == 0:
        continue
    lst.sort(key = itemgetter(1),reverse = True)
    ab.remove(lst[0])
    ans += 1
print(ans)


Measured memory_bytes: 39148
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;

    private static void Read() { Stream.Read(Buffer, 0, BUF_SIZE); }

    private static void Move() { if (++ptr >= Buffer.Length) { Read(); ptr = 0; }  }

    private static byte Current { get { return Buffer[ptr]; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Current < 48) Move();
            do { res = res * 10 + (Current ^ 48); Move(); } while (48 <= Current);
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; 
            while (Current < 45) Move(); if (Current == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Current ^ 48); Move(); } while (48 <= Current);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin>>S;
    char a=S[0]=='R';
     char b=S[1]=='R';
      char c=S[2]=='R';

     if(a&b&c)
     {
         cout<<"3";
     }
     else if(a&b||b&c)
     {
         cout<<"2";
     }
     else if(a|b|c)
     {
         cout<<"1";

     }
     else
     {

    cout<<"0";
     }
    return 0;
    }


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    string s;

    cin >> n >> s;
    string ans = "No";
    string a, b;
    if(s.length()%2==0){
        for(int i=0; i<n/2; i++){
            a+=s[i];
        }
        for(int i=n/2; i<n; i++){
            b+=s[i];
        }
        if(a==b) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	A = list(map(int, input().split()))
	for i in range(N):
		A[i] -= i+1
	A.sort()


	mid1 = A[N//2]
	mid2 = A[N//2]
	if N >= 2:
		mid2 = A[N//2 + 1]

	ans1 = 0
	ans2 = 0
	for i in range(N):
		ans1 += abs(A[i] - mid1)
		ans2 += abs(A[i] - mid2)

	print(min(ans1, ans2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 26176
#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<int>q;
	string s;
	int k;
	while(cin>>s,s!="end"){
		if(s=="insert")cin>>k,q.push(k);
		else cout<<q.top()<<endl,q.pop();
	}
}



Measured memory_bytes: 7072
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int a[25][25];
    rep(i, N) rep(j, N) cin >> a[i][j];
    ll dp[10001000];
    dp[0] = 1;
	for(int S = 1; S < (1<<N) ; S ++) {
		int i = __builtin_popcount(S);
		rep(j, N) {
			if((S & (1<<j)) && a[i - 1][j] == 1) {
				dp[S] += dp[S & ~(1<<j)];
				dp[S] %= mod;
			}
		}
	}
	cout << dp[(1<<N) - 1] << endl;
	return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 100 * 1000 + 7;

vector<int> g[MAX];
vector<int> gt[MAX];
set<int> gs[MAX];
int order[MAX];
int par[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n - 1 + m)
	{
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].PB(v);
		gt[v].PB(u);
		gs[u].insert(v);
	}
	set<PII> S;
	FOR(i, 0, n)
		S.insert(MP(SZ(gs[i]), i));
	FOR(i, 0, n)
	{
		int v = S.begin()->second;
		S.erase(S.begin());
		order[v] = i;
		FOR(j, 0, SZ(gt[v]))
		{
			int u = gt[v][j];
			S.erase(MP(SZ(gs[u]), u));
			gs[u].erase(v);
			S.insert(MP(SZ(gs[u]), u));
		}
	}
	FOR(i, 0, n)
		par[i] = -1;
	FOR(i, 0, n)
	{
		FOR(j, 0, SZ(g[i]))
		{
			int to = g[i][j];
			if(par[to] == -1 || order[i] < order[par[to]])
				par[to] = i;
		}
	}
	FOR(i, 0, n)
		cout << par[i] + 1 << "\n";
	return 0;
}

Measured memory_bytes: 26624
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))

ll H, W, K;
vector<set<ll>> sx, sy;
vector<vector<ll>> tbl;

pair<ll, ll> nxt(ll i, ll j, ll d) {
	if (d == 0) {
		auto itr = sy[j].lower_bound(i);
		if (itr == sy[j].begin())return { -1,-1 };
		--itr;
		return { *itr, j };
	}
	if (d == 2) {
		auto itr = sy[j].upper_bound(i);
		if (itr == sy[j].end())return { -1,-1 };
		return { *itr,j };
	}

	if (d == 1) {
		auto itr = sx[i].lower_bound(j);
		if (itr == sx[i].begin())return { -1,-1 };
		--itr;
		return { i, *itr };
	}
	if (d == 3) {
		auto itr = sx[i].upper_bound(j);
		if (itr == sx[i].end())return { -1,-1 };
		return { i, *itr };
	}

	return { -1,-1 };
}

void erase(ll i, ll j) {
	sx[i].erase(j);
	sy[j].erase(i);
}

ll dist(pair<ll, ll> a, pair<ll, ll> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
	cin >> H >> W >> K;
	sx.resize(H);
	sy.resize(W);
	REP(i, 0, H)REP(j, 0, W) {
		sx[i].insert(j);
		sy[j].insert(i);
	}
	pair<ll, ll> start, goal;
	cin >> start.first >> start.second >> goal.first >> goal.second;
	--start.first; --start.second;
	--goal.first; --goal.second;
	tbl.resize(H);
	REP(i, 0, H) {
		tbl[i].resize(W);
		string str;
		cin >> str;
		REP(j, 0, W) {
			tbl[i][j] = str[j] == '@' ? -1 : 0;
		}
	}
	queue<pair<ll, ll>> q;
	q.push(start);
	erase(start.first, start.second);
	while (!q.empty()) {
		auto p = q.front();
		q.pop();
		if (p.first == goal.first && p.second == goal.second) {
			PRI(tbl[p.first][p.second]);
			return 0;
		}
		for (int d = 0; d < 4; ++d) {
			pair<ll, ll> cur = p;
			while (true) {
				cur = nxt(cur.first, cur.second, d);
				if (cur.first == -1|| tbl[cur.first][cur.second] == -1 || dist(cur, p) > K) break;
				tbl[cur.first][cur.second] = tbl[p.first][p.second] + 1;
				q.push(cur);
				erase(cur.first, cur.second);
			}
		}
	}
	PRI(-1);
	return 0;
}

Measured memory_bytes: 153760
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    string ans,front;
    int left=0,right=n-1,mid;
    out(left);
    fflush(stdout);
    cin>>front;
    if(front=="Vacant")return 0;
    out(right);
    fflush(stdout);
    cin>>ans;
    if(ans=="Vacant")return 0;
    while(left<right){
        mid=(right+left)/2;
        out(mid);
        fflush(stdout);
        cin>>ans;
        if(ans=="Vacant"){return 0;
        }else if(mid%2==0&&ans==front){
            left=mid;
        }else if(mid%2==1&&ans!=front){
            left=mid;
        }else if(mid%2==0&&ans!=front){
            right=mid;
        }else if(mid%2==1&&ans==front){
            right=mid;
        }
        if(right-left==1){
            out(right);
            fflush(stdout);
            cin>>ans;
            if(ans=="Vacant")return 0;
        }
    }
}

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

typedef long long ll;

const int N = 100005;
int n, m, q;
ll a[N], k[N], s[N];

int main() {
	scanf("%d%d", &n, &q);
	a[m = 1] = n;
	for (ll x; q--;) {
		scanf("%lld", &x);
		while (m && a[m] >= x) --m;
		a[++m] = x;
	}
	k[m] = 1;
	for (int i = m; i; --i) {
		ll now = a[i];
		int pos = i;
		for (;;) {
			pos = upper_bound(a + 1, a + pos, now) - a - 1;
			if (!pos) {
				s[now] += k[i];
				break;
			}
			k[pos] += now / a[pos] * k[i];
			now %= a[pos];
		}
	}
	for (int i = n; i; --i) s[i] += s[i + 1];
	for (int i = 1; i <= n; ++i) printf("%lld\n", s[i]);
}


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

typedef pair<int,int> pll;

std::vector<int> Adj[100000] ;
vector<int> ans[100000];
vector<int> visited(100000,0);
set<pair<int,int>> st;

void dfs(int s)
{
    for(auto v:Adj[s])
    {
    if(!visited[v])
    {
        visited[v]=1;
        dfs(v);
        st.erase(pll(min(s,v),max(s,v)));
        
    }
    }
}


void dfs2(int s)
{
    for(auto v:Adj[s] )
    {
        if(!visited[v])
        {
            visited[v]=1;
            dfs2(v);
            if(ans[v].size()&1)
            {
                ans[v].push_back(s);
            }
            else
            {
                ans[s].push_back(v);
            }
            
        }
    }
}





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

 if (m & 1) {
        cout << -1 << endl;
        return 0;
    }
    
for(int i=0;i<m;i++)
{
    int a,b;
    cin>>a>>b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
    st.insert(pll(min(a,b),max(a,b)));
}
visited[0]=1;
dfs(0);
for(auto E:st)
{
    ans[E.first].push_back(E.second);
}
fill(visited.begin(),visited.end(),0);
visited[0]=1;
dfs2(0);
for(int i=0;i<n;i++)
{
    for(auto k:ans[i])
    {
        cout<<i+1<<" "<<k+1<<endl;
    }
}

}

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

typedef long long ll;

int main() {
    ll A;
    string B;
    cin >> A >> B;
    int n = B.size();
    ll C = stoi(B.substr(0, n - 3)) * 100 + stoi(B.substr(n - 2, 2));
    cout << A * C / 100 << "\n";
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int ans = num + (num*num) + (num*num*num);
		System.out.println(ans);
	}

}

Measured memory_bytes: 27084
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);

  int hd = b-a;
  int i,h = hd;
  for(i=0;i<hd;i++)
    h += i;

  printf("%d\n",h-b);
  return 0;
}


Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = NK[0];
            var k = NK[1];

            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(h.Where(x => x >= k).Count());
        }
    }
}


Measured memory_bytes: 19168
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int k = sc.nextInt();
		int x = sc.nextInt();
        
        int point = x - k + 1;
        int wide = (2 * k) - 1;
        String ans = "";
        for (int i =  x - k + 1; i < wide + point; i++) {
          ans += i;
          ans += " ";
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

int main() {
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  int ans=1e9;
  for(int i=0;i<=max(x,y);i++){
    int cnt=2*i*c+max(x-i,0)*a+max(y-i,0)*b;
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define maxn 1000000
using namespace std;
long long s=0;
long long ans=0;
long long a[maxn];
int n;
long long mod=1e9+7;
long long i2=5e8+4;
int main() {
    scanf("%d",&n);
    ans=0;
    for(int i=0;i<n;i++) {
        scanf("%lld",&a[i]);
        s=(s+a[i])%mod;
        ans=(ans-a[i]*a[i])%mod;
    }
    ans=(ans+s*s)%mod;
    if(ans<0) ans+=mod;
    printf("%lld",(ans*i2)%mod);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n;
    cin >> n;
    vector<int>diffarr(n);
    rep(i, n)cin >> diffarr[i];
    sort(all(diffarr));
    int diff = diffarr[n / 2] - diffarr[(n / 2) - 1];
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 640
s = gets.chomp.split('')

shead = s[0...(s.size/2)]
stail = s[(s.size/2)..-1]
stail.shift if s.size.odd?
stail.reverse!
c = 0
shead.zip(stail).each { |h, t| c += 1 unless h == t }
puts c


Measured memory_bytes: 1788
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();

        long ans = 1;

        long[] arr = new long[n];

        int cnt = 0;
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextLong();
            if (arr[i] == 0) cnt++;
        }

        if (0<cnt) {
            System.out.println(0);
            return;
        }

        Arrays.sort(arr);

        for (int i=0; i<n; i++) {
            long s = arr[i];
            long tmp = ans * s;
            if ((tmp / ans) != s) {
                System.out.println(-1);
                return;
            }
            ans *= s;
            if ((long)1e18 < ans || ans < 0) {
                System.out.println(-1);
                return;
            }
        }

        System.out.println(ans);

    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL a, b, q;cin >> a >> b >> q;
    vector<LL> s(a), t(b), x(q);
    inc(i, 0, a) cin >> s[i];
    inc(i, 0, b) cin >> t[i];
    inc(i, 0, q) cin >> x[i];
    inc(i, 0, q){
        int ls = lower_bound(s.begin(), s.end(), x[i]) - s.begin()-1;
        int rs = upper_bound(s.begin(), s.end(), x[i]) - s.begin();
        int lt = lower_bound(t.begin(), t.end(), x[i]) - t.begin()-1;
        int rt = upper_bound(t.begin(), t.end(), x[i]) - t.begin();
        vector<LL> v;
        if(ls != -1 && lt != -1) v.pb(x[i] - min(s[ls], t[lt]));
        if(ls != -1 && rt !=  b) v.pb(min(x[i] - s[ls], t[rt] - x[i]) + (t[rt] - s[ls]));
        if(rs !=  a && lt != -1) v.pb(min(x[i] - t[lt], s[rs] - x[i]) + (s[rs] - t[lt]));
        if(rs !=  a && rt !=  b) v.pb(max(s[rs], t[rt]) - x[i]);
        cout << *min_element(v.begin(), v.end()) << endl;
    }
    return 0;
}


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

int main() {
	
	int N, digit, count;
	cin >>N;
	
	count=0;
	
	for(int i=0; i<N; i++){
		
		digit=0;
		int C=i+1;
		while(C>0){
			
			C /=10;
			digit++;
			
		}
		
		if(digit%2==1){
			
			count++;
			
		}
		
	}
	cout <<count <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const long long N = 1e9 + 7;
typedef long long ll;
map <char,int> ma;
int main()
{
	int n, r;
	cin >> n >> r;
	if(n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vec a(n);
    rep(i,n)a[i]=in();
    vector<vecll> dp(2,vecll(n));
    dp[0][0]=a[0]/2;
    dp[1][0]=(a[0]-1)/2;
    rep2(i,1,n-1){
        dp[0][i]=a[i-1]>0?max(dp[0][i-1]+a[i]/2,dp[1][i-1]+(a[i]+1)/2):max(dp[0][i-1]+a[i]/2,dp[1][i-1]+a[i]/2);
        dp[1][i]=a[i-1]>0?max(dp[0][i-1]+(a[i]-1)/2,dp[1][i-1]+a[i]/2):max(dp[0][i-1]+(a[i]-1)/2,dp[1][i-1]+(a[i]-1)/2);
    }
    cout<<max(dp[0][n-1],dp[1][n-1])<<endl;
}


Measured memory_bytes: 2944
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		LinkedHashSet<String> set = new LinkedHashSet<>();
		
		int num = scan.nextInt();
		
		for(int i = 0; i < num; i++) {
			String word = scan.next();
			set.add(word);
		}
		
		if(set.size() != num) {
			System.out.println("No");
			return;
		}
		
		String pword = "";
		for(String word : set) {
			if("".equals(pword)) {
				pword = word;
				continue;
			}
			
			if(!pword.endsWith(word.substring(0, 1))) {
				System.out.println("No");
				return;
			}
			pword = word;
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A[] = new int[N+1];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }

        int c = 0;
        while (true) {
            boolean done = false;
            for (int i = 0; i < N; i++) {
                if (A[i] % 2 != 0) done = true;
            }

            if (done) break;

            for (int i = 0; i < N; i++) {
                A[i] /= 2;
            }

            ++c;
        }

        System.out.println(c);
    }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 入力フェーズ
		string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    int B = int.Parse(input[2]);

    int max = Math.Min(A, B);
    int min = A + B - N;
    if(min < 0) min = 0;
    
		//出力
		Console.WriteLine(max + " " + min);
	}
}


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


int main(){


	int n;
	cin >>  n;

	vector<int>findid;

	int max = 0;
	int findmax = 0;
	bool MAX = false;
	int a[100];

	/*何回割れるかを求める*/
	for (int i = 1; i < n; ++i) {
		int count = 0;
		a[i] = i;

		while (a[i] % 2 == 1) {

			
			a[i] = a[i] / 2;
			count++;

		}

		if (max <= count) {
			max = count;
			findid.push_back(i);
		}
	}
	
	/*最大の値を求める*/
	for (int j = 0; j < findid.size(); ++j) {
		if (findmax < findid[j])
			findmax = findid[j];
	}

	/*output*/

	//cout << max << endl;
	cout << findmax+1 << endl;

}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;

  vector<pii> edge(N-1); // 枝が結んでいる頂点
  vector<int> edge_col(N-1, -1); // 色
  vector<map<int,int>> node_col(N); // 各頂点で使われた色

  vector<vector<int>> node_edge(N); // 各頂点が持つ枝
  queue<int> q;

  for(int i = 0; i < N-1; i++){
    int tmp1,tmp2; cin >> tmp1 >> tmp2;
    tmp1--; tmp2--;

    edge[i] = make_pair(tmp1,tmp2);

    node_edge[tmp1].push_back(i);
    node_edge[tmp2].push_back(i);
  }

  int max_deg = 0;
  int max_deg_node;
  for(int i = 0; i < N; i++){
    int deg = node_edge[i].size();

    if(deg > max_deg){
      max_deg_node = i;
      max_deg = deg;
    }
  }

  q.push(max_deg_node);
  while(!q.empty()){
    int now = q.front();
    q.pop();

    for(int e: node_edge[now]){
      if(edge_col[e] != -1){
        continue;
      } 

      int node_1 = edge[e].first;
      int node_2 = edge[e].second;

      int next = (node_1 == now ? node_2 : node_1);
      q.push(next);
      // cerr << now << " " << next << endl;

      int index = node_col[now].size();
      // 最悪max_deg回探索する
      for(int time = 0; time < max_deg; time++){
        index += time;
        index %= max_deg;
        if(node_col[now][index] == 0 && node_col[next][index] == 0){
          node_col[now][index] = 1;
          node_col[next][index] = 1;
          edge_col[e] = index;
          break;
        }
      }
    }
  }

  cout << max_deg << endl;
  for(int i = 0; i < N-1; i++){
    cout << edge_col[i] + 1 << endl;
  }



}


Measured memory_bytes: 24112
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
i=0
total=0
while True:
    if b<c[i]:
        print(total)
        break
    elif i==a-1:
        if b==c[i]:
            print(total+1)
        else:
            print(total)
        break
    else:
        total+=1
        b=b-c[i]
        i+=1

Measured memory_bytes: 9088
while line = gets
  a_ary, b_ary = line.chomp.split, gets.chomp.split

  hit, blow = 0, 0
  not_hit_a_ary, not_hit_b_ary = [], []

  a_ary.zip(b_ary) do |a, b|
    if a == b
      hit += 1
    else
      not_hit_a_ary << a
      not_hit_b_ary << b
    end
  end

  blow = (not_hit_a_ary & not_hit_b_ary).length

  print "%d %d\n" % [hit, blow]
end

Measured memory_bytes: 8584
import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  val comp = compareBy(Triple<Int, String, Int>::second).thenByDescending(Triple<Int, String, Int>::third)
  val r = sortedSetOf(comp)
  repeat(n) {
    val (s, p) = readLine()!!.split(' ')
    r.add(Triple(it + 1, s, p.toInt()))
  }
  r.forEach { println(it.first) }
}


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

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

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut a: Vec<Vec<u32>> = vec![vec![0; m]; n];
    let mut b: Vec<u32> = vec![0; m];

    for index_n in 0..n {
        for index_m in 0..m {
            a[index_n][index_m] = read();
        }
    }

    for index_m in 0..m {
        b[index_m] = read();
    }

    for index_n in 0..n {
        let mut sum: u32 = 0;
        for index_m in 0..m {
            sum += a[index_n][index_m] * b[index_m];
        }
        println!("{}", sum);
    }
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

double caldist(vector<int> a, vector<int> b){
    double tmp = 0.0;
    for(int i=0;i<a.size();i++){
        tmp += (a[i]-b[i])*(a[i]-b[i]);
    }
    return sqrt(tmp);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;cin>>n>>d;
    vector<vector<int>> x;
    rep(i,n){
        vector<int> t;
        rep(i,d){
            int u;cin>>u;
            t.emplace_back(u);
        }
        x.emplace_back(t);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double t = caldist(x[i], x[j]);
            int u = (int)t;
            if(t==u) ++ans;
        }
    }
    cout<<ans<<endl;

}

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

int main(){
    i64 A, B, C, K;
    cin >> A >> B >> C >> K;

    i64 ans = min(A, K); K -= min(A, K);
    K -= min(B, K);
    ans -= min(C, K); 
    cout << ans << endl;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
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> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[410][410];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //区間DP
    int n;
    cin >> n;
    VLL a(n);
    rep(i,n) cin >> a[i];
    VLL sum(n);
    sum[0] = a[0];
    rep(i,n-1) sum[i+1] = sum[i] + a[i+1];
    rep(i,410)rep(j,410) dp[i][j] = 1e15;
    // rep(i,n) cout << sum[i] << ' ';
    // cout << endl;
    FOR(len,1,n+1){
        rep(i,n-len+1){//区間の右端
            FOR(k,i,i+len){//区間の真ん中
                int j = i + len - 1;
                if(i == j){
                     dp[i][j] = 0;
                     continue;
                }
                if(i != 0) dp[i][j] = min(dp[i][k] + dp[k+1][j] + sum[j] - sum[i-1], dp[i][j]);
                else dp[i][j] = min(dp[i][k] + dp[k+1][j] + sum[j], dp[i][j]);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 1536
N = int(input())
A = [int(input()) for _ in range(N)]

left = [0]
right = [0]

# print(A)
for i in range(N):
    left.append(max(left[-1], A[i]))
# print(left)


for i in range(N-1, -1, -1):
    right.append(max(right[-1], A[i]))
# print(right)

# print(len(left))
# print(len(right))

right.reverse()

for i in range(N):
    print(max(left[i], right[i+1]))


Measured memory_bytes: 15656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    string S;
    cin >> S;
    int x = S.size();

    int n = 0, s = 0, w = 0, e = 0;
    for(int i = 0; i < x; i++)
    {
        if(S[i] == 'N') n++;
        if(S[i] == 'S') s++;
        if(S[i] == 'W') w++;
        if(S[i] == 'E') e++;
    }

    if(n == 0)
    {
        if(s > 0)
        {
            cout << "No" << endl;
        }
        else
        {
            if(w == 0)
            {
                if(e > 0)
                {
                    cout << "No" << endl;
                }
                else
                {
                    cout << "Yes" << endl;
                }
            }
            else
            {
                if(e == 0)
                {
                    cout << "No" << endl;
                }
                else
                {
                    cout << "Yes" << endl;
                }
            }
        }
    }
    else
    {
        if(s == 0)
        {
            cout << "No" << endl;
        }
        else
        {
            if(w == 0)
            {
                if(e > 0)
                {
                    cout << "No" << endl;
                }
                else
                {
                    cout << "Yes" << endl;
                }
            }
            else
            {
                if(e == 0)
                {
                    cout << "No" << endl;
                }
                else
                {
                    cout << "Yes" << endl;
                }
            }
        }
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

template <typename Tp, size_t Nb>
auto make_vector(std::vector<size_t> &sizes, Tp const &x) {
    if constexpr (Nb == 1) {
        return std::vector<Tp>(sizes[0], x);
    } else {
        size_t size = sizes[Nb - 1];
        sizes.pop_back();
        return std::vector(size, make_vector<Tp, Nb - 1>(sizes, x));
    }
}

template <typename Tp, size_t Nb>
auto make_vector(size_t const (&sizes)[Nb], Tp const &x = Tp()) {
    std::vector<size_t> s(Nb);
    for (size_t i = 0; i < Nb; ++i)
        s[i] = sizes[Nb - i - 1];
    return make_vector<Tp, Nb>(s, x);
}

template <typename T> void warshall_floyd(vector<vector<T>> &g) {
    size_t v = g.size();
    for (size_t k = 0; k < v; k++) {
        for (size_t i = 0; i < v; i++) {
            for (size_t j = 0; j < v; j++) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, l;
    cin >> n >> m >> l;

    ll inf = 1LL << 60;
    auto g = make_vector({size_t(n), size_t(n)}, inf);
    rep(i, n) { g[i][i] = 0; }
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a][b] = c;
        g[b][a] = c;
    }
    warshall_floyd(g);

    ll q;
    cin >> q;
    ll s[q], t[q];
    rep(i, q) {
        cin >> s[i] >> t[i];
        s[i]--;
        t[i]--;
    }

    auto g2 = make_vector({size_t(n), size_t(n)}, inf);
    rep(i, n) {
        rep(j, n) {
            if (g[i][j] <= l) {
                g2[i][j] = 1;
            }
        }
    }
    rep(i, n) { g2[i][i] = 0; }
    warshall_floyd(g2);
    rep(i, q) {
        if (g2[s[i]][t[i]] == inf) {
            cout << -1 << endl;
            continue;
        }
        cout << g2[s[i]][t[i]] - 1 << endl;
    }
    return 0;
}



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

#define testcase            int t; cin>>t; while (t--)
#define sc(a)               scanf("%lld",&a)
#define sc2(a,b)            scanf("%lld %lld",&a,&b)
#define pb                  push_back
#define reversed(s)         reverse(s.begin(), s.end())
#define asort(s)            sort(s.begin(), s.end())
#define dsort(s)            sort(s.begin(), s.end(),greater<ll>())
#define gtl(x)              getline(cin, (x))
#define PI                  acos(-1)
#define CLR(x, y)           memset(x, y, sizeof(x))
#define Precision(a)        cout << fixed << setprecision(a)
#define FasterIo            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                "\n"

template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}

int main()
{
    FasterIo
    int a=0, b=0, c=0, d=0, e=0, f=0;
    string s;
    testcase
    {
        cin >> s;
        if(s[0]=='A') a++;
        if(s[0]=='W') b++;
        if(s[0]=='T') c++;
        if(s[0]=='R') d++;
    }
    cout << "AC" << " x " << a << endl;
    cout << "WA" << " x " << b << endl;
    cout << "TLE" << " x " << c << endl;
    cout << "RE" << " x " << d << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int a[5];
	for(int i=0; i<5; i++) cin >> a[i];
	int maxDist = -1;
	for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
			maxDist = max(maxDist, abs(a[i]-a[j]));
		}
	}
	int k; cin >> k;
	if(maxDist <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int cnt = parseCnt();

		while (cnt-- > 0) {
			double	diff = parseDiffAngle();
			if (diff < 30.0 || 330.0 < diff) {
				System.out.println("alert");
			} else if (90.0 <= diff && diff <= 270.0) {
				System.out.println("safe");
			} else {
				System.out.println("warning");
			}
		}
	}
 
	private static double parseDiffAngle() {
		double	diff = 0;
		double	tmp1 = 0;
		double	tmp2 = 0;
		String  time = null;

		if ((time = parseStdin()) != null) {
			String[]  lines = time.split(":");
			tmp1 = Double.parseDouble(lines[1]) / 30.0;
			tmp2 = (Double.parseDouble(lines[0]) * 60.0 + Double.parseDouble(lines[1])) / 360.0;
			diff = (tmp1 > tmp2) ? tmp1 - tmp2 : tmp2 - tmp1;
		}

		return diff * 180.0;
	}
 
	private static int parseCnt() {
		int     cnt = 0;
		String  str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}
 
	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) stdin = tmp;
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll d, s, t; 
    cin >> d >> s >> t;
    if(d<=s*t){
        cout << "Yes" << "\n";
        return 0;
    }else{
        cout << "No" << "\n";
        return 0;
    }
    
}   

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
long long move(long long x,long long y)
{
   return (x-1+y-1);
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x,n, y=10e17,i=1;
    cin>>x;    //cout<<y<<endl;

    n=sqrt(x*1.0)+2;
    while(i<n)
    {
       if(x%i==0)
       {
         // cout<<i<<endl;
          y=min(move(i,x/i),y);
       }
       i++;
    }
    cout<<y<<endl;


    return 0;
}



Measured memory_bytes: 256
n,k = [int(x) for x in input().split()]

per = 0
for i in range(1,n+1):
    p = i
    t = 0
    
    while(p < k):
        t += 1
        p = p*2
#        print(i,p,t)
    
    if(t == 0):
        t = 0
#        print(i,p,t)

        
    per +=1/n * (1/2 ** t)
    
print("{:}".format(per))
    

Measured memory_bytes: 2940
l=gets.to_i
n=l.bit_length
es=[]
2.upto(n){|i|
  b=1<<(n-i)
  es.push([i-1,i,0])
  es.push([i-1,i,b])
  next if l&b==0
  es.push([1,i,l&~(b*2-1)])
}
puts "#{n} #{es.size}"
es.each{|r| puts r.join(' ') }

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

int getDigit(int n) {
    int digit = 0;
    while(n != 0) {
        n = n / 10;
        ++digit;
    }
    return digit;
}

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

    int digit = 0;
    int count = 0;
    for(int i = 1; i <= n; ++i) {
        digit = getDigit(i);
        if(digit % 2 != 0) {
            count++;
        };
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

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

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

            List<Integer> list = new ArrayList<>();
            while (N > 0) {
                if (N <= M) {
                    list.add(N);
                    break;
                }
                int dice = 0;
                for (int i = M; i >= 1; i--) {
                    if (S.charAt(N - i) == '0') {
                        dice = i;
                        break;
                    }
                }
                if (dice == 0) {
                    out.println(-1);
                    return;
                }
                list.add(dice);
                N -= dice;
            }
            Collections.reverse(list);
            String ret = list.stream().map(String::valueOf).collect(Collectors.joining(" "));
            out.println(ret);
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 36260
#include <stdio.h>

int main(void){
  int i;

  int n;
  scanf("%d", &n);

  int sum = 0;
  int a[n],b[n],c[n-1];
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i=0; i<n; i++){
    scanf("%d", &b[i]);
    sum += b[i];
  }
  for(i=0; i<n-1; i++){
    scanf("%d", &c[i]);
  }

  for(i=0; i<n-1; i++){
    if(a[i+1]-a[i] == 1){
      sum += c[a[i]-1];
    }
  }

   printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128