akhauriyash/Code-Regression huggingface dataset:
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int ans=0;
		int[][] a=new int[n][];
		int[][] b=new int[n][];
		for(int i=0;i<n;i++){a[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}
		for(int i=0;i<n;i++){b[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}
		Array.Sort(a,ca1);
		Array.Sort(b,ca2);
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(b[i][0]>a[j][0]&&b[i][1]>a[j][1]){
					a[j][0]=int.MaxValue;
					ans++;
					break;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
	static int ca1(int[] a,int[] b){
		if(a[1]<b[1]){return 1;}
		else if(a[1]>b[1]){return -1;}
		else if(a[0]<b[0]){return 1;}
		else if(a[0]>b[0]){return -1;}
		else{return 0;}
	}
	static int ca2(int[] a,int[] b){
		if(a[0]>b[0]){return 1;}
		else if(a[0]<b[0]){return -1;}
		else if(a[1]>b[1]){return 1;}
		else if(a[1]<b[1]){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 13396
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// alice-and-brown.rs --- Alice&Brown
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[allow(dead_code)]
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")
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let (x, y) = get!(u64, u64);
    let ans = 1 < (x as i64 - y as i64).abs();
    with_bufwriter(|mut out| writeln!(out, "{}", if ans { "Alice" } else { "Brown" }).unwrap());
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int B[102][102], C, xg, yg;

bool rec(int x, int y) {
  if (B[x][y] != C)
    return false;
  if (x == xg && y == yg)
    return true;
  B[x][y] = 0;
  if (rec(x+1, y) || rec(x-1, y) || rec(x, y+1) || rec(x, y-1))
    return true;
  return false;
}

int main() {
  for (;;) {
    int w, h;
    cin >> w >> h;
    if (!w && !h) return 0;
    for (int x = 0; x < w+2; x++)
      for (int y = 0; y < h+2; y++)
        B[x][y] = 0;
    int xs, ys, n;
    cin >> xs >> ys >> xg >> yg >> n;
    for (int i = 0; i < n; i++) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 4; k++)
          (d ? B[x+j][y+k] : B[x+k][y+j]) = c;
    }
    if (!B[xs][ys]) {
      cout << "NG" << endl;
      continue;
    }
    C = B[xs][ys];
    cout << (rec(xs, ys) ? "OK" : "NG") << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
int a[M];
int sum[M];
int main(int argc, char const *argv[])
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sum[0]=0;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	double ans=0;

	for(int i=1;i+k-1<=n;i++){
		int j=i+k-1;
		int tt=sum[j]-sum[i-1]-k+1;
		double tmp=(double)(tt+k-1)*(tt+k)/2-(double)k*(k-1)/2;
		ans=max(ans,tmp/tt);
	}
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n);

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

	LL cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 0)cnt++;
	}

	LL sum = 0;
	LL mi = INF2;
	for (int i = 0; i < n; i++) {
		LL tmp = abs(a[i]);
		sum += tmp;

		mi = min(mi, tmp);
	}

	if (cnt % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * mi << endl;
	}

	
	return 0;
}

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

int main() {
  int N, M, num;
  long long int ans = 0;
  cin >> N >> M;
  priority_queue<int> A;
  for(int i = 0; i < N; i++) {
    cin >> num;
    A.push(num);
  }
  for(int i = 0; i < M; i++) {
    A.push(A.top() / 2);
    A.pop();
  }
  for(int i = 0; i < N; i++) {
    ans += A.top();
    A.pop();
  }
  cout << ans << endl;
}

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long long int ll;

#define endl '\n'
#define SZ(x) (int)(x.size())
#define ALL(x) x.begin(), x.end()
#define FOR(i, n) for(int i=0;i<n;i++)

int main()  {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    double t;
    cin >> t;
    t = pow(t/3 ,3);
    printf("%.6lf\n", t);
    return 0;
}


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

int main()
{
    int n,y,ans; cin>>n>>y;
    int a=-1,b=-1,c=-1;
    
    for(int i=0;i<=n;++i){
        for(int j=0;j<=n;++j){
            if(n-i-j>=0 && 10000*i + 5000*j + 1000*(n-i-j) ==y){
                a=i,b=j,c=n-i-j;
            break;
            }
        }
    }
	cout<<a<<" "<<b<<" "<<c<<endl;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555555555555555555555545555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
import java.awt.geom.*;
import java.util.*;

public class Main {
	final double EPS = 1.0e-08;
	Point2D [] plist;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			plist = new Point2D[n];
			for(int i=0; i < n; i++){
				double x = sc.nextDouble(), y = sc.nextDouble();
				plist[i] = new Point2D.Double(x, y);
			}
			int ans = 1;
			for(int i=0; i < n; i++){
				for(int j=i+1; j < n; j++){					
					Point2D [] cpList = centerPoint(plist[i], plist[j]);
					if(cpList == null) continue;
					int res1 = distanceWithin1Radius(cpList[0]);
					int res2 = distanceWithin1Radius(cpList[1]);
					ans = Math.max(ans, Math.max(res1, res2));
				}
			}
			System.out.println(ans);
		}
	}

	private Point2D[] centerPoint(Point2D p1, Point2D p2) {
		double r = 1.0;
		double midx = (p1.getX() + p2.getX()) / 2.0;
		double midy = (p1.getY() + p2.getY()) / 2.0;
		Point2D midP = new Point2D.Double(midx, midy);
		Point2D p2p1 = sub(p2,p1);
		Point2D normalV1 = normalVector1(p2p1);
		Point2D normalV2 = normalVector2(p2p1);
		double halfdis = p1.distance(p2) / 2.0;
		if(halfdis > r + EPS) return null;
		double tocenterDis = Math.sqrt(r - halfdis * halfdis);
		Point2D [] res = new Point2D[2];
		res[0] = add(mul(normalV1, tocenterDis / norm(normalV1)), midP);
		res[1] = add(mul(normalV2, tocenterDis / norm(normalV1)), midP);
		return res;
	}
	private Point2D add(Point2D p1, Point2D p2) {
		double x = p2.getX() + p1.getX();
		double y = p2.getY() + p1.getY();
		return new Point2D.Double(x, y);
	}
	
	private Point2D sub(Point2D p2, Point2D p1) {
		double x = p2.getX() - p1.getX();
		double y = p2.getY() - p1.getY();
		return new Point2D.Double(x, y);
	}
	
	private Point2D mul(Point2D p,double value) {
		return new Point2D.Double(p.getX() * value, p.getY() * value);
	}
	
	private double norm(Point2D p){
		return Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
	}
	
	private Point2D normalVector1(Point2D p) {
		return new Point2D.Double(-p.getY(), p.getX());
	}
	
	private Point2D normalVector2(Point2D p) {
		return new Point2D.Double(p.getY(), -p.getX());
	}

	private int distanceWithin1Radius(Point2D p) {
		int count = 0;
		for(int i=0; i < plist.length;i++){
			double res = p.distance(plist[i]);
			if(res<= 1.0 + EPS) count++;
		}
		return count;
	}

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

Measured memory_bytes: 13000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int n;
   cin >> n;
   out(n*n*n);
}

