akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b){int r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5 ;
int a[N] ; 
signed main(){
	int n;
	cin >> n ;
	f(n) cin >> a[i] ;
	int sum = 0 ,cnt =0 ;
	f(n) a[i] = a[i]-i ;
	sort( a+1 , a+n+1) ;
	int x = a[(n+1)/2] ;
	f(n) sum += abs(x-a[i]) ;
	cout << sum ;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
string s;
int n;
int res;
int main(){
	cin>>n;
	cin>>s;
	char flag=s[0];
	if(n==1){
		cout<<1<<endl;
		exit(0);
	}
	reg(i,1,n-1){
		if(s[i]==flag){
			
		}else{
			res++;
			flag=s[i];
		}
	}
	cout<<res+1<<endl;
	return 0;
}




Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	stack<int>st;
	string s;

	int a = 0, b = 0;
	while (cin >> s) {
		// if (s == "b") break;
		
		if (s == "+") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b + a);
		} else if (s == "-") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b - a);
		} else if (s == "*") {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b * a);
		} else {
			st.push(stoi(s));
		}
	}

	cout << st.top() << "\n";
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	int R; cin >> R;
	printf("%.10f\n", 2*R*M_PI);


	return 0;

}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int q, h, s, d;
int n;

signed main() {
	cin >> q >> h >> s >> d;
	cin >> n;
	n *= 4;
	
	h = min(2 * q, h);
	s = min(2 * h, s);
	d = min(2 * s, d);
	
	int ans = 0;
	ans += d * (n / 8); n %= 8;
	ans += s * (n / 4); n %= 4;
	ans += s * (n / 2); n %= 2;
	ans += q * n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VECMAX 10000

int main(){
    unsigned short *A,*B;

    int C[VECMAX+1];
    int n,i,j;
    scanf("%d",&n);

    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);

    for(i=0;i<=VECMAX;i++) C[i]=0;

    for(i=0;i<n;i++){
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }

    for (i=1;i<VECMAX;i++) C[i]=C[i]+C[i-1];

    for(j=1;j<=n;j++){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }

    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 9536
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node {int parent,left,right;};
struct Node T[MAX];

int n,D[MAX];

void setDepth(int,int);
void printChildren(int);


void setDepth(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)
    setDepth(T[u].right,p);
  if(T[u].left!=NIL)
    setDepth(T[u].left,p+1);
}
void printChildren(int u){
  int c,i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);
  if(T[u].parent==NIL)
    printf("root, ");
  else if(T[u].left==NIL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  c=T[u].left;
  while(c!=NIL){
    printf("%d",c);
    c=T[c].right;
    if(c!=NIL) printf(", ");
  }
  printf("]\n");
}
int main(){
  int i,j,v,d,l,c,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }
  setDepth(r,0);
  for(i=0;i<n;i++)
    printChildren(i);
  return 0;
    }
    
  



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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

const int MAXN = 110;
int w[MAXN], v[MAXN];
int main() {
  int N, W;
  scanf("%d %d", &N, &W);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &w[i], &v[i]);
  }

  vector<ll> dp(W + 1, 0);
  for (int i = 0; i < N; i++) {
    for (int sumW = W; sumW >= w[i]; sumW--) {
      dp[sumW] = max(dp[sumW], v[i] +  dp[sumW - w[i]]);
    }
  }

  printf("%lld\n", dp[W]);
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        if (a == b && b == c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        if(K<=A[i])
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 400
int d[MAX_V][MAX_V];
int V;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	V = 10;
	rep(i, 0, 10) rep(j, 0, 10) d[i][j] = 1e9;

	rep(i, 0, 10) rep(j, 0, 10) {
		cin >> d[i][j];
	}
	warshall_floyd();
	int rsl = 0;
	rep(i, 0, H) rep(j, 0, W) {
		int a;
		cin >> a;
		if(a == -1) continue;
		rsl += d[a][1];
	}

	cout << rsl << endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n,k,x,y int
	fmt.Scan(&n,&k,&x,&y)
	
	fee := 0
	if n <= k {
		fee = x * n
	} else {
		fee = x * k + y * (n - k)
	}
	fmt.Println(fee)
}

