akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

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

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

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

ll N, M;
map<ll, vector<ll>> G;

bool bfs(pair<ll, ll> b) {
    queue<ll> q;
    set<ll> memo;
    q.push(1);
    while (!q.empty()) {
        ll n = q.front();
        q.pop();
        if (!memo.count(n)) {
            memo.insert(n);
            for (auto i : G[n]) {
                if ((n == b.fst && i == b.snd) ||
                    (n == b.snd && i == b.fst)) {
                    continue;
                }
                q.push(i);
            }
        }
    }
    return memo.size() != N;
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> N >> M;
    rep (i, M) {
        ll a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll ans = 0;
    for (auto it : G) {
        for (ll j : it.snd) {
            if (bfs({it.fst, j})) {
                ++ans;
            }
        }
    }
    ans /= 2;
    cout << ans << endl;
}



Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;


int main() {
	int x, y;
	cin >> x >> y;
	if (x%y == 0) {
		cout << -1 << endl;
	}
	else if (y%x != 0) {
		cout << x << endl;
	}
	else {
		cout << y - x << endl;
	}


	return 0;
}



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


int main() {
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<int>> data(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        cin >> A.at(i).at(j);
        data.at(i).at(j) = 0;
      }
    }

    int N;
    vector<int> B(N);

    cin >> N;

    for (int index = 0; index < N; index++) {
      cin >> B.at(index);

      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (A.at(i).at(j) == B.at(index)) {
            data.at(i).at(j) = 1;
          }
        }
      }
        
    }

    string ans = "No";
    
    if ((data.at(0).at(0) == 1 && data.at(0).at(1) == 1 && data.at(0).at(2) == 1) ||
        (data.at(1).at(0) == 1 && data.at(1).at(1) == 1 && data.at(1).at(2) == 1) ||
        (data.at(2).at(0) == 1 && data.at(2).at(1) == 1 && data.at(2).at(2) == 1) ||
        (data.at(0).at(0) == 1 && data.at(1).at(0) == 1 && data.at(2).at(0) == 1) ||
        (data.at(0).at(1) == 1 && data.at(1).at(1) == 1 && data.at(2).at(1) == 1) ||
        (data.at(0).at(2) == 1 && data.at(1).at(2) == 1 && data.at(2).at(2) == 1) ||
        (data.at(0).at(0) == 1 && data.at(1).at(1) == 1 && data.at(2).at(2) == 1) ||
        (data.at(0).at(2) == 1 && data.at(1).at(1) == 1 && data.at(2).at(0) == 1)
      ) {
      ans = "Yes";
    }
    
    
    
    

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

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 8");
            WillReturn.Add("7 9 8 9");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 8");
            WillReturn.Add("6 6 9");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8 5");
            WillReturn.Add("3 6 2 8 7 6 5 9");
            //19
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("33 3");
            WillReturn.Add("3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3");
            //8589934591
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[1];
        int[] XArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        //場合の数[枚数,合計]なDP表
        int UB_I = wkArr[0];
        int UB_J = XArr.Sum();
        long[,] DPArr = new long[UB_I + 1, UB_J + 1];
        DPArr[0, 0] = 1;

        foreach (int EachX in XArr) {
            for (int I = UB_I; 0 <= I; I--) {
                for (int J = UB_J; J >= 0; J--) {
                    if (DPArr[I, J] == 0) continue;
                    int NewI = I + 1;
                    int NewJ = J + EachX;
                    DPArr[NewI, NewJ] += DPArr[I, J];
                }
            }

            //Console.WriteLine("DPの結果");
            //for (int I = 0; I <= UB_I; I++) {
            //    for (int J = 0; J <= UB_J; J++) {
            //        Console.WriteLine("DPArr[{0},{1}]={2}", I, J, DPArr[I, J]);
            //    }
            //}
        }

        long AnswerCnt = 0;
        for (int I = 1; I <= UB_I; I++) {
            for (int J = 0; J <= UB_J; J++) {
                if (J == A * I)
                    AnswerCnt += DPArr[I, J];
            }
        }
        Console.WriteLine(AnswerCnt);
    }
}


