akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(n,m);
  OUT(n-m+1);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 3) {
        for(; arr[1]+3 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 3) {
        for(; arr[0]+3 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2]);
      t.step = step;

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2));
        que.peekLast().step = cur.step + 1;
      }

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      }
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      step = 0;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 22996
#include<complex>
#include<cstdio>
#include<cmath>
using namespace std;
typedef complex<double> P;
class Tr{
	P a,b,c;double A,B,C;double x,y,z;
	double F(double a,double b, double c){
		return acos((b*b+c*c-a*a)/(2*b*c));
	}
public:
	Tr(P p1, P p2, P p3){
		a=p1;b=p2;c=p3;B=abs(c-a);A=abs(b-c);C=abs(a-b);x=F(A,B,C);y=F(B,C,A);z=F(C,A,B);
	}
	double R(){
		return A/sin(x)/2.;
	}
	double X(){
		double A=sin(2*x),B=sin(2*y),C=sin(2*z);
		return(a.real()*A+b.real()*B+c.real()*C)/(A+B+C);
	}
	double Y(){
		double A=sin(2*x),B=sin(2*y),C=sin(2*z);
		return(a.imag()*A+b.imag()*B+c.imag()*C)/(A+B+C);
	}
};
int main(){
	int n,i;
	double x1,x2,x3,y1,y2,y3;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		P a(x1,y1),b(x2,y2),c(x3,y3);
		Tr T(a,b,c);
		printf("%.3f %.3f %.3f\n",T.X(),T.Y(),T.R());
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+100;
string Max(string a,string b){
    if(a=="-") return a>b?a:b;
    if(a.size()>b.size()) return a;
    if(a.size()<b.size()) return b;
    return a>b?a:b;
}
int Mp[11]={0,2,5,5,4,5,6,3,7,6};
int a[11];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i];
    }
    vector<string> dp(N+10,"-");
    dp[0]="";
    for(int i=0;i<=n;i++){
        if(dp[i]=="-") continue;
        for(int j=1;j<=m;j++){
            if( i+Mp[a[j]]<=n ){
                dp[i+Mp[a[j]]]=Max(dp[i+Mp[a[j]]],dp[i]+char(a[j]+'0'));
            }
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 43648
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

tuple<bool, bool> dfs(const vector<vecint>& g, int i, int p=-1) {
  int lcnt = 0;
  for (auto&& to : g[i]) {
    if (to == p) continue;
    bool win, isl;
    tie(win, isl) = dfs(g, to, i);
    if (win) return make_tuple(true, false);
    if (isl) ++lcnt;
  }
  if (lcnt >= 2) return make_tuple(true, false);
  else if (lcnt == 1) return make_tuple(false, false);
  else return make_tuple(false, true);
}

int main()
{
  int n;
  cin>>n;
  vector<vecint> g(n);
  for(int i:irange(0,n-1)) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bool win, isl;
  tie(win, isl) = dfs(g, 0);
  win = win || isl;
  if (win) {
    cout<<"First\n";
  } else {
    cout<<"Second\n";
  }
  return 0;
}


Measured memory_bytes: 5760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

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

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    ll n=in,k=in;
    if (n==k) {
        out(0);
        return 0;
    }
    else if (n>k) out(min(n%k,k-(n%k)));
    else out(min(n,k-n));
}

Measured memory_bytes: 256
import heapq

N, K = map(int,input().split())
V = list(map(int,input().split()))
rV = V[::-1]

lsum = [0]
rsum = [0]
lmsum = [0]
rmsum = [0]
for i in range(N):
    lsum.append(lsum[-1]+V[i])
    rsum.append(rsum[-1]+rV[i])
    if V[i] < 0:
        lmsum.append(lmsum[-1]+V[i])
    else:
        lmsum.append(lmsum[-1])
    if rV[i] < 0:
        rmsum.append(rmsum[-1]+rV[i])
    else:
        rmsum.append(rmsum[-1])
ans = 0 # 最も悪くて0
for l in range(N+1):
    for r in range(N-l+1):
        if l + r > K:
            break
        got = V[:l]+rV[:r]
        if not got:
            break
        heapq.heapify(got)
        val = sum(V[:l]+rV[:r])
        ans = max(ans, val)
        for b in range(min(K-l-r,l+r)):
            val -= heapq.heappop(got)
            ans = max(ans, val)
print(ans)
    
    
    
    
    
    
    

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

int main() {
    int n;cin >> n;
    int l[n];
    rep(i,n)cin >> l[i];
    int sum = 0;
    int max = 0;
    rep(i,n){
        sum+=l[i];
        if(l[i]>max)max=l[i];
    }
    if(max < sum - max)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]

a.sort()

ans=1
# 落とす橋の左端、右端を記録
l=a[0][0]
r=a[0][1]
for i in range(1,m):
    l = a[i][0]
    if l>=r:
        r=a[i][1]
        ans+=1
    else:
        r= min(a[i][1],r)

print(ans)

Measured memory_bytes: 61016
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	xu = [list(input().split()) for _ in range(n)]
	otoshidama = 0
	for x, u in xu:
		if u == 'JPY':
			otoshidama += int(x)
		else:
			otoshidama += float(x) * 380000

	print(otoshidama)

if __name__=='__main__':
	main()


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m, q;
    cin >> n >> m >> q;

    vector<vector<bool>> s(n + 1, vector<bool>(m + 1));
    for (auto i : irange(0L, n)) {
        bitset<2001> bs;
        cin >> bs;

        // bsは順序が逆
        for (auto j : irange(0L, m)) {
            s[i + 1][j + 1] = bs[m - j - 1];
        }
    }

    vector<vector<int64_t>> t(n + 1, vector<int64_t>(m + 1));
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, m)) {
            t[i + 1][j + 1] = t[i][j + 1] + t[i + 1][j] - t[i][j];
            if (s[i + 1][j + 1] && !s[i + 1][j] && !s[i][j + 1]) {
                ++t[i + 1][j + 1];
            }
            if (s[i + 1][j + 1] && s[i + 1][j] && s[i][j + 1]) {
                --t[i + 1][j + 1];
            }

            // cerr << "t[" << i + 1 << "][" << j + 1 << "] = " << t[i + 1][j +
            // 1]
            //      << endl;
        }
    }

    vector<vector<int64_t>> bx(n + 1, vector<int64_t>(m + 1)),
            by(n + 1, vector<int64_t>(m + 1));
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, m)) {
            bx[i + 1][j + 1] = bx[i + 1][j];
            if (s[i + 1][j + 1] && s[i][j + 1]) {
                ++bx[i + 1][j + 1];
            }

            by[i + 1][j + 1] = by[i][j + 1];
            if (s[i + 1][j + 1] && s[i + 1][j]) {
                ++by[i + 1][j + 1];
            }

            // cerr << "bx[" << i + 1 << "][" << j + 1
            //      << "] = " << bx[i + 1][j + 1] << endl;
            // cerr << "by[" << i + 1 << "][" << j + 1
            //      << "] = " << by[i + 1][j + 1] << endl;
        }
    }

    for (auto _ : irange(0L, q)) {
        int64_t x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        cout << t[x2][y2] - t[x1 - 1][y2] - t[x2][y1 - 1] + t[x1 - 1][y1 - 1] +
                        bx[x1][y2] - bx[x1][y1 - 1] + by[x2][y1] -
                        by[x1 - 1][y1]
             << "\n";
    }
}