Measured memory_bytes: 384
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def Yes(x):print("Yes")if x==True else print("No")
t=[i for i in input()]
n=len(t)
for i in range(n):
    if t[i]=="?":
        t[i]="D"
print("".join(t))

Measured memory_bytes: 10880
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;


int main(){
	string str;
	
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
	cin>>str;
		string x="  ";
	
if(str[0]=='>'){
	for(int j=0;j<2;j++)
		x[j]=str[j];
	
	if(str[1]=='\''&&str[str.size()-1]=='~'){
		bool f=true;int C=0;
		int mid=(2+str.size()-2)/2;
		for(int j=2;j<=str.size()-2;j++)
		{if(j!=mid&&str[j]!='='){f=false;}
		else if(j==mid&&str[j]!='#')f=false;
		if(str[j]=='=')C++;
		}
		if(C%2!=0||C==0)f=false;
		
		if(f==true)cout<<"A"<<endl;
		else cout<<"NA"<<endl;
	}

	else if(str[1]=='^'&&str[str.size()-1]=='~'&&str[str.size()-2]=='~'){
		bool f=true;int C=0;
		
		for(int j=2;j<str.size()-2;j++)
		{
			C++;
			if(C%2==0&&str[j]!='=')f=false;
			if(C%2==1&&str[j]!='Q')f=false;

		}
	
		if(C%2!=0||C==0)f=false;
		
		if(f==true)cout<<"B"<<endl;
		else cout<<"NA"<<endl;
	
	
	}
	else cout<<"NA"<<endl;

	}
	else cout<<"NA"<<endl;


	}
	return 0;
}