Measured memory_bytes: 3928
package main

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

var sc = bufio.NewScanner(os.Stdin)

func solve(K int, h []int) int {
	sort.Ints(h)

	k := K - 1

	minDiff := 1000000000
	for i := 0; i < len(h)-k; i++ {
		diff := h[i+k] - h[i]
		if diff < minDiff {
			minDiff = diff
		}
	}

	return minDiff
}

func main() {
	var N, K int
	fmt.Scan(&N)
	fmt.Scan(&K)

	nums := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanln(&nums[i])
	}
	fmt.Println(solve(K, nums))
}


Measured memory_bytes: 5504
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let k: i64 = input();
    let a: Vec<i32> = (0..n).map(|_| input()).collect();
    const MOD: i64 = 1000000007;

    let mut t = 0;
    for i in 0..n {
        for j in i + 1..n {
            if a[i] > a[j] {
                t += 1;
            }
        }
    }

    let mut ans = t * k as i64 % MOD;
    for i in 0..n {
        let mut c = 0;
        for j in 0..n {
            if a[i] > a[j] {
                c += 1;
            }
        }
        ans += k * (k - 1) / 2 % MOD * c % MOD;
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <unistd.h>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }


int main() {
    int n;
    cin >> n;
    int p[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i]; p[i]--;
        r[p[i]] = i;
    }
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        a[i] = 20200 * (i+1);
        b[i] = 20200 * (n-i);
        a[i] += r[i];
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    } cout << endl;
    for (int i = 0; i < n; i++) {
        cout << b[i] << " ";
    } cout << endl;
    return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
import string


def solve(N: int, S: str):
    l = list(string.ascii_uppercase)
    ans = ''
    for s in S:
        ans += l[(l.index(s) + N) % 26]
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


int main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{

	int n,m;
	cin>>n>>m;
	int a[m];
	ll sum=0;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	n-=sum;
	cout<<max(-1,n);

	
}
return 0;
}









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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int a, b;
    cin >> a >> b;

    if (13 <= a) cout << b << endl;
    else if (6 <= a) cout << b / 2 << endl;
    else cout << "0\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)