Measured memory_bytes: 96512
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& e : a) cin >> e;
	sort(a.begin(), a.end(), greater<int>());

	bool f = false;
	ll x;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			if (f) {
				cout << x * a[i] NL;
				return 0;
			} else {
				f = true;
				x = a[i];
			}
          	i++;
		}
	}

	cout << '0' NL;

	return 0;

}



Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int i, j, k, n, a, b, dice[7],
		side[5] = { 2, 3, 5, 4, 2 };
	char order[7][3] = { "", "", "N", "W", "E", "S", "NN" };

	for (i = 1; i<7; i++)
		scanf("%d", &dice[i]);

	scanf("%d", &n);
	
	for (i = 0; i<n; i++){
		scanf("%d%d", &a, &b);

		for (j = 1; dice[j] != a; j++){
		}
		

		for (k = 0; order[j][k] != '\0'; k++){

			dice[0] = dice[1];

			switch (order[j][k]){

			case 'E':
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = dice[0];
				break;

			case 'N':
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = dice[0];
				break;

			case 'S':
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = dice[0];
				break;

			case 'W':
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = dice[0];
				break;

			}
		}

		for (j = 0; b != dice[side[j]]; j++){
		}

		printf("%d\n", dice[side[j + 1]]);

	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int calc(int& a, int& b, int& c)
{
  return a * 10 + b + c;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  chmax(ans, calc(a, b, c));
  chmax(ans, calc(b, a, c));
  chmax(ans, calc(c, a, b));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0,res=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') res++;
        else res=0;
        ans=max(ans,res);
    }
    cout<<ans;
}


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