Measured memory_bytes: 1208
/*
 *	Argorithms and Data Structures
 *	Lectuire 5 
 *	Exhaustive Search
 */

#include <stdio.h>

#define N 20
#define Q 200
#define TRUE 1
#define FALSE 0

int A[N], M[Q];
int n, q;

int solve(int i, int m){
	if( i == n )
		return !m;
	 
	return ( solve(i+1, m) || solve(i+1, m-A[i]) );
}

int main(void){
	int i;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}

	scanf("%d", &q);
	for(i=0; i<q; i++){
		scanf("%d", &M[i]);
	}

	for(i=0; i<q; i++){
		if( solve(0, M[i]) == TRUE)
			printf("yes\n");
		else
			printf("no\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static bool  cmp(string s1, string s2){
     return (s1 + s2) < (s2 + s1)? true : false;
}
int main(){
	int n,m,count=0,i,j;
	cin>>n>>m;
	string s[101];

	for( i=0;i<n;i++){
		cin>>s[i];
		count++;
	}
	sort(s,s+count,cmp);
	for(i=0;i<n;i++){
		cout<<s[i];
	}
	cout<<endl; 
	return 0;
}  

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long max1 = 0;
    long max2 = 0;
    long[] a = new long[n];
    for(int i = 0; i<n; i++){
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    for(int i = n-1; i>0; i--){
      if(a[i-1] == a[i]){
        max1 = a[i];
        for(int j = i-2; j > 0; j--){
          if(a[j-1] == a[j]){
            max2 = a[j];
            System.out.println(max1*max2);
            return;
          }
          if(j ==1){
            System.out.println(0);
            return;
          }
        }
      }
    }
    System.out.println(0);
  }
}


Measured memory_bytes: 59052
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

arrs = set([int(input()) for _ in range(M)])
anss = [0, 1]
for i in range(1, N+1):
  if i in arrs:
    anss.append(0)
  else:
    anss.append((anss[-2] + anss[-1]) % MOD)
print(anss[-1] % MOD)

Measured memory_bytes: 13192
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define inv (mod+1)/3
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
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);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return(a.second<=b.second);}

//https://www.youtube.com/watch?v=k4V3Mo61fJM

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll n, t, a, ans = -1;
    cin >> n >> t >> a;
    double best_temp_diff = 100000;
    for (ll i = 0; i < n; i++)
    {
        ll h;
        double temp_diff;
        cin >> h;
        temp_diff = abs(t - h * 0.006 - a);
        if (temp_diff < best_temp_diff) {
            best_temp_diff = temp_diff;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    cin>>a[0]>>a[1];
    int dp[n];
    int mn;
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        cin>>a[i];
        mn=dp[i-1]+abs(a[i]-a[i-1]);
        for(int j=2;j<=k && j<=i;j++)
        {
            if(mn>dp[i-j]+abs(a[i]-a[i-j])) mn=dp[i-j]+abs(a[i]-a[i-j]);
        }
        dp[i]=mn;
    }
    cout<<dp[n-1];
    return 0;
}


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

