akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class Main {
	static boolean debug = false;

	public static void main(String[] args) throws IOException {

		UserScanner scan = new UserScanner();
		PrintWriter pwriter = new PrintWriter(System.out);

		int x0 = scan.nextInt();
		int y0 = scan.nextInt();
		int x1 = scan.nextInt();
		int y1 = scan.nextInt();

		Projection projection = new Projection(x0, y0, x1, y1);

		int q = scan.nextInt();
		for (int i = 0; i < q; i++) {
			int x2 = scan.nextInt();
			int y2 = scan.nextInt();
			projection.calc(x2, y2, pwriter);
		}
		pwriter.flush();

		scan.close();
		System.exit(0);
	}
}

class Projection {
	// tx = x2*cos*cos + y2*sin*cos + x0*sin*sin - y0*sin*cos
	// ty = x2*sin*cos + y2*sin*sin - x0*sin*cos + y0*cos*cos
	double cos2, sin2, sincos;
	double txd, tyd;

	public Projection(int x0, int y0, int x1, int y1) {
		double t2 = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
		cos2 = (x1 - x0) * (x1 - x0) / t2;
		sin2 = (y1 - y0) * (y1 - y0) / t2;
		sincos = (x1 - x0) * (y1 - y0) / t2;
		txd = x0 * sin2 - y0 * sincos;
		tyd = -x0 * sincos + y0 * cos2;
	}

	public void calc(int x2, int y2, PrintWriter pw) {
		double tx = x2 * cos2 + y2 * sincos + txd;
		double ty = x2 * sincos + y2 * sin2 + tyd;
		pw.print(String.valueOf(tx));
		pw.print(' ');
		pw.println(String.valueOf(ty));
	}
}

class UserScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean read() throws IOException {
		ptr = 0;
		buflen = in.read(buffer);
		if (buflen <= 0)
			return false;
		else
			return true;
	}

	private byte getByte() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			return -1;
		} else
			return buffer[ptr++];
	}

	private void skipCtlSpace() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			ptr++;
			skipCtlSpace();
		}
	}

	private boolean isCtlSpace(byte b) {
		if (b <= ' ' || b > '~')
			return true;
		else
			return false;
	}

	public void close() throws IOException {
		in.close();
	}

	public String next() throws IOException {
		skipCtlSpace();
		StringBuilder sb = new StringBuilder();
		byte b;
		while ((b = getByte()) != -1) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() throws IOException {
		skipCtlSpace();
		int n = 0;
		boolean minus = false;
		byte b;
		while ((b = getByte()) != -1) {
			if (b == '-')
				minus = true;
			else {
				n *= 10;
				n += (b - '0');
			}
		}
		if (minus)
			return n * -1;
		else
			return n;
	}
}

Measured memory_bytes: 26564
import java.io.IOException;

public class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	num = 0;

		while((num = parseNum()) != 0) {
			solve(num);
		}
	}

	private static void solve(int num) {
		int[][][]	map = new int[num+1][num+2][5];
		int			max = 0;

		for (int i = 1; i <= num; i++) {
			for (int j = 1; j <= num; j++) {
				map[i][j][0] = parseDot();
				if (map[i][j][0] == 1) {
					map[i][j][1] = (map[i][j-1][0] == 1)?map[i][j-1][1]+1:1;		// left
					map[i][j][2] = (map[i-1][j-1][0] == 1)?map[i-1][j-1][2]+1:1;	// up+left
					map[i][j][3] = (map[i-1][j][0] == 1)?map[i-1][j][3]+1:1;		// up
					map[i][j][4] = (map[i-1][j+1][0] == 1)?map[i-1][j+1][4]+1:1;	// up+right
					max = Math.max(max, map[i][j][1]);
					max = Math.max(max, map[i][j][2]);
					max = Math.max(max, map[i][j][3]);
					max = Math.max(max, map[i][j][4]);
				}
			}
		}

		System.out.println(max);
	}

	private static int parseDot() {
		try {
			int	buf = 0;

			// 0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf >= '0' && buf <= '9') {
					return buf - '0';
				}
			}
		} catch (IOException e) {}
		return -1;
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if ((skp == 0 || buf == -1) && buf != '.') {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> w(n);
  for (int i=0; i<n; i++){
    cin >> w.at(i);
  }
  
      int ans = 1e9;
  
  for (int i=1; i<n; i++){
    int sum1 = 0;
    int sum2 = 0;
    for (int j=0; j<i; j++){
      sum1 += w.at(j);
    }
    for (int j=i; j<n; j++){
      sum2 += w.at(j);
    }
    
    ans = min(ans, abs(sum2 - sum1));
  }
  
  cout << ans << endl;
}


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