Measured memory_bytes: 512
def binary_search(lst, t, i):
    left = -1
    right = len(lst)

    while abs(right - left) > 1:
        mid = (left + right) // 2
        if i == 0:
            if lst[mid] < t:
                left = mid
            else:
                right = mid
        elif i == 1:
            if lst[mid] > t:
                right = mid
            else:
                left = mid

    return left


def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    ans = 0

    for b in B:
        a = binary_search(A, b, 0)
        c = binary_search(C, b, 1)
        ans += (a + 1) * (n - c - 1)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105396
#include<bits/stdc++.h>
using namespace std;
string a;
bool cf[2]={0}; 
int main() 
{
	cin>>a;
	for(int i=0;i<a.length();i++) 
	{ 
		if(a[i]=='C') cf[0]=1;
		if(a[i]=='F'&&cf[0]) cf[1]=1;
	}
	if(cf[1]) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = True

while flag:
    ans = []
    for i in a:
        if i % 2 == 1:
            flag = False
        else:
            ans.append(i/2)
    if len(ans) == n:
        cnt += 1
        a = ans

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,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;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
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; }


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

  ll n;
  cin >> n;

  ll ans = INF;
  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0){
      ll a = i;
      ll b = n / i;

      ll cnta = 0, cntb = 0;
      while(a){
        a /= 10;
        cnta++;
      }
      while(b){
        b /= 10;
        cntb++;
      }
      ll cnt = max(cnta, cntb);
      chmin(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static void setEdge(List<ArrayList<int[]>> edge, String input) {
		String[] str = input.split(",");
		int from = Integer.parseInt(str[0]);
		int to = Integer.parseInt(str[1]);
		int cost1 = Integer.parseInt(str[2]);
		int cost2 = Integer.parseInt(str[3]);
		edge.get(from - 1).add(new int[] { to - 1, cost1 });
		edge.get(to - 1).add(new int[] { from - 1, cost2 });
	}
	
	static int[][] floydwarshall(List<ArrayList<int[]>> edge){
		int[][] dist = new int[edge.size()][edge.size()];
		/* 初期化 */
		for(int i = 0; i < edge.size(); i++){
			for(int j = 0; j < edge.size(); j++){
				dist[i][j] = Integer.MAX_VALUE;
			}
			dist[i][i] = 0;
			/*　隣接している接点についてコスト計算 */
			for(int[] e : edge.get(i)){
				dist[i][e[0]] = e[1];
			}
		}
		
		/* 中継地点となる節点について繰り返す */
		for(int k = 0; k < edge.size(); k++){
			for(int i = 0; i < edge.size(); i++){
				/* 2節点が隣接していない場合は処理しない */
				if(dist[i][k] == Integer.MAX_VALUE){
					continue;
				}
				
				for(int j = 0; j < edge.size(); j++){
					long newLength = dist[i][k];
					/* 
					 * どの節点と隣接しているかは考慮せず、
					 * 単にコスト計算と更新処理を行う
					 */
					newLength += dist[k][j];
					if(newLength < dist[i][j]){
						dist[i][j] = (int)newLength;
					}
				}
			}
		}
		
		return dist;
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int city = s.nextInt();
		int numEdge = s.nextInt();
		List<ArrayList<int[]>> edge = new ArrayList<ArrayList<int[]>>();
		for(int i = 0; i < city; i++){
			edge.add(new ArrayList<int[]>());
		}
		for (int i = 0; i < numEdge; i++) {
			setEdge(edge, s.next());
		}
		String[] input = s.next().split(",");
		int start = Integer.parseInt(input[0]);
		int dest = Integer.parseInt(input[1]);
		int money = Integer.parseInt(input[2]);
		int price = Integer.parseInt(input[3]);

		int[][] dist = floydwarshall(edge);
		System.out.println(money - price - dist[start - 1][dest - 1] - dist[dest - 1][start - 1]);
	}

}

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

const int W = 100010, N = 105;
long long w[N], v[N], dp[W], n, m;

int main() {
    memset(dp, 0, sizeof(dp));
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    	cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i++)
    	for (int j = m; j >= w[i]; j--) {
			dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
		}			
	
	cout << dp[m];    
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=1e+9+1;
int main(){
	int N;
	int a[100000],b[100000],c[100000];
	int Q,K;
	int x[100000],y[100000];
	ll mindis[100001];
	vector<pint> connect[100001];
	scan(N);
	rep(i,N-1){
		scan(a[i]);scan(b[i]);scan(c[i]);
		pint patha(b[i],c[i]);
		pint pathb(a[i],c[i]);
		connect[a[i]].push_back(patha);
		connect[b[i]].push_back(pathb);
	}
	rep1(i,N){
		mindis[i]=1e+16;
	}
	scan(Q);scan(K);
	mindis[K]=0;
	vint recordnode;
	recordnode.push_back(K);
	while(recordnode.size()){
		vint beforenode=recordnode;
		recordnode.clear();
		rep(i,beforenode.size()){
			rep(j,connect[beforenode[i]].size()){
				//printf("%d %d %lld\n",beforenode[i],connect[beforenode[i]][j].first,mindis[connect[beforenode[i]][j].first]);
				if(mindis[connect[beforenode[i]][j].first]!=1e+16) continue;
				mindis[connect[beforenode[i]][j].first]=mindis[beforenode[i]]+connect[beforenode[i]][j].second;
				recordnode.push_back(connect[beforenode[i]][j].first);
			}
		}
	}
	rep(i,Q){
		scan(x[i]);scan(y[i]);
		prin(mindis[x[i]]+mindis[y[i]]);
	}

	return 0;
}


Measured memory_bytes: 11252
n,a[3333];
long dp[3333][3333];
i;
long f(i,j)
{
	return i-j?dp[i][j]?:(dp[i][j]=fmax(a[i]-f(i+1,j),a[j-1]-f(i,j-1))):0;
}
main()
{
	for(scanf("%d",&n);~scanf("%d",a+i++););
	printf("%ld",f(0,n));
}

Measured memory_bytes: 80256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aa := getIntList(scanner)
	sums := make([]int, n+1)
	xors := make([]int, n+1)
	ans := 0
	for i := 0; i < n; i++ {
		sums[i+1] = sums[i] + aa[i]
		xors[i+1] = xors[i] ^ aa[i]
	}
	for l, r := 0, 1; l <= r && r <= n; {
		if sums[r]-sums[l] == xors[r]^xors[l] {
			ans += r - l
			r++
			continue
		}
		l++
	}
	fmt.Println(ans)
}


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