maxi = 10**6+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 1:
        ans += 1

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  int minv = 1e9;
  rep(i,n){
    minv = min(minv, p[i]);
    if(minv==p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int maxn = 2e5 + 10;

typedef long long ll;

ll p[maxn];
ll a[maxn],b[maxn];
map<ll,int> m;
ll lowbit(ll x) {return x & -x;};

ll sum(ll x) {
    ll res = 0;
    while (x > 0) {
        res += p[x];
        x -= lowbit(x);
    }
    return res;
}

void add(ll x) {
    while (x < maxn) {
        p[x]++;
        x += lowbit(x);
    }
}

int main() {
    int n,k; cin>>n>>k;
    for (int i = 1; i <= n; i++) {
        cin>>a[i];
        a[i] += a[i - 1] - k;
        b[i] = a[i];
    }
    sort(b, b + n + 1);
    int len = 1;
    for (int i = 0; i <= n; i++) {
        if (m[b[i]]) continue;
        m[b[i]] = len++;
    }
    ll res = 0;
    for (int i = 0; i <= n; i++) {
        ll t = m[a[i]];
        res += sum(t);
        add(t);
    }
    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 17408
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<stdio.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; }






int main() {



	long long w, h, x, y;
	cin >> w >> h >> x >> y;
	
	printf("%lf ", double(w)*double(h)*0.5);

	if (w == 2*x && h == 2*y)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


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

double dist(ll int x,ll int y)
{
    return sqrt(x*x+y*y);
}
void solve()
{
  int k;
  cin >> k;
  ll ini = 7;
  for (int c=1;c<=k;c++)
    {
        if (ini%k==0)
            {cout << c << endl;return;}
        ini=(ini*10+7)%k;
    }
    cout << -1 << endl;
    return;

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);     
    int t;
    //cin >> t;
    t=1;
    for (int tt=0;tt<t;tt++)
        {
            solve();
        }    
        return 0;
}

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

int main(){
    int N;
    long long M;
    cin >> N >> M;
    int s, t;
    vector<int> edge[N+1];
    rep(i, M){
        cin >> s >> t;
        edge[s].push_back(t);
    }
    double E[N][N+1];
    E[0][N] = 0;
    rep3(i, N-1, 0){
        double n = edge[i].size();
        double sum = 0;
        rep(j, n){
            sum += E[0][edge[i][j]];
        }
        E[0][i] = sum/n + 1;
    }
    rep2(i, 1, N){
        rep3(j, N, i){
            E[i][j] = E[0][j];
        }
        double n = edge[i].size();
        if(n == 1){
            E[i][i] = E[i][edge[i][0]] + 1;
        }
        else{
            double sum = 0;
            double maxi = 0;
            rep(k, n){
                sum += E[i][edge[i][k]];
                maxi = max(maxi, E[i][edge[i][k]]);
            }
            E[i][i] = (sum-maxi)/(n-1) + 1; 
        }
        rep3(j, i-1, 0){
            double n = edge[j].size();
            double sum = 0;
            rep(k, n){
                sum += E[i][edge[j][k]];
            }
            E[i][j] = sum/n + 1;
        }
    }
    double ans = E[0][1];
    rep2(i, 1, N){
        ans = min(ans, E[i][1]);
    }
    cout << setprecision(12) << ans << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a;
    char c;
    cin >> a >> c >> a;
    if (a <= 4)
    {
        cout << "Heisei";
    }
    else
    {
        cout << "TBD";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n,m,r,q,t,nn,mm,s,ts,te;
    int si[10001]={};
    int ei[10001]={};
    int pcn[10001]={};
    int lts[1000]={};
    int lte[1000]={};
    int ni[1000]={};
    while(1){
        cin >> n >> m;
        if(n==0){return 0;}
        for(int i=1;i<=m;i++){
            si[i]=-1;
            pcn[i]=0;
        }
        cin >> r;
        int pi=0;
        for(int i=0;i<r;i++){
            cin >> t >> nn >> mm >> s;
            if(s){
                pcn[mm]++;
                if(pcn[mm]==1){
                    if(si[mm]==-1){
                        si[mm]=pi;
                    }else{
                        ni[ei[mm]]=pi;
                    }
                        ei[mm]=pi;
                        lts[pi]=t;
                        ni[pi]=-1;
                        pi++;
                }
            }else{
                pcn[mm]--;
                if(pcn[mm]==0){
                    lte[ei[mm]]=t;
                }
            }
        }
        cin >> q;
        for(int i=0;i<q;i++){
            cin >> ts >> te >> mm;
            int tt=0;
            for(int j=si[mm];j!=-1;j=ni[j]){
                if(lts[j]<ts && lte[j]>=ts && lte[j]<te){
                    tt=lte[j]-ts;
                }
                if(lts[j]<ts && lte[j]>=te){
                    tt=te-ts;
                    break;
                }
                if(lts[j]>=ts && lte[j]<te){
                    tt+=lte[j]-lts[j];
                }
                if(lts[j]>=ts && lts[j]<te && lte[j]>=te){
                    tt+=te-lts[j];
                    break;
                }
                if(lts[j]>=te){
                    break;
                }
            }
            cout << tt << endl;
        }
    }
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  map<char, vector<int>> kek;
  map<char, set<int>> kek2;
  for (int i = 0; i < n; ++i) {
    kek[s[i]].push_back(i);
    kek2[s[i]].insert(i);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (s[i] == s[j]) {
        continue;
      }
      char c = 'R' + 'G' + 'B' - s[i] - s[j];
      int cur = kek[c].end() - lower_bound(kek[c].begin(), kek[c].end(), j);
      if (kek2[c].count(j + j - i)) {
        --cur;
      }
      ans += cur;
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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 a, b, c ;
  cin >> a >> b >> c ;
  if(a==b && b == c ){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }


  return 0 ;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
	string x,y;
	cin >> x;
	cin >> y;
	int m,n;
	m=x.size();
	n=y.size();
	int i,j,k;
	int l[m+1][n+1];
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i==0||j==0)
			l[i][j]=0;
			else if(x[i-1]==y[j-1])
			l[i][j]=l[i-1][j-1]+1;
			else if(x[i-1]!=y[j-1])
			l[i][j]=max(l[i-1][j],l[i][j-1]);
		}
	}
	i=m;j=n;
	int index=l[m][n];
	string lcs="";
	while(i>0&&j>0)
	{
		if(x[i-1]==y[j-1])
		{
			lcs+=x[i-1];
			i--;j--;index--;
		}
		else if(l[i-1][j]>=l[i][j-1])
		i--;
		else if(l[i-1][j]<=l[i][j-1])
		j--;
	}
	reverse(lcs.begin(),lcs.end());
	cout  << lcs;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,C;
vector<ll> A,B;

ll dp[404][404];
ll coef[404][404];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

void mul(ll &a,ll b){
    a=a*b%MOD;
}

int main(){
  cin>>N>>C;
  A.resize(N);
  B.resize(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];

  for(int i=0;i<N;i++){
      for(int j=A[i];j<=B[i];j++){
          ll val=j;
          for(int k=1;k<=C;k++){
              add(coef[i][k],val);
              mul(val,j);
          }
      }
  }

  dp[0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=C;j++){
          add(dp[i+1][j],(B[i]-A[i]+1)*dp[i][j]);

          for(int k=1;k<=C-j;k++){
              ll res=dp[i][j];
              mul(res,coef[i][k]);
              add(dp[i+1][j+k],res);
          }
      }
  }

  cout<<dp[N][C]<<endl;

  return 0;
}


Measured memory_bytes: 2816
N = int(input())

dp = [10**6] * (N+1)
dp[0] = 0
# 配る DP --- dp[n] から遷移を出して行く
for i in range(N):
    pow6 = 1
    pow9 = 1
    while i + pow6 <= N:
        dp[i+pow6] = min(dp[i+pow6], dp[i]+1)
        pow6 *= 6
    while i + pow9 <= N:
        dp[i+pow9] = min(dp[i+pow9], dp[i]+1)
        pow9 *= 9
print(dp[N])

Measured memory_bytes: 42732
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
const int maxn=1e5+1000;
using namespace std;
int n,m,fa[maxn],out[maxn];
vector<int>side[maxn];
int get(int x){
	if(fa[x]==x)return x;
	fa[x]=get(fa[x]);
	return fa[x];	
}
void uni(int x,int y){
	fa[get(x)]=get(y);	
}
void dfs(int now,int fa){
	for(int i=0;i<side[now].size();i++){
		int v=side[now][i];if(v==fa)continue;
		dfs(v,now);
		if(out[v]&1){printf("%d %d\n",v,now);}
		else{out[now]++;printf("%d %d\n",now,v);}	
	}
	return;
}
int main(){
	scanf("%d%d",&n,&m);
	if(m&1){printf("-1");return 0;}
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++){
		int u,v;scanf("%d%d",&u,&v);
		if(get(u)!=get(v)){side[u].push_back(v);side[v].push_back(u);uni(u,v);}
		else{
			out[v]++;
			printf("%d %d\n",v,u);
		}
	}
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int N = 200005;
const int C = 1000000;
const int MOD = 998244353;
int n;
int a[N];

int add(int x, int y)
{
    x += y;
    if (x >= MOD)
    {
        x -= MOD;
    }
    return x;
}
int mult(int x, int y)
{
    return x * (ll)y % MOD;
}

namespace sieve
{
    int d[C + 6];
    void build()
    {
        iota(d, d + C + 6, 0);
        for (int x = 2; x <= C; ++x)
        {
            if (d[x] == x)
            {
                for (ll y = x * (ll)x; y <= C; y += x)
                {
                    chkmin(d[y], x);
                }
            }
        }
    }
    void get_divisors(int x, vector<int> &f)
    {
        f.pb(1);
        while (x > 1)
        {
            int p = d[x];
            int w = 0;
            while (d[x] == p)
            {
                x /= p;
                ++w;
            }
            int sz = f.size();
            for (int j = 1; j <= w; ++j)
            {
                int SZ = (int)f.size();
                for (int i = SZ - sz; i < SZ; ++i)
                {
                    f.pb(f[i] * p);
                }
            }
        }
    }
}

ll S[C + 6];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    sieve::build();

    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        vector<int> f;
        sieve::get_divisors(x, f);
        sort(all(f));
        int k = f.size();

        vector<ll> s(k, 0);
        for (int j = k - 1; j >= 0; --j)
        {
            s[j] = S[f[j]];
            for (int u = j + 1; u < k; ++u)
            {
                if (f[u] % f[j] == 0)
                {
                    s[j] -= s[u];
                }
            }
            ans = add(ans, mult(x, (s[j] / f[j]) % MOD));
        }

        for (int d : f)
            S[d] += x;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n;
ll a[110000];


int main(){
  cin>>n;
  int r=0,res=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]<0) res++;
    if(a[i]==0) r++;
  }

  if(res%2==0||(res+r)%2==0){
    ll ans=0;
    rep(i,n){
      ans+=abs(a[i]);
    }
    cout<<ans<<endl;
  } else{
    int s=0;

    rep(i,n){
      if(abs(a[i])<abs(a[s]))
        s=i;
    }

    ll ans=-abs(a[s]);
   
    rep(i,n){
      if(i==s) continue;
      ans+=abs(a[i]);
    }

    cout<<ans<<endl;
  }

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] in = sc.nextLine().split(" ");
        int N = Integer.parseInt(in[0]);
        int M = Integer.parseInt(in[1]);

        // いもす法で解いてみる
        int[] imos = new int[N + 1];
        for (int i = 0; i < M; i++) {
            int start = Integer.parseInt(sc.next());
            int end = Integer.parseInt(sc.next());
            imos[start - 1]++;
            imos[end]--;
        }

        // 累積和
        for (int i = 0; i < N; i++) {
            imos[i + 1] += imos[i];
        }

        // 答え
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (imos[i] == M) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 49196
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 S, W;
  std::cin >> S >> W;
  std::cout << (W >= S ? "unsafe" : "safe") << std::endl;
  return 0;
}