#define SIZE(x) ((x).size())
#define int long long

using namespace std;

const int N = 5e5 + 2, K = 102, P = 102;

string str(int x) {
    string ret;
    ret.clear();
    while(x) {
        ret += char((x % 10) + '0');
        x /= 10;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

string sum(string s1, string s2) {
    string ret;
    ret.clear();
    if(SIZE(s1)<SIZE(s2)) swap(s1, s2);
    string add;
    add.clear();
    while(SIZE(s2) + SIZE(add) < SIZE(s1)) {
        add+='0';
    }
    s2 = add + s2;
    for(int i = 0 ; i < SIZE(s2) ; i++ ) ret += '0';
    int car = 0;
    for(int i = SIZE(s1) - 1 ; i >= 0 ; i-- ) {
        ret[i] = char(((car + s1[i] + s2[i] - '0' - '0') % 10) + '0');
        if(car + s1[i] + s2[i] - '0' - '0' >= 10) {
            car = 1;
        }
        else car = 0;
    }
    ret = str(car) + ret;
    return ret;
}

int32_t main () {
    ios::sync_with_stdio(),cin.tie(0),cout.tie(0);
    string ll;
    string l2;
    cin >> ll;
    l2 = ll;
    for(int i = 0 ; i < 8 ; i++ ) {
        l2 = sum(ll, l2);
    }
    int l = 1, r = SIZE(l2) * 9;
    while(l < r) {
        int mid = (l + r) / 2;
        int sm = 0;
        string ch = l2;
        ch = sum(ch, str(9 * mid));
        for(char c: ch) sm += c - '0';
        if(sm <= 9 * mid) r = mid;
        else l = mid + 1;
    }
    cout << l << '\n';
}


Measured memory_bytes: 7572
#include<bits/stdc++.h>
using namespace std;
int n,x[20],z[20][20],t[2],ans=0;
bool y[20][20],honest[20];
bool check()
{
	for(int i=1;i<=n;i++)
	{
		if(!honest[i]) continue;
		for(int j=1;j<=x[i];j++)
		{
			int m=z[i][j];
			if(honest[m]!=y[i][m])
			{return false;}
		}
	}
	return true;
}
void dfs(int depth,int num)
{
/*	for(int i=1;i<=n;i++)
	{
		if(honest[i]) cout<<1<<" ";
		else cout<<0<<" ";
	}
	cout<<depth<<" "<<num<<endl;*/
	if(n-depth+num<=ans) return;
	if(depth==n&&check()){ans=num;return;}
	if(depth==n) return;
	honest[depth+1]=true;dfs(depth+1,num+1);
	honest[depth+1]=false;dfs(depth+1,num);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];honest[i]=false;
		for(int j=1;j<=x[i];j++)
		{
			cin>>t[0]>>t[1];
			y[i][t[0]]=t[1];
			z[i][j]=t[0];
		}
	}
	dfs(0,0);
	cout<<ans;
	return 0;
}

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

