akhauriyash/Code-Regression huggingface dataset:
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

while True:
    try:
        a,b=map(int,input().split())
        print(gcd(a,b),lcm(a,b))
    except:
        break


Measured memory_bytes: 5596
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    for(int i = 0; i < len; i++){
        if(s[i] == ',')printf(" ");
        else printf("%c", s[i]);
    }


    return 0;
}


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

#define N 1000
int main() {

  int n;
  cin>>n;
  int cats[N];

  int cat, tail = 0;
  for(int i = 0; i < n; i++) {
    cin>>cat;
    if (cat > 0) {
      for (int j = 0; j < tail; j++) {
        if (cats[j] == cat) {
	  cout<<i+1<<endl;
          return 0;
        }
      }
      cats[tail] = cat;
      tail++;
    } else {
      if (cats[tail-1] != -cat) {
	cout<<i+1<<endl;
	return 0;
      }
      tail--;
    }
  }

  cout<<"OK"<<endl;
  
  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    ll x,y;
    cin >> x >> y;
    
    ll ans = 0;
    if(x > 0 && y > 0){
        if(abs(x) > abs(y)){
            ans = x-y+2;
        }else{
            ans = y-x;
        }
        
    }else if(x < 0 && y > 0){
        
        if(abs(x) >= abs(y)){
            ans = abs(x)-y+1;
        }else{
            ans = 1+y+x;
        }
        
    }else if(x > 0 && y < 0){
        if(abs(x) >= abs(y)){
            ans = x - abs(y) + 1;
        }else{
            ans = abs(y)-x+1;
        }
    }else if(x < 0 && y < 0){
        if(abs(x) > abs(y)){
            ans = y-x;
        }else{
            ans = (x-y)+2;
        }
    }else if(x == 0){
        if(y > 0) ans = y;
        else ans = 1-y;
    }else if(y == 0){
        if(x < 0) ans = -x;
        else ans = 1+x;
    }
    
    
    cout << ans << endl;
    
    
    
    

    return 0;
}


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

using namespace std;

int main() {

  string S;
  cin >> S;

  int min_diff = 1000;
  for (int i = 0; i < S.length() - 2; ++i) {
    int hoge1 = S[i] - '0';
    int hoge2 = S[i+1] - '0';
    int hoge3 = S[i+2] - '0';
    int num_i = hoge1 * 100 + hoge2 * 10 + hoge3;
    int diff = abs(num_i - 753);
    // cout << num_i << "," << diff << endl;
    min_diff = min(diff, min_diff);
  }
  cout << min_diff << endl;
}

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

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

int main() {
  ll n, ans = 0;
  cin >> n;
  ll a[n][n], dp[n][n];
  rep(i, n) rep(j, n) cin >> a[i][j], dp[i][j] = a[i][j];

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j || i == k || k == j || dp[i][k] == -1 || dp[k][j] == -1)
          continue;
        if (a[i][j] == dp[i][k] + dp[k][j]) {
          dp[i][j] = -1;
        } else if (a[i][j] > dp[i][k] + dp[k][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  rep(i, n) rep(j, n) if (dp[i][j] != -1) ans += dp[i][j];

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

Measured memory_bytes: 2172
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;

int r;

int main() {
	cin >> r;
	cout << r * r << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    string S;
    cin >> S;

    map<char, int> mp;
    for(int i = 0; i < S.length(); i++)
    {
        mp[S[i]]++;
    }

    bool isContain = true;
    for(auto m : mp)
    {
        if(m.second != 1)
        {
            isContain = false;
        }
    }

    if(isContain) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Map <Long,Long> mapA = new HashMap<Long,Long> ();
		Map <Long,Long> mapB = new HashMap<Long,Long> ();
			// 整数の入力
		int k,x,start,end,index;

		k = sc.nextInt();
		x = sc.nextInt();
		sc.close();
		
		start=x-k+1;
		end=x+k-1;
		for(index=start;index<end;index++) {
			System.out.print(index);
			System.out.print(" ");
		}
		System.out.print(end);

			// 出力
 
	}
}

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



int main(){
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) cout << S << endl;
    else{
        S = S.erase(K);
        S = S + "...";
        cout << S << endl;
    }
}