int main(int argc, char** argv) {
    
    int n;
    int q;
    int S[100000];
    int left;
    int right;
    int mid;
    int count = 0;
    int key;
    int i;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);

    for(i=0; i<q; i++){
        scanf("%d", &key);
        left = 0;
        right = n;
        while(right>=left){
            mid = (left+right)/2;
            if(S[mid]==key){
                count++;
                break;
            }
            if(S[mid]<key){
                left = mid + 1;
            }
            else{
                right = mid-1;
            }   
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().StartsWith("YAKI") ? "Yes" : "No");
            Console.Read();
        }
    }
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> road(N,0);
  int a,b;
  for (int i=0;i<M;i++){
    cin>>a>>b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  for (int i=0;i<N;i++){
    cout<<road.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#!python3

# input
A, B, C = list(map(int, input().split()))


def main():
    m = max(A, B, C)
    s = sum([m - A, m - B, m - C])
    ans = (s + 1) // 2
    if s % 2 == 1:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

#define pb push_back
#define mp make_pair

#define mod 1000000007

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define vin(v, n) for (int i = 0; i < (int)(n); i++) cin >> (v)[i];
#define vout_sp(v, n) for (int i = 0; i < (int)(n); i++) cout << (v)[i] << " ";
#define vout_nl(v, n) for (int i = 0; i < (int)(n); i++) cout << (v)[i] << endl;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, n, templ, tempm, flag1 = 0, flag2 = 0;
    cin >> x >> n;
    templ = x;
    tempm = x;
    vll p(n);
    vin(p, n);
    do
    {
        flag1 = 0;
        flag2 = 0;
        for(int i=0; i<n; i++)
        {
            if(templ==p[i])
            {
                templ--;
                flag1 = 1;
                break;
            }
        }
        for(int i=0; i<n; i++)
        {
            if(tempm==p[i])
            {
                tempm++;
                flag2 = 1;
                break;
            }
        }
    }while(flag1 && flag2);
    if(tempm-x >= x-templ && flag1 == 0)
    {
        cout << templ << endl;
    }
    else if(n!=0 && flag2 == 0)
    {
        cout << tempm << endl;
    }
}


Measured memory_bytes: 3656
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)



count = 0
t.each do |tt|
  left = 0
  right = n - 1
  middle = (left + right)/2
  while true do
    if s[middle] == tt
      count += 1
      break
    elsif s[middle] > tt
      right = middle
      if (right - left) == 1
        if s[left] == tt || s[right] == tt
          count += 1
          break
        else
          break
        end
      end
      middle = (left + right)/2
    else
      left = middle
      if (right - left) == 1
        if s[left] == tt || s[right] == tt
          count += 1
          break
        else
          break
        end
      end
      middle = (left + right)/2
    end
  end
end

puts count


Measured memory_bytes: 15652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

string s;
int n;