map<int, int> counter(vector<int> sequence){
    map<int, int> freq;
    for (auto s : sequence){
        freq[s]++;
    }
    return freq;
}


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

    int max_val = *max_element(sequence.begin(), sequence.end());
    auto freq = counter(sequence);
    int second_max = 0;
    for (auto item : freq){
        if (second_max <= item.first){
            if (item.first != max_val){
                second_max = item.first;
            }
        }
    }

    for (auto s: sequence){
        if (s == max_val){
            if (freq[s] == 1){
                cout << second_max << endl;
            } else {
                cout << max_val << endl;
            }
        } else {
            cout << max_val << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7920
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};
fn main() {
    input!(w:String);

    let mut map = HashMap::new();
    for c in 0..26 {
        let mut c = c + b'a';
        map.insert(c as char, 0);
    }
    for c in w.chars() {
        let c = c as char;
        *map.get_mut(&c).unwrap() += 1;
    }
    for c in 0..26 {
        let mut c = c + b'a';
        if map[&(c as char)] % 2 != 0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2196
r,c = map(int,input().split())
a = []
for i in range(r):
    a.append(list(map(int,input().split())))
    a[i].append(sum(a[i]))
b = []
for i in range(c+1):
    x = [row[i] for row in a]
    b.append(sum(x))
a.append(b)
for x in a:
    print(*x)



Measured memory_bytes: 6232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long


int main(){

	string s;
	cin >> s;

	int n = s.length();
	if (n == 2){
		if (s[0] == s[1]){
			cout << 1 << " " << 2 << endl;
			return 0;
		}
		else{
			cout << "-1 -1" << endl;
			return 0;
		}
	}

	for (int i = 0; i <= n - 3; i++){
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdlib.h>
using namespace std;

struct node{
  int key;
  node *right, *left, *parent;
};

node *root, *nil;

node *find(node *u, int k){
  while(u != nil && k != u->key){
    if(k < u->key) u = u->left;

    else u = u->right;
    
  }

  return u;
  
}

void insert(int k){
  node *y = nil;
  node *x = root;
  node *z;

  z = (node *)malloc(sizeof(node));
  z->key = k;
  z->left = nil;
  z->right = nil;

  while(x != nil){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;

  }

    z->parent = y;

    if(y == nil) root = z;

    else{
      if(z->key < y->key) y->left = z;

      else y->right = z;

  }  
}

void inorder(node *a){
  if(a == nil) return;

  inorder(a->left);

  cout << " " << a->key;

  inorder(a->right);
}

void preorder(node *a){
  if(a == nil) return;

  cout << " " << a->key;
  
  preorder(a->left);
  preorder(a->right);
  
}

int main()
{
  int n, x;
  string s;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> s;

    if(s == "find"){
      cin >> x;
      node *t = find(root, x);

      if(t != nil) cout << "yes" << endl;
      else cout << "no" << endl;
      
    }

    else if(s == "insert"){
      cin >> x;
      insert(x);
     
    }

    else if(s == "print"){
      inorder(root);
      cout << endl;

      preorder(root);
      cout << endl;
    }
  }

  return 0;
  
}



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

int main(){
  
  int circumference;
  cin >> circumference;
   
  int n_houses;
  cin >> n_houses;
  

  vector<int> pos_list;
  for (int i = 0; i < n_houses; ++i){
    int pos_of_house;
    cin >> pos_of_house;
    pos_list.push_back(pos_of_house);
  }
  pos_list.push_back(pos_list.at(0) + circumference);
  
  
  vector<int> dist_list;
  for (int i = 0; i < n_houses; ++i){
    int dist_between_two_houses = pos_list.at(i+1) - pos_list.at(i);
    dist_list.push_back(dist_between_two_houses);
  }
  

  vector<int>::iterator max_it = max_element(dist_list.begin(), dist_list.end());
  dist_list.erase(max_it);
  
  int min_dist = 0;
  for (int i = 0; i < dist_list.size(); ++i){
    min_dist += dist_list.at(i);
  }

  cout << min_dist << endl;
}


Measured memory_bytes: 2548
H, W = map(int, input().split())
S =['.'*(W+2)]+ ['.'+input()+'.' for i in range(H)]+['.'*(W+2)]
flag = True
for i in range(1, H+1):
    for k in range(1, W+1):
        if S[i][k] == '#':
            if S[i-1][k] == '.' and S[i+1][k] == '.' and S[i][k+1] == '.' and S[i][k-1] == '.':
                flag = False
                break
    if not flag:
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#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 MOD 998244353
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#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;
int main(){
	fast_io();
	int n;
	cin >> n;
	cout << (n + 110)/111 * 111 << endl;
}


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

int main() {
  int n, ans = 0;

  cin >> n;

  vector<int> d(n);

  for (int i = 0; i < n; i++) cin >> d[i];

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

  ans = d[n / 2] - d[n / 2 - 1];

  cout << ans;

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int i, j, h, w;
  char img[102][102];

  for (i = 0; i < 102; i++) {
    for (j = 0; j < 102; j++) {
      img[i][j] = '#';
    }
  }

  scanf("%d %d%*c", &h, &w);

  for (i = 1; i < h + 1; i++) {
    for (j = 1; j < w + 1; j++) {
      scanf("%c", &img[i][j]);
    }
    getchar();
  }

  for (i = 0; i < h + 2; i++) {
    for (j = 0; j < w + 2; j++) {
      putchar(img[i][j]);
    }
    putchar('\n');
  }

  return 0;
}


Measured memory_bytes: 128
/*input
9
6 4
100110
3 2
1?1
3 2
1?0
4 4
????
7 4
1?0??1?
10 10
11??11??11
4 2
1??1
4 4
?0?0
6 2
????00
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];

void dfs(int node){
	visited[node] = true;
	for(int n: adj_list[node]){
		if(!visited[n]){
			dfs(n);
		}
	}
}



int main() {
 	int d;
 	int t;
 	int s;
 	cin>>d>>t>>s;
 	if(t*s>=d){
 		cout<<"Yes"<<endl;
 	}
 	else{
 		cout<<"No"<<endl;
 	}
}



 


Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K;
    cin >> K;
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    cout << A[K-1] << endl;

}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

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

  cin >> n;

  llint res = 1;
  REP(i, n) {
    llint t;
    cin >> t;
    llint a = res, b = t, r;
    if (a < b) {
      swap(a, b);
    }
    r = a % b;
    while (r != 0) {
      a = b;
      b = r;
      r = a % b;
    }
    res = res / b * t;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
def main():
    T = input()

    ans = ''
    flag_q = False
    flag_p = False
    for t in T:
        if t != '?':
            if flag_q and t == 'D':
                ans += 'PD'
                flag_q = False
                flag_p = False
            elif flag_q and t == 'P':
                ans += 'DP'
                flag_q = False
                flag_p = True
            else:
                if t == 'P':
                    flag_p = True
                else:
                    flag_p = False
                ans += t
        else:
            if flag_q:
                ans += 'PD'
                flag_q = False
                flag_p = False
            elif flag_p:
                ans += 'D'
                flag_q = False
                flag_p = False
            else:
                flag_q = True

    if flag_q:
        ans += 'D'

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9604
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, m;
int x[1919], y[1919], z[1919];
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> x[i] >> y[i] >> z[i];
	int ans = 0;
	rep(i, 8) {
		int a[1919];
		fill(a, a + n, 0);
		rep(j, n) {
			if ((i >> 0) & 1)a[j] += x[j];
			else a[j] -= x[j];
			if ((i >> 1) & 1)a[j] += y[j];
			else a[j] -= y[j];
			if ((i >> 2) & 1)a[j] += z[j];
			else a[j] -= z[j];
		}
		int sum = 0;
		sort(a, a + n, greater<>());
		rep(j, m) {
			sum += a[j];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int N;
	double sum=0;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
        sum+=1/A[i];
        }
       
	cout << 1/sum << endl;
}



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

n = int(input())

n_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81]

if n in n_list:
  print('Yes')
else:
  print('No')

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

int main(){
    string s;

    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"Yes";
    }else if(s[1]==s[2]&&s[2]==s[3]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define R(i,y,k) for(int i=1;i<=y;++i,k)
int main(){
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    R(i,H,puts(""))
      R(j,W,1)
        if(i%h||j%w) printf("1000 ");
        else printf("%d ", -1000*(h*w-1)-1);
  }else puts("No");
  return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
#include <queue>
const int MAX = 20010;
const int maxn = 20010;
const int INF = 1e9;

using namespace std;

struct road_{
	int to, dis, cost;
	road_ (){}
	road_ (int a, int b, int c){to = a;dis =b;cost=c;}
};
typedef pair <int, int> P;
vector <road_> road[MAX];

int N, M;
int cost[MAX];
int dis[MAX];

//思路： dijkstra算法，在更新最短距离时，如果最短距离相等，保留最小的花费 
void Dijkstra(){
	fill(dis, dis+MAX, INF);
	fill(cost, cost+MAX, INF);
	dis[1] = 0;
	cost[1]=0;
	priority_queue <P, vector<P>, greater<P> > que;
	que.push(P(0,1));
	
	while(!que.empty()){
		P p = que.top();
		int v = p.second;
		que.pop();
		if(dis[v] < p.first)continue;
		//更新距离 
		for(int i=0; i<road[v].size(); i++){
			road_ r = road[v][i];
			if(dis[r.to] < dis[v] + r.dis) continue;
			//如果小于最短距离，更新距离入队,更新花费 
			if(dis[r.to] > dis[v] + r.dis) {
				dis[r.to] = dis[v] + r.dis;
				cost[r.to]	= r.cost;
				que.push(P(dis[r.to], r.to));
			}
			//等于最短距离，比较大小
			else
				cost[r.to] = min(cost[r.to], r.cost);
				
		}		
	}
}

//测试函数 
int main(){
/*	ifstream cin ("D:\\钢铁程序员\\程序数据\\067道路修建.txt");//从文件读取数据流，省去手动输入的麻烦 
	if(!cin){//读取如果失败 
		cout << "ERROR" << endl;
	}*/
    int n,m,a,b,c,d;
    while(cin>>n>>m){
        if(n==0&&m==0) break;
        for(int i=0;i<maxn;i++) road[i].clear();
        for(int i=0;i<m;i++){
            cin >> a >> b >> c >> d;
            road[a].push_back(road_(b,c,d));
            road[b].push_back(road_(a,c,d));
        }
        Dijkstra();
        int sum = 0;
		for(int i=1; i<=n; i++)
			sum += cost[i];
		cout << sum << endl;
    }
 //   cin.close();
    return 0;
}


Measured memory_bytes: 5392
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

std::vector<int > bit(500005, 0);
int N, Q;

void add(int pos, int val) {
  while(pos<=N) {
    //printf("pos=%d\n", pos);
    bit[pos]+=val;
    //printf("bit[%d]+=%d\n", pos, val);
    pos += pos & (-pos);
  }
  return;
}

int sum(int pos) {
  int retval = 0;
  while(pos>0) {
    //printf("pos=%d\n", pos);
    retval += bit[pos];
    pos -= pos & (-pos);
  }
  return retval;
}

void print(){
  for (int i=1; i<=N; i++) {
    printf("bit[%d]=%d\n", i, bit[i]);
  }
  return;
}

int dp[404][404];
const int INF = 1001001001;
int main(){
  int N, Ma, Mb;
  std::cin >> N >> Ma >> Mb;
  std::vector<int > a(N), b(N), c(N);
  for (int i=0; i<N; i++) {
    std::cin >> a[i] >> b[i] >> c[i];
  }
  for (int i=0; i<404; i++) {
    for (int j=0; j<404; j++) {
      dp[i][j] = INF;
     }
  }
  dp[0][0]=0;
  for (int k=0; k<N; k++) {
    for (int i=400; i>=0; i--) {
      for (int j=400; j>=0; j--) {
        if (i+a[k]<=400 && j+b[k]<=400) {
          dp[i+a[k]][j+b[k]] = std::min(dp[i+a[k]][j+b[k]], dp[i][j]+c[k]);
        }
      }
    }
  }
  int ans = INF;
  //printf("dp[1][2]=%d\n", dp[1][2]);
  for (int i=1; i<=400; i++) {
    for (int j=1; j<=400; j++) {
      if (Ma*j == Mb*i && i>0) {
        //printf("dp[%d][%d]=%d\n", i, j, dp[i][j]);
        ans = std::min(ans, dp[i][j]);
      }
    }
  }
  printf("%d\n", (ans==INF)?-1:ans);
  return 0;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%d", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long
#define float long double 
#define ll long long

const int inf = (int) 1e16;
const int upper = (int) 4e5 + 15;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	int n; cin >> n;

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

	int dp[n + 1];

	for (int i = 1; i <= n; i += 1) dp[i] = inf;

	dp[1] = 0;

	for (int i = 2; i <= n; i += 1) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i]);
		if (i - 2 >= 1) dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i]);
	}

	cout << dp[n];
 	end_routine();	
}