Measured memory_bytes: 3600
N = int(input())
A = [0] + list(map(int, input().split()))
x = [0] + [0]*N

# x[i+1] = 2*A[i] - x[i]
S = sum(A)
x[1] = S - 2 * (sum([A[i] for i in range(2, N, 2)]))
for i in range(2, N+1):
    x[i] = 2*A[i-1] - x[i-1]

print(*x[1:])


Measured memory_bytes: 67044
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
ans =0 
for i,j in enumerate(A):
    B[i] = j-(i+1)
B=sorted(B)
b=np.median(np.array(B))
for i,j in enumerate(A):
    ans+= abs(j-(int(b)+i+1))
print(ans)

Measured memory_bytes: 49448
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int M = Integer.parseInt(tokens[0]);
		int D = Integer.parseInt(tokens[1]);
		int count = 0;
		
		for (int d0 = 2; d0 < 10; ++d0) {
			for (int d1 = 2; d1 < 10; ++d1) {
				int day = d0 * 10 + d1;
				if (day > D) {
					continue;
				}
				if (d0 * d1 <= M) {
					++count;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  int a, b, c; cin >> a >> b >> c;
  for(int i = a; i <= (b+1)*a; i += a){
    if (i % b == c) plexit("YES")
  }
  plexit("NO")
  return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    ans = 10 ** 5
    ans = min(ans, abs(a - b) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(a - b))
    print(ans)
    return

#B
def B():
    s, t = S(), S()
    f = 0
    for i in range(len(s)):
        f = f or s[i:] + s[:i] == t
    print(["No","Yes"][f])
    return

#C
def C():
    return

# D
# 解説AC
# 貪欲かよ
# 言われればその通りでbi昇順でソートしていれば
# 直前で取り除いたものに関してはその橋より左側
# の街について絶対に橋が途切れているからね
# fuck!!! 
def D():
    n, m = LI()
    d = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        if d[a] < n - b:
            d[a] = n - b
    mi = 0
    ans = 0
    for i in range(n - 1):
        if mi < d[i]:
            mi = d[i]
        if i == n - mi - 1:
            mi = 0
            ans += 1
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 55260
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0};
const int dy[8] = {0, 1, 0, -1};

void solve() {
  int h, w; cin >> h >> w;
  vector<string> grid(h); rep(i, h) cin >> grid[i];
  vector<P> dots;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '.') dots.push_back(make_pair(i, j));
    }
  }

  ll ans = 0;
  const int MAX = 20;
  bool visited[MAX][MAX] = {};
  for (int i = 0; i < dots.size(); i++) {
    int sy = dots[i].first;
    int sx = dots[i].second;

    queue<ll> qx, qy, qc;
    qx.push(sx);
    qy.push(sy);
    qc.push(0);
    visited[sy][sx] = true;

    while (!qx.empty()) {
      int x = qx.front(); qx.pop();
      int y = qy.front(); qy.pop();
      int c = qc.front(); qc.pop();
      ans = max(ans, c);

      for (int k = 0; k < 4; k++) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (nx >= 0 && nx < w && ny >= 0 && ny < h && !visited[ny][nx] && grid[ny][nx] == '.') {
          visited[ny][nx] = true;
          qx.push(nx);
          qy.push(ny);
          qc.push(c + 1);
        }
      }
    }

    memset(visited, false, sizeof(visited));
  }

  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; ++i)
            a[i] = scanner.nextLong();
        long[] prefix = new long[n];
        prefix[0] = a[0];
        for (int i = 1; i < n; ++i)
            prefix[i] = prefix[i - 1] + a[i];
        long suffix = 0;
        long ans = Long.MAX_VALUE;
        for (int i = n - 1; i > 0; --i) {
            suffix += a[i];
            ans = Math.min(ans, Math.abs(suffix - prefix[i - 1]));
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 47496
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;
	ll a[101];
	ll y=0;

	cin>>n;

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

	for(ll i=1; i<n+1; ++i){
		if(a[i]==a[i+1]){
			y+=1;
			a[i]=0;
			a[i+1]=0;
		}
	}
	cout<<y<<endl;
	return 0;
}


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

