akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

/* ?????????????´??????????????????? */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* ??£??\??????????´??????????1????????????????????? */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* ?????\?????????(0??????????????????) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,N,M;
  cin >> N >> M;
  vector<int> road(2*M);
  vector<int> number_of_road(N);
  
  for(i=0;i<2*M;i+=2){
  	cin >> road.at(i) >> road.at(i+1); 
    number_of_road.at(road.at(i)-1)++;
    number_of_road.at(road.at(i+1)-1)++;
  }
  
  
  for(i=0;i<N;i++){
  	cout << number_of_road.at(i) << endl;
  }
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let mut a: Vec<Vec<usize>> = vec![vec![0; 3]; 3];
    for i in 0..3 {
        for j in 0..3 {
            a[i][j] = sc.read();
        }
    }
    let mut ok = vec![vec![false; 3]; 3];
    let n: usize = sc.read();
    for _ in 0..n {
        let x: usize = sc.read();
        for i in 0..3 {
            for j in 0..3 {
                if a[i][j] == x {
                    ok[i][j] = true;
                }
            }
        }
    }

    let mut done = false;
    for i in 0..3 {
        done |= ok[i].iter().all(|&a| a);
    }
    for j in 0..3 {
        done |= ok.iter().all(|row| row[j]);
    }
    done |= ok[0][0] && ok[1][1] && ok[2][2];
    done |= ok[2][0] && ok[1][1] && ok[0][2];

    if done {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	// 後日解説を見てから
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		scan.close();

		System.out.println("Christmas");

		while(N<25) {
			System.out.println(" Eve");
			N++;
		}
	}



}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long a[n + 1];
    for(int i = 0 ; i <= n ; i++)
    	cin >> a[i];
    long long b[n];
    for(int i = 0 ; i < n ; i++)
    	cin >> b[i];
    long long ans = 0;
    for(int i = n - 1 ; i >= 0 ; i--){
        long long x = min(a[i + 1 ], b[ i ]);
    	a[i + 1] -= x;
    	b[i] -= x;
    	ans += x;
    	x = min(a[i] , b[i]);
    	a[i] -= x;
    	b[i] -= x;
    	ans += x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL t[N],n,a,wynik;
vector <int> vek[N];
bool cmp(const int &a,const int &b) {
    return t[a]>t[b];
}
int32_t main(void) {
    boost;
    cin>>n;
    f0(i,(1<<n)) {
        cin>>t[i];
        vek[i].PB(i);
    }
    f1(i,(1<<n)-1) {
        f0(j,n) {
            if(i&(1<<j)) {
                int zm=i-(1<<j);
                f0(k,vek[zm].size()) {
                    vek[i].PB(vek[zm][k]);
                }
            }
        }
        sort(ALL(vek[i]));
        vek[i].resize(distance(vek[i].begin(),unique(ALL(vek[i]))));
        sort(ALL(vek[i]),cmp);
        vek[i].resize(2);
        wynik=max(wynik,t[vek[i][0]]+t[vek[i][1]]);
        cout<<wynik<<endl;
    }
}


Measured memory_bytes: 62592
#include <bits/stdc++.h>
using namespace std;
int n,dp[100005],way[100005];
int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&way[i]);
    way[0] = way[1];
    for(int i = 2; i <= n; i++)
        dp[i] = min(dp[i-1]+abs(way[i-1]-way[i]),dp[i-2]+abs(way[i-2]-way[i]));
    printf("%d",dp[n]);
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

using P = pair<int, int>;
using Graph = vector<vector<int>>;

void dfs(int prev, int cur, int color, const Graph &g, map<P, int> &mp, vector<int> &ans)
{
    int c = 1;
    for (auto nxt: g[cur]) {
        if (nxt == prev) continue;

        if (c == color) c++;
        int num = mp[make_pair(cur, nxt)];
        ans[num] = c;
        dfs(cur, nxt, c, g, mp, ans);
        c++;
    }
}

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

    int n; cin >> n;
    auto g = Graph(n); // 隣接リスト
    map<P, int> mp;    // 辺と番号の対応
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        auto p1 = make_pair(a, b);
        auto p2 = make_pair(b, a);
        mp[p1] = i;
        mp[p2] = i;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> ans(n - 1);
    dfs(0, 0, 0, g, mp, ans);

    cout << *max_element(ans.begin(), ans.end()) << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << ans[i] << endl;
    } 
    return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

