akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define graph_from1 true
#define graph_tree false
#define graph_weight false
#define graph_digraph true

class Graph_func
{
public:
	int Vnum;
	int Enum;
	vector<pair<int, int> > edgelist;
	vector<ll> edgeweight;
	vector<vector<int> > adjlist;
	vector<vector<ll> > adjlistweight;
	vector<int> adjnum;

	vector<ll> xdist;

	vector<bool> x_visited;
	vector<int> x_prqarr;
	vector<bool> x_filled;

	void read_edge();
	void adjini();
	void visited_ini();
	double solve();

	bool xydist_def = false;
};

void Graph_func::read_edge()
{
	cin >> Vnum;
	if (graph_tree)
		Enum = Vnum - 1;// graph
	else
		cin >> Enum;
	edgelist.resize(Enum);
	edgeweight.resize(Enum);
	adjnum.resize(Vnum);
	xdist.resize(Vnum);
	adjlist.resize(Vnum);
	if (graph_weight)
		adjlistweight.resize(Vnum);
	for (int i = 0; i < Enum; i++)
	{
		if (graph_weight)
			cin >> edgelist[i].first >> edgelist[i].second >> edgeweight[i];
		else
			cin >> edgelist[i].first >> edgelist[i].second;
		if (graph_from1)
		{
			edgelist[i].first--;
			edgelist[i].second--;
		}
	}
	return;
}

void Graph_func::adjini()
{
	for (int i = 0; i < Vnum; i++)
		adjnum[i] = 0;
	for (int i = 0; i < Enum; i++)
	{
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		adjlist[x].push_back(y);
		if (!graph_digraph)
			adjlist[y].push_back(x);
		if (graph_weight)
		{
			ll xyweight = edgeweight[i];
			adjlistweight[x].push_back(xyweight);
			if (!graph_digraph)
				adjlistweight[y].push_back(xyweight);
		}
		adjnum[x]++;
		if (!graph_digraph)
			adjnum[y]++;
	}
	x_visited.resize(Vnum);
	visited_ini();

	return;
}

void Graph_func::visited_ini()
{
	for (int i = 0; i < Vnum; i++)
		x_visited[i] = false;
	x_prqarr.resize(0);
}


double Graph_func::solve()
{
	vector<double> eplist(Vnum, 0.0);
	eplist[Vnum - 1] = 0.0;
	double ans = pow(10, 9);
	rep(k, Vnum) {
		for (int x = Vnum - 2; x >= 0; x--) {
			int Ntmp = adjnum[x];
			double epmax = -1.0;
			int epmax_x = -1;
			int Ndiv = Ntmp;
			if (Ntmp != 1 && x == k) { // 塞いでよし
				rep(i, Ntmp) {
					int x_new = adjlist[x][i];
					if (eplist[x_new] > epmax) {
						epmax = eplist[x_new];
						epmax_x = x_new;
					}
				}
				Ndiv--;
			}
			double epsum = 0.0;
			rep(i, Ntmp) {
				int x_new = adjlist[x][i];
				if (x_new != epmax_x) {
					epsum += eplist[x_new] + 1.0;
				}
			}
			eplist[x] = epsum / (double)Ndiv;
		}
		ans = min(ans, eplist[0]);
	}
	return ans;
}

int main(void)
{
	Graph_func graph;
	graph.read_edge();
	graph.adjini();
	ll Vnum = graph.Vnum;
	ll Enum = graph.Enum;
	double ans = graph.solve();
	printf("%.12f\n", ans);
	return 0;
}

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

int main(){
    int i, j, k;
    int m, n;
    int constel[200][2];
    int constel_margin[199][2];
    int stars[1000][2];
    int temp[2];
    bool finish;
    cin >> m;
    while(m){
        cin >> constel[0][0] >> constel[0][1];
        for(i=1;i<m;i++){
            cin >> constel[i][0] >> constel[i][1];
            constel_margin[i-1][0] = constel[i][0] - constel[i-1][0];
            constel_margin[i-1][1] = constel[i][1] - constel[i-1][1];
        }
        cin >> n;
        for(i=0;i<n;i++){
            cin >> stars[i][0] >> stars[i][1];
        }
        for(i=0;i<n;i++){
            k=0;
            temp[0] = stars[i][0] + constel_margin[k][0];
            temp[1] = stars[i][1] + constel_margin[k][1];
            j=0;
            finish = false;
            while(j<n){
                if(stars[j][0] == temp[0] && stars[j][1] == temp[1]){
                    if(k==m-2){
                        finish = true;
                        break;
                    }
                    k++;
                    temp[0] = stars[j][0] + constel_margin[k][0];
                    temp[1] = stars[j][1] + constel_margin[k][1];
                    j=0;
                }
                j++;
            }
            if(finish){
                break;
            }
        }
        cout << stars[i][0] - constel[0][0] << " ";
        cout << stars[i][1] - constel[0][1] << endl;
        cin >> m;
    }
    return 0;
}