int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      sum += X;
    } else {
      sum += Y;
    }
  }
  cout << sum << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int gcd(int a, int b)
{
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

int main() {

	int x;

	cin >> x;

	cout << lcm(x, 360) / x << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  
  long double eps = 1.0E-14;
  
  if ( sqrt(a) + sqrt(b) + eps < sqrt(c)) {
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl; 
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
req = [list(map(int, input().split())) for i in range(M)]
req.sort()
ans = 0
left = 0
right = 0
for i in range(M):
    if req[i][0] >= right:
        ans += 1
        left, right = req[i][0], req[i][1]
    else:
        left = req[i][0]
        right = min(req[i][1], right)
 
print(ans)

Measured memory_bytes: 27876
import heapq
def main():
    N, M, S = map(int, input().split())
    money_max = 50*N
    S = min(S, money_max)
    dp = [[float("inf")]*(money_max+1) for _ in range(N)]
    dp[0][S] = 0
    G = [[] for _ in range(N)]
    exchange = [None]*N
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G[u].append([v, a, b])
        G[v].append([u, a, b])
    for i in range(N):
        c, d = map(int, input().split())
        exchange[i] = [c, d]
    q = []
    heapq.heapify(q)
    heapq.heappush(q, [0, 0, S])
    while 0 < len(q):
        pre_time, idx, s = heapq.heappop(q)
        if dp[idx][s] < pre_time:
            continue
        ex = min(s + exchange[idx][0], money_max)
        if dp[idx][s] + exchange[idx][1] < dp[idx][ex]:
            dp[idx][ex] = dp[idx][s] + exchange[idx][1]
            heapq.heappush(q, [dp[idx][ex], idx, ex])
        for to, money, time in G[idx]:
            if money <= s:
                if dp[idx][s] + time < dp[to][s-money]:
                    dp[to][s-money] = dp[idx][s] + time
                    heapq.heappush(q, [dp[to][s-money], to, s-money])
    for i in range(1, N):
        print(min(dp[i]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 26760
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    T, A = [None] * N, [None] * N
    used = [False] * N
    for i in range(N):
        a, b = map(int, input().split())
        T[i] = (a + b, a, i)
        A[i] = (a + b, b, i)
    T.sort(reverse = True)
    A.sort(reverse = True)
    hapiness = 0
    ti, ai = 0, 0
    for i in range(N):
        if i % 2 == 0:
            while used[T[ti][2]]: ti += 1
            hapiness += T[ti][1]
            used[T[ti][2]] = True
            ti += 1           
        else:
            while used[A[ai][2]]: ai += 1
            hapiness -= A[ai][1]
            used[A[ai][2]] = True
            ai += 1
    print(hapiness)
   
    return 0

if __name__ == "__main__":
    solve()

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


int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N);
    for(int i=0;i<N;i++){
        int num;
        cin >> num;
        for(int j=0;j<num;j++){
            int x, y;
            cin >> x >> y;
            A[i].push_back(100*y+x-1);
        }
    }
    int ans=0;
    for(int tmp;tmp<(1<<N);tmp++){
        int cnt=0;
        bitset<15> s(tmp);
        for(int i=0;i<N;i++){
            if(s.test(i)){
                for(int j=0;j<A[i].size();j++){
                    if(A[i][j]/100==1 && !s.test(A[i][j]%100)){
                        cnt=0;
                        goto OUT;
                    }
                    else if(A[i][j]/100==0 && s.test(A[i][j]%100)){
                        cnt=0;
                        goto OUT;
                    }
                }
                cnt++;
            }
        }
        OUT:
        ans=max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

a,b,x = map(int,input().split())


Vc = a*a*b/2



if x > Vc:
    theta = math.atan(2/a**3 *(a**2 * b - x))

    
else:
    theta = math.atan((a * b**2)/(2*x))

    
    
print(math.degrees(theta))
    




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

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)


# 辺を取り除くのではなく、辺が無い状態から始めて辺を順にグラフに追加していくことを考える
# 最初は辺が無いので不便さは N * (N-1) / 2
# 辺 u <-> v を追加したとき、頂点 u, v が既に到達可能であるなら、不便さは変わらない
# そうでなければ、不便さは直前の値より size[u] * size[v] だけ小さくなる

N, M = map(int, input().split())
edges = []
for _ in range(M):
    u, v = map(int, input().split())
    # 0-index
    edges.append([u-1, v-1])


def root(v):
    if parents[v] < 0:
        return v
    parents[v] = root(parents[v])
    return parents[v]


def has_same_root(u, v):
    return root(u) == root(v)


# unite by size
def unite(u, v):
    u_root = root(u)
    v_root = root(v)
    if size(u_root) > size(v_root):
        u_root, v_root = v_root, u_root
    parents[u_root] -= size(v_root)
    parents[v_root] = u_root


def size(v):
    return -parents[root(v)]


# the parent node of a root node has the size of tree (negative value)
parents = [-1 for v in range(N)]

ans = []
current = N * (N-1) // 2
for i in range(M):
    u, v = edges[M-1-i]
    # print(f'current = {current}')
    # print(f'u = {u}, v = {v}')
    # print(f'parents = {parents}')
    ans.append(current)
    if has_same_root(u, v):
        # print('skip')
        continue
    # print(f'size(u) = {size(u)}, size(v) = {size(v)}')
    current -= size(u) * size(v)
    unite(u, v)
    # print(f'parents = {parents}\n')

for i in reversed(range(M)):
    print(ans[i])


Measured memory_bytes: 166412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//DがTを含んでいれば良い
//Tの要素が全てDにあれば良い
//Dの要素のうち、Tにあるもののみ、個数をメモする
int main() {
    long long K,A,B;
    cin >> K >> A >> B;
    //B-A >= ２なら出来るだけ交換する
    /*Aー1回叩いてA枚にし、A枚を１円に交換し１円をB枚に交換するので、
      最初の交換操作にA+1回の操作が必要
      一回の交換でB-A枚増える
    */
    /*2回目以降の交換操作は、2回の操作で1回交換できるので、
   　　(K-A-1)/2回交換できる
      (K-A-1)/%2 == 1なら(K-A-1)/2回の交換と1回叩く
    */
  long long ans = 0;
   if(B-A >= 2 && K >= A+1){
     ans = B;
     ans += ((K-A-1)/2 )*(B-A);
     if((K-A-1)%2 == 1) ans += 1;
   }
   else if(B-A >=2 && K <= A) ans = K+1;
   else{
       ans = K+1;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    if (X%Y == 0) {
      System.out.println(-1);
    } else {
      System.out.println((long)X*(Y+1));
    }
  }
}

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

#define ff       first
#define ss       second
#define vpop     pop_back
#define pb       push_back
#define mp       make_pair
#define ll       long long int
#define umap	 unordered_map
#define pii	 pair<int, int>
#define clz(x)   __builtin_clz(x)       
#define ctz(x)   __builtin_ctz(x)      
#define all(v)   v.begin(), v.end() 
#define sbts(x)  __builtin_popcount(x) 
#define ull      unsigned long long int
#define ms(a,v)  memset(a, v, sizeof(a))
#define ps(x, y) fixed << setprecision(y) << x
const int MOD  = 1e9 + 7;
const ll  INF  = 1e12;
const int   N  = 1e5 + 1;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);
//  *-------------------------------*
    int n, k; cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }    
    int dp[n + 1];
    dp[0] = 0; 
    for (int i = 1; i <= n; i++) {
        dp[i] = INT_MAX;
        for (int j = 1; j <= min(k, i); j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}



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

int main() {
  string s1;
  cin >> s1;

  int n = s1.size();
  string s2 = s1;
  reverse(s2.begin(), s2.end());
  if(s1 != s2){
    cout << "No" << endl;
    return 0;
  }
  
  s2 = s1.substr(0, (n - 1) / 2);
  string s3 = s2;
  reverse(s3.begin(), s3.end());
  if(s2 != s3){
    cout << "No" << endl;
    return 0;
  }

  s2 = s1.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);
  s3 = s2;
  reverse(s3.begin(), s3.end());
  if(s2 != s3){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

#define INF 1000000005
#define NMAX 20

int takeBook[NMAX]; // 0 -> nu iau cartea, 1 -> iau cartea
int answer = INF, n, m, x, cost[NMAX];
int levelup[NMAX][NMAX];

void verificare() {
    int costTotal = 0;
    int lvl[NMAX];
    for(int i = 1; i <= m; i++) {
        lvl[i] = 0;
    }
    for(int i = 1; i <= n; i++) {
        if(!takeBook[i])
            continue;
        costTotal += cost[i];   
        for(int j = 1; j <= m; j++) {
            lvl[j] = lvl[j] + levelup[i][j];
        }
    }
    for(int i = 1; i <= m; i++) {
        if(lvl[i] < x) {
            return ;
        }
    }
    answer = min(answer, costTotal);
}

void back(int poz) {
    if(poz == n + 1) {
        verificare();
        return ;
    }
    takeBook[poz] = 0;
    back(poz + 1);
    takeBook[poz] = 1;
    back(poz + 1);
}

int main () {
    
    scanf("%d%d%d", &n, &m, &x);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &cost[i]);
        for(int j = 1; j <= m; j++) {
            scanf("%d", &levelup[i][j]);
        }
    }
    
    back(1);
    
    if(answer == INF) {
        printf("-1\n");
    }
    else {
        printf("%d\n", answer);
    }
    
    return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int d,t,s;
	cin >> d >> t >> s;
	if(t >= (d + s - 1)/s){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//# define m 163577857
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)
const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}

signed main()
{
    gok
   //fact0();

  string s1,s2;
  cin>>s1>>s2;
  bool ch=true;
  for(int i=0;i<s1.size();i++)
  {
      if(s1[i]!=s2[i])
        ch=false;
  }
  if(ch)
    cout<<"Yes";
  else
    cout<<"No";























 return 0;
}


Measured memory_bytes: 3644
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(N):
    P[i] -= 1

ans = -10 ** 18
for si in range(N):
    x = si
    c = []
    tot = 0
    while True:
        x = P[x]
        c.append(C[x])
        tot += C[x]
        if x == si:
            break

    s = 0
    for k in range(len(c)):
        if k + 1 > K:
            break
        s += c[k]
        ss = s
        if tot > 0:
            ss += tot * int((K - (k + 1)) // len(c))
        ans = max(ss, ans)

print(ans)

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

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

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RLong;

            var a = new List<long>();

            while (n > 0)
            {
                long work = 0;
                work = n % 26;
                if (work == 0) work = 26;
                a.Add(work);

                n -= work;
                n /= 26;
            }
            string ans = "";
            a.Reverse();
            for (int i = 0; i < a.Count; i++)
            {
                char work = (char)('a' + a[i] - 1);
                ans += work;
            }
            WriteLine(ans);
        }
    }

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

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

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

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

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

Measured memory_bytes: 27828
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  string s,t;cin >> s >> t;
  for (int i = 0; i < 3; ++i)
  {
    if(s[i] != t[2-i]){
      cout << "NO" << endl;return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

int main() {
    ll d[2], k;
    cin >> d[0] >> d[1] >> k;

    int cnt = 0;
    rep(i, k) {
        int id = cnt % 2;
        if (d[id] % 2 == 1)
            --d[id];
        d[id] /= 2;
        d[1 - id] += d[id];
        ++cnt;
    }

    cout << d[0] << " " << d[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a > b) printf("Alice\n");
  else if(b > a) printf("Bob\n");
  else printf("Draw\n");
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import itertools
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())

ans = 0

for i in range(1, n+1):
    num = n // i
    last = num * i
    ans += int((i + last) * num / 2)

print(ans)

Measured memory_bytes: 67248
#include<stdio.h>

int Sort(int A[], int N) {
  int i, j, t, sr, ij;
  sr = 0;
  for (i = 0; i < N - 1; i++) {
    ij = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[ij])ij = j;
    }
    t = A[i]; A[i] = A[ij]; A[ij] = t;
    if (i != ij)sr++;
  }
  return sr;
}

int main() {
  int A[100], N, i, sr;

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  sr = Sort(A, N);

  for (i = 0; i < N; i++) {
    if (i > 0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n",sr);

  return 0;
}


Measured memory_bytes: 2084
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include <queue>
#include<cmath>
#define rep(i,n) for(int i(0);i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    int c = a * b;

    if(c%2==0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main() {
	int N, M;
	long long ans = 0;
	cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	vector<pair<int, int>> AB(N);

	for (int i = 0; i < N; i++) {
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(), AB.end());
	for (int i = 0; i < N; i++)
	{
		int buy = min(M, AB[i].second);
		ans += (long long)buy * AB[i].first;
		M -= buy;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int li[3];
  cin >> li[0] >> li[1] >> li[2];
  if(li[0]==li[1] && li[1]==li[2]){
    cout << 1;
  }else if(li[0]==li[1] || li[1]==li[2] || li[0]==li[2]){
    cout << 2;
  }else{
    cout << 3;
  }
}


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

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll > 
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884197169399375105;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x) % MOD, n/2);
	return (x*binaryExpo((x*x) % MOD, n/2)) % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/

void solve(void)
{
	int n, k;
	cin >> n >> k;
	ll a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];

	int ans = -1;
	for(int i = 1; i < n; i++)
	{
		if(a[i] + a[i - 1] >= k)
		{
			ans = i;
			break;
		}
	}

	if(ans == -1)
	{
		cout << "Impossible" << endl;
		return ;
	}

	cout << "Possible" << endl;
	for(int i = 1; i < ans; i++)
		cout << i << endl;

	for(int i = n - 1; i > ans; i--)
		cout << i << endl;

	cout << ans << endl;

	

}


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

	// int t;
	// cin >> t;
	// while(t--)
	{	
		solve();
	}




	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
signed main(){
    long long n;
    cin>>n;
    for(int i=0;i<d5;i++){
        if(i*(i+1)>=2*n){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int n, m;
    cin >> n >> m;
    PUTS(n * (n - 1) / 2 + m * (m - 1) / 2);
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<map>
#include <bits/stdc++.h>
#include<cmath>
#define mod 1000000007
#define ll long long 
using namespace std;

int main() {


  
 char c;
 cin>>c;
 if(c>='A' && c<='Z')
 {
 	cout<<'A'<<endl;
 }
 else
 {
 	cout<<'a'<<endl;
 }
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long result = max({ a*c, b*d, a*d, b*c });
	cout << result << endl;
}

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

const int N = 105;
const int k = 50;

int a, b;
bool grid[N][N];

void paintWhite() {
	for (int i = 1; i <= k - 1; i += 2) {
		for (int j = 1; j <= 2 * k; j += 2) {
			if (a == 0) break;
			grid[i][j] = 0;
			a--;
		}
	}
}

void paintBlack() {
	for (int i = 2 * k; i >= k + 2; i -= 2) {
		for (int j = 1; j <= 2 * k; j += 2) {
			if (b == 0) break;
			grid[i][j] = 1;
			b--;
		}
	}
}

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d %d", &a, &b);
	a--; b--;
	printf("%d %d\n", 2 * k, 2 * k);
	for (int i = k - 1; i >= 1; i--) 
		for (int j = 1; j <= 2 * k; j++) grid[i][j] = 1;
	paintBlack();
	paintWhite();
	for (int i = 1; i <= 2 * k; i++) {
		for (int j = 1; j <= 2 * k; j++) {
			(grid[i][j] == 1) ? putchar('#') : putchar('.');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]==a[j])
                continue;
            for(int k=j+1;k<n;k++)
            {
                if(a[k]==a[j]||a[k]==a[i])
                    continue;
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i])
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
}

   

Measured memory_bytes: 3632
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

difference = 9999999
ans = 0
for i in range(len(H)):
	temp = T - H[i] * 0.006
	if difference > abs(temp - A):
		difference = abs(temp - A)
		ans = i + 1
		
print(ans)

Measured memory_bytes: 38384
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << double(w * h) / 2 << " " << (w == x * 2 and h == y * 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string A, B;
   cin >> A >> B;
   if (A.size() > B.size()) {
      cout << "GREATER" << endl;
      return 0;
   } else if (A.size() < B.size()) {
      cout << "LESS" << endl;
      return 0;
   } else {
      int N = A.size();
      for (int i = 0; i < N; i++) {
         if (A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
         } else if (A[i] < B[i]) {
            cout << "LESS"<< endl;
            return 0;
         }
      }
   }
   cout << "EQUAL" << endl;
   return 0;
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
data=[[[],[],[],[]] for i in range(4**n)]
inf=float("inf")
for i in range(4**n):
    k=i
    for j in range(n):
        m=k//4**(n-1-j)
        if m>0:
            data[i][m].append(j)
            k%=4**(n-1-j)
        else:
            data[i][0].append(j)
            
ans=inf
for h in data:
    if h[0] and h[1] and h[2]:
        count=0
        
        count+=(len(h[0])-1)*10
        count+=(len(h[1])-1)*10
        count+=(len(h[2])-1)*10
        
        s=0
        for i in h[0]:
            s+=l[i]
        count+=abs(s-a)
        
        s=0
        for i in h[1]:
            s+=l[i]
        count+=abs(s-b)
        
        s=0
        for i in h[2]:
            s+=l[i]
        count+=abs(s-c)
        
        ans=min(ans,count)
print(ans)

Measured memory_bytes: 75932
MOD = 10 ** 9 + 7
M = 2 * 10 ** 6
fac = [1] * (M + 1)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD


def comb(n, k):
    return fac[n] * pow(fac[n - k], MOD - 2, MOD) * pow(fac[k], MOD - 2, MOD) % MOD


k = int(input())
s = input()
n = len(s)
ans = 0
for i in range(n, n + k + 1):
    ans += pow(25, n + k - i, MOD) * comb(n + k, i)
print(ans % MOD)


Measured memory_bytes: 123340
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MAX_N = 50;
int N, M;
bool G[MAX_N][MAX_N];
bool used[MAX_N];
int ord[MAX_N], low[MAX_N];
int o = 0;

void dfs(int i, int p) {
    used[i] = true;
    ord[i] = o++;
    low[i] = ord[i];
    REP(j, N) {
        if (!G[i][j]) {
            continue;
        } else if (!used[j]) {
            dfs(j, i);
            amin(low[i], low[j]);
        } else if (j != p) {
            amin(low[i], ord[j]);
        }
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fill(G[0], G[MAX_N - 1], false);
    fill(used, used + MAX_N - 1, false);
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b] = G[b][a] = true;
    }
    dfs(0, -1);
    int res = 0;
    REP(i, N) {
        REP(j, N) {
            if (i != j && G[i][j] && ord[i] < low[j]) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(b>=a)
    cout<<0<<endl;
    else
    if(2*b>=a)
    cout<<0<<endl;
    else
    cout<<a-2*b<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B, C, D;
    string S; cin >> S;
    A = S[0]-'0'; B = S[1]-'0'; C = S[2]-'0'; D = S[3]-'0';
    if(A+B+C+D == 7) cout << A << "+" << B << "+" << C << "+" << D << "=" << 7 << endl;
    else if(A+B+C-D == 7) cout << A << "+" << B << "+" << C << "-" << D << "=" << 7 << endl;
    else if(A+B-C+D == 7) cout << A << "+" << B << "-" << C << "+" << D << "=" << 7 << endl;
    else if(A+B-C-D == 7) cout << A << "+" << B << "-" << C << "-" << D << "=" << 7 << endl;
    else if(A-B+C+D == 7) cout << A << "-" << B << "+" << C << "+" << D << "=" << 7 << endl;
    else if(A-B+C-D == 7) cout << A << "-" << B << "+" << C << "-" << D << "=" << 7 << endl;
    else if(A-B-C+D == 7) cout << A << "-" << B << "-" << C << "+" << D << "=" << 7 << endl;
    else if(A-B-C-D == 7) cout << A << "-" << B << "-" << C << "-" << D << "=" << 7 << endl;
    
    return 0;
}

Measured memory_bytes: 256