#define M 16
#define N 4
#define yes 1
#define no -1
#define lim 100

typedef struct{
  int a[M],b,c;
}Puzzle;

Puzzle now;

int s1[4]={0,-1,0,1};
int s2[4]={1,0,-1,0};
char contl[4]={'r','u','l','d'};
int bord[M][M];

int max,leng[lim];

int in_bord(Puzzle x){
  int i,count=0;
  for(i=0;i<M;i++){
    if(x.a[i]==M) continue;
    count+=bord[i][x.a[i]-1];
  }
  return count;
}

int dfs(int deep,int z){
  int i,r1,r2,y1,y2,change;
  
  if(now.c==0) return yes;
  if(deep+now.c>max) return no;

   r1=now.b/N;
   r2=now.b%N;
  Puzzle comp;

  for(i=0;i<4;i++){
    y1=r1+s1[i];
    y2=r2+s2[i];

    if(y1<0 || y2<0 || y1>=N || y2>=N) continue;
    if(abs(z-i)==2) continue;
    comp=now;

    now.c-=bord[y1*N+y2][now.a[y1*N+y2]-1];
    now.c+=bord[r1*N+r2][now.a[y1*N+y2]-1];
    change=now.a[y1*N+y2];
    now.a[y1*N+y2]=now.a[r1*N+r2];
    now.a[r1*N+r2]=change;
    now.b=y1*N+y2;
    if(dfs(deep+1,i)==yes){
      leng[deep]=i;
      return yes;
    }
    now=comp;
  }
  return no;
}

void solve(Puzzle x){
  int i,count=0;
  
  x.c=in_bord(x);
  for(max=x.c;max<=lim;max++){
    now=x;
    if(dfs(0,-100)==yes){
      for(i=0;i<max;i++){
	count++;
      }
      printf("%d\n",count);
      return;
    }
  }
}
      