Measured memory_bytes: 876
#include <bits/stdc++.h>
using namespace std;
#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()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int W, H;
    cin >> W >> H;
    vector<pll> edge;
    rep(i, W) {
        int p;
        cin >> p;
        edge.emplace_back(p, 0);
    }
    rep(i, H) {
        int p;
        cin >> p;
        edge.emplace_back(p, 1);
    }
    sort(All(edge));
    ll w = W + 1, h = H + 1;
    ll num = 0;
    ll res = 0;
    for(int i = 0; i < W + H; i++) {
        if(edge[i].second == 1) {
            res += edge[i].first * w;
            h--;
        } else {
            res += edge[i].first * h;
            w--;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 7472
#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>;

void solve() {
    ll n, k;
    cin >> n >> k;
    ll c = n / k;
    n -= c * k;
    cout << min(n, abs(n-k)) << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint r[33]={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};
llint k;
void solve(){
	cin >> k;
	for(int i=0;i<32;i++){
		if(i==k-1){
			cout << r[i];
			break;
		}
	}
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n, Y;
	cin >> n >> Y;
	rep2(x, 0, n) {
		rep2(y, 0, n - x) {
			int z = n - x - y;
			if (x * 10000 + y * 5000 + z * 1000 == Y) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
}


Measured memory_bytes: 256
from math import sqrt, gcd
import sys


def osk_a(M):
    p = [i for i in range(M+1)]
    for x in range(2, int(sqrt(M))+1):
        if p[x] == x:
            for y in range(2*x, M+1, x):
                if p[y] == y:
                    p[y] = x
    return p


def g(a):
    g = 0
    for x in a:
        g = gcd(g, x)
    return g


def main():
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    if g(a) > 1:
        print("not coprime")
        exit()
    p = osk_a(10**6)
    chk = set()
    t = a[0]
    while t > 1:
        chk.add(p[t])
        t //= p[t]

    for x in a[1:]:
        tmp = set()
        while x > 1:
            tmp.add(p[x])
            x //= p[x]
        if len(chk & tmp):
            print("setwise coprime")
            exit()
        else:
            chk |= tmp
    print("pairwise coprime")


if __name__ == "__main__":
    main()


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

int main()
{
    
   int n;
   cin>>n;
   
   map<string,int>mp;
   
   while(n--)
   {
       string s;
       cin>>s;
       mp[s]++;
   }
   cout<<mp.size();
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>d(n);
  vector<bool>p(25);
  p[0] = p[24] = 1;
  rep(i,0,n) cin >> d[i];
  sort(d.begin(),d.end());
  rep(i,0,n){
    if(i%2 == 0){
      if(p[d[i]]){
        if(p[24-d[i]]){
          cout << 0 << endl;
          return 0;
        }
        p[24-d[i]] = 1;
      }
      else p[d[i]] = 1;
    }
    else{
      if(p[24-d[i]]){
        if(p[d[i]]){
          cout << 0 << endl;
          return 0;
        }
        p[d[i]] = 1;
      }
      else p[24-d[i]] = 1;
    }
  }
  int ans = 24,m = 0;
  rep(i,1,25){
    if(p[i]){
      ans = min(ans,i-m);
      m = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		long K = sc.nextLong();
		long A = K/50;
		long B = K%50;
		
		long[] a = new long[50];
		for(int i=0; i<50; i++) {
			a[i] = i + A;
		}
		
		for(int i=49; i>49-B; i--) {
			a[i]++;
		}
		
		System.out.println(50);
		for(int i=0; i<50; i++) {
			System.out.print(a[i]);
			if(i != 49) {
				System.out.println(" ");
			}
		}
		System.out.println();
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21332
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var str="";
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(" ");
var a=arr[0]-0;
var b=arr[1];
var c=arr[2]-0;
if(b==="?")break;
if(b==="+")str+=a+c;
if(b==="-")str+=a-c;
if(b==="*")str+=a*c;
if(b==="/")str+=Math.floor(a/c);
str+="\n";
}
console.log(str.trim());



Measured memory_bytes: 15348
#include <cstring>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

int N;
int top[100], bottom[100];
int dp[100][100];

int solve(int s, int e) {
  //cerr << "solve(" << s << "," << e << ")" << endl;
  int &res = dp[s][e];
  if(res != -1) return res;
  if(e - s == 1) return 0;
  res = numeric_limits<int>::max();
  for(int i = s + 1; i <= e - 1; ++i) {
    res = min(res, solve(s, i) + solve(i, e) + top[s]*bottom[i-1]*top[i]*bottom[e-1]);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> top[i] >> bottom[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, N) << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;


int func(ll m, ll n){
    if(m > n) return 0;
    string s = to_string(m);
    int c3 = 0, c5 = 0, c7 = 0;
    rep(i, s.length()){
        if(s[i] == '3') c3++;
        else if(s[i] == '5') c5++;
        else if(s[i] == '7') c7++;
    }
    int tmp = 0;
    if(c3 && c5 && c7) tmp++;
    tmp += func(m * 10 + 3, n) + func(m * 10 + 5, n) + func(m * 10 + 7, n);
    return tmp;
}

int main() {
    ll n;
    cin >> n;
    cout << func(0, n) << endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        p: [(i32, i32); n],
    }
    let s = p.iter().fold(0, |s, p| s + (p.0.abs() + p.1.abs()) % 2);
    if 0 < s && s < n as i32 {
        writeln!(out, "-1").unwrap();
        return;
    }
    let mut d = vec![];
    if s == n as i32 {
        d.push(1i32);
    }
    d.push(1);
    for i in 0..31 {
        d.push(1 << i);
    }
    d.reverse();
    writeln!(out, "{}", d.len()).unwrap();
    for (i, d) in d.iter().enumerate() {
        if i > 0 {
            write!(out, " ").unwrap();
        }
        write!(out, "{}", *d).unwrap();
    }
    writeln!(out, "").unwrap();
    for (mut x, mut y) in p {
        for &d in d.iter() {
            if x.abs() >= y.abs() {
                if x < 0 {
                    write!(out, "L").unwrap();
                    x += d;
                } else {
                    write!(out, "R").unwrap();
                    x -= d;
                }
            } else {
                if y < 0 {
                    write!(out, "D").unwrap();
                    y += d;
                } else {
                    write!(out, "U").unwrap();
                    y -= d;
                }
            }
        }
        assert!(x == 0 && y == 0);
        writeln!(out, "").unwrap();
    }
}

fn main() {
    run();
}


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

int main() {
	// your code goes here
    int w,h;
    cin>>w>>h;
    
    if(2*h >= w){
        cout<<0<<endl;
    }else{
        cout<<w-(2*h)<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
// In The Name Of God
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	while (n) {
		if (n % 10 == 9)
			return cout << "Yes" << endl, 0;
		n /= 10;
	}
	return cout << "No" << endl, 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second

string S;
string T;

bool comp(ll p) {
    for (ll i = p, j = 0; j < T.size(); ++i, ++j) {
        if (S[i] != '?' && S[i] != T[j]) {
            return false;
        }
    }
    return true;
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> S;
    cin >> T;
    rrep (i, S.size() - T.size()) {
        if (comp(i)) {
            rep (j, S.size()) {
                if (i == j) {
                    cout << T;
                    j += T.size() - 1;
                } else if (S[j] == '?') {
                    cout << 'a';
                } else {
                    cout << S[j];
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}



Measured memory_bytes: 256
import re
s = input()
K = int(input())

chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
         'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
         's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

current = ""

for i in range(K):
    if current == "":
        current = min(s)
        continue

    startIndexes = [m.start() for m in re.finditer(current, s)]
    candidates = [s[index:index+len(current)+1] for index in startIndexes]
    for candidate in candidates:
        if candidate == current:
            candidates.remove(candidate)
    if not candidates:
        current = min(s.replace(current[0], ""))
    else:
        current = min(candidates)

print(current)


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] array = new int[a];
		int count = 1;
		int z = 0;
		for(int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		for(int i = 0; i < array.length; i++) {
			z += array[i];
			if(z <= b) {
				count++;
			}	
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
ll p[1000000];
char grid[500][500];
bool flag[1000][1000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
pair<ll,ll> func(ll x,ll y,char c,pair<ll,ll> num){
	if(grid[x][y]!=c || flag[x][y]){
		return num;
	}
	if(c=='.')num.second++;
	else num.first++;
	flag[x][y]=true;
	rep(i,0,4){
		char c1;
		if(c=='.')c1='#';
		else c1='.';
		num=func(x+dx[i],y+dy[i],c1,num);
	}
	return num;
}
int main() {
	cin>>H>>W;
	rep(i,0,500){
		rep(j,0,500){
			grid[i][j]='K';
		}
	}
	rep(i,0,H){
		string s;
		cin>>s;
		rep(j,0,W){
			grid[j+1][i+1]=s[j];
		}
	}
	ans=0;
	rep(i,0,500){
		rep(j,0,500){
			if(!flag[i][j]){
				pair<ll,ll> num=func(i,j,'#',make_pair(0,0));
				//cerr<<i<<" "<<j<<" "<<num.first<<" "<<num.second<<endl;
				ans+=(num.first)*(num.second);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;
ll mod = 1e9 + 7;
int main(){
    int i,j,k,n,m,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    cin>>m>>n;
    char ch[m+5][n+5];
    ll arr[m+5][n+5];
    cin.ignore();
    for(i=0;i<m;i++) scanf("%s",ch[i]);
    memset(arr,0,sizeof arr);

    for(i=m-2;i>=0;i--){
        if(ch[i][n-1]=='#')break;
        arr[i][n-1]=1;
    }

    for(i=n-2;i>=0;i--){
        if(ch[m-1][i]=='#')break;
        arr[m-1][i]=1;
    }
    for(i=m-2;i>=0;i--){
        for(j=n-2;j>=0;j--){
            if(ch[i][j]=='#')arr[i][j]=0;
            else arr[i][j]=(arr[i][j+1]+arr[i+1][j])%mod;
        }
    }
    printf("%lld\n",arr[0][0]);
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 9088
from math import factorial

N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

orderP = 1 + (P[0]-1)*factorial(N-1)
orderQ = 1 + (Q[0]-1)*factorial(N-1)
for i in range(1,N):
  redP = 0
  redQ = 0
  for j in range(i):
    if P[j] < P[i]: redP += 1
    if Q[j] < Q[i]: redQ += 1
  orderP += (P[i]-redP-1)*factorial(N-i-1)
  orderQ += (Q[i]-redQ-1)*factorial(N-i-1)
print(abs(orderP - orderQ))

Measured memory_bytes: 62224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int X = in.nextInt();
            int Y = in.nextInt();

            int min = (int) 1e9;
            int maxXY = 2 * Math.max(X, Y) + 2;
            for (int c = 0; c < maxXY; c += 2) {
                int a = Math.max(0, X - c / 2);
                int b = Math.max(0, Y - c / 2);
                min = Math.min(min, A * a + B * b + C * c);
            }

            System.out.println(min);
        }
    }
}


Measured memory_bytes: 26852
#include "bits/stdc++.h"
using namespace std;

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

set < int > s[26];

int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n , q ;	string str ; 
	cin >> n >> str >> q ;
	int x = str.size();
	for(int i = 0 ; i < x ; ++i)
		s[str[i] -'a'].insert(i+1);
	char c  ; int y , z ;
	for(int i = 1 ; i <= q ; ++i)
	{
		cin >> x ; 
		if(x == 1)
		{
			cin >> y >> c ;
			if(str[y-1] == c) continue;
			else
			{
				s[str[y - 1] -'a'].erase(s[str[y - 1] - 'a'].find(y));
				str[y - 1] = c;
				s[c - 'a'].insert(y);
			}
		}
		else
		{
			cin >> y >> z ;
			int cnt = 0;
			for(int i = 0 ; i < 26 ; ++i)
			{
				int xx = *s[i].lower_bound(y);
				cnt += (xx <= z && xx >= y? 1 : 0);
			}
			cout << cnt << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 24348
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int nums[100000];

int main(void)
{
	scanf("%d", &N);
	for (int n = 0; n < N; ++n)
		scanf("%d", nums + n);
	sort(nums, nums + N);
	long long minabs;
	int minidx = -1;
	for (int n = 0; n < N - 1; ++n)
	{
		long long nv = abs((long long)nums[N - 1] - 2 * ((long long)nums[n]));
		if (minidx == -1 || minabs > nv)
		{
			minabs = nv;
			minidx = n;
		}
	}
	printf("%d %d", nums[N - 1], nums[minidx]);
	return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split()) 
asl = []
for _ in range(M):
    a, b = map(int, input().split()) 
    cl = list(map(int, input().split())) 
    s = 0
    for c in cl:
        s += 1<<(c-1)
    asl.append([a,s])

INF = 10**8
dp = [INF]*(2**N)
dp[0] = 0
for i in range(2**N):
    for as_v in asl:
        a, s = as_v
        dp[i|s] = min(dp[i]+a ,dp[i|s])

ans = dp[2**N-1]
if ans == INF:
    print(-1)
else:
    print(ans)


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

int main(void){
    int n;
    cin >> n;
    int array[2][n];
    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin >> array[i][j];
        }
    }
    int max = 0;
    for(int i=0; i<n; i++){
        int j = 0, sum = 0;
        while(j <= i){
            sum += array[0][j];
            j++;
        }
        j--;
        while(j < n){
            sum += array[1][j];
            j++;
        }
        if(sum > max){
            max = sum;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int N,i;
    cin>>N>>i;
    cout << N-i+1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t a,b;
  cin >> a >> b;
  int64_t ans = -1;
  for(int64_t i=100000;i >= 1;i--){
    if(floor(i * 0.08) == a && floor(i * 0.1) == b){
      ans = i;
    }
  }
  cout << ans << endl;
    
}
      
    

Measured memory_bytes: 256
S = input()
T = input()

Ls = len(S)
Lt = len(T)

dp = [[0] * (Lt + 1) for _ in range(Ls + 1)]

for i in range(Ls):
    for j in range(Lt):
        if S[i] == T[j]:
            # dp[i+1][j+1] = max(dp[i][j]+1, dp[i][j+1], dp[i+1][j])
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

match = []
now_row = Ls
now_column = Lt
while now_row > 0 and now_column > 0:
    if dp[now_row][now_column] == dp[now_row-1][now_column]:
        now_row -= 1
    elif dp[now_row][now_column] == dp[now_row][now_column-1]:
        now_column -= 1
    else:
        match.append(T[now_column-1])
        now_column -= 1
        now_row -= 1


match.reverse()
print("".join(match))

Measured memory_bytes: 112220
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;

}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>vec;
int N, x[1000], y[1000], w[1000];
int main() {
	while (true) {
		vec.clear();
		cin >> N;
		if (N == 0) { break; }
		for (int i = 0; i < N; i++) {
			cin >> w[i] >> x[i] >> y[i];
			int ok1 = 1, ok2 = 1;
			for (int j = 0; j < vec.size(); j++) {
				if (vec[i] == x[i]) { ok1 = 0; }
				if (vec[i] == y[i]) { ok2 = 0; }
			}
			if (ok1 == 1) { vec.push_back(x[i]); }
			if (ok2 == 1) { vec.push_back(y[i]); }
		}
		sort(vec.begin(), vec.end());
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < vec.size(); j++) {
				if (vec[j] == x[i]) { x[i] = j; break; }
			}
			for (int j = 0; j < vec.size(); j++) {
				if (vec[j] == y[i]) { y[i] = j; break; }
			}
		}
		int W = 0; int ok = 1;
		for (int i = 0; i < vec.size(); i++) {
			for (int j = 0; j < N; j++) {
				if (x[j] == i) { W += w[j]; }
				if (y[j] == i) { W -= w[j]; }
			}
			if (W > 150) { ok = 0; }
		}
		if (ok == 1) { cout << "OK" << endl; }
		if (ok == 0) { cout << "NG" << endl; }
	}
	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==5&&b==5)&&c==7)printf("YES");
  else if((a==5&&b==7)&&c==5)printf("YES");
  else if((a==7&&b==5)&&c==5)printf("YES");
  else printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  long ans = 0;
  // a, c, g, t
  long t[4][4][4];
  if (n == 1) {
    cout << 4 << endl;
    return 0;
  }
  if (n == 2) {
    cout << 16 << endl;
    return 0;
  }
  if (n == 3) {
    cout << 61 << endl;
    return 0;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        t[i][j][k] = 1;
      }
    }
  }
  t[0][2][1] = 0;
  t[0][1][2] = 0;
  t[2][0][1] = 0;

  long next[4][4][4];
  if (n >= 4) {
    for (int cnt = 3; cnt < n; cnt++) {
      memset(next, 0, sizeof next);
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
          for (int k = 0; k < 4; k++) {
            next[j][k][0] += t[i][j][k];
            next[j][k][3] += t[i][j][k];
            if (j != 0 || k != 1) {
              next[j][k][2] += t[i][j][k];
            }
            if (!((j == 0 && k == 2) || (j == 2 && k == 0) || (i == 0 && j == 2) || (i == 0 && k == 2))) {
              next[j][k][1] += t[i][j][k];
            }
            next[i][j][k] %= 1000000007;
          }
        }
      }
      memcpy(t, next, sizeof next);
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ans += t[i][j][k];
        ans %= 1000000007;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;


int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int mcxi_suu(string a) //??????????????°???
{
	int i, j;
	int temp; // number in front of mozi
	int sum = 0;

	queue<char> qu;

	for (i = 0; i < a.size(); i++) {
		qu.push(a[i]);
	}

	while (1) { 

		if (qu.empty() == true) {
			break;
		}

		temp = 1;

		if (qu.front() != 'm' && qu.front() != 'c' && qu.front() != 'x' && qu.front() != 'i') {
			temp = ctoi(qu.front()); //char??????int?????????????????°????????????
			qu.pop();
		}

		if (qu.front() == 'm') {
			sum = sum + temp * 1000;
		}

		if (qu.front() == 'c') {
			sum = sum + temp * 100;
		}

		if (qu.front() == 'x') {
			sum = sum + temp * 10;
		}

		if (qu.front() == 'i') {
			sum = sum + temp;
		}

		qu.pop();

	}



	return (sum);

}



string mcxi_st(int a)
{
	int i;
	int suu[4]; // [0]...1 [1]...10 [2]...100 [3]...1000
	string str;
	queue <char> qu;
	int size;
	char temp[10];

	suu[3] = a / 1000;
	a = a - 1000 * suu[3];

	suu[2] = a / 100;
	a = a - 100 * suu[2];

	suu[1] = a / 10;
	a = a - 10 * suu[1];

	suu[0] = a;

	//qu???????????????
	if (suu[3] == 1) {
		qu.push('m');
	}
	else if (suu[3] != 0) {
		sprintf(temp, "%d", suu[3]);
		qu.push(temp[0]);
		qu.push('m');
	}

	if (suu[2] == 1) {
		qu.push('c');
	}
	else if (suu[2] != 0) {
		sprintf(temp, "%d", suu[2]);
		qu.push(temp[0]);
		qu.push('c');
	}

	if (suu[1] == 1) {
		qu.push('x');
	}
	else if (suu[1] != 0) {
		sprintf(temp, "%d", suu[1]);
		qu.push(temp[0]);
		qu.push('x');
	}

	if (suu[0] == 1) {
		qu.push('i');
	}
	else if (suu[0] != 0) {
		sprintf(temp, "%d", suu[0]);
		qu.push(temp[0]);
		qu.push('i');
	}

	size = qu.size();

	for (i = 0; i < size; i++) {
		str.push_back(qu.front());
		qu.pop();
	}


	return (str);

}



int main(void)
{
	int n;
	int i, j;
	int sum = 0;
	vector<string> ans;
	string a, b; //????????????????????????
	string temp;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a >> b;

		sum = mcxi_suu(a) + mcxi_suu(b);

	

		temp = mcxi_st(sum);



		ans.push_back(temp); 



	}

	for (i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}


	return (0);
}

Measured memory_bytes: 3396
N,K = map(int,input().split(' '))
num_list = list(reversed(range(N+1))) 
sum_list_reversed = [num_list[0]]
for i in range(1,N+1):
    sum_list_reversed.append(sum_list_reversed[i-1] + num_list[i])
num_list = list(range(N+1))
sum_list = [num_list[0]]
for i in range(1,N+1):
    sum_list.append(sum_list[i-1] + num_list[i])
ans = 0

for i in range(K-1,N+1):
    current_sum = sum_list_reversed[i] - (sum_list[i] -1)
    ans += current_sum
    ans = ans%(10**9+7)
print(ans)

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

using namespace std;

void Main() {
    int N, Y;
    cin >> N >> Y;

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N - i; ++j) {
            int k = N - i - j;
            if (k * 10000 + j * 5000 + i * 1000 == Y) {
                cout << k << " " << j << " " << i << endl;
                return;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/format.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  const string pat = (boost::format("^\\d{%d}-\\d{%d}$") % A % B).str();
  const regex re(pat);
  cout << (regex_match(S, re) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};

    int main()
    {
    int n;
    cin>>n;
    int cost[100005];
    vector<int> h(n,0);
    REP(i,n) {cin>>h[i];}
    cost[0]=0;
    cost[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++)
    {
        cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
    }
        cout<<cost[n-1]<<endl;
    }

Measured memory_bytes: 1024
function main()
    X, K, D = parse.(BigInt, split(readline()))
    X = abs(X)

    if X >= K*D
        println(X - K*D)
    else
        n = X ÷ D
        if iseven(K - n)
            println(X - n*D)
        else
            println(abs(X - (n+1)*D))
        end
    end

end

main()

Measured memory_bytes: 180036
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  string s;
  cin >> s;
  map<int, int> m;
  rep(i, 4) {
    if (m.find(s[i]) == m.end()) {
      m[s[i]] = 1;
    } else {
      m[s[i]]++;
    }
  }
  bool ok = true;
  if (m.size() == 2) {
    for (auto &x : m) {
      if (x.second != 2) {
        ok = false;
      }
    }
  } else {
    ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 888
H, W, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]

takasa = [0]*(H)
haba = [0]*(W)

for i in range(M):
    takasa[A[i][0]-1] += 1
    haba[A[i][1]-1] += 1

mt = max(takasa)
mh = max(haba)
ct = takasa.count(mt)
ch = haba.count(mh)

a = 0
for i in range(M):
    if takasa[A[i][0]-1] == mt and haba[A[i][1]-1] == mh:
        a += 1

if a == ct*ch:
    print(mt+mh-1)
else:
    print(mt+mh)

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

int main(){
  int64_t n,f=114514;
  cin >>n;
  for(int64_t i=1;i<=(int64_t)sqrt(n)+1;i++){
    if(n%i != 0) continue;
    int64_t b = n/i;
    f = min(f, (int64_t)max(to_string(i).size(),to_string(b).size()));
  }
  cout << f << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
def run():
    K = int(input())
    S = input()
    if K >= len(S):
        print(S)
    else:
        print(S[:K]+str('...'))
if __name__ == "__main__":
    run()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,x,y,sum=0;
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        sum+=(x*k);
        sum+=((n-k)*y);
    }
    else
    {
        sum+=(n*x);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3620
N = int(input())
dp = [[0] * 3 for _ in range(N + 1)]

for i in range(1, N + 1):
    ipt = list(map(int, input().split()))
    for j in range(3):
        if j != 0:
            dp[i][j] = max(dp[i][j], dp[i - 1][0] + ipt[j])
        if j != 1:
            dp[i][j] = max(dp[i][j], dp[i - 1][1] + ipt[j])
        if j != 2:
            dp[i][j] = max(dp[i][j], dp[i - 1][2] + ipt[j])

print(max(dp[N][0], dp[N][1], dp[N][2]))


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
const ll max_n = 1000000000;
bool boggo[max_n];
bool totrue(int k){
    if(boggo[k] == false){
        boggo[k] = true;
      }else{
        boggo[k] = false;
          totrue(k + 1);
        }
  }

int main(){
  int n;
  int a,b;
  cin >> n;
  REP(i,n){
    cin >> a >> b;
    totrue(a + b);
    }
  REP(i, max_n){
      if(boggo[i] == true){
          cout << i << " 0" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3252
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#define TASK ""

using namespace std;

typedef long long ll;
typedef long double ld;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((long long)(x).size())
const ld eps = 1e-19 * 0.9;
const ll inf = numeric_limits<ll>::max() / 2 - 1;
const ll mod = 1000000007;
const ll maxn = 150001;

inline int run() {
    ll n;
    cin >> n;
    ll l = 0;
    ll r = n + 10;
    while (l + 1 != r) {
        ll mid = (l + r) >> 1;
        if (mid * (mid + 1) / 2 >= n) r = mid;
        else l = mid;
    }
    cout << r << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    if (strlen(TASK) > 0) {
        freopen(TASK".in", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }
#endif
    run();
    cerr << clock() * 1000 / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){cout<<"Alice";}
    else{cout<<"Borys";}
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

/////////////////////////////////////////////////////////

ll rec(ll a, ll b){
  if(a > b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
  if(b % a == 0) return (2 * (b / a) - 1) * a;
  return 2 * (b / a) * a + rec(a, b % a);
}

void Main() {
  ll N, X; cin >> N >> X;
  cout << N + rec(X, N - X) << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

#define WORD_MAX 31
#define DATASET_MAX 100

void initialize_c(char array[][WORD_MAX], int y, int x);
void initialize_d(int array[][DATASET_MAX], int y, int x);
void sorting(char w[][WORD_MAX], int p[][DATASET_MAX], int n);
void moving(char w[][WORD_MAX], int p[][DATASET_MAX], int n);
void bubble(int p[], int n);
void output(char w[][WORD_MAX], int p[][DATASET_MAX], int n);

main()
{
	int n = 0; //入力回数をカウント
	char word[DATASET_MAX][WORD_MAX];
	int page[DATASET_MAX][DATASET_MAX];
	initialize_c(word, DATASET_MAX, WORD_MAX); //char型配列の初期化
	initialize_d(page, DATASET_MAX, DATASET_MAX); //int型配列の初期化
	while(scanf("%s %d", word[n], &page[n][0]) != EOF)
	{
		n++;
	}
	sorting(word, page, n);
	moving(word, page, n);
	output(word, page, n);
	return 0;
}
void initialize_c(char array[][WORD_MAX], int y, int x)
{
	int i = 0, j = 0;
	for(i = 0; i < y; i++)
	{
		for(j = 0; j < x; j++)
		{
			array[i][j] = 0x00; //ヌル文字を代入
		}
	}
}
void initialize_d(int array[][DATASET_MAX], int y, int x)
{
	int i = 0, j = 0;
	for(i = 0; i < y; i++)
	{
		for(j = 0; j < x; j++)
		{
			array[i][j] = 1001; //page番号は1000まで
		}
	}
}
void sorting(char w[][WORD_MAX], int p[][DATASET_MAX], int n)
{
	int i = 0, j = 0;
	char temp_c[WORD_MAX]; //入れ替え用(char型)
	for(i = 0; i < WORD_MAX; i++) //初期化
	{
		temp_c[i] = 0x00;
	}
	int temp_d = 0; //入れ替え用(int型)
	/*
	for(i = 0; i < n; i++)
	{
		printf("w[%d] = %s p[%d] = %d\n", i, w[i], i, p[i][0]);
	}
	*/
	for(i = 0; i < n; i++)
	{
		for(j = i + 1; j < n; j++)
		{
			if(strcmp(w[j], w[i]) < 0)
			{
				strcpy(temp_c, w[i]); //文字列の入れ替え
				strcpy(w[i], w[j]);
				strcpy(w[j], temp_c);
				temp_d = p[i][0]; //ページ場号の入れ替えも同時に行う
				p[i][0] = p[j][0];
				p[j][0] = temp_d;
			}
		}
	}
	/*
	for(i = 0; i < n; i++)
	{
		printf("w[%d] = %s p[%d] = %d\n", i, w[i], i, p[i][0]);
	}
	*/
}
void moving(char w[][WORD_MAX], int p[][DATASET_MAX], int n)
{
	int i = 0, j = 0, k = 0;
	for(i = 0; i < n; i++)
	{
		for(j = i + 1; j < n; j++)
		{
			if(strcmp(w[i], "\0") == 0)
			{
				break;
			}
			if(strcmp(w[i], w[j]) == 0)
			{
				k++;
				p[i][k] = p[j][0];
				strcpy(w[j], "\0"); //ヌル文字代入
			}
		}
		k = 0;
	}
}
void bubble(int p[], int n)
{
	int temp = 0;
	int i = 0, j = 0;
	for(i = 0; p[i + 1] != 1001; i++)
	{
		for(j = i + 1; p[j] != 1001; j++)
		{
			if(p[i] > p[j])
			{
				temp = p[i];
				p[i] = p[j];
				p[j] = temp;
			}
		}
	}
}
void output(char w[][WORD_MAX], int p[][DATASET_MAX], int n)
{
	int i = 0, j = 0;
	for(i = 0; i < n; i++)
	{
		if(strcmp(w[i], "\0") == 0)
		{
			//printf("continue\n");
			continue;
		}
		else
		{
			printf("%s\n", w[i]);
			bubble(p[i], n);
			for(j = 0; p[i][j] != 1001; j++)
			{
				if(p[i][j + 1] != 1001)
				{
					printf("%d ", p[i][j]);
				}
				else
				{
					printf("%d\n", p[i][j]);
				}
			}
		}
	}
}

Measured memory_bytes: 672
S2 = input()
T = input()
N = len(S2)

Tplace = {i:False for i in range(N)}
#print(Tplace)

for i in range(N-len(T)+1):
  counter = 0
  for j in range(len(T)):
    if S2[i+j] == T[j] or S2[i+j] == "?":     
      counter += 1
#      print(S2[i+j],T[j],counter)
      continue
    else:
#      print(2,i,j,S2[i+j])
      break
#  print(3)
  if counter == len(T):
    Tplace[i] = True
#print(Tplace)

ans = []

for key, value in Tplace.items():
  if value:
    tmp = S2[:key] + T + S2[key+len(T):] 
    tmp2 = tmp.replace('?', 'a')
    ans.append(tmp2)
ans.sort()
print(ans[0] if len(ans) > 0 else "UNRESTORABLE")
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (w >= v)
    {
        cout << "NO" << endl;
    }
    else
    {
        ll vec = v - w;
        if (abs(a - b) <= vec * t)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3640