akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >>n;
    string s;
    cin >> s;
    vector<int>siro(n+1,0),kuro(n+1,0);
    for(int i=0;i<n;i++){
        if(s.at(i)=='.'){
            siro.at(i+1)++;
        }
        siro.at(i+1)+=siro.at(i);
    }
    reverse(s.begin(),s.end());
    for(int i=0;i<n;i++){
        if(s.at(i)=='#'){
            kuro.at(i+1)++;
        }
        kuro.at(i+1)+=kuro.at(i);
    }   
    reverse(s.begin(),s.end());
    reverse(kuro.begin(),kuro.end());
    int ans = 1e8;
    for(int i=0;i<=n;i++){
        ans = min(ans,(n-i-kuro.at(i))+i-siro.at(i));
    }
    cout << ans << endl;
}
    



Measured memory_bytes: 2180
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

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

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [usize; n]
    };
    let mut p = p;
    p.sort();
    let mut ans = 0;
    for i in 0..k {
        ans += p[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    int a=-1,ans=0;
    for(int i=0;i<s.size();i++){
        if(a<0&&s[i]=='A') a=i;
        if(a>=0&&s[i]=='Z') ans=max(ans,i-a);
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
 
int main()
{
 int num[10]; 
 int i = 0;
 int n;
 while(scanf("%d",&n) != EOF)
 {
  if(n == 0)
  {
   printf("%d\n",num[i-1]);
   i -= 2;
  }else num[i] = n;
  i++;
 }
 return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long m = scanner.nextLong();
        long answer = n * 2 >= m ? m / 2 : (n * 2 + m) / 4;
        System.out.println(answer);
    }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;

constexpr int INF = 1001001001;
int N, M, P;
int A[5100], B[5100], C[5100];
std::vector<int> G[2600], rG[2600];
bool used[2600], re1[2600], reN[2600];
int d[2600];

int calc(){
    std::fill(d, d + N, INF);
    d[0] = 0;

    for(int i=1;i<=N;++i){
        bool updated = false;

        for(int j=0;j<M;++j){
            if(!(re1[A[j]] && reN[B[j]])){continue;}

            if(d[B[j]] > d[A[j]] + C[j]){
                d[B[j]] = d[A[j]] + C[j];
                updated = true;
            }
        }

        if(updated && i == N){
            return -1;
        }
    }

    return std::max(-d[N-1], 0);
}

void dfs(int v, std::vector<int> (&G)[2600], bool (&re)[2600]){
    used[v] = true;
    re[v] = true;

    for(int w : G[v]){
        unless(used[w]){
            dfs(w, G, re);
        }
    }
}

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

  std::cin >> N >> M >> P;

  for(int i=0;i<M;++i){
      std::cin >> A[i] >> B[i] >> C[i];

      A[i] -= 1;
      B[i] -= 1;
      C[i] = P - C[i];

      G[A[i]].emplace_back(B[i]);
      rG[B[i]].emplace_back(A[i]);
  }

  dfs(0, G, re1);
  memset(used, 0, sizeof(used));
  dfs(N - 1, rG, reN);

  std::cout << calc() << std::endl;
}


Measured memory_bytes: 768
# encoding: utf-8
import sys
# input = sys.stdin.readline

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

d.sort()

if d[N // 2] > d[N // 2 - 1]:
    print(d[N // 2] - d[N // 2 - 1])
else:
    print(0)

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

using namespace std;


#ifdef CLION

ifstream ifs("/home/kyuridenamida/CLionProjects/untitled4/input.txt");
#define cin ifs
#define scanf DONT_USE_SCANF
#endif

typedef long long ll;

bool dp_[2][1 << 24];

int main() {
    int n;
    cin >> n;
    int determined = 1;
    int cnt[13] = {};
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        cnt[v]++;
    }

    vector<int> V;
    for (int i = 0; i <= 12; i++) {
        if (i == 0 && cnt[i] >= 1) {
            cout << 0 << endl;
            return 0;
        } else if (cnt[i] >= 3) {
            cout << 0 << endl;
            return 0;
        } else if (cnt[i] >= 2) {
            determined = determined | (1 << i) | (1 << (24 - i));
        } else if (cnt[i] == 1) {
            V.push_back(i);
        }

    }
    bool *dp = dp_[0];
    bool *ndp = dp_[1];
    dp[0] = 1;
    for (int i = 0; i < V.size(); i++) {
        memset(ndp, 0, sizeof(dp_[0]));
        for (int j = (1 << 24) - 1; j >= 0; j--) {
            ndp[j | (1 << V[i])] |= dp[j];
            ndp[j | (1 << (24 - V[i]))] |= dp[j];
        }
        swap(ndp, dp);
    }


    int gans = 0;
    for (int i_ = 0; i_ < (1 << 24); i_++) {
        if (dp[i_]) {
            int i = i_ | determined;
            int ans = 1e9;
            for (int k = 0; k <= 24; k++) {
                for (int j = k + 1; j <= 24; j++) {
                    if ((i >> k & 1) && (i >> j & 1)) {
                        ans = min(ans, min(abs(k - j), 24 - abs(k - j)));
                    }
                }
            }
            gans = max(ans, gans);
        }
    }
    cout << gans << endl;
}



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

struct Edge {
	int from, to;
	Edge(int f, int t) : from(f), to(t) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;
pair<vector<int>, Edges> bridge(const Graph& g) {
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	vector<int>ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	Edges brdg;
	function<void(int, int)> dfs = [&](int v, int u) {
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for (auto& e : g[v]) {
			int w = e.to;
			if (ord[w] == -1)dfs(w, v);
			else if (u != w && onS[w])
				while (ord[roots[t - 1]]>ord[w])--t;
		}
		if (v == roots[t - 1]) {
			brdg.emplace_back(u, v);
			while (true) {
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if (v == w)break;
			}
			--t;
			++k;
		}
	};
	for (int u = 0; u<n; ++u) {
		if (ord[u] == -1) {
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return make_pair(cmp, brdg);
}

int main()
{
	int V, E;
	cin >> V >> E;
	Graph G(V);
	for (int i = 0, s, t; i < E; i++) {
		cin >> s >> t;
		G[s].emplace_back(s, t);
		G[t].emplace_back(t, s);
	}
	auto br = bridge(G);
	vector<pair<int, int>> res;
	for (auto& e : br.second) {
		res.emplace_back(min(e.from, e.to), max(e.from, e.to));
	}
	sort(res.begin(), res.end());
	for (auto p : res) {
		cout << p.first << ' ' << p.second << endl;
	}
	return 0;
}

Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n{};
    long long sum{};
    cin >> n;
    for(int i=1; i<=n; i++) {
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std ;
int main(){
	string s , t ;
	cin >> s >> t ;
	int n = s.length() ;
	int m = t.length() ;
	int ans = n ;
	for(int i = 0 ; i < n-m+1 ; i++){
	    int cnt = 0 ;
		for(int j = 0 ; j < m ;j++){
			if(t[j] != s[i + j]) cnt++;
		}
	 ans = min(ans , cnt);
	}
	cout << ans ;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
	#define ll long long int
	using namespace std;
	const long double pi = 3.14159265358979323;
	const double EPS = 1e-9;
	const int N = 1e6 + 5;
	const int MOD = 1e9 + 7;

	ll h[200];
	
	int main(){
		fast;
		string s;
		cin >> s;
		ll k, len = 0;
		cin >> k;
		for(int i = 1; i <= (int)s.size(); i++){
			if(s[i - 1] == '1') h[i] = 1;
			else{ 
				h[i] = 1e18 + 2;
				break;
			}
		}
		for(int i = 1; i <= (int)s.size(); i++){
			len += h[i];
			if(len >= k)
				return cout << s[i - 1], 0;
		}
		return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong N, M, a[100020];

llong ANS[100020];

const llong MOD = 1000000007;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i];
	}
	a[M] = MOD;
	ANS[0] = 1;

	if (a[0] == 1) ANS[1] = 0;
	else ANS[1] = 1;

	int counter = 0;

	for (int i = 2; i <= N; i++) {
		for (;;) {
			if (a[counter] < i) counter++;
			else break;
		}

		if (a[counter] == i) {
			ANS[i] = 0;
		}

		else {
			ANS[i] = ANS[i - 1] + ANS[i - 2];
			ANS[i] %= MOD;
		}
	}

	ANS[N] %= MOD;

	cout << ANS[N];
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

use rand::prelude::*;

const CN: usize = 26;

fn calc(cv: &[isize], sv: &[Vec<isize>], tv: &[usize]) -> isize {
    let mut last = vec![0; CN];
    let mut res = 0;
    for i in 0..sv.len() {
        let t = tv[i];
        res += sv[i][t];
        last[t] = i + 1;
        for j in 0..CN {
            res -= cv[j] * (i + 1 - last[j]) as isize;
        }
    }
    res
}

fn gen_tv(rng: &mut rand::rngs::ThreadRng, d: usize) -> Vec<usize> {
    (0..d)
        .into_iter()
        .map(|_| rng.gen::<usize>() % CN)
        .collect::<Vec<_>>()
}

fn main() {
    input! {
        d: usize,
        cv: [isize; CN],
        sv: [[isize; CN]; d],
    };

    let mut rng = rand::thread_rng();
    let mut tv = gen_tv(&mut rng, d);
    let mut res = calc(&cv, &sv, &tv);
    for _ in 0..20000 {
        let tv2 = gen_tv(&mut rng, d);
        let p = calc(&cv, &sv, &tv2);
        if p > res {
            tv = tv2;
            res = p;
        }
    }
    for _ in 0..370000 {
        let di = rng.gen::<usize>() % d;
        let q = rng.gen::<usize>() % CN;
        let old = tv[di];
        tv[di] = q;
        let p = calc(&cv, &sv, &tv);
        if p > res {
            res = p;
        } else {
            tv[di] = old;
        }
    }
    println!("{}", tv.into_iter().map(|x| x + 1).join("\n"));
}


Measured memory_bytes: 2740
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF = 10**8
n = INT()
B = LIST()
B.append(INF)
ans = B[0]
for i in range(n-1):
  ans += min(B[i], B[i+1])
 
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N, M;
vector<int> s, c;

bool ok(string str) {
    if (str.size() != N) return false;
    for (int i = 0; i < M; ++i) {
        if (str[s[i]] != (char)(c[i] + '0')) return false;
    }
    return true;
}

string solve() {
    for (int i = 0; i <= 999; ++i) {
        stringstream iss;
        iss << i;
        string str = iss.str();
        //COUT(str);
        if (ok(str)) return str;
    }
    return "-1";
}

int main() {
    while (cin >> N >> M) {
        s.resize(M); c.resize(M);
        for (int i = 0; i < M; ++i) cin >> s[i] >> c[i], --s[i];
        cout << solve() << endl;
    }
}


Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
K = lines[0][1]

for i in 1..N-K do
  if lines[1][K+i-1] > lines[1][i-1] then
    puts "Yes"
  else
    puts "No"
  end
end

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

void print_arr(vector<int> &a){
    rep(i,a.size()-1){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[a.size()-1]);
}

void bubble_sort(vector<int> &a){
    bool flag = true;
    int swaps = 0;
    while(flag){
        flag = false;
        for(int i=(int)a.size()-1; i>0; i--){
            if(a[i] < a[i-1]){
                int temp = a[i];
                a[i] = a[i-1];
                a[i-1] = temp;
                flag = true;
                swaps++;
            }
        }
    }
    print_arr(a);
    cout << swaps << endl;
}

int main(){
    int n; cin >> n;
    vector<int> a(n); collect(a, n);
    bubble_sort(a);
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;

int main(){
  
  int n;
  std::cin >> n;
  double a[n];
  rep(i,n)std::cin >> a[i];
  //std::cout << a[1] << std::endl;
  double w=0;
  rep(i,n){w+=(1/(a[i]));}
  
  
  

  std::cout << 1/w << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

 if (S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(0) == S.at(2)){
  cout << "No" << endl;
 }
  
  else {
    cout << "Yes" << endl;
 }
}





Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int A,B,K;
	int i;
	int cnt;
	
	cin >> A >> B >> K;
	
	cnt=0;
	for(i=min(A,B); i>=0; i--){
		if(A%i==0 && B%i==0){
			cnt++;
			
			if(cnt==K){
				cout << i << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int i,int j){
  return (i%j==0) ? j:gcd(j,i%j);
}

int main()
{
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int ans=A[0];
  for(int i=1;i<N;i++){
    ans=gcd(ans,A[i]);
  }
  cout<<ans;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,M;
    cin>>N>>M;
    vector<tuple<ll,ll,ll>> vec(M);
    rep(i,M){
        ll p,y;
        cin>>p>>y;
        vec[i]=make_tuple(p,y,i);
    }
    sort(all(vec));
    map<ll,ll> m;
    vs Ans(M);
    rep(i,M){
        ll a=get<0>(vec[i]);
        m[a]++;
        ll b=m[a];
        ll c=get<2>(vec[i]);
        string F,L;
        F=to_string(a);
        L=to_string(b);
        while(F.size()<6){
            F='0'+F;
        }
        while(L.size()<6){
            L='0'+L;
        }
        Ans[c]=F+L;
    }
    rep(i,M){
        cout<<Ans[i]<<endl;
    }
}


Measured memory_bytes: 14876
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func calc(h []int, A, B, n int) bool {
	m := int64(n)
	for _, v := range h {
		if m < 0 {
			return false
		}
		var u int64 = int64(v) - int64(B)*int64(n)
		if u <= 0 {
			break
		}
		a := int64(A - B)
		l := u / a
		if u%a != 0 {
			l++
		}
		m -= l
	}
	if m < 0 {
		return false
	}
	return true
}

func main() {
	defer stdout.Flush()

	N := readInt()
	A := readInt()
	B := readInt()
	h := make([]int, N)
	for i := range h {
		h[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(h)))

	//eprintln(A, B)
	//eprintln(h)

	l := 0
	r := h[0]/B + 1

	for l < r {
		m := (l + r) / 2
		able := calc(h, A, B, m)
		if able {
			r = m
		} else {
			l = m + 1
		}
	}
	println(r)
}


Measured memory_bytes: 3072
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

n, m = map(int, input().split())

t = [0] * (m+1)

for _ in range(n):
    ka = [int(x) for x in input().split()]
    for a in ka[1:]:
        t[a] += 1

print(sum(1 for x in t if x == n))

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

int main(){
  int n, m, ans=0, a, b;
  cin>>n >>m;
  int h[n], ma[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
    ma[i]=0;
  }
  
  for(int i=0;i<m;i++){
    cin>>a >>b;
    a--; b--;
    ma[a]=max(ma[a], h[b]);
    ma[b]=max(ma[b], h[a]);
  }
  
  for(int i=0;i<n;i++){
    ans+=h[i]>ma[i];
  }
  
  cout<<ans<<endl;
  return 0;
}

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

bool triangles(int a, int b, int c){
    if(a<(b+c) && b<(c+a) && c<(a+b)){ return true;}
    else{return false;}
}

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ans=0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int r=j+1; r<n; r++){
                if(triangles(l[i], l[j], l[r])==true){ans++;}
                else{continue;}
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if(a>9){
    cout << "-1" << endl;
  }
  else if(b>9){
    cout << "-1" << endl;
  }
  else{
    cout << a * b << endl;
  }
}


Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TheLastAnt solver = new TheLastAnt();
        try {
            int testNumber = 1;
            while (true)
                solver.solve(testNumber++, in, out);
        } catch (UnknownError e) {
            out.close();
        }
    }

    static class TheLastAnt {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int l = in.nextInt();
            if (n == 0 && l == 0) throw new UnknownError();
            int last = 0;
            int[] ltunnel = new int[l];
            int[] rtunnel = new int[l];
            for (int i = 0; i < n; i++) {
                String d = in.next();
                int p = in.nextInt();
                if (d.equals("R")) {
                    last = Math.max(last, l - p);
                    rtunnel[p] = i + 1;
                } else {
                    last = Math.max(last, p);
                    ltunnel[p] = i + 1;
                }
            }
            int[] newltunnel, newrtunnel;
            int cnt = n, lastant = -1;
            while (true) {
                //outArray(ltunnel);
                //outArray(rtunnel);
                if (cnt == 0) {
                    out.println(last + " " + lastant);
                    return;
                }
                newltunnel = new int[l];
                newrtunnel = new int[l];
                Arrays.fill(newltunnel, 0);
                Arrays.fill(newrtunnel, 0);
                for (int i = 0; i < l; i++) {
                    if (rtunnel[i] != 0) {
                        if (i + 1 != l) newrtunnel[i + 1] = rtunnel[i];
                        else {
                            lastant = rtunnel[i];
                            cnt--;
                        }
                    }
                    if (ltunnel[i] != 0) {
                        if (i != 0) newltunnel[i - 1] = ltunnel[i];
                        else {
                            lastant = ltunnel[i];
                            cnt--;
                        }
                    }
                }
                for (int i = 0; i < l; i++) {
                    if (newltunnel[i] != 0 && newrtunnel[i] != 0) {
                        final int buf = newrtunnel[i];
                        newrtunnel[i] = newltunnel[i];
                        newltunnel[i] = buf;
                    }
                }
                ltunnel = newltunnel;
                rtunnel = newrtunnel;
            }
        }

    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

    ll n;cin >> n;
    map<string, int> mp;

    REP(i, n){
        string str;cin >> str;
        mp[str]++;
    }

    vector<pair<int, string>> v;

    for(auto it: mp){
        v.EB(-it.SE, it.FI);
    }

    sort(ALL(v));

    REP(i, v.size()){
        if(i != 0 && v[i].FI != v[i-1].FI)break;
        cout << v[i].SE << endl;
    }

	return 0;
}


Measured memory_bytes: 28144
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;

// 最大公約数
ll d(int f, int s)
{
  if(s<f)
    swap(s,f);
    if (s % f == 0)
        return f;
    else
        return d(s % f, f);
}
int main()
{
    int N;
    cin >> N;
    vector<ll> A;
ll common;
  cin>>common;
    for (int i = 1; i < N; i++)
    {
        ll ai;
        cin >> ai;
        common=d(common,ai);
    }
    cout << common << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
x=list(map(int,input().split()))
tmin=1000000000
for i in range(N-K+1):
    a=x[i+K-1]
    b=x[i]
    res=a-b+min([abs(a),abs(b)])
    if tmin>res:
        tmin=res
print(tmin)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
vector<int> mm2[1000001];

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    vector<int> isp(1000001, 1);
    vector<int> mm(1000001, 0);
    for(int i=2; i<1000000; i++) {
        if(isp[i]) {
            mm2[i].push_back(i);
            for(int j=i+i; j<=1000000; j+= i) isp[j] = 0, mm2[j].push_back(i);
        }
    }
    int n; cin >> n;
    for(int i=0; i<n; i++) {
        int a; cin >> a;
        for(int x:mm2[a]) {
            mm[x]++;
        }
    }
    int ok = 0;
    for(int i=1; i<= 1000000; i++) {
        if(mm[i] == n) {
            cout << "not coprime" << endl;
            return 0;
        }
        if(mm[i] > 1) {
            ok = 1;
        }
    }
    if(ok) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "pairwise coprime" << endl;
    }
}


Measured memory_bytes: 66532
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	SORT(A);
	int ans = 0;
	bool F[1000010] = { false };
	bool FF[1000010] = { false };
	REP(i, N) {
		int n = A[i];
		bool f = 1;
		if (F[n] && !FF[n]) {
			//cout << n << endl;
			ans--;
			FF[n] = 1;
			continue;
		}


		for (int i = 1; i*i <= n; ++i)
		{
			if (n%i == 0)
			{
				if (F[i]) {
					f = 0;
					FF[n] = 1;
					break;
				}
				if (i*i != n)
				{
					if (F[n / i]) {
						f = 0;
						FF[n] = 1;
						break;
					}
				}
			}
		}
		F[A[i]] = 1;
		if (f)ans++;

	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 6628
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

N,K = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = N % K
ans2 = (ans1 - K) * -1
# print(ans1,ans2)
print(min(ans1,ans2))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll out = 0;
    ll a = 0;
    ll b = 0;
    ll ab = 0;
    ll ba = 0;
    rep(i,N){
        string s;
        cin >> s;
        if(s[0]=='B') b++;
        if(s[s.size()-1]=='A') a++;
        rep(j,s.size()-1){
            if(s[j]=='A'&&s[j+1]=='B') ab++;
        }
        if(s[0]=='B'&&s[s.size()-1]=='A') ba++;
    }
    out = min(a,b)+ab;
    if(ba>0&&a==ba&&b==ba) out--;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3640
def getlist():
	return list(map(int, input().split()))

N = int(input())
a = getlist()
L = [0] * N
ans = []

c = 0
for i in range(N):
	x = int(N // (N - i))
	val = 0
	for j in range(1, x):
		if L[(N - i) * (j + 1) - 1] == 1:
			val += 1
	if val % 2 != a[N - 1 - i]:
		L[N - 1 - i] = 1
		ans.append(N - i)
		c += 1

print(c)
ans = list(map(str, ans))
print(" ".join(ans))

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

using namespace std;

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

  int n, a, res = 0; 
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    res += a-1;
  }

  cout << res << endl;


  return 0;
}



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

typedef struct List {
	struct List *next;
	int v;
} list;

int DFS(list** adj, int s, int flag[])
{
	int size = flag[s];
	list *p;
	for (p = adj[s]; p != NULL; p = p->next) {
		if (flag[p->v] == 0) {
			flag[p->v] = -flag[s];
			size += DFS(adj, p->v, flag);
		} else if (flag[p->v] == flag[s]) return -100000;
	}
	return size;
}

int main()
{
	int i, u, w, N, M, mat[701][701] = {};
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		scanf("%d %d", &u, &w);
		mat[u][w] = 1;
		mat[w][u] = 1;
	}
	
	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *d = (list*)malloc(sizeof(list) * (N * (N - 1) - M * 2));
	for (u = 1, i = 0; u < N; u++) {
		for (w = u + 1; w <= N; w++) {
			if (mat[u][w] == 0) {
				d[i*2].v = w;
				d[i*2+1].v = u;
				d[i*2].next = adj[u];
				d[i*2+1].next = adj[w];
				adj[u] = &(d[i*2]);
				adj[w] = &(d[i*2+1]);
				i++;
			}
		}
	}
	
	int k, flag[701] = {}, size[701];
	for (i = 1, k = 0; i <= N; i++) {
		if (flag[i] != 0) continue;
		flag[i] = 1;
		size[++k] = DFS(adj, i, flag);
		if (size[k] < -1000) break;
		else size[k] = abs(size[k]);
	}
	if (i <= N) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int j, l[2], dp[2][1401] = {}, pos[2][701];
	for (i = 1, l[0] = 1, dp[0][N] = 1, pos[0][0] = N; i <= k; i++) {
		l[i%2] = 0;
		for (j = 0; j < l[1-i%2]; j++) {
			if (pos[1-i%2][j] >= size[i] && dp[i%2][pos[1-i%2][j] - size[i]] == 0) {
				dp[i%2][pos[1-i%2][j] - size[i]] = 1;
				pos[i%2][l[i%2]++] = pos[1-i%2][j] - size[i];
			}
			if (pos[1-i%2][j] <= N * 2 - size[i] && dp[i%2][pos[1-i%2][j] + size[i]] == 0) {
				dp[i%2][pos[1-i%2][j] + size[i]] = 1;
				pos[i%2][l[i%2]++] = pos[1-i%2][j] + size[i];
			}
			dp[1-i%2][pos[1-i%2][j]] = 0;
		}
	}
	
	for (i = N; i >= 0; i--) if (dp[k%2][i] == 1) break;
	for (j = N; j <= N * 2; j++) if (dp[k%2][j] == 1) break;
	j = (N - i > j - N)? j - N: N - i;
	printf("%d\n", ((N + j) * (N + j - 2) + (N - j) * (N - j - 2)) / 8);
	fflush(stdout);
	return 0; 
}

Measured memory_bytes: 9728
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CGoToSchool {
public:
	void solve(std::istream& in, std::ostream& out) {
        int  n;
        in >> n;
        vector<pair<int,int>> a(n);
        rep(i,n){
            in >> a[i].first;
            a[i].second=i+1;
        }
        sort(a.begin(),a.end());
        rep(i,n){
            out << a[i].second << " ";
        }out << endl;
	}
};


int main() {
	CGoToSchool solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

int main(){
	ll n;
	ll a[1010];
	scanf("%lld",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&a[i]);
	}
	
	ll sum[2] = {};
	for(int i = 0 ; i < n ; i ++){
		if(a[i]>0)sum[i&1] += a[i];
	}
	vector<ll> vec;
	for(int i = 0 ; i < n ; i ++){
		vec.push_back(a[i]);
	}
	vector<ll> ans;
	
	bool ok = false;
	for(int i = 0 ; i < n ; i ++){
		if(a[i] > 0)ok = true;
	}
	if(!ok){
		int MAX = -1000000009;
		int x = -1;
		for(int i = 0 ; i < n ; i ++){
			if(MAX < a[i]){
				MAX = a[i];
				x = i;
			}
		}
		if(x&1){
			sum[1] = MAX;
			sum[0] = -1000000009;
		}
		else {
			sum[1] = -1000000009;
			sum[0] = MAX;
		}
		vec[x] = 1;
	}
	
	if(sum[0] < sum[1]){
		int loc = 1;
		int len = n;
		while(loc < len){
			if(vec[loc] < 0){
				ans.push_back(loc);
				if(loc+1 != len){
					vec.erase(vec.begin()+loc-1,vec.begin()+loc+1);
					len -= 2;
				}
				else {
					vec.erase(vec.begin()+loc,vec.end());
					len -= 1;
				}
			}
			else loc += 2;
		}
		ans.push_back(0);
		len --;
		while(1 < len){
			ans.push_back(1);
			len -= 2;
		}
	}
	else {
		//puts("DEBUG");
		int loc = 0;
		int len = n;
		while(loc < len){
			if(vec[loc] < 0){
				ans.push_back(loc);
				if(loc != 0){
					if(loc+1 != len){
						vec.erase(vec.begin()+loc-1,vec.begin()+loc+1);
						len -= 2;
					}
					else {
						vec.erase(vec.begin()+loc-1,vec.end());
						len -= 1;
					}
				}
				else {
					vec.erase(vec.begin(),vec.begin()+1);
					len --;
					loc ++;
				}
			}
			else loc += 2;
		}
		
		/*cout << ans.size() << " ";
		for(int i = 0 ; i < ans.size() ; i ++){
			cout << ans[i]+1 << endl;
		}*/
		
		if(loc&1){
			ans.push_back(0);
			len --;
		}
		
		/*cout << ans.size() << " ";
		for(int i = 0 ; i < ans.size() ; i ++){
			cout << ans[i]+1 << endl;
		}*/
		
		while(len>1){
			ans.push_back(1);
			len -= 2;
		}
		
		/*cout << ans.size() << " ";
		for(int i = 0 ; i < ans.size() ; i ++){
			cout << ans[i]+1 << endl;
		}*/
	}
	
	cout << max(sum[0],sum[1]) << endl;
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size() ; i ++){
		cout << ans[i]+1 << endl;
	}
}



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

namespace CircleInRectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var w_h_x_y_r = Console.ReadLine().Split(new char[] { ' ' }).Select(n => decimal.Parse(n)).ToList();
            var w = w_h_x_y_r[0];
            var h = w_h_x_y_r[1];
            var x = w_h_x_y_r[2];
            var y = w_h_x_y_r[3];
            var r = w_h_x_y_r[4];

            if (x <= 0 || y <= 0)
            {
                Console.WriteLine("No");
                return;
            }

            if (x - r < 0 || y - r < 0)
            {
                Console.WriteLine("No");
                return;
            }

            if (x + r > w || y + r > h)
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
        }
    }
}



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

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

int main(){

	int N;
	int a;
	bool judge = true;

	cin >> N;

	for(int i=0; i < N; ++i){
		cin >> a;
		if(a%2==0){
			if(a%3 != 0 && a%5 != 0){judge = false; break;}
		}
	}

	judge ? cout << "APPROVED" << endl : cout << "DENIED" << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;



int a,b,c,d,n,m;
bool vis[1002][1002];
char mat[1002][1002];

bool valid(int i,int j) {
    return i>=1 && j>=1 && i<=n && j<=m;
}

int dr[] = {0,0,1,-1};
int dc[] = {-1,1,0,0};


 
void test_case() {

  
 
    cin>>n>>m;

    cin>>a>>b;
    cin>>c>>d;

    fo(i,1,n) {
        fo(j,1,m) {
            cin>>mat[i][j];
        }
    }

    deque<pair< pii, int> >dq;
    dq.push_front(mpr(mpr(a,b),0));

    while(!dq.empty()) {
        pair<pii, int> temp = dq.front();
        dq.pop_front();

        pii pos = temp.first;

       // cout<<pos.first<<pos.second<<endl;


        if(pos.first == c && pos.second == d) {
            cout<<temp.second<<endl;
            return;
        }

        if(vis[pos.first][pos.second] == 1) continue;

        vis[pos.first][pos.second] = 1;

        for(int i=0; i<4; i++) {
            int x = pos.first + dr[i];
            int y = pos.second + dc[i];
            if(valid(x,y) && mat[x][y] == '.' && vis[x][y] == 0 ) {
                dq.push_front(mpr(mpr(x,y), temp.second));
            }
        }  

        for(int i=-2; i<=2; i++) {
            for(int j=-2; j<=2; j++) {
                int x = pos.first + i;
                int y = pos.second + j;
                if(pos.first == 3 && pos.second == 3) {
                // cout<<x<<" "<<y<<endl;
            }
                if(valid(x,y) && mat[x][y] == '.' && vis[x][y] == 0) {
                    // cout<<x<<" "<<y<<" hwcijkckw";
                    dq.push_back(mpr(mpr(x,y), temp.second+1));
                }
            }
        }


    }

    cout<<-1<<endl;

}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
   //  cin >> t;
    while (t--)
    {
        test_case();
    }
}


Measured memory_bytes: 6360
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    ll N; cin>>N;
    vector<ll> an(N+1,0);
    for(ll i=1;i<=N;++i){
        cin>>an[i];
    }
    ll sum=0;
    for(ll i=N;i>=1;--i){
        if(i%2==1){
            sum+=an[i];
        } else {
            sum-=an[i];
        }
    }
    ll ans=sum/2;
    cout<<ans*2;
    ll prev=ans;
    for(ll i=1;i<N;++i){
        prev =an[i]-prev;
        cout<<" "<<(prev)*2;
    }
    cout<<endl;
    return 0;
}

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

int main()
{
   string s;
   cin>>s;
  long long sum =0;
  int n = s.length();
  int temp;
  for(int i=0;i<n;i++)
  {
    temp = s[i]-'0';
    sum = sum+temp;
  }
  if(sum%9==0)
     cout<<"Yes";
  else
     cout<<"No";
 return 0; 
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// usage:
//   combination comb(n+5);
//   ans = comb(n,r);
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};
combination comb(2000005);

mint func(int x, int y) {
	mint ans = comb(x + 1 + y + 1, x + 1) - 1;
	return ans;
}

void solve_abc154() {
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	mint d = func(r2, c2);
	d -= func(r1 - 1, c2);
	d -= func(r2, c1 - 1);
	d += func(r1 - 1, c1 - 1);

	cout << d.x << "\n";
}

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

	solve_abc154();

	return 0;
}

Measured memory_bytes: 31488