int main(){
  int i,j,keep;
  Puzzle in;

  for(i=0;i<M;i++){
    for(j=0;j<M;j++){
      bord[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
    }
  }

  for(i=0;i<M;i++){
    scanf("%d",&in.a[i]);
    if(in.a[i]==0) keep=i;
  }
      in.a[keep]=M;
      in.b=keep;

  solve(in);

  return 0;
}
  




Measured memory_bytes: 2136
#include<stdio.h>

int main(void){
  int i,j,s,n,m;
  static int a[100][100],b[100],c[100];

  scanf("%d%d",&n,&m);

  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

  for(i=0;i<m;i++)
    scanf("%d",&c[i]);

  for(i=0;i<n;i++){
    s = 0;
    for(j=0;j<m;j++)
      s += a[i][j] * c[j];
    printf("%d\n",s);
  }
  
  return 0;
}


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


int main() {
    string s;
    cin >> s;
    int n = s.length();
    string ans = "Yes";
    if (n%2!=0) ans = "No";
    for(int i=0; i<n-1; i+=2){
        if (!((s[i] == 'h')&&(s[i+1] == 'i'))) ans = "No";
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
a=int(input())
b=""
if a%7==0:
    b="Yes"
elif a%4==0:
    b="Yes"
else:
    for i in range(1,16):
        for j in range(1,26):
            if 4*j+7*i==a:
                b="Yes"
                break
            else:
                b="No"
        if b=="Yes":
            break
print(b)

Measured memory_bytes: 3060
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(n, m + 1)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[i, j] = b[j]
  end
end
min = Float::INFINITY
[0, 1].repeated_permutation(n) do |bit|
  ans = 0
  sum = 0
  v = 0
  1.upto(m) do |j|
    v = Vector.elements(bit)
    sum = (a.column(j).covector * v)[0]
    break if sum < x
  end
  if sum >= x
    ans = (a.column(0).covector * v)[0]
    min = ans if min > ans
  end
end
puts (min == Float::INFINITY ? -1 : min)

Measured memory_bytes: 15116
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using usize = std::size_t;

std::vector<i32> edges[100001];
i32 ans[100001];

auto main() -> i32 {
	i32 n, m;
	scanf("%d%d", &n, &m);
	for (i32 i = 0; i < m; ++i) {
		i32 a, b;
		scanf("%d%d", &a, &b);
		edges[a].emplace_back(b);
		edges[b].emplace_back(a);
	}
	std::queue<i32> q;
	q.emplace(1);
	while (q.size() > 0) {
		auto v = q.front();
		q.pop();
		for (auto to : edges[v]) {
			if (ans[to] == 0) {
				ans[to] = v;
				q.emplace(to);
			}
		}
	}
	puts("Yes");
	for (i32 i = 2; i <= n; ++i) {
		printf("%d\n", ans[i]);
	}
	return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    int res = 0;
    for(auto c : s) {
        if(c == '+')res++;
        if(c == '-')res--;
    }
    cout << res << endl;
    return 0;
}



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

void solver() {
  long long n, k;
  cin >> n >> k;

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

  sort(hs.begin(), hs.end(), greater<long long>());

  for (int i = 0; i < k && i < n; i++) {
    hs[i] = 0;
  }

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += hs[i];
  }

  cout << ans << "\n";
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 1792
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        int[][] a = new int[h][w];
        int[] point = new int[90001];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                a[i][j] = sc.nextInt();
                point[a[i][j]] = i * w + j;
            }
        }
        long[] ds = new long[h * w + 1];
        for (int i = 1; i <= h * w; i++) {
            if (i > d) ds[i] = ds[i - d] + abs(point[i] / w - point[i - d] / w) + abs(point[i] % w - point[i - d] % w);
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            out.println(ds[r] - ds[l]);
        }
    }
    static class sc {
        static Scanner s = new Scanner(in);

        static String next() {
            return s.next();
        }

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

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

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

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

int main() {
	ll x;
	cin>>x;
	for(ll a=-N+1;a<N;a++){
		for(ll b=a;b<N;b++){
			if(((b*b*b*b*b)-(a*a*a*a*a))==x){
				cout<<b<<' '<<a<<'\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    LL n,k;cin >> n >> k;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < k; i++) {
        vector<LL> b(n + 1, 0);
        for (int j = 0; j < n; j++) {
            LL l = max(0LL, j - a[j]);
            LL r = min(n, j + a[j] + 1);
            b[l]++;
            b[r]--;
        }
        for (int j = 0; j < n; j++) {
            b[j + 1] += b[j];
        }
        vector<LL> na(n);
        for (int i = 0; i < n; i++) {
            na[i] = b[i];
        }
        if(na == a) break;
        a = na;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << (i + 1 == n ? "\n": " ");
    }
    return 0;
}


Measured memory_bytes: 7896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	static int cnt = 0;
	final static int[] H = {797161, 265720, 88573, 29524, 9841,
			3280, 1093, 364, 121, 40, 13, 4, 1};

	static void insertionSort(int[] A, int n, int g) {
		for (int i = g; i < n; i++) {
			int v = A[i];
			int j = i - g;
			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j + g] = v;
		}
	}

	static void shellSort(int[] A, int n) {
		cnt = 0;
		int m;

		int i;
		for (i = 0; i < H.length; i++) {
			if (n >= H[i])
				break;
		}

		m = H.length - i;
		int[] G = new int[m];
		System.arraycopy(H, H.length-m, G, 0, m);
		
		System.out.println(m);
		
		for (i = 0; i < m; i++) {
			System.out.print(G[i]);
			if (i != m-1) {
				System.out.print(" ");
			}
			insertionSort(A, n, G[i]);
		}
		System.out.println();
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}

		shellSort(A, n);

		System.out.println(cnt);

		for (int i = 0; i < n; i++) {
			System.out.println(A[i]);
		}

		scan.close();
	}

}