int main()
{
	cin >> s;
	n = s.size();
	bool T = false;
	rep(i,0,n-1){
		if(s[i] != s[n-i-2]) T = true;
	}
	if(s[0] == '0' or s[n-1] == '1' or T){
		cout << -1 << endl;
		return 0;
	}
	int t = -1;
	vector<int> v;
	rep(i,0,n){
		if(i > (n-2)/2)break;
		if(s[i] == '1'){
			v.push_back(i-t);
			t = i;
		}
	}
	v.push_back(n-t-1);
	rep(i,0,v.size()-1){
		cout << i+1 << " " << i+1+1 << endl;
	}
	int s = v.size();
	rep(i,0,v.size()){
		//頂点iから延ばす
		rep(j,0,v[i]-1){
			cout << i+1 << " " << (s++)+1 << endl;
		}
	}

	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
#define mp make_pair

using namespace std;

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

const ll inf = 1e18;
const ld pi = 4 * atan(1.0);

int main() {

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

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);
    //ofstream cout("output.txt");

	ll xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;

	int n;
	cin >> n;

	vector<ll> x(n), y(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}

	ld bad = 0;
	
	vector<pll> v;
	for (int i = 0; i < n; ++i) {
		if (x[i] >= min(xs, xt) && x[i] <= max(xs, xt) && y[i] >= min(ys, yt) && y[i] <= max(ys, yt)) {
			v.pb({x[i], y[i]});
			if (xs == xt) {
				bad = abs(ys - yt) * 100 + (pi - 2) * 10;
				break;
			}
			if (ys == yt) {
				bad = abs(xs - xt) * 100 + (pi - 2) * 10;
				break;
			}
		}
	}

	if (bad != 0) {
		cout << fixed;
		cout.precision(12);
		cout << bad << "\n";
		return 0;
	}

	sort(all(v));

	ll xmin = min(xs, xt);
	ll xmax = max(xs, xt);
	ll ymin = min(ys, yt);
	ll ymax = max(ys, yt);
	/*ll dx = 0, dy = 0;
	bool cons = true;
	if (sz(v) <= 1) {
		cons = false;
	}
	if (sz(v) > 1) {
		dy = v[1].second - v[0].second;
		dx = v[1].first - v[0].first;
	}
	if (abs(dx) != 1) {
		cons = false;
	}
	if (abs(dy) != 1) {
		cons = false;
	}
	if (cons) {
		for (int i = 2; i < sz(v); ++i) {
			if (v[i].first - v[i - 1].first != dx || v[i].second - v[i - 1].second != dy) {
				cons = false;
			}
		}
	}*/

	if (sz(v) == 0) {
		cout << abs(xs - xt) * 100 + abs(ys - yt) * 100 << "\n";
		return 0;
	}

	bool f = false;
	if (v[0].first == xmin && v.back().first == xmax && sz(v) == xmax - xmin + 1) {
		f = true;
	}
	if (min(v[0].second, v.back().second) == ymin && max(v[0].second, v.back().second) == ymax && sz(v) == ymax - ymin + 1) {
		f = true;
	}

	bool inc;
	if (ys < yt && xs < xt) {
		inc = true;
	} else if (ys < yt) {
		inc = false;
	} else if (ys > yt && xs < xt) {
		inc = false;
	} else {
		inc = true;
	}

	if (!inc) {
		for (int i = 0; i < sz(v); ++i) {
			v[i].second = -v[i].second;
		}
	}

	vector<ll> dp;
	dp.pb(-inf);
	for (int i = 0; i < sz(v); ++i) {
		int lf = 0, rg = sz(dp);
		while (rg - lf > 1) {
			int md = (lf + rg) >> 1;
			if (dp[md] < v[i].second) {
				lf = md;
			} else {
				rg = md;
			}
		}
		if (lf + 1 == sz(dp)) {
			dp.pb(v[i].second);
		} else {
			dp[lf + 1] = v[i].second;
		}
	}

	ll k = sz(dp) - 1;
	//cout << xs << " " << xt << " " << ys << " " << yt << "\n";
	ld ans = abs(xs - xt) + abs(ys - yt);
	ans *= 100;
	ans -= ld(k) * (2 - pi / 2) * 10;

	if (f && sz(v) == k) {
		ans += pi / 2 * 10;
	}

	cout << fixed;
	cout.precision(20);
	cout << ans << "\n";

}


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

static const int N=100;