Measured memory_bytes: 1792
in_value = int(input())
if 400 <= in_value <= 599:
    print(8)
elif 600 <= in_value <= 799:
    print(7)
elif 800 <= in_value <= 999:
    print(6)
elif 1000 <= in_value <= 1199:
    print(5)
elif 1200 <= in_value <= 1399:
    print(4)
elif 1400 <= in_value <= 1599:
    print(3)
elif 1600 <= in_value <= 1799:
    print(2)
elif 1800 <= in_value <= 1999:
    print(1)

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

int main(){
    int n;
    cin >> n;
    vector<tuple<string,int,int>> t(n);
    rep(i,n){
        string s;
        int a;
        cin >>s >>a;
        t[i] = make_tuple(s,-a,i+1);
    }
    sort(t.begin(),t.end());
    rep(i,n){
        cout << get<2>(t[i]) << endl;
    }
    return 0;
}


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

namespace Volume0_0009
{
    class Program
    {
        static void Main(string[] args)
        {
            const int MAX = 1000000;

            bool[] primes = Enumerable.Repeat(true, MAX).ToArray();
            primes[0] = primes[1] = false;

            int[] primeCounts = new int[MAX];

            int count = 0;
            double limit = Math.Sqrt(MAX);

            for (int i = 2; i < MAX; i++)
            {
                if (primes[i])
                {
                    if (i < limit)
                    {
                        for (int j = i * i; j < MAX; j += i) primes[j] = false;
                    }
                    count++;
                }
                primeCounts[i] = count;
            }

            string input;
            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int n = Convert.ToInt32(input);
                Console.WriteLine(primeCounts[n].ToString());
            }
        }
    }
}