const ll N = 1e5 + 5;

#define str pair < pair < ll, ll >, pair < ll, ll > > 

ll n;

ll a[N];

map < str, ll > M;
map < str, bool > F;

ll solve (ll l, ll r, ll x, ll y){
    if (l > r)
        return 0;
    str S = {{l, r}, {x, y}};
    if (F[S] == 1)
        return M[S];
    F[S] = 1;
    ll ans = 0, pas;
    ll ind = l;
    for (ll i = l; i <= r; i++){
        pas = (x + y) * a[i] + solve (l, i - 1, x, x + y) + solve (i + 1, r, x + y, y);
        if (i == l || pas < ans){
            ans = pas;
            ind = i;
        }
    }
    M[S] = ans;
    return ans;
}

main ()
{
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    a[0] = solve (2, n - 1, 1, 1);
    cout << a[0] + a[1] + a[n] << endl;
    return 0;
}


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


int main(void){
  ll n; cin >> n;
  ll h[n]; rep(i,n) cin >> h[i];
  for(int i = n - 2; i >= 0; i--){
    if(h[i] <= h[i+1]){
      continue;
    }
    else if(h[i] - h[i+1] == 1){
      h[i]--;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i < n-1; i++){
    if(h[i] > h[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

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

    if (s.size() == 2) {
        if (s[0] == s[1]) {
            cout << 1 << " " << 2 << endl;
        } else {
            cout << -1 << " " << -1 << endl;
        }
        return 0;
    }
    
    int sp = -1;
    for (int i = 0; i < (int)s.size() - 2; i++) {
        map<char, int> cnt;
        for (int j = 0; j < 3; j++) {
            if (++cnt[s[i + j]] == 2) {
                sp = i;
                goto end;
            }
        }
    }
    end:;
    if (sp == -1) {
        cout << -1 << " " << -1 << endl;
    } else {
        cout << sp + 1 << " " << sp + 3 << endl; 
    }        
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        int p;
        cin>>p;
        a[i]=p;
    }
    
    int ans=0;
    for(int i=2;i<=n;i++){
        if(a[i]>a[i-1]){
            ans++;
            
        }
    }
    
    
    cout<<ans<<endl;
    return 0;
    
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int L, N;
int X[220000];
int l[220000], r[220000];
int lsum[220000], rsum[220000];

signed main() {
    cin >> L >> N;
    for (int i = 0; i < N; i++)cin >> X[i];
    for (int i = 0; i < N; i++)l[i + 1] = X[i], r[N - i] = L - X[i];
    for (int i = 1; i <= N; i++)lsum[i] = l[i] + lsum[i - 1], rsum[i] = r[i] + rsum[i - 1];
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int ll = i, rr = N - i;
        if (ll < rr) {
            ans = max(ans, l[i] + 2 * (lsum[ll - 1] + rsum[rr] - rsum[rr - ll]));
        } else {
            ans = max(ans, l[i] + 2 * (lsum[ll - 1] - lsum[ll - 1 - rr] + rsum[rr]));
        }
        rr = i, ll = N - i;
        if (rr < ll) {
            ans = max(ans, r[i] + 2 * (rsum[rr - 1] + lsum[ll] - lsum[ll - rr]));
        } else {
            ans = max(ans, r[i] + 2 * (rsum[rr - 1] - rsum[rr - 1 - ll] + lsum[ll]));
        }
    }
    cout << ans << endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;

    vector<int> dp(N + 1, INF);
    dp[0] = 0;

    dp[0] = 0;
    for (int i = 0; i < N; i++) {

        dp[i + 1] = min(dp[i + 1], dp[i] + 1);

        for (int j = 1; i + pow(6, j) <= N; j++) {
            int plus     = pow(6, j);
            dp[i + plus] = min(dp[i + plus], dp[i] + 1);
        }

        for (int j = 1; i + pow(9, j) <= N; j++) {
            int plus     = pow(9, j);
            dp[i + plus] = min(dp[i + plus], dp[i] + 1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	int n; cin >> n;
	string s; cin >> s;
	s = '$' + s;
	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3792
#include<iostream>
#include<string>

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.length(); i++){
		S[i] = (S[i] - 'A' + N) % 26 + 'A';
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

namespace{
	const int mod=1e9+7;
	int fac[999],rev[999];
	int mul(int x,int y){
		return (ll)x*y%mod;
	}
	int power(int x,int p){
		int res=1;
		for(;p;p>>=1,x=mul(x,x))
			if(p&1) res=mul(res,x);
		return res;
	}
	void add(int &x,int y){
		x=(x+y>=mod?x+y-mod:x+y);
	}
	void init(int n){
		fac[0]=1;
		rep(i,1,n) fac[i]=mul(fac[i-1],i);
		rev[n]=power(fac[n],mod-2);
		per(i,n,1) rev[i-1]=mul(rev[i],i);
	}
}

const int N=21,M=1<<20;
int cnt[M],sum[M],f[M],w[N],n,m,a,b;
vector<pii> e[N];

void dfs(int u,int fa){
	for(auto v:e[u]){
		if(v.fi==fa) continue;
		w[v.fi]=w[u]|(1<<v.se);
		dfs(v.fi,u);
	}
}

int main(){
	read(n),read(m),init(m+2),n--;
	rep(i,1,n){
		read(a),read(b);
		e[a].pb(mp(b,i-1));
		e[b].pb(mp(a,i-1));
		f[1<<(i-1)]++;
	}
	dfs(1,0);
	rep(i,n+1,m){
		read(a),read(b);
		f[w[a]^w[b]]++;
	}
	for(int k=0,d=1;k<n;k++,d<<=1)
		for(int i=0;i<(1<<n);i+=d<<1){
			int *l=f+i,*r=f+i+d;
			REP(j,d) (*r++)+=*l++;
		}
	cnt[(1<<n)-1]=1;
	for(int s=(1<<n)-1;s;s--) REP(i,n){
		if(!(s>>i&1)) continue;
		int t=s^(1<<i),C=cnt[s],S=sum[s];
		int num=m-f[s],nw=f[s]-f[t]-1;
		C=mul(C,mul(fac[num+nw],rev[num]));
		S=mul(S,mul(fac[num+nw+1],rev[num+1]));
		add(S,mul(C,n-__builtin_popcount(t)));
		add(cnt[t],C),add(sum[t],S);
	}
	cout<<sum[0]<<endl;
	return 0;
}

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

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {

    int n;
    int a[100000], b[100000], c[100000];
    cin >> n;

    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];

    sort(a, a+n);
    sort(c, c+n);

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int a_idx = distance(begin(a), lower_bound(a, a+n, b[i]));
        int c_idx = distance(begin(c), upper_bound(c, c+n, b[i]));

        ans += (ll)a_idx*(n - c_idx);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
int a[N];

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


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

#define Sq(x) x*x
#define EPS 1e-10

class Point {
public:
  double x, y;
  
  Point operator+ ( Point p ) { return Point( x+p.x, y+p.y ); }
  Point operator- ( Point p ) { return Point( x-p.x, y-p.y ); }
  Point operator* ( double k ) { return Point( k*x, k*y ); }
  Point operator/ ( double k ) { return Point( x/k, y/k ); }

  bool operator< ( const Point &p ) const {
    return x != p.x ? x < p.y : y < p.y;
  }
  
  bool operator==( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
  
  double norm() { return Sq(x)+Sq(y); }
  double abs() { return sqrt(norm()); }
  
  Point( double x = 0, double y = 0 ) : x(x), y(y) {}
};

typedef Point Vector;

double norm( Vector a ) { return Sq(a.x)+Sq(a.y); }
double dot( Vector a, Vector b ) { return a.x*b.x+a.y*b.y; }
Point proj( Vector base, Vector v ) {
  double k = dot( base, v ) / norm( base );
  return base*k;
}

int main() {
  
  double x, y;
  char d;
  while( cin >> x >> d >> y >> d ) {
    Vector P1 = Vector(x, y);
    cin >> x >> d >> y >> d; Vector P2 = Vector(x, y);
    cin >> x >> d >> y;      Vector OQ = Vector(x, y);
    
    Vector P1Q = OQ-P1;
    Vector P12 = P2-P1;
    /* 
       OC = P1 + proj(P12, P1Q)
       OC = ( OQ + OR ) / 2
       OR = 2*OC - OQ
     */
    Vector OR = ( P1 + proj(P12, P1Q) )*2.0 - OQ;
    
    printf("%.6f %.6f\n", OR.x, OR.y);
  }
  
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <iomanip>
#include <ios>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int N, M, ans1[200000], ans2[200000];
  cin >> N >> M;
  vector<vector<pair<int, int> > > v(N+1);

  for(int i=0;i<M;i++){
    int x, y;
    cin >> x >> y;
    v[x].push_back(make_pair(y, i));
  }
  for(int i=1;i<=N;i++){
    sort(v[i].begin(), v[i].end());
    for(int j=0;j<v[i].size();j++){
      int id=v[i][j].second;
      ans1[id]=i;
      ans2[id]=j+1;
    }
  }
  for(int i=0;i<M;i++){
    cout << setfill('0') << right << setw(6) << ans1[i];
    cout << setfill('0') << right << setw(6) << ans2[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 7808
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
//hash base 177013

double dist(pair<double,double> p)
{
	return sqrt((p.first)*(p.first)+(p.second*p.second));
}

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//for(ll t=0;t<testcase;t++)
	{
		ll n;
		cin>>n;
		if(n%2==0||n==5)
		{
			cout<<-1<<'\n';
			return 0;
		}
		if(n%7==0)n/=7;
		ll temp=1LL;
		int count=0;
		bool flag=false;
		while(1)
		{
			count++;
			if(temp%n==0)
			{
				break;
			}
			temp=(temp%n)*10+1;
			if(count>1000000)
			{
				flag=true;
				break;
			}
		}
		if(flag)cout<<-1;
		else
			cout<<count<<'\n';
		
							
	}
}


Measured memory_bytes: 3660
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-09 16:21:07
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A[MAXN] , cnt[LOG][LOG];

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

    cin >> n;
    for(int i = 0 ; i < n ; i++){
        string s;
        cin >> s;
        int flag = 0 , cnt = 0;
        for(int j = 0 ; j < SZ(s) ; j++){
            if(s[j] == '.'){
                flag = 1;
                continue;
            }
            cnt += flag;
            A[i] = A[i] * 10 + s[j] - 48;
        }
        while(cnt < 9){
            A[i] *= 10;
            cnt++;
        }
    }
    for(int i = 0 ; i < n ; i++){
        ll x = A[i] , c2 = 0 , c5 = 0;
        while(x % 2 == 0){
            x /= 2;
            c2++;
        }
        while(x % 5 == 0){
            x /= 5;
            c5++;
        }
        c2 = min(c2 , 20ll);
        c5 = min(c5 , 20ll);
        cnt[c2][c5]++;
    }

    ll ans = 0;
    for(int i = 0 ; i < LOG ; i++){
        for(int j = 0 ; j < LOG ; j++){
            for(int k = 0 ; k < LOG ; k++){
                for(int l = 0 ; l < LOG ; l++){
                    if(i + k < 18 || j + l < 18)    continue;
                    ans += cnt[i][j] * cnt[k][l];
                    if(i == k && j == l)    ans -= cnt[i][j];
                }
            }
        }
    }
    cout << ans / 2 << endl;

    return 0;
}
/*

*/


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

int main(void){
    int n,k; cin >> n >> k;
    int x = 1;

    for(int i=0;i<n;i++){
        x = min(x*2, x+k);
    }

    cout << x << endl;
    return 0;
}

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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i, m) cin >> b[i];
	vector<int> a(m);
	int ans = 0;

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			int a;
			cin >> a;
			sum += a * b[j];

		}
		sum += c;
		if (sum > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> dist(n);
    
    for (int i=1; i<=n-1; i++){
        for (int j=i+1; j<=n; j++){
            int a = min(j-i, abs(i-x)+abs(y-j)+1);
            dist.at(a)++;
        }
    }
    
    for (int i=1; i<=n-1; i++){
        cout << dist.at(i) << endl;
    }
  }

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,h,w;

int main(){
    cin >> n >> h >> w;
    ll ans = 0;
    rep(i,n/2){
        ll a,b;
        cin >> a >> b;
        ans += h * min(w - a,b);
        ans += h * min(w - b,a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        String str=scan.next();
        int i,j;
        for(i=0;i<str.length();i++){
            for(j=0;j<i;j++){
                if(str.charAt(i)==str.charAt(j)){
                    System.out.println("no");
                    return;
                }
            }
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 23252
s=str(input())
t=str(input())
sn=len(s)
tn=len(t)
ans=0
for i in range(sn-tn+1):
  ck=s[i:tn+i]
  #tとckを比較していけばいい
  #print(ck)
  cnt=0
  for j in range(tn):
    if ck[j]==t[j]:
      cnt+=1
    ans=max(cnt, ans)
  #print(ans)
print(tn-ans)
         
    

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

int main(){
    
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    a=(a-c)*(a-c)+(b-d)*(b-d);
    cout<<fixed<< setprecision(8);
    cout<<sqrt(a)<<endl;
    
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll x[n], y[n];
    ll xx[n], yy[n];
    rep(i, n) {
        cin >> x[i] >> y[i];
        xx[i] = x[i] + y[i];
        yy[i] = x[i] - y[i];
    }
    sort(xx, xx + n);
    sort(yy, yy + n);
    cout << max(xx[n - 1] - xx[0], yy[n - 1] - yy[0]) << endl;
    return 0;
}

Measured memory_bytes: 9880
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
A = lmi()
absA = list(map(abs, A))
absA.sort()
cnt = 0

for i in A:
    if i < 0:
        cnt += 1
# print(cnt)
if cnt % 2 == 1:
    print(sum(absA) - 2 * absA[0])
else:
    print(sum(absA))

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

int main() {
	ll N;
	cin >> N;
	vector<int> a(N+1), b, now(N+1,0),ex(N+1,0);
	for(int i=1;i<=N;i++)
		cin >> a[i];

	for(int i=N;i>=1;i--)
	{
		for(int j=2*i;j<=N;j+=i)
			now[i] += ex[j];

		now[i] %= 2;
		if(a[i] != now[i])
		{
			b.push_back(i);
			ex[i] = 1;
			now[i] = (now[i]+1)%2;
		}
	}

	bool flag =true;
	for(int i=1;i<=N;i++)
	{
		if(a[i] != now[i])
		{
			flag = false;
			break;
		}
	}
	if(flag){
		cout << b.size() << endl;
		for(int i=b.size()-1;i>=0;i--)
			cout << b[i] << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  ll A[n];
  for(int i=0; i<n; ++i) cin >> A[i];
  ll sum = 0, pm = 0, mp = 0;
  for(int i=0; i<n; ++i){
    sum += A[i];
    if(i%2 == 0 && sum <= 0){ pm += 1-sum; sum = 1; }
    if(i%2 != 0 && sum >= 0){ pm += 1+sum; sum = -1; }
  }
  sum = 0;
  for(int i=0; i<n; ++i){
    sum += A[i];
    if(i%2 == 0 && sum >= 0){ mp += 1+sum; sum = -1; }
    if(i%2 != 0 && sum <= 0){ mp += 1-sum; sum = 1; }
  }
  cout << min(pm, mp) << endl;
}

Measured memory_bytes: 4348
N, M = map(int, input().split())
Cake, Par = [], []
for i in range(N):
    x, y, z = map(int, input().split())
    Cake.append((x, y, z))
    Par.append([i, x+y+z, x+y-z, x-y+z, x-y-z, -x+y+z, -x+y-z, -x-y+z, -x-y-z])

def sumPar(L):
    I = []
    for i in range(M):
        I.append(L[i][0])
    X, Y, Z = 0, 0, 0
    for i in I:
        X += Cake[i][0]
        Y += Cake[i][1]
        Z += Cake[i][2]
    return abs(X) + abs(Y) + abs(Z)

Par000 = sorted(Par, key = lambda x:-x[1])
Par001 = sorted(Par, key = lambda x:-x[2])
Par010 = sorted(Par, key = lambda x:-x[3])
Par011 = sorted(Par, key = lambda x:-x[4])
Par100 = sorted(Par, key = lambda x:-x[5])
Par101 = sorted(Par, key = lambda x:-x[6])
Par110 = sorted(Par, key = lambda x:-x[7])
Par111 = sorted(Par, key = lambda x:-x[8])

sumC = sumPar(Par000)
sumC = max(sumPar(Par001), sumC)
sumC = max(sumPar(Par010), sumC)
sumC = max(sumPar(Par011), sumC)
sumC = max(sumPar(Par100), sumC)
sumC = max(sumPar(Par101), sumC)
sumC = max(sumPar(Par110), sumC)
sumC = max(sumPar(Par111), sumC)
print(sumC)

Measured memory_bytes: 3700
#include<stdio.h>
int main()
{
	int n,i, max=0,v[n],c[n];
	scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&v[i]);}
		for(i=0;i<n;i++){
			scanf("%d",&c[i]);}
	for(i=0;i<n;i++){
	if(v[i]>c[i]){
		max+=v[i]-c[i];
		}
	}
 printf("%d",max);
return 0;
}

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

int main() {
	int n,m,k;
	int pos[200]={};
	int nu[200]={};
	cin >> n >> m;
	for(int i=0;i<2*n;i++){
		pos[i]=i;
	}
	for(int i=0;i<m;i++){
		cin >> k;
		if(k==0){
			for(int j=0;j<2*n;j++){
				if(pos[j]<n){
					pos[j]=2*pos[j];
				}else{
					pos[j]=2*(pos[j]-n)+1;
				}
			}
		}else{
			for(int j=0;j<2*n;j++){
				if(pos[j]<k){
					pos[j]=2*n-k+pos[j];
				}else{
					pos[j]=pos[j]-k;
				}
			}
		}
	}
	for(int i=0;i<2*n;i++){
		nu[pos[i]]=i;
	}
	for(int i=0;i<2*n;i++){
		cout << nu[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        int x = 1;
        int i = 0;
        while (x < b)
        {
            x = x - 1 + a;
            i++;
        }
        cout << i << "\n";
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
long long int a[45];
long long int b[45];
int main(){
    long long int A,B;
    cin >> A >> B;
        A--;
        long long int ans=0;
        for(long long int i=0;i<45;i++){
            if(i==0)a[0]=A%(1LL<<2);
            else a[i]=A%(1LL<<(i+1));
            if((1LL<<(i+1))>A)break;
        }
        for(long long int i=0;i<45;i++){
            if(i==0)b[0]=B%(1<<2);
            else b[i]=B%(1LL<<(i+1));
            if((1LL<<(i+1))>B)break;
        }
        long long int aa,bb;
        for(long long int i=0;i<45;i++){
            if(i==0){
            if(a[0]==1 || a[0]==2)aa=1;
            else aa=0;
            if(b[0]==1 || b[0]==2)bb=1;
            else bb=0;
            ans += (1<<0)*(aa^bb);
            }
            else{
                if(a[i]>=(1LL<<i))aa=(a[i]-(1LL<<i)+1)%2;
                else aa=0;
                if(b[i]>=(1LL<<i))bb=(b[i]-(1LL<<i)+1)%2;
                else bb=0;
                ans += (1LL<<i)*(aa^bb);
            }
        }
        cout << ans << endl;    
}

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

int n, t;
pair<int, int> a[3010];

int memo[3010][3010];

int dp(int i, int j){
    if(i == n || j >= t){
        return 0;
    }

    if(memo[i][j] != -1){
        return memo[i][j];
    }

    return memo[i][j] = max(dp(i+1, j+a[i].first)+a[i].second, dp(i+1, j));
}


int main(){
    cin >> n >> t;

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

    sort(a, a+n);

    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0) << endl;
    return 0;
}




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

int main() {
    
    int k, x;
    
    cin >> k >> x;
    
    if(500 * k >= x) cout << "Yes";
    else cout << "No";
    
    return 0;
}




Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

typedef int SegT;
const SegT defvalue=0;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}

class SegTree{
	private:
		vector<SegT>val;
		int n;
		SegT combine(SegT a,SegT b){return gcd(a,b);}
	public:
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n,defvalue);
		}
		SegTree(const vector<SegT> &in){
			n=1;
			while(n<in.size())n<<=1;
			val=vector<SegT>(2*n,defvalue);
			for(int i=n-1+in.size()-1;i>=0;i--){
				if(n-1<=i)val[i]=in[i-(n-1)];
				else val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
			if(r==-1)r=n;
			if(r<=a||b<=l)return defvalue;
			if(a<=l&&r<=b)return val[k];
			else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
		}
		void tmp(){
			rep(i,val.size())cout<<" "<<val[i];cout<<endl;
		}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	SegTree st(in);
	int out=0;
	rep(i,n){
		int t=gcd(st.query(0,i),st.query(i+1,n));
		cmax(out,t);
	}
	cout<<out<<endl;
}











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

int main() {
    string left = "qwert asdfg zxcvb";
    string right = "yuiop hjkl nm";
    map<char, bool> isLeft;
    for (char& c : left) isLeft[c] = true;
    for (char& c : right) isLeft[c] = false;

    string s;
    while (cin >> s, s != "#") {
        int n = s.length();
        vector<bool> a(n);
        for (int i = 0; i < n; i++) a[i] = isLeft[s[i]];
        int cnt = 0;
        for (int i = 0; i + 1 < n; i++) {
            if (a[i] != a[i + 1]) cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;


    vector< int > G[n];
    int jisuu[n] = {};
    REP(i,n-1){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        jisuu[a] ++;
        jisuu[b] ++;
    }

    queue<int> Q;
    int size = 0;
    REP(i,n) if(jisuu[i] == 1){
        Q.push(i);
        size ++;
    }

    int C[n];
    int res = 0;
    REP(i,n){
        scanf("%lld",&C[i]);
        res += C[i];
    }
    sort(C,C+n);
    res -= C[n-1];
    cout << res << endl;

    int ans[n] = {};
    int cind = 0;
    while(size){
        int tmp = Q.front();
        ans[tmp] = C[cind];
        cind ++;
        Q.pop();
        size --;
        itrfor(itr,G[tmp]){
            jisuu[*itr] --;
            if(jisuu[*itr] == 1){
                Q.push(*itr);
                size ++;
            }
        }
    }
    REP(i,n) printf("%lld ",ans[i]);
    cout << endl;

}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <bitset>
#include <cmath>
using namespace std;

int main(void){	
	string s;
	while(cin>>s){
		int c_index = -1;
		int f_index = -1;
		for(int i=0;i<s.length();i++){
			if(s[i] == 'C' && c_index == -1){
				c_index = i;
			}
			if(s[i] == 'F'){
				f_index = i;
			}
		}
		//cout<<c_index<<" "<<f_index<<endl;
		if(c_index!=-1 && f_index != -1 && c_index < f_index) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

struct edge{
    ll to,cost;  

    edge(ll to,ll cost) : to(to),cost(cost) {}; 
};

void dijkstra(ll V,vector<vector<edge> > &G,vector<vector<ll> > &d,ll s){
    PQ que;
    fill(d[s].begin(),d[s].end(), LINF);
    d[s][s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        ll v = p.second;
        if(d[s][v] < p.first) continue;

        rep(i,0,G[v].size()){
            edge e = G[v][i];
            if(d[s][e.to] > d[s][v] + e.cost){
                d[s][e.to] = d[s][v] + e.cost;
                que.push(P(d[s][e.to],e.to));
            }

        }
    }


}

int main(){
    ll n,x,y;
    cin >> n >> x >> y;

    ll ans[n] = {};
    vector<vector<edge> > G(n);
    vector<vector<ll> > dist(n,vector<ll>(n));

    rep(i,0,n-1){
        G[i].push_back(edge(i+1,1));
        G[i+1].push_back(edge(i,1));
    }
    G[x-1].push_back(edge(y-1,1));
    G[y-1].push_back(edge(x-1,1));

    rep(i,0,n){
        dijkstra(n,G,dist,i);
    }

    rep(i,0,n){
        rep(j,0,n){
            ans[dist[i][j]-1]++;
        }
    }

    rep(i,0,n-1){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l,d;
  cin >> n >> l;
  if(l>=0){
    cout << n*l+n*(n+1)/2-n-l << endl;
  }
  else if(l+n-1<=0){
    cout << n*l+n*(n+1)/2-n-(l+n-1) << endl;
  }
  else{
    for (int i=1; i<n;i++){
      if(l+i-1<0&&l+i>=0){
        if(abs(l+i-1)>abs(l+i)){
          d=l+i;
          break;
        }
        else{
          d=l+i-1;
          break;
        }
      }
    }
  cout << n*l+n*(n+1)/2-n-d << endl;
  }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int res = 1e9 + 100;
    for(int i = 0; i < s.size() - 2; i ++){
        int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
        res = min(res, abs(x - 753));
    }
    cout << res << '\n';
}

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

d = [[0]*N for _ in [0]*N]
l = [0]*N
for i in range(N):
    j = i
    cnt = 0
    while True:
        prev_j = j
        j = P[j]-1
        d[i][j] = d[i][prev_j] + C[j]
        cnt += 1
        if j==i: break
    l[i] = cnt

ans = -(10**10)
for i in range(N):
    n = (K-N)//l[i]
    tmp = max(0,d[i][i]) * n
    k = K - n*l[i]
    j = i
    for _ in range(2*N):
        if k<=0: break
        k -= 1
        tmp += C[j]
        j = P[j] -1
        ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 270532
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void solve()
{ int n;
  cin>>n;
  if(n%1000==0)
    cout<<0;
  else 
    cout<<1000-(n%1000);

  


   
 } 
     

  
  
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {solve();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

Measured memory_bytes: 3776
<?php
list($n) = ints();
$s = (string) $n;
$l = strlen($s);
for ($i = 0; $i < intdiv($l, 2); ++$i) {
    if ($s[$i] !== $s[$l - $i - 1]) exit('No');
}
echo 'Yes';
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,n,j,k,c=0;
    cin>>n;
    long long A[n];
    for(i=0;i<n;i++) cin>>A[i];
    sort(A,A+n);
    for(i=0;i<n;i++)
      {
        for(j=i+1;j<n;j++)
        {
          for(k=j+1;k<n;k++)
          {
                if(A[i]+A[j]>A[k])
                c++;
          }
        }

      }

    cout<<c<<endl;

return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e4+500)
#define BARRS int(6e4+600)
#define MAX ((int)(2e9+15))
#define EP ((double)(1e-12))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000000ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008


#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    //cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll n,m,k,d=MAX;
    string s;
	cin>>s;
	n=s.size();
    for(int c='a'; c<='z'; c++){
        ll k=MAX;
        ll p=0,t=0,l;
        for(l=n; l>=0; l--){
			bool e=1;
			ll ls=MAX;
            for(int i=n-1; i>=0; i--){
				if(((int)s[i])==c)ls=i;
				//cout<<l<<" "<<i<<" "<<ls<<" "<<t<<" "<<s[i]<<" "<<c<<endl;
				if(i<l&&abs(i-ls)>t)e=0;
				if(!e)break;
            }
            t++;
			if(e)break;
        }
        //cout<<(char)c<<" "<<l<<endl;
		d=min(d,n-l);
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 256
c[1100000],n=1e6;main(i,j){for(i=2;i*i<n;++i)for(j=i;!c[i]&&j<n;c[j+=i]=1);for(j=0;~scanf("%d",&n);j=!printf("%d\n",j))for(i=n;i>1;j+=!c[i--]);}

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

using namespace std;

typedef long long int64;


int main()
{
  int64 L;
  int N;
  int64 S[100000], T[100000], A[200001];
  A[0] = 0;

  cin >> L;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> T[i];
    A[i + 1] = T[i] - S[i] + A[i];
  }

  int64 ret = 0, tail = 0;
  for(int i = 0; i < N; i++) {
    int64 start = S[i], end = S[i] + L - 1;
    while(tail + 1 < N && end > S[tail + 1]) ++tail;
    ret = max(ret, A[tail] - A[i] + max(0LL, min(T[tail] - 1, end) - S[tail] + 1));
  }
  cout << ret << endl;
}

Measured memory_bytes: 4288
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  string y = s.substr(0,2);
  string m = s.substr(2,2);
  
  int yy = stoi(y);
  int mm = stoi(m);
  
  if (mm >= 1 && mm <= 12) {
    if (yy >= 1 && yy <= 12) {
      cout << "AMBIGUOUS" << endl;
    }
    if (yy > 12 || yy == 0) {
      cout << "YYMM" << endl;
    }
  }
  if (yy >= 1 && yy <= 12) {
    if (mm == 0 || mm > 12) {
      cout << "MMYY" << endl;
    }
  }
  if (mm == 0 && yy > 12 || yy == 0 && mm > 12) {
    cout << "NA" << endl;
  }
  if (mm == 0 && yy == 0) {
    cout << "NA" << endl;
  }
  if (mm > 12 && yy > 12) {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    string S; cin >> S;
    
    if(S == "Sunny") cout << "Cloudy" << "\n";
    if(S == "Cloudy") cout << "Rainy" << "\n";
    if(S == "Rainy") cout << "Sunny" << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){

   string s;cin >> s;
   bool p=true;
   for(int i=0;i<s.size();i++){
    if(s[i]=='7'){p=false;break;}
   }
   if(!p) cout << "Yes\n";
   else cout << "No\n";



}


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

int main() {

int A, B, C, D;
cin >> A >> B >> C >> D;

while( (A > 0 ) && (C > 0) ){
    C = (C - B);
    A = (A - D);
    if(C <= 0){
        cout << "Yes" << endl;
    } else if (A <= 0){
        cout << "No" << endl;
    } 
}
return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n - 1);
  rep(i,n-1) cin >> b[i];

  a[0] = b[0];
  a[n-1] = b[n-2];
  
  for(int i = 0; i < n-2; ++i){
    a[i+1] = min(b[i], b[i+1]);
  }

  int ans = 0;
  rep(i, n){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256