Measured memory_bytes: 3632
/******************************************c++
* 20.04.16 AtCoder Beginner Contest 159. C - Maximum Volume
* 
* 
*********************************************/
/*********************************************
 
問題文
正の整数Lが与えられます。縦、横、高さの長さ
(それぞれ、整数でなくてもかまいません)
の合計がLの直方体としてありうる体積の最大値を求めてください。

::test input::
999

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

class CRun{
private:
    struct {
        double L;
    }gv;
public:
    CRun(){}; ~CRun(){};
    void build(); void solve();
};

void CRun::build(){
    cin >> gv.L;
}

void CRun::solve(){
    double side = gv.L/3;
    cout << fixed << setprecision(12) << pow(side,3) << ET;
}


int main(){
    CRun run;
    run.build();
    run.solve();
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;
struct X { long long int b, c; };
bool cmp(X x, X y) {
	return x.c > y.c;
}
int main() {
	X x[200005];
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, k,a[200005],L[200001], R[200001],res=0,now=0;
	long long int sum=0;
	cin >> n >> m;
	for (int i = 0; i <n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < m; i++) {
		cin >> x[i].b >> x[i].c;
		sum += x[i].b;
	}
	sort(x, x + m, cmp);
	for (int i = 0; i < m; i++) {
		next:
		if (a[now] < x[i].c) {
			while (a[now] < x[i].c&&x[i].b != 0&&now!=n) {
				a[now] = x[i].c;
				now++;
				x[i].b--;
			}
			
		}

	}
	for (int i = 0; i < n; i++) {
		res += a[i];
	}
	cout << res;
}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  vector<char> s;
  for( int i = 0; i < b.size(); i++ ) { 
    if( b[ i ] == 'B' ) { 
      if( s.size() != 0 ) {
        s.pop_back();
      }
    }
    else {
      s.push_back( b[ i ] );
    }
  }

  for( int i = 0; i < s.size(); i++ ) {
    cout << s[ i ];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<vector<ll>> dp(2002, vector<ll>(2002));
//dp.at(i).at(j)はXがi番目、Yがj番目のカードを持っているときから
//開始したときのスコア
//i<j ならXの手番から、j<i ならYの手番から

int main(){
  int N;
  ll Z, W;
  cin >> N >> Z >> W;
  vector<ll> a(N+2);
  a.at(0) = Z;
  a.at(1) = W;
  rep(i, N){
    cin >> a.at(i+2);
  }
  rep(i, N+1){
    dp.at(N+1).at(i) = abs(a.at(N+1) - a.at(i));
    dp.at(i).at(N+1) = abs(a.at(N+1) - a.at(i));
  }
  bool ch = false;
  vector<int> bestX(N+2, -1); 
  //bestX.at(i)はXの手番でYがi番目のカードを持っているときに何番目のカードを手にすべきか
  vector<int> bestY(N+2, -1);
  rep(i, N+2){
    rep(j, N+1){
      if(i == j){
        continue;
      }
      else if(i > j){ // Xの手番
        if(bestX.at(N+1-j) >= 0){
          dp.at(N+1-i).at(N+1-j) = dp.at(bestX.at(N+1-j)).at(N+1-j);
          continue;
        }
        ll a = -1;
        rep2(k, 1, j+1){
          if(chmax(a, dp.at(N+1-j+k).at(N+1-j))){
            bestX.at(N+1-j) = N+1-j+k;
          }
          ch = true;
        }
        if(ch){
          dp.at(N+1-i).at(N+1-j) = a;
        }
        ch = false;
      }
      else{
        if(bestY.at(N+1-i) >= 0){
          dp.at(N+1-i).at(N+1-j) = dp.at(N+1-i).at(bestY.at(N+1-i));
          continue;
        }
        ll b = INF;
        rep2(k, 1, i+1){
          if(chmin(b, dp.at(N+1-i).at(N+1-i+k))){
            bestY.at(N+1-i) = N+1-i+k;
          }
          ch = true;
        }
        if(ch){
          dp.at(N+1-i).at(N+1-j) = b;
        }
        ch = false;
      }
    }
  }
  cout << dp.at(0).at(1) << endl;
}

Measured memory_bytes: 31616
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

fn main() {
    let k = read_line_to_tuple!(usize);

    let mut ans = String::new();
    for _ in 0..k {
        ans.push_str("ACL");
    }
    println!("{}", ans);
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
        var s = Console.ReadLine();
          if(s[0] == s[2])
            Console.WriteLine("=");
          else if(s[0] < s[2])
            Console.WriteLine("<");
          else if(s[0] > s[2])
            Console.WriteLine(">");
        }
    }
}


Measured memory_bytes: 13140
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	ans := 0

	mm := map[int]int{}
	for i := 1; i <= n; i++ {
		s := fmt.Sprintf("%d", i)
		if s[len(s)-1] == '0' {
			continue
		}
		k := int(s[0]-'0')*10 + int(s[len(s)-1]-'0')
		ans += mm[(k%10)*10+k/10] * 2

		mm[k]++
		if k/10 == k%10 {
			ans++
		}

	}

	fmt.Fprintln(stdout, ans)
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;
const int INF = 1e9;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;

    int k;
    cin >> k;

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

    vector<int> dp(n,INF);;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        int j = i-1;
        int cnt = 1;
        while (j >= 0 && cnt <= k) {
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
            j--;
            cnt++;
        }
    }

    out(dp[n-1]);
    
    return 0;
}


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

using namespace std;

int main()
{
   int a,b,c,d;
   string A;
   cin >> A;
   a = A.length();
   bool r = true;
   for(b = 0;b < a;b++){
       if(b % 2 == 0){
           if(A[b] == 'L'){
               r = false;
               break;
           }
       }else{
           if(A[b] == 'R'){
               r = false;
               break;
           }
       }
   }
   if(r){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 3588
#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 EPS (1e-7)

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n;
	cin>>n;
	ll a[n],b[n];
	REP(i,n)cin>>a[i];
	REP(i,n)cin>>b[i];
	bool flag=true;
	ll sum=0;
	ll k=0;
	REP(i,n){
		if(b[i]>a[i])sum+=(b[i]-a[i])/2;
		if(a[i]>b[i])k+=a[i]-b[i];
	}
	if(k>sum || sum<0){
		flag=false;
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
#include <sstream> 
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;





int main()
{
    ll n;
    cin >> n;
    
    ll ans;
    rep(i, 10) {
        if ((i + 1) * 1000 >= n) {
            ans = (i + 1) * 1000 - n;
            break;
        }
    }
    cout << ans;

}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    char c;
    cin >> c;
    cout << (char)(((c - 'a' + 1) % 26) + 'a') << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split(" "))    # N:人数, K:初期スコア, Q:問題数
A = [int(input()) for i in range(Q)]    # 正解者のリスト
B = [0 for i in range(N)]    # 各人の正解数

for i in range(Q):
    num_ans_person = A[i] - 1
    B[num_ans_person] += 1

# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + B[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8644
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int _C[200006];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);

	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> B = A;
	sort(B.begin(), B.end());
	int all = N*(N + 1) / 2;
	int u = N - 1;
	int d = -1;
	//cerr << (all / 2) + 1 << endl;
	vector<int> X(N + 1, 0);
	int *C = _C + 100003;
	int sum;
	while (u - d > 1) {
		int m = (u + d) / 2;
		//cerr << m << endl;
		for (int i = 0; i < N; i++) {
			if (A[i] <= B[m])X[i + 1] = 1;
			else X[i + 1] = -1;
			
		}
		for (int i = -N; i <= N; i++) {
			C[i] = 0;
		}
		for (int i = 0; i < N; i++) {
			X[i + 1] += X[i];
		}
		int num = 0;
		sum = 0;
		cerr << m << endl;
		for (int i = N; i >= 0; i--) {
			num += sum;
			//cerr << i <<  " " <<  sum << endl;
			C[X[i]]++;
			if (i > 0) {
				if (X[i - 1] < X[i]) {
					sum += C[X[i]];
				}
				else {
					sum -= C[X[i] + 1];
				}
			}
		}
		//cerr << m << " " << num << endl;
		if (num < (all / 2) + 1) {
			d = m;
		}
		else {
			u = m;
		}
	}
	cout << B[u] << endl;
}

Measured memory_bytes: 4224
# coding:utf-8

import sys
import random
# from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    red = [LI() for _ in range(n)]
    blue = [LI() for _ in range(n)]
    blue.sort()

    used = [0] * n
    res = 0
    for a, b in blue:
        t = -1
        k = -1
        for i, (x, y) in enumerate(red):
            if used[i]:
                continue

            if x < a and b > y > t:
                t = y
                k = i

        if k != -1:
            used[k] = 1
            res += 1

    return res


print(main())


Measured memory_bytes: 4208
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    pair<int,int>pii[n];
    for(int i=0;i<n;i++){
      int a,b,c,d,e,f,g,h;
      cin>>pii[i].S;
      cin>>a>>b>>c>>d>>e>>f>>g>>h;
      pii[i].F=100*((a+c+e+g)+(b+d+f+h)/60)+(b+d+f+h)%60;
    }
    sort(pii,pii+n);

    cout<<pii[0].S<<endl;
    cout<<pii[1].S<<endl;
    cout<<pii[n-2].S<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

H,W = map(int, input().split())

Map = []
for i in range(H):
    h = list(map(int, input().split()))
    Map.append(h)

N = 0
ans = []

for i in range(H):
    for j in range(W-1):
        if Map[i][j] % 2 == 1:
            N += 1
            Map[i][j] -= 1
            Map[i][j+1] += 1
            ans.append((i+1,j+1,i+1,j+2))

for i in range(H-1):
    if Map[i][W-1] % 2 == 1:
        N += 1
        Map[i][W-1] -= 1
        Map[i+1][W-1] += 1
        ans.append((i+1,W,i+2,W))

print(N)
for a in ans:
    print(' '.join(map(str, a)))

Measured memory_bytes: 35444
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
int mod = 1000000007;

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

	vector<ll> A(N);
	ll sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
		sum %= mod;
	}

	ll ans = 0;
	REP(i, N) {
		sum -= A[i];
		if (sum < 0) sum += mod;

		ans += A[i] * sum;
		ans %= mod;
	}

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

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	int n; cin >> n;

	string ans = "APPROVED";
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x % 2 == 0 and !(x%3==0 or x%5==0)) ans = "DENIED";
	}

	cout << ans << endl;

	return 0;
}



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

int main()
{

        vector<int> H;
        vector<int> W;

        while (1) {

                int tmp1, tmp2;
                cin >> tmp1 >> tmp2;
                if (tmp1 == 0 && tmp2 == 0) {
                        break;
                }
                H.push_back(tmp1);
                W.push_back(tmp2);

        }
        int n = H.size();
        for (int i = 0; i < n; ++i) {

                for (int k = 0; k < H[i]; ++k) {
                        for (int j = 0; j < W[i]; ++j) {
                                cout << '#';
                        }
                        cout << endl;
                }
                cout << endl;
        }



}



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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  cin >> v.at(i);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int k;
    cin >> k;
    auto bound = equal_range(v.begin(), v.end(), k);
    cout << bound.first - v.begin() << " " << bound.second - v.begin() << endl;
  }
}


Measured memory_bytes: 3096
import itertools
import collections

N = int(input())
x_y = [list(map(int, input().split())) for _ in range(N)]

count = collections.defaultdict(int)
for i in itertools.combinations(x_y, 2):
    count[(i[0][0]-i[1][0], i[0][1]-i[1][1])] += 1
    count[(i[1][0]-i[0][0], i[1][1]-i[0][1])] += 1
if not count:
    print(N)
else:
    print(N-max(count.values()))

Measured memory_bytes: 40304
while True:
	H, W = list(map(int, input().split()))
	if H == 0 and W == 0:
		break
	else:
		a = list(input() for i in range(H))
		visitedlist = []
		h = 0
		w = 0
		while True:
			if [h, w] not in visitedlist:
				visitedlist.append([h, w])
				if a[h][w] == '>':
					w += 1
				if a[h][w] == '<':
					w -= 1
				if a[h][w] == '^':
					h -= 1
				if a[h][w] == 'v':
					h += 1
				if a[h][w] == '.':
					print(w, h)
					break
			else:
				print('LOOP')
				break
				

Measured memory_bytes: 7696
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, sum = 0; cin >> n;
	int a[300000] = { 0 };
	for (int i = 0; i < n * 3; i++) {
		cin >> a[i];
	}
	sort(a, a + n * 3);
	for (int h = n; h < n * 3; h++) {
		sum += a[h];
		h++;
	}
	cout << sum << endl;
	cin >> n;
}

Measured memory_bytes: 1408
from fractions import gcd
from math import sqrt
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


def main():
    a, b = map(int, input().split())
    print(len(prime_factorize(gcd(a, b))) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <stdio.h>
 
int main(void){
    char s[200000];
    char t[200000];
    
    int i, j;
    i = 0;
    j = 0;
    
    scanf("%s\n%s", s, t);
    
    while (s[i] != '\0' && t[i] != '\0'){
            if(s[i] != t[i]){
                s[i] = t[i];
                j++;
            }
            i++;
    }
    printf("%d\n", j);
    
    return 0;
}

Measured memory_bytes: 2076
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b&&b!=c)
{
cout<<"Yes";
}
else if(a==c&&a!=b)
{
cout<<"Yes";
}
else if(b==c&&a!=b)
{
cout<<"Yes";
}
else 
cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <cctype>

using namespace std;

const int64_t INF=10000000000000000;

class UnionFind{
	int32_t *par;
	int32_t *rank;
	int64_t *movable_size;
private:
	int32_t root(int32_t num){
		if(par[num]==num){
			return num;
		}else{
			return par[num]=root(par[num]);
		}
	}
public:
	UnionFind(const int32_t size){
		par = new int32_t[size];
		rank=new int32_t[size];
		movable_size=new int64_t[size];
		for(int32_t i=0;i<size;i++){
			par[i]=i;
			rank[i]=0;
			movable_size[i]=1;
		}
	}
	bool same(int32_t a,int32_t b){
		return root(a)==root(b);
	}
	void unite(int32_t a,int32_t b){
		if(root(a)==root(b)){
			return;
		}
		a=root(a);
		b=root(b);
		if(rank[a]<rank[b]){
			par[a]=b;
			movable_size[b]=movable_size[a]+movable_size[b];
		}else if(rank[a]==rank[b]){
			par[a]=b;
			rank[b]++;
			movable_size[b]=movable_size[a]+movable_size[b];
		}else{
			par[b]=a;
			movable_size[a]=movable_size[a]+movable_size[b];

		}

	}
	int64_t getSize(int64_t a){
		return movable_size[root(a)];
	}
	virtual ~UnionFind(){
		delete[] par;
		delete[] rank;
	}
};


int main(){
    int32_t n,m;
    int32_t ans=0;
    cin>>n>>m;
    UnionFind uf = UnionFind(n);
    for(int32_t i1=0;i1<m;i1++){
        int32_t x,y,z;
        cin>>x>>y>>z;
        if(uf.same(x-1,y-1)){
            continue;
        }else{
            uf.unite(x-1,y-1);
            ans++;
        }
    }
    ans=n-ans;
    cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main {        
    public static void main(String args[]) {
        int n=II();
        int k=II();

        int a[]=IIA(n);

        for(int i=0;i<n-k;i++){
            if(a[i+k]>a[i])
                System.out.println("Yes");
            else
                System.out.println("No");
        }

    }
    
    ////////////////////////////////////
    static scan in=new scan(System.in);
    static int II() {
        return in.nextInt();
    }
    static long IL() {
        return in.nextLong();
    }
    static int[] IIA(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;i++) {
            a[i]=II();
        }
        return a;
    }
    static String IS() {
        return in.next();
    }
    static char IC(){
        return in.next().charAt(0);
    }
    static String[] ISA(int n) {
        String a[]=new String[n];
        for(int i=0;i<n;i++) {
            a[i]=IS();
        }
        return a;
    }
    static char[] ICA(int n) {
        char a[]=new char[n];
        for(int i=0;i<n;i++) {
            a[i]=IC();
        }
        return a;
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

}

Measured memory_bytes: 56280
$N, $A, $B, $C = gets.split(' ').map(&:to_i)
$LIST = $N.times.map { gets.to_i }

def dfs(depth, arr)
  return arr if depth > $N
  return dfs(depth + 1, [[0], [1], [2], [3]]) if depth == 1

  current_arr = []

  arr.each do |e|
    4.times do |i|
      current_arr << (e.clone << i)
    end
  end

  dfs(depth + 1, current_arr)
end

min = -1
dfs_arr = dfs(1, [])
dfs_arr.each do |e|
  abc = [0, 0, 0]
  mp = 0
  e.each_with_index do |n, i|
    unless n == 3
      mp += 10 if abc[n] > 0
      abc[n] += $LIST[i]
    end
  end

  next if abc[0] == 0 || abc[1] == 0 || abc[2] == 0

  mp += (($A - abc[0]).abs + ($B - abc[1]).abs + ($C - abc[2]).abs)
  min = mp if mp < min || min == -1
end

puts min


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define sz s.size();
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int m, n;
char a[123][120];
char b[123][120];

void init(){
	si2(n, m);
	forn(i, n)
	{
		forn(j, n)
		{
			cin >> a[i][j];
		}
	}
	forn(k, m)
	{
		forn(l, m)
		{
			cin >> b[k][l];
		}
	}
	int match = 0;
	forn(ly, n)
	{
		forn(lx, n)
		{
			if(ly - 1 + m >= n or lx + m - 1 >= n) {
				continue;
			}  
			int exist = 1;
			forn(y, m) 
			{
				forn(x, m)
				{
					if(a[ly + y][lx + x] != b[y][x]) exist = 0;
				}
			}
			if(exist){
				match = 1;
			}
		}
	}
	if(match)
	{
		printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	init();
	return 0;
}

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    a,b = map(float, input().split())
    for i in range(2000):
        if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
            print(i)
            exit()
    print(-1)

if __name__=="__main__":
    main()


Measured memory_bytes: 63728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,k,a;
    cin>>n>>k;
    cout<<(n-1+k-2)/(k-1);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
      String ss[]=s.split("",0);
      int max=0,index=0;
      for(int i=0;i<ss.length;i++){
      	if(ss[i].equals("A")||ss[i].equals("C")||ss[i].equals("G")||ss[i].equals("T")){
        	index++;
          max=Math.max(max,index);
        }
        else {
          max=Math.max(max,index);
        	index=0;
        }
        
      }
      System.out.println(max);
    }
}


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

#define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) ((a)>(b))?(a):(b)

int N, Z, W;
int a[2000];
int s[2][2000];
int INF=2000000000;

int searchScore(int teban, int i,int x, int y){
    //printf("teban=%d, i=%d, x=%d, y=%d ",teban,i,x,y);
    if(i==N)return abs(x-y);
    //printf("a");
    if(s[teban][i]>=0)return s[teban][i];
    //printf("b");
    int j;
    int ret;
    int score;
    if(teban){
        ret=INF;
        for(j=i+1;j<=N;j++){
            //printf("c1");
            //printf("y%d\n",a[j-1]);
            score=searchScore(0,j,x,a[j-1]);
            ret=MIN(ret,score);
            //printf("d1");
        }
    }else{
        ret=0;
        for(j=i+1;j<=N;j++){
            //printf("c2");
            //printf("x%d\n",a[j-1]);
            score=searchScore(1,j,a[j-1],y);
            ret=MAX(ret,score);
            //printf("d2");
        }
    }
    //printf("ret=%d\n",ret);
    return s[teban][i]=ret;
}

int main()
{
    scanf("%d %d %d",&N,&Z,&W);
    int i,j;
    for(i=0;i<N;i++)scanf("%d",&a[i]);

    for(i=0;i<2;i++)for(j=0;j<N;j++)s[i][j]=-1;
    int ans=searchScore(0,0,Z,W);
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
def abc(a,b,c):
    if a==n:
        pass
    else:
        if b == 1:
            c += A[a]
            s.add(c)
        abc(a+1,0,c)
        abc(a+1,1,c)

n = int(input())
A = [int(a) for a in input().split()]
q = int(input())
M = [int(m) for m in input().split()]
s = set()

abc(0,0,0)
abc(0,1,0)

for m in M:
    if m in s:
        print("yes")
    else:
        print("no")

Measured memory_bytes: 7748
-- Digit Number
main = getContents >>= putStr . solve
-- main = getContents >>= putStr . unlines . map show . solve

-- solve :: String -> [Int]
-- solve = map (length . show . sum . map read) . map words . lines
solve :: String -> String
solve = unlines . map (show . length . show . sum . map read) . map words . lines

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int64_t A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if((V-W)*T>=abs(A-B))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> a;
  vector<int> b;
  int i,temp;
  for(i = 0;i < m;++i){
    cin >> temp;
    if(temp < x){
      a.push_back(temp);
    }else{
      b.push_back(temp);
    }
  }
  cout << min(a.size(),b.size()) << endl;
  return 0;
}


Measured memory_bytes: 256
def f_b():
    from math import ceil
    *a, = map(int, open(0).read().split())
    a.sort(key=lambda x: (10-x%10)%10)
    print(sum(map(lambda x: ceil(x/10)*10, a[:-1]))+a[-1])

if __name__ == "__main__":
    f_b()


Measured memory_bytes: 2940
n = int(input())
cnt_tb = [0]*(n+1)
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp < n+1):
        cnt_tb[tmp] += 1
        j += 1
        tmp = i*j
ans = 0
for i in range(1, len(cnt_tb)):
    ans += i * cnt_tb[i]
print(ans)

    

Measured memory_bytes: 151340
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

class Node {
    constructor(n) {
        this.value = n;
        this.prev = null;
        this.next = null;
    }
}

class List {
    constructor() {
        this.size = 0;
        this.head = null;
        this.tail = null;
    }

    insert(n) {
        const newNode = new Node(n);
        if (this.size === 0) {
            this.head = newNode;
            this.tail = newNode;
        } else {
            newNode.next = this.head;
            this.head.prev = newNode;
            this.head = newNode;
        }
        this.size++;
    }

    del(n) {
        let delNode = this.head;
        while(delNode.value !== n) {
            delNode = delNode.next;
            if (delNode === null) return;
        }
        if (delNode.prev !== null) delNode.prev.next = delNode.next;
        else this.head = delNode.next;
        if (delNode.next !== null) delNode.next.prev = delNode.prev;
        else this.tail = delNode.prev;
        
        this.size--;
    }

    deleteFirst() {
        this.head = this.head.next;
        if (this.head !== null) this.head.prev = null;
        this.size--;
    }

    deleteLast() {
        this.tail = this.tail.prev;
        if (this.tail !== null) this.tail.next = null;
        this.size--;
    }

    toArray() {
        let currentNode = this.head;
        const arr = [];
        while(currentNode !== null) {
            arr.push(currentNode.value);
            currentNode = currentNode.next;
        }

        return arr;
    }
}


const cmds = line.slice(1);
const ans = cmds.reduce((acc, x) => {
    const cmd = x.split(' ');
    switch (cmd[0]) {
        case 'insert':
            acc.insert(parseInt(cmd[1]));
            break;
        case 'delete':
            acc.del(parseInt(cmd[1]));
            break;
        case 'deleteFirst':
            acc.deleteFirst();
            break;
        case 'deleteLast':
            acc.deleteLast();
            break;
    }

    return acc;
}, new List()).toArray().map(x => x.toString()).join(' ');

console.log(ans);



Measured memory_bytes: 263828
#include<bits/stdc++.h>
using namespace std;
int main(){int a,b,m,i,ma=100000,mb=100000,ans,l,r,c;
cin>>a>>b>>m;
int A[a+1],B[b+1];
for(i=1;i<=a;i++){cin>>A[i];
    ma=min(ma,A[i]);
}
for(i=1;i<=b;i++){cin>>B[i];
    mb=min(mb,B[i]);
}
ans=mb+ma;
while(m--){
    cin>>l>>r>>c;
    ans=min(ans,A[l]+B[r]-c);
}
cout<<ans;
    return 0;}

Measured memory_bytes: 1024
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int L[210000];
int R[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++){
		L[i]=i+1+p[i];
		R[i]=i+1-p[i];
	}
	std::sort(L,L+a);
	std::sort(R,R+a);
	long long ret=0;
	for(int i=0;i<a;i++){
		ret+=upper_bound(L,L+a,R[i])-lower_bound(L,L+a,R[i]);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 4040
#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 6)

N, Q = map(int, input().split())

edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

query = []
for _ in range(Q):
    p, x = map(int, input().split())
    query.append([p, x])

counter = [0 for _ in range(N)]
for p, x in query:
    counter[p - 1] += x


def dfs(v, parent):
    for v_next in edges[v]:
        if v_next != parent:
            counter[v_next] += counter[v]
            dfs(v_next, v)


root = 0
dfs(root, None)

print(*counter)


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

int main(void){
    long long int x = 0, yokin = 0; 
    int ans = 0;

    scanf("%lld", &x);
    yokin = 100;

    while(yokin < x){
        yokin = floor(yokin * 1.01);
        ans++;
    }

    printf("%d\n", ans);
    return 0;

} 


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, c;
  cin >> a >> b >> c;
  cout << min({a+b, a+c, b+c}) << endl;
}

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

int main()
{
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e9;
int main() 
{
	ll n, k;
	cin >> n >> k;
	n = n % k;
	while (n > k / 2) {
		n = abs(n - k);
	}
	cout << n;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// Tenka1 Programmer Bginner Contest A - Measure

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;  cin >> S;
  int N = S.size();
  if(N == 2){
    cout << S << endl;
  }else{
    REP(i, 3){
      cout << S[2-i];
    }
    cout << endl;
  }
}

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

using namespace std;

int main()
{
    int n, m;
    static long long s[100000], t[100000], p[100001];
    static long long esum[100001], osum[100001];
    
    scanf("%d %d", &n, &m);
    
    for (int i = 0; i < n; i++) scanf("%lld %lld", s + i, t + i);
    for (int i = 0; i < m; i++) scanf("%lld", p + i);
    p[m++] = 0;
    sort(p, p + m);
    
    for (int i = 0; i < m; i++){
        if (i & 1){
            osum[i] = p[i] + (i ? osum[i - 1] : 0);
            osum[i + 1] = osum[i];
        }
        else {
            esum[i] = p[i] + (i ? esum[i - 1] : 0);
            esum[i + 1] = esum[i];
        }
    }
    
    
    long long ans = 0;
    
    for (int i = 0; i < n; i++){
        int mini = min(s[i], t[i]), maxi = max(s[i], t[i]);
        int minpos = upper_bound(p, p + m, mini) - p;
        int maxpos = upper_bound(p, p + m, maxi) - p - 1;
        
        if (minpos == m){
            ans += maxi - mini;
            continue;
        }
        
        long long tmp = osum[maxpos] - osum[minpos - 1] - esum[maxpos] + esum[minpos - 1];
        
        if ((maxpos - minpos + 1) & 1){
            if (s[i] > t[i]){
                //t[i] / ---- s[i]
                ans += s[i] + ((maxpos & 1) ? -tmp : tmp);
            }
            else {
                //s[i] --- / t[i]
                ans += ((maxpos & 1) ? tmp : -tmp) - s[i];
            }
        }
        else {
            ans += abs(t[i] - s[i]) + min(tmp, -tmp);
        }
    }
    
    printf("%lld\n", ans);
    
    return (0);
}

Measured memory_bytes: 5108
<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));
$h = [];
for ($i=0; $i<$n; $i++) {
    fscanf(STDIN, "%d", $h[$i]);
}
array_multisort($h);

$ans = 10000000000;
for ($i=0; $i<=$n-$k; $i++) {
    $ans1 = $h[$i+$k-1]-$h[$i];
    $ans = $ans>$ans1?$ans1:$ans;
}
echo $ans;

Measured memory_bytes: 16884
#include<stdio.h>
int main(){
  char s[11];
  scanf("%s",s);
  int i,j,count=0;
  int max=0;
  for(i=0;i<11;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      count++;
      for(j=i+1;j<11;j++){
        if(s[j]=='A'||s[j]=='T'||s[j]=='C'||s[j]=='G'){
          count++;
        }else{
          if(count>max) max=count;
          count=0;
          break;
        }
      }
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128