Measured memory_bytes: 16052
#include <iostream>
#include <vector>

using namespace std;

#define lli long long int

const int maxN = 2e5 + 5;

vector<lli> a(maxN), x(maxN);

int main()
{
    int n;
    cin >> n;
    lli xr = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        xr ^= a[i];
    }
    for(int i = 0; i < n; i++) cout << (xr ^ a[i]) << ' ';
    return 0;
}


Measured memory_bytes: 6228
/*-------------------*/
/*       Darsein     */
/*      O(K logK)    */
/* implement: 40 min */
/* debug:     20 min */
/*-------------------*/

#include<bits/stdc++.h>
using namespace std;

int main(){
  long long w,h,k,n;
  cin >> w >> h >> k >> n;

  map< int, vector<int> > odd, even;
  set<int> row;
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    if(x&1) odd[y].emplace_back(x);
    else even[y].emplace_back(x);
    row.emplace(y);
  }

  if((w+1)/2 > k){
    cout << -1 << endl;
    return 0;
  }
  k -= (w+1)/2;

  long long ans = 0;
  for(auto r : row){
    vector<int> e = even[r];
    e.emplace_back(0);
    e.emplace_back(w+1);
    sort(e.begin(), e.end());

    vector<int> o = odd[r];
    sort(o.begin(), o.end());
    size_t oidx = 0;

    for(size_t i=1;i<e.size();i++){
      int len = (e[i] - e[i-1])/2;
      if(len%2 == 0) continue;

      int cnt = 0;
      while(oidx < o.size() && o[oidx] < e[i-1]) oidx++;
      while(oidx < o.size() && o[oidx] < e[i]){
	int relative_pos = (o[oidx] - e[i-1])/2;
	if(relative_pos%2==0) cnt++;
	oidx++;
      }
      if(cnt == (len+1)/2) ans++; 
    }
  }

  ans = max(0LL, ans-k);
  cout << max(0LL, (h-1)/2*(w+1)/2 + ans - k) << endl;
}

