akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 100005;
ll fac[N], inv[N];
int n;

ll mod_pow(ll x, ll p){
	ll res = 1;
	while(p > 0){
		if(p&1)res = res * x % MOD;
		p>>=1;
		x = x * x % MOD;
	}
	return res;
}


inline ll mul(ll x, ll y){
	return x * y % MOD;
}

inline ll comb(int n, int k){
	assert(n >= 0);
	assert(k >= 0);
	if(n < k)return 0;
	return mul(mul(fac[n], inv[k]), inv[n-k]);
}

int main(){
	fast_io();
	fac[0] = inv[0] = 1;
	cu(i,1,N){
		fac[i] = mul(fac[i-1],i);
		inv[i] = mod_pow(fac[i], MOD - 2);
	}
	cin >> n;
	int pos[n+1] = {};
	int s = 0, e = 0;
	int x;
	fu(i,1,n+1){
		cin >> x;
		if(pos[x]){
			s = pos[x];
			e = i;
		}
		pos[x] = i;
	}
	whatis(s);
	whatis(e);
	fu(i,1,n+1){
		ll ans = (comb(n+1,i) - comb(n + 1 - e + s - 1,i-1) + MOD) % MOD;
		cout << ans << '\n';
	}
}


Measured memory_bytes: 3200
N, K = gets.split.map(&:to_i)

ans = 0
if K > 0
  ((K + 1)..N).each do |b|
    q, r = N.divmod(b)
    ans += (b - K) * q
    ans += [r - K + 1, 0].max
  end
else
  ans = N * N
end

puts ans


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

signed main()
{
    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
/**
 *      ABC 112 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-06 21:03:16
**/

#include <bits/stdc++.h>
#define int32 int_fast32_t
#define int64 int_fast64_t
using namespace std;

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

    if (N == 1){
        cout << "Hello World" << endl; return 0;
    }
    int A, B; cin >> A >> B;
    cout << A + B << endl; 
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n, t, a, h[1001], index=0, i, poor[1001], min;

	scanf("%d%d%d", &n, &t, &a);
	scanf("%d", h);
	
	poor[0] = 1000*a-1000*t+h[0]*6;
	if (poor[0] < 0) {
		poor[0] *= -1;
	}

	min = poor[0];
	
	for (i = 1; i < n; i++) {
		
		scanf("%d", h + i);
		poor[i] = 1000 * a - 1000 * t + h[i] * 6;

		if (poor[i] < 0) {
			poor[i] *= -1;
		}

		if (poor[i] < min) {
			index = i;
			min = poor[i];
		}
	}
	printf("%d", index+1);

	return 0;
}

Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Y = sc.nextInt();
		Y = Y / 1000;
		int tmp = Y - n;
		int x = 0;
		int y = 0;
		int z = 0;
		int sum = 0;
		for (int t = 0; t <= tmp / 9; t++) {
			x = t;
			y = (tmp - 9 * x) / 4;
			sum = 9 * x + 4 * y;
			if (sum == tmp) {
				z = n - x - y;
				if (z >= 0) {
					System.out.println(x + " " + y + " " + z);
					return;
				}

			}
		}
		System.out.println("-1 -1 -1");

	}
}


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

string table[1000];
int dp[1000][1000];

int main() {
  for(int N; cin >> N, N; ) {
    for(int i = 0; i < N; i++) cin >> table[i];
    for(int i = 0; i < N; i++)
      for(int j = 0; j < N; j++)
        dp[i][j] = 0;

    for(int i = 0; i < N; i++) if( table[i][0] == '.' ) dp[i][0] = 1;
    for(int j = 0; j < N; j++) if( table[0][j] == '.' ) dp[0][j] = 1;

    for(int i = 1; i < N; i++)
      for(int j = 1; j < N; j++)
        if( table[i][j] == '.' && table[i - 1][j] == '.' && table[i][j - 1] == '.')
          dp[i][j] = 1 + min( dp[i-1][j-1], min( dp[i][j-1], dp[i-1][j] ));
        else if( table[i][j] == '.' )
          dp[i][j] = 1;
        else
          dp[i][j] = 0;

    int best = 0;
    for(int i = 0; i < N; i++)
      for(int j = 0; j < N; j++)
        if( best < dp[i][j] )
          best = dp[i][j];
    cout << best << endl;

  }
}