int main(){
    int n,p[N+1],m[N+1][N+1];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i-1]>>p[i];
    for(int i=1;i<=n;i++)m[i][i]=0;
    for(int h=2;h<=n;h++){
        for(int i=1;i<=n-h+1;i++){
            int j=i+h-1;
            m[i][j]=(1<<21);
            for(int k = i;k<=j-1;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout<<m[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 3132
import collections

n = int(input())
s = []


def main():
    for _ in range(n):
        w = list(input())
        w.sort()
        s.append("".join(w))

    counter = collections.Counter(s)
    _, c = zip(*counter.most_common())

    ans = 0

    for num in c:
        if num == 1:
            return ans
        ans += num * (num-1) // 2

    return ans


print(main())


Measured memory_bytes: 31632
// ABC170-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

    int x,n;
    cin>>x>>n;
    set<int> p;
    rep(i,n){
        int qq;
        cin>>qq;
        p.insert(qq);
    }
    int ans=x;
    int near=10000;
    for(int i=101;i>=0;i=i-1){
        auto itr=p.find(i);
        if(itr!=p.end()) continue;
        if(abs(x-i)<=near){
            ans=i,near=abs(x-i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
//ALDS1_6_C_QuickSort.cpp
#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;
typedef pair<int,int> Pair;
typedef long long LL;
int cnt=0;

struct card{
    char suit;
    int num;
};

void merge(card A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    card *L=new card[n1+1];
    card *R=new card[n2+1];
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1].num=R[n2].num=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i].num<=R[j].num){
            A[k]=L[i];
            i=i+1;
        }else {
            A[k]=R[j];
            j=j+1;
        }
        cnt++;
    }
    delete[] L;
    delete[] R;
}

void mergeSort(card A[],int left,int right){
    if(left+1<right){
        int mid =(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int partition(card A[],int p,int r){
    int x=A[r].num;
    int i=p-1;
    card tmp;
    for(int j=p;j<r;j++){
        if(A[j].num<=x){
            i++;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    return i+1;
}

void quickSort(card A[],int p, int r){
    if(p<r){
        int q=partition(A,p,r);
        quickSort(A,p,q-1);
        quickSort(A,q+1,r);
    }
}

int main(){
    int n;
    cin >> n;
    card A[100100];
    card M[100100];
    char str[10];
    for(int i=0;i<n;i++){
        scanf("%s %d",str,&A[i].num);
        A[i].suit=str[0];
        M[i]=A[i];
    }
    quickSort(A,0,n-1);
    mergeSort(M,0,n);
    bool stable=1;
    for(int i=0;i<n;i++){
        if(A[i].suit!=M[i].suit) stable=0;
    }
    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    for(int i=0;i<n;i++){
        cout << A[i].suit << " " << A[i].num << endl;
    }

    return 0;
}



Measured memory_bytes: 5176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        int K = int.Parse(Console.ReadLine());

        //計算
        char x_let = S[K - 1];  //K番目の文字

        //新しく作る文字列
        string ans = "";

        for (int i = 0; i < N; i++) {
            if (S[i] != x_let) {
                ans += '*';
            } else {
                ans += S[i].ToString();
            }
        }

        //出力
        Console.WriteLine(ans);


    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (s); i < (e); ++i)
#define per(i,s,e) for(int i = (s)-1; i >= e; --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

const int inf = 1001001001;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<typename T, size_t N, typename U>
void Fill(T (&a)[N], const U&v){
    std::fill((U*)a,(U*)(a+N),v);
}

int main(){
  int n, m; cin >> n >> m;
  vector<P<int,int>> keys(m);
  for(auto&e:keys){
    int a, b, c = 0; cin >> a >> b;
    rep(i,0,b){
      int x; cin >> x;
      c |= (1 << (x-1));
    }
    e = {c, a};
  }
  vector<int> dp(1<<n,inf);
  dp[0] = 0;
  rep(i,0,1<<n){   
    rep(j,0,m){
      int nxt = (i | keys[j].first);
      if(dp[nxt] > dp[i] + keys[j].second){
	dp[nxt] = dp[i] + keys[j].second;
      }
    }
  }
  int ans = dp[(1<<n)-1];
  if(ans == inf) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    vec<u32> a(3);
    for (u32& x: a) std::cin >> x;
    std::sort(ALL(a));
    std::cout << (std::accumulate(ALL(a), u32{0})==2*a.back() ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
string s, t;
int dp[3010][3010], bk[3010][3010];
int fun(int a, int b){
	if(a == s.length() || b == t.length())
		return 0;
	if(dp[a][b] != -1)
		return dp[a][b];
	if(s[a] == t[b]){
		bk[a][b] = 0;
		return dp[a][b] = 1 + fun(a + 1, b + 1);
	}
	int x = fun(a + 1, b);
	int y = fun(a, b + 1);
	if(x < y)
		bk[a][b] = 2;
	else bk[a][b] = 1;
	return dp[a][b] = max(x, y);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> t;
	memset(dp, -1, sizeof(dp));
	int curx = 0, cury = 0;
	string ans = "";
	fun(0, 0);
	while(curx < s.length() && cury < t.length()){
		if(bk[curx][cury] == 0){
			ans += s[curx];
			curx++, cury++;
		}
		else if(bk[curx][cury] == 1)
			curx += 1;
		else cury += 1;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 71296
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return true;
    }
    return false;
}

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

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

ll weight[110][100010]; // 添え字は価値に対応
int main() {
    int N,W; cin >> N >> W;
    vector<int>w(N),v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }
    Fill(weight, INF);

    for(int i=0; i<=N; i++){
        weight[i][0]=0LL;
    }

    for(int i=0; i<=N; i++){
        for(int j=0; j<=100010; j++){
            if(j-v[i]<0){
                weight[i+1][j]=weight[i][j];
            }else{
                weight[i+1][j]=min(weight[i][j-v[i]]+w[i], weight[i][j]);
            }
        }
    }

    ll maximum=0LL;
    for(int i=0; i<100010; i++){
        if(weight[N][i]==INF) continue;
        if(weight[N][i]>W) continue;
        maximum=i;
    }

    cout << maximum << endl;
    return 0;
}


Measured memory_bytes: 86144
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
using namespace std;

int main() {
	int n;
	vector<string> s(2);
	string y = "YES", no = "NO";
	cin >> s[0];
	cin >> s[1];
	if (s[0][0] == s[1][2] && s[0][1] == s[1][1] && s[0][2] == s[1][0]) cout << y;
	else cout << no;

	return 0;
}





Measured memory_bytes: 256
from collections import deque

n,m = map(int,input().split())
g = [set() for _ in range(n+1)]
gg = [0]*(n+1)
for _ in range(n-1+m):
    a,b = map(int,input().split())
    g[a].add(b)
    gg[b] += 1
p = [-1]*(n+1)
q = deque()
for i in range(1,n+1):
  if gg[i] == 0:
    p[i] = 0
    q.append(i)
    break
while q:
  v = q.popleft()
  for x in g[v]:
    gg[x] -= 1
    if gg[x] == 0:
      q.append(x)
      p[x] = v
for x in p[1:]:
  print(x)


Measured memory_bytes: 36876
N,K,C=map(int,input().split())
S=list(input())

work_last=-float("inf")
llist=[]
for i in range(1,N+1):
  if S[i-1]=="o":
    if i-work_last>C:
      llist.append(i)
      work_last=i
  if len(llist)==K:
    break
#print(llist)

work_last=float("inf")
rlist=[]
for i in reversed(range(1,N+1)):
  if S[i-1]=="o":
    if work_last-i>C:
      rlist.append(i)
      work_last=i
  if len(rlist)==K:
    break
rlist.reverse()
#print(rlist)

for i in range(K):
  if llist[i]==rlist[i]:
    print(llist[i])

Measured memory_bytes: 109488
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> H(n, 0);
    REP(i, n) cin >> H[i];
    sort(ALL(H));

    int mi = 1e9;
    for(int i=0; i<n-k+1; i++)
        mi = min(mi, H[i+k-1]-H[i]);
    
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>

#define pi 3.1415926535798932

int main(void){
  int a,b,carg;
  double s,c,l,h;

  scanf("%d%d%d",&a,&b,&carg);
  s=a*b*sin((double)pi*carg/180)/2;
  c=sqrt(a*a+b*b-2*a*b*cos((double)pi*carg/180));
  l=a+b+c;
  h=2*s/a;

  printf("%f\n%f\n%f\n",s,l,h);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int64_t N,P;
  cin>>N>>P;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    if(A[i]%2!=0){cout<<(int64_t)pow(2,N-1)<<endl;return 0;}
  }
  if(P==0){cout<<(int64_t)pow(2,N)<<endl;}
  else{cout<<0<<endl;}
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll x[110],y[110],h[110];

int main(void){
	int n,k,b;
	ll i,j,p;
	bool flag;
	cin >> n;
	for(k=0; k<n; ++k){
		cin >> x[k] >> y[k] >> h[k];
		if(h[k]){
			b = k;
		}
	}
	for(i=0; i<101; ++i){
		for(j=0; j<101; ++j){
			p = h[b]+abs(x[b]-i)+abs(y[b]-j);
			flag = true;
			for(k=0; k<n; ++k){
				if(max(p-abs(x[k]-i)-abs(y[k]-j),0ll)!=h[k]){
					flag = false;
				}
			}
			if(flag){
				cout << i << " " << j << " " << p << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  ll n;
  cin >> n;
  REP(a,1,3501){
    REP(b,1,3501){
      ll upper=n*a*b;
      ll lower=4*a*b-n*a-n*b;
      if(lower<=0) continue;
      if(upper%lower==0 && upper/lower<=3500){
        prt3(a, b, upper/lower);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0 , so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    string ss;
    cin >> ss;
    ll s = 0 , e = 0 , w =0 , n = 0 ;
    forn(i , 0 , ss.length() - 1 ){
       if(ss[i] == 'S') ++s;
       else if(ss[i] == 'E') ++e ;
       else if(ss[i] == 'N') ++n;
       else if(ss[i] == 'W') ++w;
    }
    ll flag = -1 ;
    if(s > 0 and n == 0 or s==0 and n > 0 ) {
        flag = 0 ;
    }
    if(e == 0 and w > 0 or e > 0 and w == 0 ){
        flag = 0 ;
    }
    if(flag == 0){
        cout <<"No\n";
        ro ;
    }
    else if(flag == -1){
        cout <<"Yes\n";
        ro ;
    }
}



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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back

const int mod = 1e9 + 7;
const int maxn = 1e3 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

int n;
queue<int>a[maxn];
int day[maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    rep(i,1,n) {
    	rep(j,1,n - 1) {
    		 int c; 
    		 cin >> c;
    		 a[i].push(c);
    	}
    }
    int sum = n * (n - 1);
    while(1){
    	bool flag = false;
    	rep(i,1,n){
    		if(a[i].empty()) continue;
    		if(a[a[i].front()].front() == i) {
    			day[i] = day[a[i].front()] = max(day[i],day[a[i].front()]) + 1;
    			//cout << i << " " << a[i].front() << endl;
    			a[a[i].front()].pop();
    			a[i].pop();
    			sum -= 2;
    			flag = true;
    		}
    	}
    	//cout << sum << endl;
    		if(flag == false) {
    			cout << -1 << endl;
    			return 0;
    		}
    		if(!sum) break;

    }
    int ans = 0;
    rep(i,1,n) ans = max(ans,day[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;
    std::sort(a.begin(), a.end());

    std::vector<int> done(1000001);
    int ret = 0;
    for (int i = 0; i < n; i++) {
        const int e = a[i];
        if (done[e]) continue;
        if (i == n - 1 || a[i + 1] != e) ret++;
        for (int j = 1; j * e <= 1000000; j++) done[j * e] = 1;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0, loop##i = (int)(n); i < loop##i; ++i)
#define SZ(x) ((int)(x.size()))
#define ALL(x) x.begin(), x.end()
#define BIN(w, x) bitset<w>(x)

int m, n;
int memo[1 << 11][1 << 11];
int bits[200];
int rec(int used, int yesno) {
	auto &MEMO = memo[used][yesno];
	if (MEMO != -1) return MEMO;
	
	int cnt = 0;
	REP(j, n) {
		if ((bits[j] & used) == yesno) {
			cnt++;
		}
	}
	if (cnt == 0 || cnt == 1) return MEMO = 0;
	
	int ret = 1e9;
	REP(i, m) {
		if (used >> i & 1) continue;
		ret = min(ret,
					max(rec(used | (1 << i), yesno | (1 << i)) + 1,
						rec(used | (1 << i), yesno | (0 << i)) + 1)
				 );
	}
	return MEMO = ret;
}

signed main() {
	while (1) {
		REP(i, 1 << 11) REP(j, 1 << 11) memo[i][j] = -1;
		cin >> m >> n;
		if (m == 0 && n == 0) break;
		REP(i, n) {
			string s;
			cin >> s;
			bits[i] = stoll(s, nullptr, 2);
		}
		cout << rec(0, 0) << endl;
	}
}



Measured memory_bytes: 35900
#include<iostream>
using namespace std;
int main(){
    int A, a=101, b=0,i;
    for(i=1;i<=3;i++){
        cin>>A;
        if(A>b){
            b=A;
        }
        if(A<a){
            a=A;
        }
    }
    cout<<b-a;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const ll inf = 9e18;
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

class debug
{
public:
    typedef long long ll;
    template<typename T> void vd(vector<T> vec);
    template<typename T> void vd2(vector<vector<T>> vec);
    template<typename T> void vpd(vector<pair<int, int>> vec);
    template<typename T> void ad(T *arr, ll n);
    template<typename T, size_t N> void ad2(T (&arr)[N], ll n);
    template<typename T> void md(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vd(vector<T> vec)
{
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T> void debug::vd2(vector<vector<T>> vec)
{
    for(auto vv : vec) for(auto vvv : vv) cout << vvv << " ";
    cout << endl;
}

template<typename T> void debug::vpd(vector<pair<int, int>> vec) {
    for(auto const& vv : vec) {
        cout << vv.first << " " << vv.second << endl;
    }
    cout << endl;
}

template<typename T> void debug::ad(T *arr, ll n)
{
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T, size_t N> void debug::ad2(T (&arr)[N], ll n)
{
    for(int i=0; i<=N; i++) for(int j=0; j<=n; j++) cout << arr[i][j] << " ";
    cout << endl;
}

template<typename T> void debug::md(T mp)
{
    cout << "key : value" << endl;
    for(auto const& m : mp) cout << m.first << " : " << m.second << endl;
    cout << endl;
}
debug debug;

class AFrog1 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    vector<int> h(n);
	    for(int i=0; i<n; i++){
	        in >> h[i];
	    }

	    int dp[100010];
	    for(int i=0; i<n; i++){
	        dp[i] = 1e9;
	    }
	    dp[0] = 0;
	    for(int i=0; i<n; i++){
	        int ni = i+1;
            if(ni < n) chmin(dp[ni], dp[i] + abs(h[ni] - h[i]));
            ni++;
            if(ni < n) chmin(dp[ni], dp[i] + abs(h[ni] - h[i]));
            //debug.ad(dp, n);
	    }

	    out << dp[n-1] << endl;
	}
};


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


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

void dfs(string s, char mx){
    if(s.length() == N){
        cout << s <<endl;
    }else{
        for (char c = 'a'; c <= mx; c++) {
            dfs(s+c, ((c==mx) ? (char)(c+1) : mx));
        }
    }

}

int main() {
    cin >> N;
    dfs("",'a');
    return 0;
}

Measured memory_bytes: 1536
local mfl, mce = math.floor, math.ceil
local mod = 1000000007
local n, k = io.read("*n", "*n")
local ret = 0
for i = k, n + 1 do
  local smallest = mfl(i * (i - 1) / 2)
  local largest = mfl((n + n - i + 1 ) * i / 2)
  -- print(smallest, largest)
  ret = (ret + largest - smallest + 1) % mod
end
print(ret)


Measured memory_bytes: 2796