Measured memory_bytes: 6188
#include <iostream>
#include <iomanip>
int main()
{
  int N, K;
  std::cin >> N >> K;

  long double ans = 0.0;

  for (int i = 1; i <= N; i++) {
    long double h = 1.0;
    for (int j = i; j < K; j *= 2) {
      h *= 0.5;
    }
    ans += h;
  }

  ans /= (long double)N;

  std::cout << std::setprecision(9) <<  ans << std::endl;

  return 0;
}

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

const int Mod = 1e9 + 7;
const int N = 9e5 + 10;

int n, m, k;
long long fac[N], vfac[N];

long long mpow( long long a, int b ) {
	long long rt;
	for( rt = 1; b; b >>= 1, a = (a * a) % Mod )
		if( b & 1 ) rt = (rt * a) % Mod;
	return rt;
}
void init( int n ) {
	fac[0] = 1;
	for( int i = 1; i <= n; i++ )
		fac[i] = (fac[i-1] * i) % Mod;
	vfac[n]  = mpow( fac[n], Mod - 2 );
	for( int i = n - 1; i >= 0; i-- )
		vfac[i] = vfac[i+1] * (i + 1) % Mod;
}
long long comb( int n, int m ) {
	return fac[n] * vfac[n-m] % Mod * vfac[m] % Mod;
}
int main() {
	scanf( "%d%d%d", &n, &m, &k );
	if( m < k ) swap( m, k );
	init( m + k + n );
	long long sum = 0, ans = 0;
	for( int s = 0; s <= m + k; s++ ) {
		if( s == 0 ) {
			sum = 1;
		} else if( s <= k ) {
			sum = (sum<<1) % Mod;
		} else if( s <= m ) {
			sum = ((sum<<1) + Mod - comb(s-1,s-k-1)) % Mod;
		} else {
			sum = ((sum<<1) + Mod - comb(s-1,s-k-1) + Mod - comb(s-1,m)) % Mod;
		}
		long long sub = sum * comb(n-1+s,n-1) % Mod * mpow(3,m+k-s) % Mod;
		ans = (ans + sub) % Mod;
//		printf( "s = %d sub = %lld\n", s, sub );
	}
	printf( "%lld\n", ans );
}



Measured memory_bytes: 14336
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
  v=a[i]
  j=i-1
  while j>=0 and a[j]>v:
    a[j+1]=a[j]
    j-=1
  a[j+1]=v
  print(*a)


Measured memory_bytes: 5980
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

void prime_factorize(int n, std::map<int,int>& prime_factors) {
	for(int i=2;i*i<=n;i++) {
		while(n%i==0) {
			prime_factors[i]++;
			n/=i;
		}
	}
	if(n!=1) prime_factors[n]++;
}