Measured memory_bytes: 297104
#include <stdio.h>

int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    while(x || y){
        if(x > y){
            printf("%d %d\n",y,x);
        } else {
            printf("%d %d\n",x,y);
        }
        scanf("%d %d",&x,&y);
    }
    return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;

class Main { 
public static void main (String[] args){
  Scanner scan = new Scanner(System.in);

  double r = scan.nextDouble();
  double x = Math.PI;

  System.out.printf("%.5f %.5f\n",r * r * x,r * 2 * x);

}
}

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

using str = string;
using ss = stringstream;

int d[10][30010];
int ans[1000];

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

    int n;cin>>n;
    str s;cin>>s;
    for(int i=0;i<n;i++)for(int j=0;j<10;j++)d[j][i+1]=d[j][i]+(j==s[i]-'0'?1:0);

    for(int i=0;i<n-2;i++)for(int j=0;j<10;j++)
    {
        if(d[j][n]-d[j][i+1]==0)continue;

        int l=i,r=n+1;
        for(int m=l+(r-l)/2;m!=l;m=l+(r-l)/2)
        {
            if(d[j][m]-d[j][i+1]>=1)r=m;
            else l=m;
        }
        for(int k=0;k<10;k++)
        {
            if(d[k][n]-d[k][l+1]>0)
            {
                ans[(s[i]-'0')*100+j*10+k]=1;
            }
        }
    }

    int cnt=0;
    for(int i=0;i<1000;i++)if(ans[i])cnt++;

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 4780
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if(search(S)) System.out.println("Bad");
        else System.out.println("Good");
        sc.close();
    }

    static boolean search(String s) {
        for(int i = 1; i < 4; i++) {
            char a = s.charAt(i-1);
            char b = s.charAt(i);
            if(a == b) return true;
        }
        return false;
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define LL long long
#define maxn 1000000

using namespace std;

const LL MOD = 1e9+7;

LL fact[maxn+5];	//阶乘
LL a[maxn+10];	// 乘法逆元
//LL inv[maxn+10];	//快速幂

LL pow(LL x)
{
	LL n = MOD-2;
    LL res=1;
	while(n>0)
	{
	   if(n%2==1)
	   	 res=res*x%MOD;
	   x=x*x%MOD;
	   n>>=1;
	}
	return res;
}

void init(){
    a[0] = a[1] = 1;
    fact[0] = fact[1] = 1;

    for(int i = 2; i <= 1000005; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
		a[i] = a[i-1] * pow(i) % MOD;	//m!的MOD次方 = (m-1)!的MOD次方 * m的MOD次方

    }
}

LL C(LL n, LL m){	//乘法逆元
	if(n<0||m<0||n<m)return 0;
    return fact[n]*a[n-m]%MOD*a[m]%MOD;
}

int main()
{
    init();
	LL n,m,a,b;
	cin>>n>>m>>a>>b;
	LL sum=0;
	for(int i=b+1;i<=m;i++)
    {
        sum+=(C(n-a+i-2,i-1)*C(a+m-i-1,m-i))%MOD;
        sum%=MOD;
    }
    cout<<sum%MOD<<endl;


}


Measured memory_bytes: 15872
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	string s;
	cin>>s;
	int len = s.length();
	int count = 1;
	for (int i = 0; i < len-1; i++){
		if(s[i] != s[i+1]){
			count++;
		}
	}
	cout<<count<<endl;

}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int x = scan.nextInt();

		String str = "YES";

		str = ((a + b >= x) && (a <= x)) ? "YES" : "NO";

		System.out.println(str);

		scan.close();

	}

}