Measured memory_bytes: 4756
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,d,e,f,ans;
bool check(int a,int b,int c){
	if((a+b+c)%2!=0)return 0;
	int now=(a+b+c)/2;
	d=now-a;e=now-b;f=now-c;
	if(d>=1&&e>=1&&f>=1)return 1;
	else return 0;
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);
	for(int i=1;i<=n;i++){
		int now=i*2;ans=0;
		for(int j=2;j<=150;j++)
		for(int k=2;k<=150;k++){
			if(now<=j*j+k*k)continue;
			int re=now-j*j-k*k;
			int s=sqrt(re);
			if(s*s==re){
				if(s<2)continue;
				if(check(j,k,s)){
//					printf("%d %d %d$$",j,k,s);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
using namespace std;
int main(void){
    long long int x,y;
    cin>>x>>y;
    long long int q=x;
    long int ans=0;
    while(1){
        if(x<=q&&q<=y){
            ans++;
            q*=2;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll n;

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

  cin >> n;
  ll arr[n + 5];
  for (ll i = 1; i < n; i++)
    cin >> arr[i];
  ll res[n + 5];

  ll ans = 0;
  arr[0] = inf;
  arr[n] = inf;
  for (ll i = 1; i <= n; i++)
    ans += min(arr[i - 1], arr[i]);

  cout << ans << en;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.printf("%d %d %f\n",
                          a / b,
                          a % b,
                          (double)a / b);
    }
}

Measured memory_bytes: 26412
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int c,d,e;
    c=a+b;d=a-b;e=a*b;
    if(c>d){
        if(c>e){printf("%d\n",c);}
        else{{printf("%d\n",e);}}
    }
    else{if(d>e){printf("%d\n",d);}
    else{printf("%d\n",e);}}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b, c;
	cin >> a >> b >> c;
	cout << 'A' << b[0] << 'C' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

class Maze {
public:
	map<char, char> next;
	map<char, char> prev;
	map<char, pair<int,int>> xy;

	Maze(vector<string> maze) : maze(maze), rest(-1) {
		next = { {'N','E'}, {'E','S'}, {'S','W'}, {'W','N'} };
		prev = { {'E','N'}, {'S','E'}, {'W','S'}, {'N','W'} };
		xy = { {'N', {0, -1}}, {'E', {1, 0}}, {'S', {0, 1}}, {'W', {-1, 0}} };
		H = maze.size();
		W = maze[0].size();
		rest = countPeople();
	}

	void move() {
		changeDirection();
		goAhead();
	}

	int countPeople() {
		if (0 <= rest) return rest;
		int count = 0;
		for (string str : maze) {
			for (char c : str) {
				count += isPerson(c);
			}
		}
		return count;
	}

private:
	vector<string> maze;
	int H, W;
	int rest;

	bool isPerson(char c) {
		return (isalpha(c) && c != 'X');
	}

	bool isPassable(char c) {
		return (c == '.' || c == 'X');
	}

	void changeDirection() {
		for (int i=0; i<H; ++i) {
			for (int j=0; j<W; ++j) {
				if ( ! isPerson(maze[i][j])) continue;
				char dir = next[maze[i][j]];
				for (int k=0; k<4; ++k) {
					int x = j + xy[dir].first;
					int y = i + xy[dir].second;
					if (maze[y][x] == '.' || maze[y][x] == 'X') {
						maze[i][j] = dir;
						break;
					}
					dir = prev[dir];
				}
			}
		}
	}

	void goAhead () {
		for (int i=0; i<H; ++i) {
			for (int j=0; j<W; ++j) {
				if ( ! isPassable(maze[i][j])) continue;
				char dir = 'E';
				for (int k=0; k<4; ++k) {
					int x = j + xy[dir].first;
					int y = i + xy[dir].second;
					if (0 <= x && x < W && 0 <= y && y < H && maze[y][x] == next[next[dir]]) {
						maze[y][x] = '*';
						if (maze[i][j] == '.') {
							maze[i][j] = tolower(next[next[dir]]);
						} else {
							rest --;
						}
						break;
					}
					dir = prev[dir];
				}
			}
		}
		for (int i=0; i<(int)maze.size(); ++i) {
			for (int j=0; j<(int)maze[i].size(); ++j) {
				if (maze[i][j] == '*') {
					maze[i][j] = '.';
				} else {
					maze[i][j] = toupper(maze[i][j]);
				}
			}
		}
	}
};

int main() {
	int W, H;
	while (cin >> W >> H && (W || H)) {
		vector<string> input(H);
		for (int i=0; i<H; ++i) cin >> input[i];

		Maze maze(input);

		if (maze.countPeople() == 0) {
			cout << 0 << endl;
			continue;
		}

		int second = 0;
		while (0 < maze.countPeople() && second <= 180) {
			maze.move();
			second ++;
		}
		if (second <= 180) cout << second << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2010;
const int INF = 1e9 + 7;
int N;
int a[MC];
int dp[MC][MC];
int x[MC],y[MC];

int main(){
	cin >> N >> a[0] >> a[1];
	repp(i,2,N+2) cin >> a[i];
	fill(x,x+MC,0);
	fill(y,y+MC,INF);
	repp(i,2,N+1){
		dp[N+1][i] = abs(a[N+1]-a[i]);
		dp[i][N+1] = abs(a[N+1]-a[i]);
		x[i] = max(x[i],dp[N+1][i]);
		y[i] = min(y[i],dp[i][N+1]);
	}
	dp[N+1][1] = abs(a[N+1]-a[1]);
	x[1] = max(x[1],dp[N+1][1]);
	dp[0][N+1] = abs(a[N+1]-a[0]);
	y[0] = min(y[0],dp[0][N+1]);
	repm(i,N,-1){
		repm(j,N,-1){
			if(i==j || i == 1 || j == 0) continue;
			if(i>j){
				dp[i][j] = y[i];
				x[j] = max(x[j],dp[i][j]);
			} else {
				dp[i][j] = x[j];
				y[i] = min(y[i],dp[i][j]);
			}
		}
	}
	cout << dp[0][1] << endl;
	return 0;
}


Measured memory_bytes: 16000
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  putStrLn . concat . replicate k $ "ACL"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a * n) << endl;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
	int n, m, X;
	cin >> n >> m >> X;
	vector<int> cost(n);
	vector<vector<int> > impr(n, vector<int>(m));
	for(int i=0;i<n;++i){
		cin >> cost[i];
		for(int j=0;j<m;++j)
			cin >> impr[i][j];
	}
	int mincost = ~(1<<31), lim = 1<<n;
	for(int i=0;i<lim;++i) {
		vector<int> sum(m);
		int tc=0;
		for(int j=0;j<n;++j) if((i>>j)&1)
		{
			tc+=cost[j];
			for(int k=0;k<m;++k) sum[k]+=impr[j][k];
		}
//		printf("i=%d\n", i);
//		for(auto&x:sum) printf("%d, ", x);
//		printf("\n tc=%d\n", tc);
		if(tc>=mincost) continue;
		int k=0;
		for(;k<m;++k) if(sum[k]<X) break;
		if(k<m) continue;
		mincost = tc;
	}
	cout << (mincost==(~(1<<31))?-1:mincost) << endl;
	return 0;
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    W, H, x, y = readnums()
    ans = W * H / 2
    if x == W / 2 and y == H / 2:
        print(ans, 1)
    else:
        print(ans, 0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    int a_cnt = 0,b_cnt = 0,c_cnt = 0;
    int ans = 0;
    rep(i,n){
        int find = 0;
        rep(j,s[i].size()){
            if(j==0&&s[i][j]=='B'){
                b_cnt++;find++;
            }
            if(j==s[i].size()-1&&s[i][j]=='A'){
                a_cnt++;find++;
            }
            if(j < s[i].size()-1){
                if(s[i][j]=='A' && s[i][j+1]=='B')ans++;
            }
        }
        if(find==2)c_cnt++;
    }
    ans += min(a_cnt,b_cnt);
    if(a_cnt==b_cnt && b_cnt==c_cnt && c_cnt==a_cnt && c_cnt!=0)ans--;
    cout << ans << endl;
}



Measured memory_bytes: 768
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}



Measured memory_bytes: 2692
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

A, B, C, K = map(int, input().split())

total = 0
if K >= A:
    total += 1 * A
    K -= A
    if K >= B:
        total += 0 * B
        K -= B
        if K >= C:
            total += (-1) * C
        else:
            total += (-1) * K
    else:
        pass

else:
    total = K * 1

print(total)




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

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

  ll N; cin >> N;
  ll Q; cin >> Q;
  queue<pair<string, ll>> que1, que2;
  ll t = 0;

  for (ll i = 0; i < N; i++) {
    string s; ll q;
    cin >> s >> q;
    que1.emplace(make_pair(s, q));
  }

  while (!que1.empty()) {
    pair<string, ll> p = que1.front(); que1.pop();
    if (p.second <= Q) {
      t += p.second;
      que2.emplace(p.first, t);
    } else {
      t += Q;
      que1.emplace(p.first, p.second - Q);
    }
  }
  for (ll i = 0; i < N; i++) {
    pair<string, ll> p = que2.front(); que2.pop();
    cout << p.first << " " << p.second << '\n';
  }
  return 0;
}


Measured memory_bytes: 6252
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


void solve1(double a, double b, double x) {
  double ng = 0, ok = 90;
  rep (_, 100) {
    double mid = (ng + ok) / 2;
    double theta = mid * pi / 180;
    if ((2*b - a*tan(theta)) / 2. <= x) {
      ok = mid;
    }
    else {
      ng = mid;
    }
  }
  Sp(ok);
}

void solve2(double a, double b, double x) {
  double ng = 0, ok = 90;
  rep (_, 100) {
    double mid = (ng + ok) / 2;
    double theta = mid * pi / 180;
    if (b*b / (2 * tan(theta)) <= a*x) {
      ok = mid;
    }
    else {
      ng = mid;
    }
  }
  Sp(ok);
}

signed main() {
  fio();
  double a, b, x;
  cin >> a >> b >> x;
  x = x / (a*a);
  if (x >= b / 2) {
    solve1(a, b, x);
  }
  else {
    solve2(a, b, x);
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 142
int main(){

    int n;
    cin >> n;
    cout << setprecision(20) << 1. * ((n + 1) / 2) / n << endl;
    
}

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

int main()
{
    int l, r, d;
    int res = 0;
    cin >> l >> r >> d;
    rep2(i, l, r+1) {
        if (i % d == 0) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N; //1-3
    int M; //0-5
    int s[5]; //1-N
    int c[5]; //0-9
    int result = 0;
    int flag_100=0;
    int flag_10 =0;
    int flag_1  =0;
    
    cin >> N >> M;
    
    //条件がないなら
    //1桁⇒0を出力
    //2桁⇒10を出力
    //3桁⇒100を出力
    if(M == 0)
    {
        if(N == 1) cout << 0;
        if(N == 2) cout << 10;
        if(N == 3) cout << 100;
        return 0;
    }
    
    for(int i=0; i<M; i++)
    {
        cin >> s[i] >> c[i];
    }

    //チェック方法
    //Nが2以上のとき、先頭桁が0はNG
    if(N>1)
    {
        for(int i=0; i<M; i++)
        {
            if(s[i] == 1 && c[i] == 0)
            {
                //debug
                //cout << "ng_1" << endl;
                
                cout << -1;
                return 0;
            }
        }
    }
    
    //s[]が同じでc[]が異なるものがあるとNG
    for(int i=0; i<M; i++)
    {
        for(int j=i+1; j<M; j++)
        {
            if( s[i] == s[j] && c[i] != c[j] )
            {
                //debug
                //cout << "ng_2" << endl;
                //cout << "i:" << i  << " " << "j:" << j << endl;
                
                cout << -1;
                return 0;
            }
        }
    }
    
    //作成可能なので、整数を作る
    //指定の桁を作り、指定がない場合は0を入れる
    if(N == 1)
    {
        //1桁であれば、条件の整数（不一致していないので、どれでもOK）
        result = c[0];
    }
    else if(N == 2)
    {
        //2桁
        for(int i=0; i<M; i++)
        {
            //10の位
            if( s[i] == 1 && flag_10 == 0)
            {
                result += 10*c[i];
                flag_10 = 1;
            }
            
            //1の位
            if( s[i] == 2 && flag_1 == 0)
            {
                result += c[i];
                flag_1 = 1;
            }
        }
        
        //10の位に指定がない場合
        //桁数を合わせるために10を加える
        if( flag_10 == 0) result += 10;
    }
    else
    {
        //3桁
        for(int i=0; i<M; i++)
        {
            //100の位
            if( s[i] == 1 && flag_100 == 0)
            {
                result += 100*c[i];
                flag_100 = 1;
            }
            
            //10の位
            if( s[i] == 2 && flag_10 == 0)
            {
                result += 10*c[i];
                flag_10 = 1;
            }
            
            //1の位
            if( s[i] == 3 && flag_1 == 0)
            {
                result += c[i];
                flag_1 = 1;
            }
        }
        
        //100の位に指定がない場合
        //桁数を合わせるために10を加える
        if( flag_100 == 0) result += 100;
    }
    
    cout << result;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n;
	cin >> n;
	vector<vector<pair<int,int>>> v(n); // {v, distance}
	REP(i,n-1){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--; // 0-based
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
	}
	
	queue<int> q;
	vector<int> cost(n,0);
	q.push(0);
	while(!q.empty()){
		int now = q.front();
		q.pop();
		
		for(auto x: v[now]){
			int child = x.first;
			if(cost[child]!=0) continue;
			cost[child] = cost[now]+x.second;
			q.push(child);
		}
	}
	
	cout << 0 << endl;
	FOR(i, 1, n){
		if(cost[i]%2){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
 	
	
	return 0;
}

Measured memory_bytes: 9496
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		for(long h=1;h<=3500;h++) {
			for(long n=1;n<=3500;n++) {
				if(4*h*n-N*n-N*h!=0 && (N*h*n)/(4*h*n-N*n-N*h)>0 && (N*h*n)%(4*h*n-N*n-N*h)==0) {
					System.out.println(h+" "+n+" "+(N*h*n)/(4*h*n-N*n-N*h));
					return;
				}
			}
		}
	}
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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


int main() {

  int N;
  cin >> N;
  map<char, ll> S;
  REP(i, N){
    char s; cin >> s;
    S[s]++;
  }

  if(S.size()==3){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
  

 
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3600
def inputs():
    return [int(s) for s in input().split()]


def main():
    M1, _ = inputs()
    M2, _ = inputs()

    if (M1 + 1) % 12 == M2 % 12:
        return 1
    else:
        return 0


if __name__ == '__main__':
    print(main())



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 1000000007
int main(void)
{
  int n,k;
  cin >> n >> k;
  ll c = 0;
  ll m=0,M=0;
  for(int i=0;i<n+1;i++)
  {
    m += i%MAX;
    M += (n-i)%MAX;
    if(i>=k-1) c += (M-m+1)%MAX;
    c = c%MAX;
  }
  cout << c << endl;
  return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
int H, W;
bool Grid[55][55];
int path[55][55];

void init()
{
  for (int i = 0; i < 55; i++)
  {
    for (int j = 0; j < 55; j++)
    {
      path[i][j] = INF;
    }
  }
}

int main()
{
  int cnt = 0;
  cin >> H >> W;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      Grid[i][j] = (c == '.');
      if (c == '#')
        cnt++;
    }
  }
  init();
  queue<pair<int, int>> Q;
  Q.emplace(0, 0);
  path[0][0] = 1;
  int dh[] = {1, 0, 0, -1};
  int dw[] = {0, -1, 1, 0};
  while (Q.size())
  {
    auto p = Q.front();
    Q.pop();
    for (int i = 0; i < 4; i++)
    {
      int nexth = p.first + dh[i], nextw = p.second + dw[i];
      if (nexth < 0 || nexth >= H || nextw < 0 || nextw >= W)
      {
        continue;
      }
      if (Grid[nexth][nextw] && path[nexth][nextw] > path[p.first][p.second] + 1)
      {
        path[nexth][nextw] = path[p.first][p.second] + 1;
        Q.emplace(nexth, nextw);
      }
    }
  }
  if (path[H - 1][W - 1] == INF)
  {
    cout << -1 << endl;
  }
  else
  {
    int ans = H * W - path[H - 1][W - 1] - cnt;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3616
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong(), M = sc.nextLong();
		List<Long> l = new ArrayList<>(), r = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			l.add(sc.nextLong());
			r.add(sc.nextLong());
		}
		Collections.sort(l);
		Collections.sort(r);
		
		Long left = l.get(l.size()-1);
		Long right = r.get(0);
		
		Long ans = right-left+1;
		if(right >= left)System.out.println(ans);
		else System.out.println(0);
		
	}
}

Measured memory_bytes: 87972
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	ll W,H; cin >> W >> H;
	vector<ll> p(W), q(H);
	rep(i,W) cin >> p[i];
	rep(i,H) cin >> q[i];

	vector<pll> A(W+H);
	rep(i,W) A[i] = make_pair(p[i],1);
	rep(i,H) A[W+i] = make_pair(q[i],0);
	sort(all(A));

	ll ans = 0;
	ll K = W+1, L = H+1;
	rep(i,W+H) {
		if (A[i].second) {
			ans += A[i].first*L;
			K--;
		} else {
			ans += A[i].first*K;
			L--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[200][200];
int h , w;
int main()
{

	cin >> h >> w;
	int n;
	cin >> n;
	int b[n + 1];
	for(int i = 1 ; i <= n ; i++)
	{
			cin >> b[i];
	}
	int num = 1,cnt = 1,x=1;
	for(int i = 1 ; i <= h ; i++){
		if(x % 2 == 1)
		{
			for(int j = 1 ; j <= w ; j++)
			{
					
					if(cnt > b[num]){
						num++;
						cnt=1;
					}
				    a[i][j] = num;
					cnt++;
			}
		}
		else
		{
			for(int j = w ; j >= 1 ; j--)
			{
					
					if(cnt > b[num]){
						num++;
						cnt=1;
					}
					a[i][j] = num;
					cnt++;
			}
		}
		//cout << endl;
		x++;
	}
	for(int i = 1 ; i <= h ; i++){
		for(int j = 1; j <= w ; j++)
			cout << a[i][j] << " ";
		cout << endl;
	}
	return 0;
} 




Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int a, b, q;
  cin >> a >> b >> q;
  vecll s(a), t(b), x(q);
  REPe(e, s) cin >> e;
  REPe(e, t) cin >> e;
  REPe(e, x) cin >> e;
  vecll ans;
  auto dist = [&](ll x, ll i, ll j) -> ll {
    if ((x - i) * (x - j) > 0) {
      return max(abs(x - i), abs(x - j));
    } else {
      return abs(i - j) + min(abs(x - i), abs(x - j));
    }
  };
  REPe(e, x) {
    auto itrs1 = lower_bound(all(s), e);
    auto itrs2 = itrs1 - 1;
    if (e <= s.front()) {
      itrs1 = itrs2 = s.begin();
    } else if (s.back() <= e) {
      itrs1 = itrs2 = s.end() - 1;
    } else if (*itrs1 == e) {
      itrs2 = itrs1;
    }
    auto itrt1 = lower_bound(all(t), e);
    auto itrt2 = itrt1 - 1;
    if (e <= t.front()) {
      itrt1 = itrt2 = t.begin();
    } else if (t.back() <= e) {
      itrt1 = itrt2 = t.end() - 1;
    } else if (*itrt1 == e) {
      itrt2 = itrt1;
    }
    // cout << *itrs2 << " " << *itrs1 << " " << *itrt2 << " " << *itrt1 << endl;
    ans.push_back(min({dist(e, *itrs1, *itrt1), dist(e, *itrs2, *itrt2),
                       dist(e, *itrs1, *itrt2), dist(e, *itrs2, *itrt1)}));
    // ans.push_back(
    //     min({abs(max(*itrs1, *itrt1) - e), abs(min(*itrs2, *itrt2) - e),
    //          abs(*itrs1 - *itrt2) + abs(min(*itrt2 - e, *itrs1 - e)),
    //          abs(*itrt1 - *itrs2) + abs(min(*itrs2 - e, *itrt1 - e))}));
  }
  REPe(e, ans) cout << e << endl;
}
//////////////////////////////////////////////


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

int main() {
    char s,ans;
    cin>>s;
    if (s=='A') ans='T';
    else if(s=='C') ans='G';
    else if(s=='G') ans='C';
    else ans='A';
    cout<<ans<<endl;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n ;
	string s;
	cin >> n >> s;
	int num[26];
	rep(i,26) num[i] = 0;
	rep(i,26){
		char c = 'a' + i ;
		rep(j,s.size()){
			if(s[j] == c){
				num[i] ++;
			}
		}
	}

	ll ans = 1;
	rep(i,26){
		if(num[i] != 0){
			ans *= num[i]+1 ;
			ans %= mod;
		}
	}
	ans --;
	cout << ans << endl;
}


Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b = LI()
    if 1 <= a <= 9 and 1 <= b <= 9:
        print(a*b)
    else:
        print(-1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in(c);
  if(c == 1)
    out("Hello World");
  else{
    in2(a, b);
    out(a + b);
  }
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstring>

#define INF (1<<28)

using namespace std;

int n, m;
stack<int> p[3];

#define AB 1
#define BC 3

int move(int from, int to, int prev) {
    int c = p[from].top();
    p[to].push(c);
    p[from].pop();
    if (p[1].top() == 0 && (p[0].top() == 0 || p[2].top() == 0)) return 1;
    if (prev == BC) {
        if (p[0].top() > p[1].top()) return move(0, 1, AB) + 1;
        else if (p[0].top() < p[1].top()) return move(1, 0, AB) + 1;
        return INF;
    } else if (prev == AB) {
        if (p[1].top() > p[2].top()) return move(1, 2, BC) + 1;
        else if (p[1].top() < p[2].top()) return move(2, 1, BC) + 1;
        return INF;
    }
}

int solve() {
    if (p[1].top() == 0 && (p[0].top() == 0 || p[2].top() == 0)) return 0;
    int ans = INF;
    stack<int> backup[3];
    for (int i = 0; i < 3; i++) backup[i] = p[i];

    if (p[0].top() > p[1].top()) {
        ans = min(ans, move(0, 1, AB));
        for (int i = 0; i < 3; i++) p[i] = backup[i];
    } else {
        ans = min(ans, move(1, 0, AB));
        for (int i = 0; i < 3; i++) p[i] = backup[i];
    }
    if (p[1].top() > p[2].top()) {
        ans = min(ans, move(1, 2, BC));
        for (int i = 0; i < 3; i++) p[i] = backup[i];
    } else {
        ans = min(ans, move(2, 1, BC));
        for (int i = 0; i < 3; i++) p[i] = backup[i];
    }
    return ans;
}

int main() {
    while (cin >> n >> m, n || m) {
        for (int i = 0; i < 3; i++) {
            p[i] = stack<int>();
            p[i].push(0);
            int s; cin >> s;
            for (int j = 0; j < s; j++) {
                int c; cin >> c;
                p[i].push(c);
            }
        }
        int step = solve();
        cout << (step > m ? -1 : step) << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	if (x == W / 2.0 && y == H / 2.0) {
		cout << W * H / 2.0 << " " << 1 << endl;
	}
	else {
		cout << W * H / 2.0 << " " << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template<int Mod> struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll sig) { int sigt = sig % Mod; if(sigt < 0) sigt += Mod; x = sigt; }
    int get() const { return (int)x; }

    ModInt &operator+=(ModInt that) { if((x += that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator-=(ModInt that) { if((x += Mod - that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % Mod; return *this; }

    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<MOD> mint;

int main(void)
{
    ll N,M;
    cin >> N >> M;
    auto f = [](ll n){
        mint x(1);
        for (ll i = 1; i <= n; i++)
        {
            x *= mint(i);
        }
        return x;
    };
    if(N == M){
        auto ans = mint(2) * f(N) * f(M);
        pr(ans.x);
    }else if(abs(N-M) == 1){
        auto ans = f(N) * f(M);
        pr(ans.x);
    }else{
        pr(0);
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
bool prime(int n);

int main(){
    ll x=1,g=0,n,k,m,l,ans=1,ptr=0;
    string s,s1,s2;
    cin >> s >> k;
    
        for(int i=0;i<s.size();i++){
            //cout << k <<endl;
            //cout << " aaa = "<<'z'-s[i] <<endl;
            while(k!=0 && s[i]!='a'){
                if(k < ('z'-s[i]+1)){
                    i++;
                    if(i>=s.size()){
                        break;
                    }
                    continue;
                }
                if(s[i]=='z')
                    s[i]='a';
                else
                    s[i]+=1;
                k--;
            }
        }
    k%=26;
    while(k>0){
        s[s.size()-1]+=1;
        k--;
    }

    cout << s <<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>

int main(){
	long int a, b, r;
	
	while(std::cin >> a >> b){
		long int product = a*b;
		
		// GCD
		if(a < b){
			long int temp = a;
			a = b;
			b = temp;
		}
		while((r = a%b) != 0){
			a = b;
			b = r;
		}
		
		// LCM
		long int lcm = product / b;
		
		// show
		std::cout << b << ' ' << lcm << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll k; cin>>k;
  if(k%2==0){
    out(-1); return;
  }
  ll n=7;
  rep(i,k+1){
    n%=k;
    if(n==0){
      out(i+1); return;
    }
    n=n*10+7;
  }
  out(-1);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var Nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = Nx[0];
            var x = Nx[1];
            var aList = Console.ReadLine().Split(' ').Select(int.Parse);

            var nokori = x;
            var output = 0;
            foreach (var a in aList.OrderBy(a => a))
            {
                nokori -= a;

                if (nokori >= 0)
                {
                    output++;
                }

                if (nokori <= 0)
                {
                    break;
                }
            }

            if (nokori > 0)
            {
                output--;
            }

            Console.WriteLine(output);
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())
d = list(map(int, input().split()))

ans = 0
for i in range(len(d)):
  x = d[i]
  for j in range(i+1, len(d)):
    y = d[j]
    ans += x * y

print(ans)


Measured memory_bytes: 3060