signed main() {
	int n;
	std::cin >> n;
	std::map<int,int> prime_factors;
	for(int i=1;i<=n;i++) {
		std::map<int,int> tmp;
		prime_factorize(i,tmp);
		for(auto x:tmp) {
			prime_factors[x.first]+=x.second;
		}
	}
	// 75 = 1x75 , 3x25, 5x15, 3x5x5
	int ans = 0;
	for(auto x:prime_factors) {
		if(x.second>=74) ans++;
	}
	for(auto x:prime_factors) {
		for(auto y:prime_factors) {
			if(x.first==y.first) continue;
			if(x.second>=2 && y.second>=24) ans++;
			if(x.second>=4 && y.second>=14) ans++;
		}
	}
	for(auto x:prime_factors) {
		for(auto y:prime_factors) {
			for(auto z:prime_factors) {
				if(x==y||y==z||z==x) continue;
				if(x.second>=2&&y.second>=4&&z.second>=4&&y.first<z.first) ans++;
			}
		}
	}
	print(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n;
	double a,ans;
	vector<double>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	ans=v[0];
	for(int i=1;i<n;i++)
	{
		ans=(ans+v[i])/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

for i in range(tx - sx):
    print('R', end="")
for i in range(ty - sy):
    print('U', end="")
for i in range(tx - sx):
    print('L', end="")
for i in range(ty - sy):
    print('D', end="")

print('D', end="")
for i in range(tx - sx + 1):
    print('R', end="")
for i in range(ty - sy + 1):
    print('U', end="")
print('L', end="")

print('U', end="")
for i in range(tx - sx + 1):
    print('L', end="")
for i in range(ty - sy + 1):
    print('D', end="")
print('R', end="")

print()



Measured memory_bytes: 76556
#include <iostream>

using namespace std;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
char fie[8][9];

void bomb(int x, int y){
  if(fie[y][x] == '1'){
    fie[y][x] = '0';
    for(int i=1; i<=3; i++){
      for(int j=0; j<4; j++){
	int bx = x+i*dx[j];
	int by = y+i*dy[j];
	if(0 <= bx && bx <= 7 && 0 <= by && by <= 7)
	  bomb(bx, by);
      }
    }
  }
}

int main(){
  int n;
  cin >> n;
  for(int a=0; a<n; a++){
    for(int i=0; i<8; i++)
      cin >> fie[i];
    int sx, sy;
    cin >> sx >> sy;
    bomb(sx-1 , sy-1);
    cout << "Data " << a+1 << ":" << endl;
    for(int i=0; i<8; i++){
      cout << fie[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
  
n = int(input())
A = list(int(i) for i in (input().split()))

front = []
end = []
for i in range(n):
  if(i == 0):
    front.append(gcd(*[A[0]]))
    end.append(gcd(*[A[n-1]]))
  else:
    front.append(gcd(*[front[i - 1],A[i]]))
    end.append(gcd(*[end[i - 1],A[n-1-i]]))

ans = 0
for i in range(n):
  if(i == 0):
    tmp = end[n-2]
  elif(i == n-1):
    tmp = front[n-2]
  else:
    tmp = gcd(*[front[i-1],end[n-2-i]])
  if(ans < tmp):
    ans = tmp
print(ans)

Measured memory_bytes: 16152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=510;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int can[maxn][maxn];
int vis[maxn];
int linker[maxn];
bool dfs(int x)
{
    repd(i,1,n)
    {
        if(can[x][i]&&vis[i]==0)
        {
            vis[i]=1;
            if(linker[i]==0||(dfs(linker[i])))
            {
                linker[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i]>>b[i];
    }
    repd(i,1,n)
    {
        cin>>c[i]>>d[i];
    }
    repd(i,1,n)
    {
        repd(j,1,n)
        {
            if(a[i]<c[j]&&b[i]<d[j])
            {
                can[j][i]=1;
            }
        }
    }
    int ans=0;
    repd(i,1,n)
    {
        memset(vis,0,sizeof(vis));
        if(dfs(i))
        {
            ans++;
        }
    }
    cout<<ans<<endl;
//    repd(i,1,n)
//    {
//        cout<<linker[i]<<endl;
//    }
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int A, B; cin >> A >> B;

	int ans = max({A+B, A-B, A*B});
	cout << ans << endl;
	


	return 0;

}


Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>

int main(void)
{
	char n[1010];
	int num1[81], num2[81];
	int i, j, max, flag;
	int roop1, roop2, ch;
	
	scanf("%d", &roop1);
	
	for (roop2 = 0; roop2 < roop1; roop2++){
		//ツ　ツ配ツ療アツ渉可甘コツ可サ
		memset(num1, 0, sizeof(num1));
		memset(num2, 0, sizeof(num2));
		memset(n, '0', sizeof(n));
		max = 0;
		flag = 1;
		
		scanf("%s", n);
		ch = strlen(n);
		i = 0;
		if (80 < ch){
			flag = 0;
		}
		else {
			max = ch;
			for (j = (ch - 1); -1 < j; j--){
				num1[i] = (n[j] - '0');
				// printf("%dツ：ツ：%dツ＼n", i, num1[i]);
				i++;
			}
		}
		
		scanf("%s", n);
		ch = strlen(n);
		if (max <= ch) { max = ch; }
		if ((80 < ch) || (flag == 0)){
			flag = 0;
		}
		i = 0;
		if (flag == 1) {
			for (j = (ch- 1); -1 < j; j--){
				num2[i] = (n[j] - '0');
				// printf("%dツ：ツ：%dツ＼n", i, num2[i]);
				i++;
			}
		}
		
		if (flag == 1) {
			for(i = 0; i < 80; i++){
				num1[i] += num2[i];
				if (10 <= num1[i]) {
					num1[i + 1] += 1;
					num1[i] %= 10;
				}
			}
			
			if (num1[80] != 0){
				flag = 0;
			}
			
			if (flag == 1){
				max--;
				if (num1[80] == 0){
					if (num1[max + 1] == 0){
						for (i = max; -1 < i; i--){
							printf("%d", num1[i]);
						}
						printf("\n");
					}
					else {
						max++;
						for (i = max; -1 < i; i--){
							printf("%d", num1[i]);
						}
						printf("\n");
					}
				}
			}
		}
		
		if (flag == 0) {
			printf("overflow\n");
		}
	}
	
	return (0);
}

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

int main() {
  ll n;
  cin >> n;
  ll k = 10000000000000000;
  rep(i,0,5) {
    ll a;
    cin >> a;
    k = min(k,a);
  }
  ll ans;
  if (n % k == 0) ans = n/k + 4;
  else ans = n/k + 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int A, B; cin >> A >> B;
	if (B == 1) {
		cout << "0" << endl; return 0;
	}
	if (B - A <= 0) {
		cout << "1" << endl; return 0;
	}
	B -= A;
	int cnt = 1;
	while (1) {
		cnt++;
		if (B - (A - 1) <= 0) {
			cout << cnt << endl;
			return 0;
		} else {
			B -= A - 1;
		}
	}
}

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

using namespace std;

long long f[55][55][2510];
int n, s;
int a[55];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&s);
	for(int i = 1; i <= n; ++i) scanf("%d",&a[i]);
	for(int i = 0; i <= n; ++i) f[i][0][0] = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= i; ++j){
			for(int k = 0; k <= 2500; ++k){
				f[i][j][k] = f[i - 1][j][k];
				if (k >= a[i]) f[i][j][k] += f[i - 1][j - 1][k - a[i]];
			}
		}
	}
	long long an = 0;
	for(int i = 1; i <= n; ++i){
		an += f[n][i][s * i];
	}
	printf("%lld",an);
	return 0;
}

Measured memory_bytes: 53504
k, x = map(int, input().split(' '))
x_min = x - k + 1 if x - k + 1 >= -1000000 else -1000000
x_max = x + k - 1 if x + k - 1 <=  1000000 else  1000000
print(' '.join(map(str, range(x_min, x_max + 1))))

Measured memory_bytes: 2940
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc083_a.cpp
 * time   : Thu Apr 30 00:33:02 2020
 * quest  : A - Libra
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (((a + b) == (c + d)) ? "Balanced" : ((a + b) > (c + d)) ? "Left" : "Right") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    char A[105],B[105],C[105];

    while(scanf("%s %s %s",A,B,C)==3)
    {
        int lena=strlen(A);
        int lenb=strlen(B);
        int lenc=strlen(C);

        int flaga=0;
        int flagb=0;
        int flagc=0;

        int cnta=0;
        int cntb=0;
        int cntc=0;

        while(1)
        {
            if(flaga==0)
            {
                if(A[cnta]=='a')
                {
                    flaga=0;
                    flagb=1;
                    flagc=1;
                }

                else if(A[cnta]=='b')
                {
                    flaga=1;
                    flagb=0;
                    flagc=1;
                }

                else if(A[cnta]=='c')
                {
                    flaga=1;
                    flagb=1;
                    flagc=0;
                }

                cnta++;

                if(cnta>lena)
                {
                    printf("A\n");

                    break;
                }
            }

            else if(flagb==0)
            {
                if(B[cntb]=='a')
                {
                    flaga=0;
                    flagb=1;
                    flagc=1;
                }

                else if(B[cntb]=='b')
                {
                    flaga=1;
                    flagb=0;
                    flagc=1;
                }

                else if(B[cntb]=='c')
                {
                    flaga=1;
                    flagb=1;
                    flagc=0;
                }

                cntb++;

                if(cntb>lenb)
                {
                    printf("B\n");

                    break;
                }
            }

            else if(flagc==0)
            {
                if(C[cntc]=='a')
                {
                    flaga=0;
                    flagb=1;
                    flagc=1;
                }

                else if(C[cntc]=='b')
                {
                    flaga=1;
                    flagb=0;
                    flagc=1;
                }

                else if(C[cntc]=='c')
                {
                    flaga=1;
                    flagb=1;
                    flagc=0;
                }

                cntc++;

                if(cntc>lenc)
                {
                    printf("C\n");

                    break;
                }
            }
        }
    }

    return (0);
}


Measured memory_bytes: 256