Measured memory_bytes: 22608
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

bool MySort(int a, int b) {
    return ( a % 10 == 0 ? a % 10 + 10 : a % 10) >
    ( b % 10 == 0 ? b % 10 + 10 : b % 10);
}
int main()
{
    int A[5];

    for (int i = 0; i < 5; i++)
    {
        cin >> A[i];
    }

    sort(A, A + 5, MySort);

    int c = 0;
    for (int i = 0; i < 4; i++)
    {
        if (A[i] % 10 == 0) {
            c += A[i];
        } else {
            c += A[i] + 10 - (A[i] % 10);
        }
    }
    c += A[4];

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0;i<H;i++){
    cin>>a[i];
  }
  vector<vector<int>>dp(H,vector<int>(W));
  vector<vector<bool>>seen(H,vector<bool>(W,false));
  dp[0][0]=1;
  queue<pair<int,int>>q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    
    auto p=q.front();q.pop();
    int y=p.first,x=p.second;
   
    seen[y][x]=true;
    if(x+1<W&&a[y][x+1]!='#'){
      if(!seen[y][x+1]){q.push(make_pair(y,x+1));}
      dp[y][x+1]+=dp[y][x];
      dp[y][x+1]%=mod;
      seen[y][x+1]=true;
    }
    if(y+1<H&&a[y+1][x]!='#'){
      if(!seen[y+1][x]){q.push(make_pair(y+1,x));}
      dp[y+1][x]+=dp[y][x];
      dp[y+1][x]%=mod;
      seen[y+1][x]=true;
    }
  }

  cout<<dp[H-1][W-1]<<endl;
  return 0;  
}