int main(int argc, char *argv[])
{
  string As, Bs, Cs, Ks;
  cin >> As >> Bs >> Cs >> Ks;
  int A = stoi(As), B = stoi(Bs), C = stoi(Cs), K = stoi(Ks);

  if (A + B >= K)
  {
    if (A >= K)
    {
      cout << K << endl;
      return 0;
    }
    else
    {

      cout << A << endl;
    }
    return 0;
  }

  if (A + B + C >= K)
  {
    int dff = K - (A + B);
    //if (A - dff > 0)
    // {
    cout << A - dff << endl;
    // }
  }
  //cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3164
input = raw_input

n, k = map(int, input().split(" "))

have = [False] * n
for _ in range(k):
    d = int(input())
    As = map(int, input().split(" "))
    for A in As:
        A -= 1
        have[A] = True

out = n - sum(have)    
print(out)

Measured memory_bytes: 69176
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <sstream>
#include <deque>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <utility>   // std::pair, std::make_pair
#include <stdlib.h>  //atoi
using namespace std;
typedef long long ll;
const  double PI = 3.141592654;
#define rep(i,x) for(int(i)=0;(i)<(ll)(x);(i)++)
#define all(s)      (s).begin(),(s).end()
#define allv(v)      (v).begin(),(v).end()
#define pb          push_back
#define sz          s.size()
#define vz          v.size()
//x = atoi(a.c_str())
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main()
{
	fast();
	int x;
	cin >> x;
	map<int, int>mp;
	rep(i, x)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	int sum = 0;
	for (auto e : mp)
	{
		if (e.first > e.second)
			sum += e.second;
		else if (e.first < e.second)
			sum += e.second - e.first;
	}
	cout << sum << endl;
	return 0;
}

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

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

int main() {
    int h,w;
    cin >> h >> w;
    ve<ve<int>> a(h,ve<int>(w)), b(h,ve<int>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w) cin >> b[i][j];
    ve<ve<int>> c(h,ve<int>(w));
    rep(i,h)rep(j,w) c[i][j] = abs(a[i][j]-b[i][j]);
    
    ve<ve<ve<bool>>> dp(h,ve<ve<bool>>(w,ve<bool>(6500,false)));
    dp[0][0][c[0][0]]=true;
    rep(i,h)rep(j,w){
        int now = c[i][j];
        rep(d,2){
            int px = i + dx[d];
            int py = j + dy[d];
            if(px < 0 || py < 0) continue;
            rep(k,6400){
                if(dp[px][py][k]){
                    dp[i][j][k+now] = true;
                    dp[i][j][abs(k-now)] = true;
                }
            }
        }
    }
    int ans;
    rep(i,6500){
        if(dp[h-1][w-1][i]){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9012
#include <iostream>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main(){
	int X, x, n, flag, ans;
	cin >> X;
	int prime[100000];
	n = 1;
	x = 2;
	prime[0] = 2;
	while(true){
		flag = 0;
		if(X == 2){
			ans = 2;
			break;
		}else{
			for(int i = 0; i < n; i++){
				if(x%prime[i] == 0){
					flag = 1;
					break;
				}
				if(prime[i]*prime[i] >= x){
					break;
				}
			}
			if(flag == 0){
				n++;
				prime[n-1] = x;
				if(x >= X){
					ans = x;
					break;
				}
			}
			x++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
    input = input.split(' ');
    let r = parseInt(input[0], 10);
    let D = parseInt(input[1], 10);
    let n = parseInt(input[2], 10);
  	let x = [n*r - D];
	for(let i = 0; i < 10; i++){
      let ans = x[i]*r - D;
      x.push(ans);
	console.log('%d',x[i]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

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

    if (s < 3){
        cout << 0 << endl;
        return 0;
    }

    combination c(10000);

    int r = s % 3;
    int n = (s / 3);
    mint ans = 0;
    while(n){
        ans += c(n+r-1, n-1);
        r += 3;

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

Measured memory_bytes: 3764
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, M;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> M;
    int maxUp = 0, maxDown = 0;
    int last; cin >> last;
    for (int j = 0; j < M-1; j++) {
      int a; cin >> a;
      if (a < last) {
        maxDown = max(maxDown, last-a);
      } else {
        maxUp = max(maxUp, a-last);
      }
      last = a;
    }
    cout << maxUp << " " << maxDown << endl;
  }
}




Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    set<char> s;
    for(auto& e : S)
    {
        auto p = s.insert(e);
        if(!p.second)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    S = input()
    R = []
    G = []
    B = []
    for i in range(N):
        if i == 0:
            if S[0] == "R":
                R.append(1)
                B.append(0)
                G.append(0)
            elif S[0] == "B":
                R.append(0)
                B.append(1)
                G.append(0)
            else:
                R.append(0)
                B.append(0)
                G.append(1)
            continue
        if S[i] == "R":
            R.append(R[i - 1] + 1)
            B.append(B[i - 1])
            G.append(G[i - 1])
        elif S[i] == "G":
            R.append(R[i - 1])
            B.append(B[i - 1])
            G.append(G[i - 1] + 1)
        else:
            R.append(R[i - 1])
            B.append(B[i - 1] + 1)
            G.append(G[i - 1])

    answer = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if (S[i], S[j]) == ("G", "R") or (S[i], S[j]) == ("R", "G"):
                answer += B[-1] - B[j]
                if 2 * j - i < N:
                    if S[2 * j - i] == "B":
                        answer -= 1
            elif (S[i], S[j]) == ("G", "B") or (S[i], S[j]) == ("B", "G"):
                answer += R[-1] - R[j]
                if 2 * j - i < N:
                    if S[2 * j - i] == "R":
                        answer -= 1
            elif (S[i], S[j]) == ("B", "R") or (S[i], S[j]) == ("R", "B"):
                answer += G[-1] - G[j]
                if 2 * j - i < N:
                    if S[2 * j - i] == "G":
                        answer -= 1
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69528