Measured memory_bytes: 9656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string S; cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    if (i%2 == 0) {
      if (S[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (S[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e10

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    ll w,z; cin>>w>>z;
    vll a(n);
    rep(i,n) cin>>a[i];
    vector<vll> dp(n, vll(2));
    rep(i,n) dp[i][0]=0;
    rep(i,n) dp[i][1]=INF;
    RFOR(i,n-1,0){
        //X
        ll Y = (i==0)?z:a[i-1];
        dp[i][0] = max(dp[i][0], abs(Y-a[n-1]));
        FOR(j,i+1,n-1) dp[i][0] = max(dp[i][0], dp[j][1]);
        //Y
        ll X = (i==0)?w:a[i-1];
        dp[i][1] = min(dp[i][1], abs(X-a[n-1]));
        FOR(j,i+1,n-1) dp[i][1] = min(dp[i][1], dp[j][0]);
    }
    cout<<dp[0][0]<<"\n";
    return 0;
}


Measured memory_bytes: 384
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

def gcd(x, y):
    while(y > 0):
        x, y = y, x%y
    return int(x)

l = abs(X - L[0])
L.sort()
if N > 1:
    D = [L[i] - L[i-1] for i in range(1, N)]
    for i in range(N-1):
        l = gcd(l, D[i])

print(l)


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

int main(){
    int n,x,temp=0,l,ans=1;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> l;
        temp+=l;
        if(temp<=x) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	int n,k;
	cin>>n>>k;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	if(k>=n)
	{
		cout<<0<<endl;
	}
	else
	{
		ll sum=0;
		for(int i=0;i<n-k;i++)
		{
			sum+=a[i];
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 4768
#include <stdio.h>

 #include <math.h>
 int isPrime(int x){
  if(x == 2){return 1;}
  if(x < 2 || x % 2 == 0) { return 0; }

  int i = 3;
  while(i <= sqrt(x)){
   if(x % i == 0){ return 0; }
   i = i + 2; }
  return 1; }

 int main(void){
 int i, a, b; int count = 0;
 scanf("%d\n", &a);
 for(i = 0; i < a; i++) {
  scanf("%d\n", &b);
  if(isPrime(b)) { count++; } }
 printf("%d\n", count);
 return 0; } 



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  a=a-c;
  b=b-d;
  cout<<a*b;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
max = 0
c = 0
s.each do |a|
  c+= 1 if 'A' == a || 'T' == a || 'G' == a || 'C' == a
  c = 0 if !('A' == a || 'T' == a || 'G' == a || 'C' == a)
  max = [max, c].max
end

p max
  

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, i, j, k, ans, p;
	cin >> n;
	vector<long long> a(n), s(n + 1);
	s[0] = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
	}

	vector<vector<long long>> dp(n, vector<long long>(n, 1LL << 60));
	for (k = 0; k < n; k++) {
		for (i = 0; i + k < n; i++) {
			j = i + k;

			if (k == 0) dp[i][j] = 0;
			else {
				for (p = i; p < j; p++) dp[i][j] = min(dp[i][j], dp[i][p] + dp[p + 1][j] + s[j + 1] - s[i]);
			}
		}
	}

	ans = dp[0][n - 1];
	cout << ans << "\n";

	return 0;
}





Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, B, Q;
    cin >> A >> B >> Q;
    vl S(A), T(B);
    rep(i, A) cin >> S[i];
    rep(i, B) cin >> T[i];

    rep(q,Q){
        ll x;
        cin >> x;
        ll si = lower_bound(all(S), x)-S.begin();
        ll ti = lower_bound(all(T), x) - T.begin();
        vl ss, tt;
        if (si == 0) ss.eb(S[si]);
        else if(si==A)
            ss.eb(S[si - 1]);
        else{
            ss.eb(S[si - 1]);
            ss.eb(S[si]);
        }
        if (ti == 0) tt.eb(T[ti]);
        else if(ti==B)
            tt.eb(T[ti - 1]);
        else{
            tt.eb(T[ti - 1]);
            tt.eb(T[ti]);
        }

        ll ans = INF;
        for(auto s:ss){
            for(auto t:tt){
                chmin(ans, min(abs(x - s), abs(x - t)) + abs(s - t));
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int pos = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (abs(a[i]) > abs(a[pos])) {
      pos = i;
    }
  }
  cout << 2 * n - 1 << '\n';
  if (a[pos] >= 0) {
    for (int i = 0; i < n; i++) {
      cout << pos + 1 << ' ' << i + 1 << '\n';
    }
    for (int i = 1; i < n; i++) {
      cout << i << ' ' << i + 1 << '\n';
    }
  }
  else {
    for (int i = 0; i < n; i++) {
      cout << pos + 1 << ' ' << i + 1 << '\n';
    }
    for (int i = n - 1; i > 0; i--) {
      cout << i + 1 << ' ' << i << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> fst;

const int N=1e5+7;
int dp[N],ar[N],n;

void solve()
{
    cin>>n;
	fin(ar,0,n);
	dp[1]=abs(ar[1]-ar[0]);
	for (int i=2;i<n;i++)
	{
		dp[i]=min(abs(ar[i]-ar[i-2])+dp[i-2],abs(ar[i]-ar[i-1])+dp[i-1]);
	}
	cout<<dp[n-1]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1024
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;

  ll sqn = sqrt((ll)N);
  vector<ll> prime(sqn+1, 0);
  
  for (ll i = 2; i <= sqn; i++) {
    ll a = i;
    while (N % a == 0) {
      prime[i]++;
      N /= a;
      a *= i;
    }
    while (N % i == 0)
      N /= i;
  }
  if (N > 1)
    prime.back()++;

  return bst::accumulate(prime, 0);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 11152
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int num;
  cin >> num;
  vector<string> str;
  string s;
  for(int i=0;i<num;i++){
    cin >> s;
    sort(s.begin(),s.end());
    str.push_back(s);
  }
  str.push_back("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
  sort(str.begin(),str.end());
  unsigned long long int cnt = 0;
  unsigned long long int same = 0;
  for(unsigned long long int i=0;i<num;i++){
    if(str[i]!=str[i+1]){
      cnt += (i - same) * (i - same + 1) / 2;
      same = i + 1;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

#define maxn 100010

typedef long long ll;
typedef long double ld;
const int MAXI=INT_MAX;
const ll MAXL=LLONG_MAX;

int n;
string s;
map <string, int> dd;

int main(){
    //freopen("TASK.inp","r",stdin);
    //freopen("TASK.out","w",stdout);
    ios_base::sync_with_stdio(0);

    cin >> n;

    for (int i = 1; i <= n; i++){
        cin >> s;
        dd[s]++;
    }

    cout << "AC" << " " << "x" << " " << dd["AC"] << '\n';
    cout << "WA" << " " << "x" << " " << dd["WA"] << '\n';
    cout << "TLE" << " " << "x" << " " << dd["TLE"] << '\n';
    cout << "RE" << " " << "x" << " " << dd["RE"] << '\n';


    return 0;
}


Measured memory_bytes: 3532
#include<iostream>
using namespace std;
int main() {
  int N;
  cin>>N;
  int count=0;
  for(int i=1;i<=N;i++) {
    string s=to_string(i);
    if(s.size()%2==1) {
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

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


signed main(){

  while(true){
    int n,l;
    cin>>n>>l;
    if(n==0&&l==0) break;
    int i=0;
    int a[1000000];
    a[i]=n;
    i++;
    bool flag =false;
    while(!flag){
      int b[10000]={};
      int m=n;
      int j=0;
      while(m){
        b[j]=m%10;
        m/=10;
        j++;
      }
      sort(b,b+l);
      int t=0,s=0;
      rep(j,l){
        t*=10;
        s*=10;
        t+=b[l-j-1];
        s+=b[j];
      }
      n=t-s;
      a[i++]=n;
      rep(j,i-1){
        if(a[i-1]==a[j]){
          cout<<j<<' '<<a[i-1]<<' '<<i-j-1<<endl;
          flag=true;
          break;
        }
      }
    }
  }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.1415926535;

int main() {
  ll N,H,ans=0;
  cin>>N>>H;
  vector<pair<ll,ll>> katana(N);
  for(int i=0;i<N;i++){
    cin>>katana[i].first>>katana[i].second;
  }
  ll Maxa=0;
  for(int i=0;i<N;i++){
    Maxa=max(katana[i].first,Maxa);
  }
  vector<ll> b(0);
  for(int i=0;i<N;i++){
    if(Maxa<katana[i].second){
      b.push_back(katana[i].second);
    }
  }
    ll sumb=0;
    for(int i=0;i<b.size();i++){
      sumb+=b[i];
    }
    if(sumb>=H){
      sort(b.begin(),b.end());
      reverse(b.begin(),b.end());
      int i=0;
      while(H>0){
        H-=b[i];
        ans++;
        i++;
      }
    }
    else{
      H-=sumb;
      ans+=b.size();
      ans+=(H+Maxa-1)/Maxa;
    }
    cout<<ans;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
    using namespace std;
    #define lmax LLONG_MAX
    #define lmin LLONG_MIN
    #define imax INT_MAX
    #define imin INT_MIN
    #define f(i,a,b) for(long long i=a;i<b;i++)
    #define tc long long t;cin>>t;while(t--)
    #define pb push_back
    #define mp make_pair
    #define gcd __gcd
    #define F first
    #define S second
    #define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
    #define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
    #define up upper_bound
    #define lo lower_bound
    #define endl "\n"
    #define mem(a) memset(a,-1,sizeof(a))
    #define ll long long
    #define umap unordered_map


    int main(){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        
        
        string s;
        cin>>s;

        if(s[0]=='R' and s[1]=='R' and s[2]=='R')cout<<3;
        else if((s[0]=='R' and s[1]=='R') or (s[1]=='R' and s[2]=='R')) cout<<2;
        else if(s[0]=='R' or s[1]=='R' or s[2]=='R') cout<<1;
        else cout<<0;

        return 0; 
    }

Measured memory_bytes: 3620
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
ans=0
l=[]
r=[]
for i,j in enumerate(a):
    l.append(i+j)
    r.append(i-j)

b=Counter(r)
for i in l:
    ans+=b.get(i,0)

print(ans)

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           200001
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(ll i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(ll i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}


void solve(ll test){

    ll n;
    cin >> n;

    ll a[4] = {0};
    fr(i,0,n,1){
        string s;
        cin >> s;
        if(s == "AC")a[0]++;
        else if(s == "TLE")a[1]++;
        else if(s == "WA")a[2]++;
        else a[3]++;
    }

    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[2] << endl;
    cout << "TLE x " << a[1] << endl;
    cout << "RE x " << a[3] << endl;


}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        // cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3684